babylon.module.d.ts 5.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224
  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 Vecto3
  1505. */
  1506. length(): number;
  1507. /**
  1508. * Gets the squared length of the Vector3
  1509. * @returns squared length of the Vector3
  1510. */
  1511. lengthSquared(): number;
  1512. /**
  1513. * Normalize the current Vector3.
  1514. * Please note that this is an in place operation.
  1515. * @returns the current updated Vector3
  1516. */
  1517. normalize(): Vector3;
  1518. /**
  1519. * Reorders the x y z properties of the vector in place
  1520. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1521. * @returns the current updated vector
  1522. */
  1523. reorderInPlace(order: string): this;
  1524. /**
  1525. * Rotates the vector around 0,0,0 by a quaternion
  1526. * @param quaternion the rotation quaternion
  1527. * @param result vector to store the result
  1528. * @returns the resulting vector
  1529. */
  1530. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1531. /**
  1532. * Rotates a vector around a given point
  1533. * @param quaternion the rotation quaternion
  1534. * @param point the point to rotate around
  1535. * @param result vector to store the result
  1536. * @returns the resulting vector
  1537. */
  1538. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1539. /**
  1540. * Normalize the current Vector3 with the given input length.
  1541. * Please note that this is an in place operation.
  1542. * @param len the length of the vector
  1543. * @returns the current updated Vector3
  1544. */
  1545. normalizeFromLength(len: number): Vector3;
  1546. /**
  1547. * Normalize the current Vector3 to a new vector
  1548. * @returns the new Vector3
  1549. */
  1550. normalizeToNew(): Vector3;
  1551. /**
  1552. * Normalize the current Vector3 to the reference
  1553. * @param reference define the Vector3 to update
  1554. * @returns the updated Vector3
  1555. */
  1556. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1557. /**
  1558. * Creates a new Vector3 copied from the current Vector3
  1559. * @returns the new Vector3
  1560. */
  1561. clone(): Vector3;
  1562. /**
  1563. * Copies the given vector coordinates to the current Vector3 ones
  1564. * @param source defines the source Vector3
  1565. * @returns the current updated Vector3
  1566. */
  1567. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1568. /**
  1569. * Copies the given floats to the current Vector3 coordinates
  1570. * @param x defines the x coordinate of the operand
  1571. * @param y defines the y coordinate of the operand
  1572. * @param z defines the z coordinate of the operand
  1573. * @returns the current updated Vector3
  1574. */
  1575. copyFromFloats(x: number, y: number, z: number): Vector3;
  1576. /**
  1577. * Copies the given floats to the current Vector3 coordinates
  1578. * @param x defines the x coordinate of the operand
  1579. * @param y defines the y coordinate of the operand
  1580. * @param z defines the z coordinate of the operand
  1581. * @returns the current updated Vector3
  1582. */
  1583. set(x: number, y: number, z: number): Vector3;
  1584. /**
  1585. * Copies the given float to the current Vector3 coordinates
  1586. * @param v defines the x, y and z coordinates of the operand
  1587. * @returns the current updated Vector3
  1588. */
  1589. setAll(v: number): Vector3;
  1590. /**
  1591. * Get the clip factor between two vectors
  1592. * @param vector0 defines the first operand
  1593. * @param vector1 defines the second operand
  1594. * @param axis defines the axis to use
  1595. * @param size defines the size along the axis
  1596. * @returns the clip factor
  1597. */
  1598. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1599. /**
  1600. * Get angle between two vectors
  1601. * @param vector0 angle between vector0 and vector1
  1602. * @param vector1 angle between vector0 and vector1
  1603. * @param normal direction of the normal
  1604. * @return the angle between vector0 and vector1
  1605. */
  1606. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1607. /**
  1608. * Returns a new Vector3 set from the index "offset" of the given array
  1609. * @param array defines the source array
  1610. * @param offset defines the offset in the source array
  1611. * @returns the new Vector3
  1612. */
  1613. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1614. /**
  1615. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1616. * This function is deprecated. Use FromArray instead
  1617. * @param array defines the source array
  1618. * @param offset defines the offset in the source array
  1619. * @returns the new Vector3
  1620. */
  1621. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1622. /**
  1623. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1624. * @param array defines the source array
  1625. * @param offset defines the offset in the source array
  1626. * @param result defines the Vector3 where to store the result
  1627. */
  1628. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1629. /**
  1630. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1631. * This function is deprecated. Use FromArrayToRef instead.
  1632. * @param array defines the source array
  1633. * @param offset defines the offset in the source array
  1634. * @param result defines the Vector3 where to store the result
  1635. */
  1636. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1637. /**
  1638. * Sets the given vector "result" with the given floats.
  1639. * @param x defines the x coordinate of the source
  1640. * @param y defines the y coordinate of the source
  1641. * @param z defines the z coordinate of the source
  1642. * @param result defines the Vector3 where to store the result
  1643. */
  1644. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1647. * @returns a new empty Vector3
  1648. */
  1649. static Zero(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1652. * @returns a new unit Vector3
  1653. */
  1654. static One(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1657. * @returns a new up Vector3
  1658. */
  1659. static Up(): Vector3;
  1660. /**
  1661. * Gets a up Vector3 that must not be updated
  1662. */
  1663. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1664. /**
  1665. * Gets a zero Vector3 that must not be updated
  1666. */
  1667. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1668. /**
  1669. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1670. * @returns a new down Vector3
  1671. */
  1672. static Down(): Vector3;
  1673. /**
  1674. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1675. * @returns a new forward Vector3
  1676. */
  1677. static Forward(): Vector3;
  1678. /**
  1679. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1680. * @returns a new forward Vector3
  1681. */
  1682. static Backward(): Vector3;
  1683. /**
  1684. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1685. * @returns a new right Vector3
  1686. */
  1687. static Right(): Vector3;
  1688. /**
  1689. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1690. * @returns a new left Vector3
  1691. */
  1692. static Left(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1695. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1696. * @param vector defines the Vector3 to transform
  1697. * @param transformation defines the transformation matrix
  1698. * @returns the transformed Vector3
  1699. */
  1700. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1701. /**
  1702. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1703. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1704. * @param vector defines the Vector3 to transform
  1705. * @param transformation defines the transformation matrix
  1706. * @param result defines the Vector3 where to store the result
  1707. */
  1708. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1709. /**
  1710. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1711. * This method computes tranformed coordinates only, not transformed direction vectors
  1712. * @param x define the x coordinate of the source vector
  1713. * @param y define the y coordinate of the source vector
  1714. * @param z define the z coordinate of the source vector
  1715. * @param transformation defines the transformation matrix
  1716. * @param result defines the Vector3 where to store the result
  1717. */
  1718. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1719. /**
  1720. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1721. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1722. * @param vector defines the Vector3 to transform
  1723. * @param transformation defines the transformation matrix
  1724. * @returns the new Vector3
  1725. */
  1726. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1727. /**
  1728. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1729. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1730. * @param vector defines the Vector3 to transform
  1731. * @param transformation defines the transformation matrix
  1732. * @param result defines the Vector3 where to store the result
  1733. */
  1734. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1735. /**
  1736. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1737. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1738. * @param x define the x coordinate of the source vector
  1739. * @param y define the y coordinate of the source vector
  1740. * @param z define the z coordinate of the source vector
  1741. * @param transformation defines the transformation matrix
  1742. * @param result defines the Vector3 where to store the result
  1743. */
  1744. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1745. /**
  1746. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1747. * @param value1 defines the first control point
  1748. * @param value2 defines the second control point
  1749. * @param value3 defines the third control point
  1750. * @param value4 defines the fourth control point
  1751. * @param amount defines the amount on the spline to use
  1752. * @returns the new Vector3
  1753. */
  1754. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1755. /**
  1756. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1757. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1758. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1759. * @param value defines the current value
  1760. * @param min defines the lower range value
  1761. * @param max defines the upper range value
  1762. * @returns the new Vector3
  1763. */
  1764. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1765. /**
  1766. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1767. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1768. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1769. * @param value defines the current value
  1770. * @param min defines the lower range value
  1771. * @param max defines the upper range value
  1772. * @param result defines the Vector3 where to store the result
  1773. */
  1774. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1775. /**
  1776. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1777. * @param value1 defines the first control point
  1778. * @param tangent1 defines the first tangent vector
  1779. * @param value2 defines the second control point
  1780. * @param tangent2 defines the second tangent vector
  1781. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1782. * @returns the new Vector3
  1783. */
  1784. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1785. /**
  1786. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1787. * @param start defines the start value
  1788. * @param end defines the end value
  1789. * @param amount max defines amount between both (between 0 and 1)
  1790. * @returns the new Vector3
  1791. */
  1792. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1795. * @param start defines the start value
  1796. * @param end defines the end value
  1797. * @param amount max defines amount between both (between 0 and 1)
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1801. /**
  1802. * Returns the dot product (float) between the vectors "left" and "right"
  1803. * @param left defines the left operand
  1804. * @param right defines the right operand
  1805. * @returns the dot product
  1806. */
  1807. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1808. /**
  1809. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1810. * The cross product is then orthogonal to both "left" and "right"
  1811. * @param left defines the left operand
  1812. * @param right defines the right operand
  1813. * @returns the cross product
  1814. */
  1815. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1816. /**
  1817. * Sets the given vector "result" with the cross product of "left" and "right"
  1818. * The cross product is then orthogonal to both "left" and "right"
  1819. * @param left defines the left operand
  1820. * @param right defines the right operand
  1821. * @param result defines the Vector3 where to store the result
  1822. */
  1823. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1824. /**
  1825. * Returns a new Vector3 as the normalization of the given vector
  1826. * @param vector defines the Vector3 to normalize
  1827. * @returns the new Vector3
  1828. */
  1829. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1830. /**
  1831. * Sets the given vector "result" with the normalization of the given first vector
  1832. * @param vector defines the Vector3 to normalize
  1833. * @param result defines the Vector3 where to store the result
  1834. */
  1835. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1836. /**
  1837. * Project a Vector3 onto screen space
  1838. * @param vector defines the Vector3 to project
  1839. * @param world defines the world matrix to use
  1840. * @param transform defines the transform (view x projection) matrix to use
  1841. * @param viewport defines the screen viewport to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1845. /** @hidden */
  1846. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1847. /**
  1848. * Unproject from screen space to object space
  1849. * @param source defines the screen space Vector3 to use
  1850. * @param viewportWidth defines the current width of the viewport
  1851. * @param viewportHeight defines the current height of the viewport
  1852. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1853. * @param transform defines the transform (view x projection) matrix to use
  1854. * @returns the new Vector3
  1855. */
  1856. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1857. /**
  1858. * Unproject from screen space to object space
  1859. * @param source defines the screen space Vector3 to use
  1860. * @param viewportWidth defines the current width of the viewport
  1861. * @param viewportHeight defines the current height of the viewport
  1862. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1863. * @param view defines the view matrix to use
  1864. * @param projection defines the projection matrix to use
  1865. * @returns the new Vector3
  1866. */
  1867. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1868. /**
  1869. * Unproject from screen space to object space
  1870. * @param source defines the screen space Vector3 to use
  1871. * @param viewportWidth defines the current width of the viewport
  1872. * @param viewportHeight defines the current height of the viewport
  1873. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1874. * @param view defines the view matrix to use
  1875. * @param projection defines the projection matrix to use
  1876. * @param result defines the Vector3 where to store the result
  1877. */
  1878. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1879. /**
  1880. * Unproject from screen space to object space
  1881. * @param sourceX defines the screen space x coordinate to use
  1882. * @param sourceY defines the screen space y coordinate to use
  1883. * @param sourceZ defines the screen space z coordinate to use
  1884. * @param viewportWidth defines the current width of the viewport
  1885. * @param viewportHeight defines the current height of the viewport
  1886. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1887. * @param view defines the view matrix to use
  1888. * @param projection defines the projection matrix to use
  1889. * @param result defines the Vector3 where to store the result
  1890. */
  1891. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1892. /**
  1893. * Gets the minimal coordinate values between two Vector3
  1894. * @param left defines the first operand
  1895. * @param right defines the second operand
  1896. * @returns the new Vector3
  1897. */
  1898. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1899. /**
  1900. * Gets the maximal coordinate values between two Vector3
  1901. * @param left defines the first operand
  1902. * @param right defines the second operand
  1903. * @returns the new Vector3
  1904. */
  1905. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1906. /**
  1907. * Returns the distance between the vectors "value1" and "value2"
  1908. * @param value1 defines the first operand
  1909. * @param value2 defines the second operand
  1910. * @returns the distance
  1911. */
  1912. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1913. /**
  1914. * Returns the squared distance between the vectors "value1" and "value2"
  1915. * @param value1 defines the first operand
  1916. * @param value2 defines the second operand
  1917. * @returns the squared distance
  1918. */
  1919. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1920. /**
  1921. * Returns a new Vector3 located at the center between "value1" and "value2"
  1922. * @param value1 defines the first operand
  1923. * @param value2 defines the second operand
  1924. * @returns the new Vector3
  1925. */
  1926. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1927. /**
  1928. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1929. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1930. * to something in order to rotate it from its local system to the given target system
  1931. * Note: axis1, axis2 and axis3 are normalized during this operation
  1932. * @param axis1 defines the first axis
  1933. * @param axis2 defines the second axis
  1934. * @param axis3 defines the third axis
  1935. * @returns a new Vector3
  1936. */
  1937. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1938. /**
  1939. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1940. * @param axis1 defines the first axis
  1941. * @param axis2 defines the second axis
  1942. * @param axis3 defines the third axis
  1943. * @param ref defines the Vector3 where to store the result
  1944. */
  1945. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1946. }
  1947. /**
  1948. * Vector4 class created for EulerAngle class conversion to Quaternion
  1949. */
  1950. export class Vector4 {
  1951. /** x value of the vector */
  1952. x: number;
  1953. /** y value of the vector */
  1954. y: number;
  1955. /** z value of the vector */
  1956. z: number;
  1957. /** w value of the vector */
  1958. w: number;
  1959. /**
  1960. * Creates a Vector4 object from the given floats.
  1961. * @param x x value of the vector
  1962. * @param y y value of the vector
  1963. * @param z z value of the vector
  1964. * @param w w value of the vector
  1965. */
  1966. constructor(
  1967. /** x value of the vector */
  1968. x: number,
  1969. /** y value of the vector */
  1970. y: number,
  1971. /** z value of the vector */
  1972. z: number,
  1973. /** w value of the vector */
  1974. w: number);
  1975. /**
  1976. * Returns the string with the Vector4 coordinates.
  1977. * @returns a string containing all the vector values
  1978. */
  1979. toString(): string;
  1980. /**
  1981. * Returns the string "Vector4".
  1982. * @returns "Vector4"
  1983. */
  1984. getClassName(): string;
  1985. /**
  1986. * Returns the Vector4 hash code.
  1987. * @returns a unique hash code
  1988. */
  1989. getHashCode(): number;
  1990. /**
  1991. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1992. * @returns the resulting array
  1993. */
  1994. asArray(): number[];
  1995. /**
  1996. * Populates the given array from the given index with the Vector4 coordinates.
  1997. * @param array array to populate
  1998. * @param index index of the array to start at (default: 0)
  1999. * @returns the Vector4.
  2000. */
  2001. toArray(array: FloatArray, index?: number): Vector4;
  2002. /**
  2003. * Adds the given vector to the current Vector4.
  2004. * @param otherVector the vector to add
  2005. * @returns the updated Vector4.
  2006. */
  2007. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2008. /**
  2009. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2010. * @param otherVector the vector to add
  2011. * @returns the resulting vector
  2012. */
  2013. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2014. /**
  2015. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2016. * @param otherVector the vector to add
  2017. * @param result the vector to store the result
  2018. * @returns the current Vector4.
  2019. */
  2020. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2021. /**
  2022. * Subtract in place the given vector from the current Vector4.
  2023. * @param otherVector the vector to subtract
  2024. * @returns the updated Vector4.
  2025. */
  2026. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2027. /**
  2028. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2029. * @param otherVector the vector to add
  2030. * @returns the new vector with the result
  2031. */
  2032. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2033. /**
  2034. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2035. * @param otherVector the vector to subtract
  2036. * @param result the vector to store the result
  2037. * @returns the current Vector4.
  2038. */
  2039. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2040. /**
  2041. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2042. */
  2043. /**
  2044. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2045. * @param x value to subtract
  2046. * @param y value to subtract
  2047. * @param z value to subtract
  2048. * @param w value to subtract
  2049. * @returns new vector containing the result
  2050. */
  2051. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2052. /**
  2053. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2054. * @param x value to subtract
  2055. * @param y value to subtract
  2056. * @param z value to subtract
  2057. * @param w value to subtract
  2058. * @param result the vector to store the result in
  2059. * @returns the current Vector4.
  2060. */
  2061. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2062. /**
  2063. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2064. * @returns a new vector with the negated values
  2065. */
  2066. negate(): Vector4;
  2067. /**
  2068. * Multiplies the current Vector4 coordinates by scale (float).
  2069. * @param scale the number to scale with
  2070. * @returns the updated Vector4.
  2071. */
  2072. scaleInPlace(scale: number): Vector4;
  2073. /**
  2074. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2075. * @param scale the number to scale with
  2076. * @returns a new vector with the result
  2077. */
  2078. scale(scale: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2081. * @param scale the number to scale with
  2082. * @param result a vector to store the result in
  2083. * @returns the current Vector4.
  2084. */
  2085. scaleToRef(scale: number, result: Vector4): Vector4;
  2086. /**
  2087. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2088. * @param scale defines the scale factor
  2089. * @param result defines the Vector4 object where to store the result
  2090. * @returns the unmodified current Vector4
  2091. */
  2092. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2093. /**
  2094. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2095. * @param otherVector the vector to compare against
  2096. * @returns true if they are equal
  2097. */
  2098. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2099. /**
  2100. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2101. * @param otherVector vector to compare against
  2102. * @param epsilon (Default: very small number)
  2103. * @returns true if they are equal
  2104. */
  2105. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2106. /**
  2107. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2108. * @param x x value to compare against
  2109. * @param y y value to compare against
  2110. * @param z z value to compare against
  2111. * @param w w value to compare against
  2112. * @returns true if equal
  2113. */
  2114. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2115. /**
  2116. * Multiplies in place the current Vector4 by the given one.
  2117. * @param otherVector vector to multiple with
  2118. * @returns the updated Vector4.
  2119. */
  2120. multiplyInPlace(otherVector: Vector4): Vector4;
  2121. /**
  2122. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2123. * @param otherVector vector to multiple with
  2124. * @returns resulting new vector
  2125. */
  2126. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2127. /**
  2128. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2129. * @param otherVector vector to multiple with
  2130. * @param result vector to store the result
  2131. * @returns the current Vector4.
  2132. */
  2133. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2134. /**
  2135. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2136. * @param x x value multiply with
  2137. * @param y y value multiply with
  2138. * @param z z value multiply with
  2139. * @param w w value multiply with
  2140. * @returns resulting new vector
  2141. */
  2142. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2143. /**
  2144. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2145. * @param otherVector vector to devide with
  2146. * @returns resulting new vector
  2147. */
  2148. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2149. /**
  2150. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2151. * @param otherVector vector to devide with
  2152. * @param result vector to store the result
  2153. * @returns the current Vector4.
  2154. */
  2155. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2156. /**
  2157. * Divides the current Vector3 coordinates by the given ones.
  2158. * @param otherVector vector to devide with
  2159. * @returns the updated Vector3.
  2160. */
  2161. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2162. /**
  2163. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2164. * @param other defines the second operand
  2165. * @returns the current updated Vector4
  2166. */
  2167. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2168. /**
  2169. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2170. * @param other defines the second operand
  2171. * @returns the current updated Vector4
  2172. */
  2173. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2174. /**
  2175. * Gets a new Vector4 from current Vector4 floored values
  2176. * @returns a new Vector4
  2177. */
  2178. floor(): Vector4;
  2179. /**
  2180. * Gets a new Vector4 from current Vector3 floored values
  2181. * @returns a new Vector4
  2182. */
  2183. fract(): Vector4;
  2184. /**
  2185. * Returns the Vector4 length (float).
  2186. * @returns the length
  2187. */
  2188. length(): number;
  2189. /**
  2190. * Returns the Vector4 squared length (float).
  2191. * @returns the length squared
  2192. */
  2193. lengthSquared(): number;
  2194. /**
  2195. * Normalizes in place the Vector4.
  2196. * @returns the updated Vector4.
  2197. */
  2198. normalize(): Vector4;
  2199. /**
  2200. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2201. * @returns this converted to a new vector3
  2202. */
  2203. toVector3(): Vector3;
  2204. /**
  2205. * Returns a new Vector4 copied from the current one.
  2206. * @returns the new cloned vector
  2207. */
  2208. clone(): Vector4;
  2209. /**
  2210. * Updates the current Vector4 with the given one coordinates.
  2211. * @param source the source vector to copy from
  2212. * @returns the updated Vector4.
  2213. */
  2214. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2215. /**
  2216. * Updates the current Vector4 coordinates with the given floats.
  2217. * @param x float to copy from
  2218. * @param y float to copy from
  2219. * @param z float to copy from
  2220. * @param w float to copy from
  2221. * @returns the updated Vector4.
  2222. */
  2223. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2224. /**
  2225. * Updates the current Vector4 coordinates with the given floats.
  2226. * @param x float to set from
  2227. * @param y float to set from
  2228. * @param z float to set from
  2229. * @param w float to set from
  2230. * @returns the updated Vector4.
  2231. */
  2232. set(x: number, y: number, z: number, w: number): Vector4;
  2233. /**
  2234. * Copies the given float to the current Vector3 coordinates
  2235. * @param v defines the x, y, z and w coordinates of the operand
  2236. * @returns the current updated Vector3
  2237. */
  2238. setAll(v: number): Vector4;
  2239. /**
  2240. * Returns a new Vector4 set from the starting index of the given array.
  2241. * @param array the array to pull values from
  2242. * @param offset the offset into the array to start at
  2243. * @returns the new vector
  2244. */
  2245. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2246. /**
  2247. * Updates the given vector "result" from the starting index of the given array.
  2248. * @param array the array to pull values from
  2249. * @param offset the offset into the array to start at
  2250. * @param result the vector to store the result in
  2251. */
  2252. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2253. /**
  2254. * Updates the given vector "result" from the starting index of the given Float32Array.
  2255. * @param array the array to pull values from
  2256. * @param offset the offset into the array to start at
  2257. * @param result the vector to store the result in
  2258. */
  2259. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2260. /**
  2261. * Updates the given vector "result" coordinates from the given floats.
  2262. * @param x float to set from
  2263. * @param y float to set from
  2264. * @param z float to set from
  2265. * @param w float to set from
  2266. * @param result the vector to the floats in
  2267. */
  2268. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2269. /**
  2270. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2271. * @returns the new vector
  2272. */
  2273. static Zero(): Vector4;
  2274. /**
  2275. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2276. * @returns the new vector
  2277. */
  2278. static One(): Vector4;
  2279. /**
  2280. * Returns a new normalized Vector4 from the given one.
  2281. * @param vector the vector to normalize
  2282. * @returns the vector
  2283. */
  2284. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2285. /**
  2286. * Updates the given vector "result" from the normalization of the given one.
  2287. * @param vector the vector to normalize
  2288. * @param result the vector to store the result in
  2289. */
  2290. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2291. /**
  2292. * Returns a vector with the minimum values from the left and right vectors
  2293. * @param left left vector to minimize
  2294. * @param right right vector to minimize
  2295. * @returns a new vector with the minimum of the left and right vector values
  2296. */
  2297. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2298. /**
  2299. * Returns a vector with the maximum values from the left and right vectors
  2300. * @param left left vector to maximize
  2301. * @param right right vector to maximize
  2302. * @returns a new vector with the maximum of the left and right vector values
  2303. */
  2304. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2305. /**
  2306. * Returns the distance (float) between the vectors "value1" and "value2".
  2307. * @param value1 value to calulate the distance between
  2308. * @param value2 value to calulate the distance between
  2309. * @return the distance between the two vectors
  2310. */
  2311. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2312. /**
  2313. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2314. * @param value1 value to calulate the distance between
  2315. * @param value2 value to calulate the distance between
  2316. * @return the distance between the two vectors squared
  2317. */
  2318. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2319. /**
  2320. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2321. * @param value1 value to calulate the center between
  2322. * @param value2 value to calulate the center between
  2323. * @return the center between the two vectors
  2324. */
  2325. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2326. /**
  2327. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2328. * This methods computes transformed normalized direction vectors only.
  2329. * @param vector the vector to transform
  2330. * @param transformation the transformation matrix to apply
  2331. * @returns the new vector
  2332. */
  2333. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2334. /**
  2335. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2336. * This methods computes transformed normalized direction vectors only.
  2337. * @param vector the vector to transform
  2338. * @param transformation the transformation matrix to apply
  2339. * @param result the vector to store the result in
  2340. */
  2341. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2342. /**
  2343. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2344. * This methods computes transformed normalized direction vectors only.
  2345. * @param x value to transform
  2346. * @param y value to transform
  2347. * @param z value to transform
  2348. * @param w value to transform
  2349. * @param transformation the transformation matrix to apply
  2350. * @param result the vector to store the results in
  2351. */
  2352. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2353. /**
  2354. * Creates a new Vector4 from a Vector3
  2355. * @param source defines the source data
  2356. * @param w defines the 4th component (default is 0)
  2357. * @returns a new Vector4
  2358. */
  2359. static FromVector3(source: Vector3, w?: number): Vector4;
  2360. }
  2361. /**
  2362. * Interface for the size containing width and height
  2363. */
  2364. export interface ISize {
  2365. /**
  2366. * Width
  2367. */
  2368. width: number;
  2369. /**
  2370. * Heighht
  2371. */
  2372. height: number;
  2373. }
  2374. /**
  2375. * Size containing widht and height
  2376. */
  2377. export class Size implements ISize {
  2378. /**
  2379. * Width
  2380. */
  2381. width: number;
  2382. /**
  2383. * Height
  2384. */
  2385. height: number;
  2386. /**
  2387. * Creates a Size object from the given width and height (floats).
  2388. * @param width width of the new size
  2389. * @param height height of the new size
  2390. */
  2391. constructor(width: number, height: number);
  2392. /**
  2393. * Returns a string with the Size width and height
  2394. * @returns a string with the Size width and height
  2395. */
  2396. toString(): string;
  2397. /**
  2398. * "Size"
  2399. * @returns the string "Size"
  2400. */
  2401. getClassName(): string;
  2402. /**
  2403. * Returns the Size hash code.
  2404. * @returns a hash code for a unique width and height
  2405. */
  2406. getHashCode(): number;
  2407. /**
  2408. * Updates the current size from the given one.
  2409. * @param src the given size
  2410. */
  2411. copyFrom(src: Size): void;
  2412. /**
  2413. * Updates in place the current Size from the given floats.
  2414. * @param width width of the new size
  2415. * @param height height of the new size
  2416. * @returns the updated Size.
  2417. */
  2418. copyFromFloats(width: number, height: number): Size;
  2419. /**
  2420. * Updates in place the current Size from the given floats.
  2421. * @param width width to set
  2422. * @param height height to set
  2423. * @returns the updated Size.
  2424. */
  2425. set(width: number, height: number): Size;
  2426. /**
  2427. * Multiplies the width and height by numbers
  2428. * @param w factor to multiple the width by
  2429. * @param h factor to multiple the height by
  2430. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2431. */
  2432. multiplyByFloats(w: number, h: number): Size;
  2433. /**
  2434. * Clones the size
  2435. * @returns a new Size copied from the given one.
  2436. */
  2437. clone(): Size;
  2438. /**
  2439. * True if the current Size and the given one width and height are strictly equal.
  2440. * @param other the other size to compare against
  2441. * @returns True if the current Size and the given one width and height are strictly equal.
  2442. */
  2443. equals(other: Size): boolean;
  2444. /**
  2445. * The surface of the Size : width * height (float).
  2446. */
  2447. readonly surface: number;
  2448. /**
  2449. * Create a new size of zero
  2450. * @returns a new Size set to (0.0, 0.0)
  2451. */
  2452. static Zero(): Size;
  2453. /**
  2454. * Sums the width and height of two sizes
  2455. * @param otherSize size to add to this size
  2456. * @returns a new Size set as the addition result of the current Size and the given one.
  2457. */
  2458. add(otherSize: Size): Size;
  2459. /**
  2460. * Subtracts the width and height of two
  2461. * @param otherSize size to subtract to this size
  2462. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2463. */
  2464. subtract(otherSize: Size): Size;
  2465. /**
  2466. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2467. * @param start starting size to lerp between
  2468. * @param end end size to lerp between
  2469. * @param amount amount to lerp between the start and end values
  2470. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2471. */
  2472. static Lerp(start: Size, end: Size, amount: number): Size;
  2473. }
  2474. /**
  2475. * Class used to store quaternion data
  2476. * @see https://en.wikipedia.org/wiki/Quaternion
  2477. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2478. */
  2479. export class Quaternion {
  2480. /** defines the first component (0 by default) */
  2481. x: number;
  2482. /** defines the second component (0 by default) */
  2483. y: number;
  2484. /** defines the third component (0 by default) */
  2485. z: number;
  2486. /** defines the fourth component (1.0 by default) */
  2487. w: number;
  2488. /**
  2489. * Creates a new Quaternion from the given floats
  2490. * @param x defines the first component (0 by default)
  2491. * @param y defines the second component (0 by default)
  2492. * @param z defines the third component (0 by default)
  2493. * @param w defines the fourth component (1.0 by default)
  2494. */
  2495. constructor(
  2496. /** defines the first component (0 by default) */
  2497. x?: number,
  2498. /** defines the second component (0 by default) */
  2499. y?: number,
  2500. /** defines the third component (0 by default) */
  2501. z?: number,
  2502. /** defines the fourth component (1.0 by default) */
  2503. w?: number);
  2504. /**
  2505. * Gets a string representation for the current quaternion
  2506. * @returns a string with the Quaternion coordinates
  2507. */
  2508. toString(): string;
  2509. /**
  2510. * Gets the class name of the quaternion
  2511. * @returns the string "Quaternion"
  2512. */
  2513. getClassName(): string;
  2514. /**
  2515. * Gets a hash code for this quaternion
  2516. * @returns the quaternion hash code
  2517. */
  2518. getHashCode(): number;
  2519. /**
  2520. * Copy the quaternion to an array
  2521. * @returns a new array populated with 4 elements from the quaternion coordinates
  2522. */
  2523. asArray(): number[];
  2524. /**
  2525. * Check if two quaternions are equals
  2526. * @param otherQuaternion defines the second operand
  2527. * @return true if the current quaternion and the given one coordinates are strictly equals
  2528. */
  2529. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2530. /**
  2531. * Clone the current quaternion
  2532. * @returns a new quaternion copied from the current one
  2533. */
  2534. clone(): Quaternion;
  2535. /**
  2536. * Copy a quaternion to the current one
  2537. * @param other defines the other quaternion
  2538. * @returns the updated current quaternion
  2539. */
  2540. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2541. /**
  2542. * Updates the current quaternion with the given float coordinates
  2543. * @param x defines the x coordinate
  2544. * @param y defines the y coordinate
  2545. * @param z defines the z coordinate
  2546. * @param w defines the w coordinate
  2547. * @returns the updated current quaternion
  2548. */
  2549. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2550. /**
  2551. * Updates the current quaternion from the given float coordinates
  2552. * @param x defines the x coordinate
  2553. * @param y defines the y coordinate
  2554. * @param z defines the z coordinate
  2555. * @param w defines the w coordinate
  2556. * @returns the updated current quaternion
  2557. */
  2558. set(x: number, y: number, z: number, w: number): Quaternion;
  2559. /**
  2560. * Adds two quaternions
  2561. * @param other defines the second operand
  2562. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2563. */
  2564. add(other: DeepImmutable<Quaternion>): Quaternion;
  2565. /**
  2566. * Add a quaternion to the current one
  2567. * @param other defines the quaternion to add
  2568. * @returns the current quaternion
  2569. */
  2570. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2571. /**
  2572. * Subtract two quaternions
  2573. * @param other defines the second operand
  2574. * @returns a new quaternion as the subtraction result of the given one from the current one
  2575. */
  2576. subtract(other: Quaternion): Quaternion;
  2577. /**
  2578. * Multiplies the current quaternion by a scale factor
  2579. * @param value defines the scale factor
  2580. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2581. */
  2582. scale(value: number): Quaternion;
  2583. /**
  2584. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2585. * @param scale defines the scale factor
  2586. * @param result defines the Quaternion object where to store the result
  2587. * @returns the unmodified current quaternion
  2588. */
  2589. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2590. /**
  2591. * Multiplies in place the current quaternion by a scale factor
  2592. * @param value defines the scale factor
  2593. * @returns the current modified quaternion
  2594. */
  2595. scaleInPlace(value: number): Quaternion;
  2596. /**
  2597. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2598. * @param scale defines the scale factor
  2599. * @param result defines the Quaternion object where to store the result
  2600. * @returns the unmodified current quaternion
  2601. */
  2602. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2603. /**
  2604. * Multiplies two quaternions
  2605. * @param q1 defines the second operand
  2606. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2607. */
  2608. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2609. /**
  2610. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2611. * @param q1 defines the second operand
  2612. * @param result defines the target quaternion
  2613. * @returns the current quaternion
  2614. */
  2615. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2616. /**
  2617. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2618. * @param q1 defines the second operand
  2619. * @returns the currentupdated quaternion
  2620. */
  2621. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2622. /**
  2623. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2624. * @param ref defines the target quaternion
  2625. * @returns the current quaternion
  2626. */
  2627. conjugateToRef(ref: Quaternion): Quaternion;
  2628. /**
  2629. * Conjugates in place (1-q) the current quaternion
  2630. * @returns the current updated quaternion
  2631. */
  2632. conjugateInPlace(): Quaternion;
  2633. /**
  2634. * Conjugates in place (1-q) the current quaternion
  2635. * @returns a new quaternion
  2636. */
  2637. conjugate(): Quaternion;
  2638. /**
  2639. * Gets length of current quaternion
  2640. * @returns the quaternion length (float)
  2641. */
  2642. length(): number;
  2643. /**
  2644. * Normalize in place the current quaternion
  2645. * @returns the current updated quaternion
  2646. */
  2647. normalize(): Quaternion;
  2648. /**
  2649. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2650. * @param order is a reserved parameter and is ignore for now
  2651. * @returns a new Vector3 containing the Euler angles
  2652. */
  2653. toEulerAngles(order?: string): Vector3;
  2654. /**
  2655. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2656. * @param result defines the vector which will be filled with the Euler angles
  2657. * @param order is a reserved parameter and is ignore for now
  2658. * @returns the current unchanged quaternion
  2659. */
  2660. toEulerAnglesToRef(result: Vector3): Quaternion;
  2661. /**
  2662. * Updates the given rotation matrix with the current quaternion values
  2663. * @param result defines the target matrix
  2664. * @returns the current unchanged quaternion
  2665. */
  2666. toRotationMatrix(result: Matrix): Quaternion;
  2667. /**
  2668. * Updates the current quaternion from the given rotation matrix values
  2669. * @param matrix defines the source matrix
  2670. * @returns the current updated quaternion
  2671. */
  2672. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2673. /**
  2674. * Creates a new quaternion from a rotation matrix
  2675. * @param matrix defines the source matrix
  2676. * @returns a new quaternion created from the given rotation matrix values
  2677. */
  2678. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2679. /**
  2680. * Updates the given quaternion with the given rotation matrix values
  2681. * @param matrix defines the source matrix
  2682. * @param result defines the target quaternion
  2683. */
  2684. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2685. /**
  2686. * Returns the dot product (float) between the quaternions "left" and "right"
  2687. * @param left defines the left operand
  2688. * @param right defines the right operand
  2689. * @returns the dot product
  2690. */
  2691. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2692. /**
  2693. * Checks if the two quaternions are close to each other
  2694. * @param quat0 defines the first quaternion to check
  2695. * @param quat1 defines the second quaternion to check
  2696. * @returns true if the two quaternions are close to each other
  2697. */
  2698. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2699. /**
  2700. * Creates an empty quaternion
  2701. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2702. */
  2703. static Zero(): Quaternion;
  2704. /**
  2705. * Inverse a given quaternion
  2706. * @param q defines the source quaternion
  2707. * @returns a new quaternion as the inverted current quaternion
  2708. */
  2709. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2710. /**
  2711. * Inverse a given quaternion
  2712. * @param q defines the source quaternion
  2713. * @param result the quaternion the result will be stored in
  2714. * @returns the result quaternion
  2715. */
  2716. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2717. /**
  2718. * Creates an identity quaternion
  2719. * @returns the identity quaternion
  2720. */
  2721. static Identity(): Quaternion;
  2722. /**
  2723. * Gets a boolean indicating if the given quaternion is identity
  2724. * @param quaternion defines the quaternion to check
  2725. * @returns true if the quaternion is identity
  2726. */
  2727. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2728. /**
  2729. * Creates a quaternion from a rotation around an axis
  2730. * @param axis defines the axis to use
  2731. * @param angle defines the angle to use
  2732. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2733. */
  2734. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2735. /**
  2736. * Creates a rotation around an axis and stores it into the given quaternion
  2737. * @param axis defines the axis to use
  2738. * @param angle defines the angle to use
  2739. * @param result defines the target quaternion
  2740. * @returns the target quaternion
  2741. */
  2742. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2743. /**
  2744. * Creates a new quaternion from data stored into an array
  2745. * @param array defines the data source
  2746. * @param offset defines the offset in the source array where the data starts
  2747. * @returns a new quaternion
  2748. */
  2749. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2750. /**
  2751. * Create a quaternion from Euler rotation angles
  2752. * @param x Pitch
  2753. * @param y Yaw
  2754. * @param z Roll
  2755. * @returns the new Quaternion
  2756. */
  2757. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2758. /**
  2759. * Updates a quaternion from Euler rotation angles
  2760. * @param x Pitch
  2761. * @param y Yaw
  2762. * @param z Roll
  2763. * @param result the quaternion to store the result
  2764. * @returns the updated quaternion
  2765. */
  2766. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2767. /**
  2768. * Create a quaternion from Euler rotation vector
  2769. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2770. * @returns the new Quaternion
  2771. */
  2772. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2773. /**
  2774. * Updates a quaternion from Euler rotation vector
  2775. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2776. * @param result the quaternion to store the result
  2777. * @returns the updated quaternion
  2778. */
  2779. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2780. /**
  2781. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2782. * @param yaw defines the rotation around Y axis
  2783. * @param pitch defines the rotation around X axis
  2784. * @param roll defines the rotation around Z axis
  2785. * @returns the new quaternion
  2786. */
  2787. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2788. /**
  2789. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2790. * @param yaw defines the rotation around Y axis
  2791. * @param pitch defines the rotation around X axis
  2792. * @param roll defines the rotation around Z axis
  2793. * @param result defines the target quaternion
  2794. */
  2795. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2796. /**
  2797. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2798. * @param alpha defines the rotation around first axis
  2799. * @param beta defines the rotation around second axis
  2800. * @param gamma defines the rotation around third axis
  2801. * @returns the new quaternion
  2802. */
  2803. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2804. /**
  2805. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2806. * @param alpha defines the rotation around first axis
  2807. * @param beta defines the rotation around second axis
  2808. * @param gamma defines the rotation around third axis
  2809. * @param result defines the target quaternion
  2810. */
  2811. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2812. /**
  2813. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2814. * @param axis1 defines the first axis
  2815. * @param axis2 defines the second axis
  2816. * @param axis3 defines the third axis
  2817. * @returns the new quaternion
  2818. */
  2819. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2820. /**
  2821. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2822. * @param axis1 defines the first axis
  2823. * @param axis2 defines the second axis
  2824. * @param axis3 defines the third axis
  2825. * @param ref defines the target quaternion
  2826. */
  2827. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2828. /**
  2829. * Interpolates between two quaternions
  2830. * @param left defines first quaternion
  2831. * @param right defines second quaternion
  2832. * @param amount defines the gradient to use
  2833. * @returns the new interpolated quaternion
  2834. */
  2835. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2836. /**
  2837. * Interpolates between two quaternions and stores it into a target quaternion
  2838. * @param left defines first quaternion
  2839. * @param right defines second quaternion
  2840. * @param amount defines the gradient to use
  2841. * @param result defines the target quaternion
  2842. */
  2843. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2844. /**
  2845. * Interpolate between two quaternions using Hermite interpolation
  2846. * @param value1 defines first quaternion
  2847. * @param tangent1 defines the incoming tangent
  2848. * @param value2 defines second quaternion
  2849. * @param tangent2 defines the outgoing tangent
  2850. * @param amount defines the target quaternion
  2851. * @returns the new interpolated quaternion
  2852. */
  2853. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2854. }
  2855. /**
  2856. * Class used to store matrix data (4x4)
  2857. */
  2858. export class Matrix {
  2859. private static _updateFlagSeed;
  2860. private static _identityReadOnly;
  2861. private _isIdentity;
  2862. private _isIdentityDirty;
  2863. private _isIdentity3x2;
  2864. private _isIdentity3x2Dirty;
  2865. /**
  2866. * Gets the update flag of the matrix which is an unique number for the matrix.
  2867. * It will be incremented every time the matrix data change.
  2868. * You can use it to speed the comparison between two versions of the same matrix.
  2869. */
  2870. updateFlag: number;
  2871. private readonly _m;
  2872. /**
  2873. * Gets the internal data of the matrix
  2874. */
  2875. readonly m: DeepImmutable<Float32Array>;
  2876. /** @hidden */
  2877. _markAsUpdated(): void;
  2878. /** @hidden */
  2879. private _updateIdentityStatus;
  2880. /**
  2881. * Creates an empty matrix (filled with zeros)
  2882. */
  2883. constructor();
  2884. /**
  2885. * Check if the current matrix is identity
  2886. * @returns true is the matrix is the identity matrix
  2887. */
  2888. isIdentity(): boolean;
  2889. /**
  2890. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2891. * @returns true is the matrix is the identity matrix
  2892. */
  2893. isIdentityAs3x2(): boolean;
  2894. /**
  2895. * Gets the determinant of the matrix
  2896. * @returns the matrix determinant
  2897. */
  2898. determinant(): number;
  2899. /**
  2900. * Returns the matrix as a Float32Array
  2901. * @returns the matrix underlying array
  2902. */
  2903. toArray(): DeepImmutable<Float32Array>;
  2904. /**
  2905. * Returns the matrix as a Float32Array
  2906. * @returns the matrix underlying array.
  2907. */
  2908. asArray(): DeepImmutable<Float32Array>;
  2909. /**
  2910. * Inverts the current matrix in place
  2911. * @returns the current inverted matrix
  2912. */
  2913. invert(): Matrix;
  2914. /**
  2915. * Sets all the matrix elements to zero
  2916. * @returns the current matrix
  2917. */
  2918. reset(): Matrix;
  2919. /**
  2920. * Adds the current matrix with a second one
  2921. * @param other defines the matrix to add
  2922. * @returns a new matrix as the addition of the current matrix and the given one
  2923. */
  2924. add(other: DeepImmutable<Matrix>): Matrix;
  2925. /**
  2926. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2927. * @param other defines the matrix to add
  2928. * @param result defines the target matrix
  2929. * @returns the current matrix
  2930. */
  2931. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2932. /**
  2933. * Adds in place the given matrix to the current matrix
  2934. * @param other defines the second operand
  2935. * @returns the current updated matrix
  2936. */
  2937. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2938. /**
  2939. * Sets the given matrix to the current inverted Matrix
  2940. * @param other defines the target matrix
  2941. * @returns the unmodified current matrix
  2942. */
  2943. invertToRef(other: Matrix): Matrix;
  2944. /**
  2945. * add a value at the specified position in the current Matrix
  2946. * @param index the index of the value within the matrix. between 0 and 15.
  2947. * @param value the value to be added
  2948. * @returns the current updated matrix
  2949. */
  2950. addAtIndex(index: number, value: number): Matrix;
  2951. /**
  2952. * mutiply the specified position in the current Matrix by a value
  2953. * @param index the index of the value within the matrix. between 0 and 15.
  2954. * @param value the value to be added
  2955. * @returns the current updated matrix
  2956. */
  2957. multiplyAtIndex(index: number, value: number): Matrix;
  2958. /**
  2959. * Inserts the translation vector (using 3 floats) in the current matrix
  2960. * @param x defines the 1st component of the translation
  2961. * @param y defines the 2nd component of the translation
  2962. * @param z defines the 3rd component of the translation
  2963. * @returns the current updated matrix
  2964. */
  2965. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2966. /**
  2967. * Adds the translation vector (using 3 floats) in the current matrix
  2968. * @param x defines the 1st component of the translation
  2969. * @param y defines the 2nd component of the translation
  2970. * @param z defines the 3rd component of the translation
  2971. * @returns the current updated matrix
  2972. */
  2973. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2974. /**
  2975. * Inserts the translation vector in the current matrix
  2976. * @param vector3 defines the translation to insert
  2977. * @returns the current updated matrix
  2978. */
  2979. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2980. /**
  2981. * Gets the translation value of the current matrix
  2982. * @returns a new Vector3 as the extracted translation from the matrix
  2983. */
  2984. getTranslation(): Vector3;
  2985. /**
  2986. * Fill a Vector3 with the extracted translation from the matrix
  2987. * @param result defines the Vector3 where to store the translation
  2988. * @returns the current matrix
  2989. */
  2990. getTranslationToRef(result: Vector3): Matrix;
  2991. /**
  2992. * Remove rotation and scaling part from the matrix
  2993. * @returns the updated matrix
  2994. */
  2995. removeRotationAndScaling(): Matrix;
  2996. /**
  2997. * Multiply two matrices
  2998. * @param other defines the second operand
  2999. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3000. */
  3001. multiply(other: DeepImmutable<Matrix>): Matrix;
  3002. /**
  3003. * Copy the current matrix from the given one
  3004. * @param other defines the source matrix
  3005. * @returns the current updated matrix
  3006. */
  3007. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3008. /**
  3009. * Populates the given array from the starting index with the current matrix values
  3010. * @param array defines the target array
  3011. * @param offset defines the offset in the target array where to start storing values
  3012. * @returns the current matrix
  3013. */
  3014. copyToArray(array: Float32Array, offset?: number): Matrix;
  3015. /**
  3016. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3017. * @param other defines the second operand
  3018. * @param result defines the matrix where to store the multiplication
  3019. * @returns the current matrix
  3020. */
  3021. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3022. /**
  3023. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3024. * @param other defines the second operand
  3025. * @param result defines the array where to store the multiplication
  3026. * @param offset defines the offset in the target array where to start storing values
  3027. * @returns the current matrix
  3028. */
  3029. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3030. /**
  3031. * Check equality between this matrix and a second one
  3032. * @param value defines the second matrix to compare
  3033. * @returns true is the current matrix and the given one values are strictly equal
  3034. */
  3035. equals(value: DeepImmutable<Matrix>): boolean;
  3036. /**
  3037. * Clone the current matrix
  3038. * @returns a new matrix from the current matrix
  3039. */
  3040. clone(): Matrix;
  3041. /**
  3042. * Returns the name of the current matrix class
  3043. * @returns the string "Matrix"
  3044. */
  3045. getClassName(): string;
  3046. /**
  3047. * Gets the hash code of the current matrix
  3048. * @returns the hash code
  3049. */
  3050. getHashCode(): number;
  3051. /**
  3052. * Decomposes the current Matrix into a translation, rotation and scaling components
  3053. * @param scale defines the scale vector3 given as a reference to update
  3054. * @param rotation defines the rotation quaternion given as a reference to update
  3055. * @param translation defines the translation vector3 given as a reference to update
  3056. * @returns true if operation was successful
  3057. */
  3058. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3059. /**
  3060. * Gets specific row of the matrix
  3061. * @param index defines the number of the row to get
  3062. * @returns the index-th row of the current matrix as a new Vector4
  3063. */
  3064. getRow(index: number): Nullable<Vector4>;
  3065. /**
  3066. * Sets the index-th row of the current matrix to the vector4 values
  3067. * @param index defines the number of the row to set
  3068. * @param row defines the target vector4
  3069. * @returns the updated current matrix
  3070. */
  3071. setRow(index: number, row: Vector4): Matrix;
  3072. /**
  3073. * Compute the transpose of the matrix
  3074. * @returns the new transposed matrix
  3075. */
  3076. transpose(): Matrix;
  3077. /**
  3078. * Compute the transpose of the matrix and store it in a given matrix
  3079. * @param result defines the target matrix
  3080. * @returns the current matrix
  3081. */
  3082. transposeToRef(result: Matrix): Matrix;
  3083. /**
  3084. * Sets the index-th row of the current matrix with the given 4 x float values
  3085. * @param index defines the row index
  3086. * @param x defines the x component to set
  3087. * @param y defines the y component to set
  3088. * @param z defines the z component to set
  3089. * @param w defines the w component to set
  3090. * @returns the updated current matrix
  3091. */
  3092. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3093. /**
  3094. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3095. * @param scale defines the scale factor
  3096. * @returns a new matrix
  3097. */
  3098. scale(scale: number): Matrix;
  3099. /**
  3100. * Scale the current matrix values by a factor to a given result matrix
  3101. * @param scale defines the scale factor
  3102. * @param result defines the matrix to store the result
  3103. * @returns the current matrix
  3104. */
  3105. scaleToRef(scale: number, result: Matrix): Matrix;
  3106. /**
  3107. * Scale the current matrix values by a factor and add the result to a given matrix
  3108. * @param scale defines the scale factor
  3109. * @param result defines the Matrix to store the result
  3110. * @returns the current matrix
  3111. */
  3112. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3113. /**
  3114. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3115. * @param ref matrix to store the result
  3116. */
  3117. toNormalMatrix(ref: Matrix): void;
  3118. /**
  3119. * Gets only rotation part of the current matrix
  3120. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3121. */
  3122. getRotationMatrix(): Matrix;
  3123. /**
  3124. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3125. * @param result defines the target matrix to store data to
  3126. * @returns the current matrix
  3127. */
  3128. getRotationMatrixToRef(result: Matrix): Matrix;
  3129. /**
  3130. * Toggles model matrix from being right handed to left handed in place and vice versa
  3131. */
  3132. toggleModelMatrixHandInPlace(): void;
  3133. /**
  3134. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3135. */
  3136. toggleProjectionMatrixHandInPlace(): void;
  3137. /**
  3138. * Creates a matrix from an array
  3139. * @param array defines the source array
  3140. * @param offset defines an offset in the source array
  3141. * @returns a new Matrix set from the starting index of the given array
  3142. */
  3143. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3144. /**
  3145. * Copy the content of an array into a given matrix
  3146. * @param array defines the source array
  3147. * @param offset defines an offset in the source array
  3148. * @param result defines the target matrix
  3149. */
  3150. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3151. /**
  3152. * Stores an array into a matrix after having multiplied each component by a given factor
  3153. * @param array defines the source array
  3154. * @param offset defines the offset in the source array
  3155. * @param scale defines the scaling factor
  3156. * @param result defines the target matrix
  3157. */
  3158. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3159. /**
  3160. * Gets an identity matrix that must not be updated
  3161. */
  3162. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3163. /**
  3164. * Stores a list of values (16) inside a given matrix
  3165. * @param initialM11 defines 1st value of 1st row
  3166. * @param initialM12 defines 2nd value of 1st row
  3167. * @param initialM13 defines 3rd value of 1st row
  3168. * @param initialM14 defines 4th value of 1st row
  3169. * @param initialM21 defines 1st value of 2nd row
  3170. * @param initialM22 defines 2nd value of 2nd row
  3171. * @param initialM23 defines 3rd value of 2nd row
  3172. * @param initialM24 defines 4th value of 2nd row
  3173. * @param initialM31 defines 1st value of 3rd row
  3174. * @param initialM32 defines 2nd value of 3rd row
  3175. * @param initialM33 defines 3rd value of 3rd row
  3176. * @param initialM34 defines 4th value of 3rd row
  3177. * @param initialM41 defines 1st value of 4th row
  3178. * @param initialM42 defines 2nd value of 4th row
  3179. * @param initialM43 defines 3rd value of 4th row
  3180. * @param initialM44 defines 4th value of 4th row
  3181. * @param result defines the target matrix
  3182. */
  3183. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3184. /**
  3185. * Creates new matrix from a list of values (16)
  3186. * @param initialM11 defines 1st value of 1st row
  3187. * @param initialM12 defines 2nd value of 1st row
  3188. * @param initialM13 defines 3rd value of 1st row
  3189. * @param initialM14 defines 4th value of 1st row
  3190. * @param initialM21 defines 1st value of 2nd row
  3191. * @param initialM22 defines 2nd value of 2nd row
  3192. * @param initialM23 defines 3rd value of 2nd row
  3193. * @param initialM24 defines 4th value of 2nd row
  3194. * @param initialM31 defines 1st value of 3rd row
  3195. * @param initialM32 defines 2nd value of 3rd row
  3196. * @param initialM33 defines 3rd value of 3rd row
  3197. * @param initialM34 defines 4th value of 3rd row
  3198. * @param initialM41 defines 1st value of 4th row
  3199. * @param initialM42 defines 2nd value of 4th row
  3200. * @param initialM43 defines 3rd value of 4th row
  3201. * @param initialM44 defines 4th value of 4th row
  3202. * @returns the new matrix
  3203. */
  3204. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3205. /**
  3206. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3207. * @param scale defines the scale vector3
  3208. * @param rotation defines the rotation quaternion
  3209. * @param translation defines the translation vector3
  3210. * @returns a new matrix
  3211. */
  3212. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3213. /**
  3214. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3215. * @param scale defines the scale vector3
  3216. * @param rotation defines the rotation quaternion
  3217. * @param translation defines the translation vector3
  3218. * @param result defines the target matrix
  3219. */
  3220. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3221. /**
  3222. * Creates a new identity matrix
  3223. * @returns a new identity matrix
  3224. */
  3225. static Identity(): Matrix;
  3226. /**
  3227. * Creates a new identity matrix and stores the result in a given matrix
  3228. * @param result defines the target matrix
  3229. */
  3230. static IdentityToRef(result: Matrix): void;
  3231. /**
  3232. * Creates a new zero matrix
  3233. * @returns a new zero matrix
  3234. */
  3235. static Zero(): Matrix;
  3236. /**
  3237. * Creates a new rotation matrix for "angle" radians around the X axis
  3238. * @param angle defines the angle (in radians) to use
  3239. * @return the new matrix
  3240. */
  3241. static RotationX(angle: number): Matrix;
  3242. /**
  3243. * Creates a new matrix as the invert of a given matrix
  3244. * @param source defines the source matrix
  3245. * @returns the new matrix
  3246. */
  3247. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3248. /**
  3249. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3250. * @param angle defines the angle (in radians) to use
  3251. * @param result defines the target matrix
  3252. */
  3253. static RotationXToRef(angle: number, result: Matrix): void;
  3254. /**
  3255. * Creates a new rotation matrix for "angle" radians around the Y axis
  3256. * @param angle defines the angle (in radians) to use
  3257. * @return the new matrix
  3258. */
  3259. static RotationY(angle: number): Matrix;
  3260. /**
  3261. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3262. * @param angle defines the angle (in radians) to use
  3263. * @param result defines the target matrix
  3264. */
  3265. static RotationYToRef(angle: number, result: Matrix): void;
  3266. /**
  3267. * Creates a new rotation matrix for "angle" radians around the Z axis
  3268. * @param angle defines the angle (in radians) to use
  3269. * @return the new matrix
  3270. */
  3271. static RotationZ(angle: number): Matrix;
  3272. /**
  3273. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3274. * @param angle defines the angle (in radians) to use
  3275. * @param result defines the target matrix
  3276. */
  3277. static RotationZToRef(angle: number, result: Matrix): void;
  3278. /**
  3279. * Creates a new rotation matrix for "angle" radians around the given axis
  3280. * @param axis defines the axis to use
  3281. * @param angle defines the angle (in radians) to use
  3282. * @return the new matrix
  3283. */
  3284. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3285. /**
  3286. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3287. * @param axis defines the axis to use
  3288. * @param angle defines the angle (in radians) to use
  3289. * @param result defines the target matrix
  3290. */
  3291. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3292. /**
  3293. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3294. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3295. * @param from defines the vector to align
  3296. * @param to defines the vector to align to
  3297. * @param result defines the target matrix
  3298. */
  3299. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3300. /**
  3301. * Creates a rotation matrix
  3302. * @param yaw defines the yaw angle in radians (Y axis)
  3303. * @param pitch defines the pitch angle in radians (X axis)
  3304. * @param roll defines the roll angle in radians (X axis)
  3305. * @returns the new rotation matrix
  3306. */
  3307. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3308. /**
  3309. * Creates a rotation matrix and stores it in a given matrix
  3310. * @param yaw defines the yaw angle in radians (Y axis)
  3311. * @param pitch defines the pitch angle in radians (X axis)
  3312. * @param roll defines the roll angle in radians (X axis)
  3313. * @param result defines the target matrix
  3314. */
  3315. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3316. /**
  3317. * Creates a scaling matrix
  3318. * @param x defines the scale factor on X axis
  3319. * @param y defines the scale factor on Y axis
  3320. * @param z defines the scale factor on Z axis
  3321. * @returns the new matrix
  3322. */
  3323. static Scaling(x: number, y: number, z: number): Matrix;
  3324. /**
  3325. * Creates a scaling matrix and stores it in a given matrix
  3326. * @param x defines the scale factor on X axis
  3327. * @param y defines the scale factor on Y axis
  3328. * @param z defines the scale factor on Z axis
  3329. * @param result defines the target matrix
  3330. */
  3331. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3332. /**
  3333. * Creates a translation matrix
  3334. * @param x defines the translation on X axis
  3335. * @param y defines the translation on Y axis
  3336. * @param z defines the translationon Z axis
  3337. * @returns the new matrix
  3338. */
  3339. static Translation(x: number, y: number, z: number): Matrix;
  3340. /**
  3341. * Creates a translation matrix and stores it in a given matrix
  3342. * @param x defines the translation on X axis
  3343. * @param y defines the translation on Y axis
  3344. * @param z defines the translationon Z axis
  3345. * @param result defines the target matrix
  3346. */
  3347. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3348. /**
  3349. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3350. * @param startValue defines the start value
  3351. * @param endValue defines the end value
  3352. * @param gradient defines the gradient factor
  3353. * @returns the new matrix
  3354. */
  3355. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3356. /**
  3357. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3358. * @param startValue defines the start value
  3359. * @param endValue defines the end value
  3360. * @param gradient defines the gradient factor
  3361. * @param result defines the Matrix object where to store data
  3362. */
  3363. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3364. /**
  3365. * Builds a new matrix whose values are computed by:
  3366. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3367. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3368. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3369. * @param startValue defines the first matrix
  3370. * @param endValue defines the second matrix
  3371. * @param gradient defines the gradient between the two matrices
  3372. * @returns the new matrix
  3373. */
  3374. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3375. /**
  3376. * Update a matrix to values which are computed by:
  3377. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3378. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3379. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3380. * @param startValue defines the first matrix
  3381. * @param endValue defines the second matrix
  3382. * @param gradient defines the gradient between the two matrices
  3383. * @param result defines the target matrix
  3384. */
  3385. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3386. /**
  3387. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3388. * This function works in left handed mode
  3389. * @param eye defines the final position of the entity
  3390. * @param target defines where the entity should look at
  3391. * @param up defines the up vector for the entity
  3392. * @returns the new matrix
  3393. */
  3394. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3395. /**
  3396. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3397. * This function works in left handed mode
  3398. * @param eye defines the final position of the entity
  3399. * @param target defines where the entity should look at
  3400. * @param up defines the up vector for the entity
  3401. * @param result defines the target matrix
  3402. */
  3403. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3404. /**
  3405. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3406. * This function works in right handed mode
  3407. * @param eye defines the final position of the entity
  3408. * @param target defines where the entity should look at
  3409. * @param up defines the up vector for the entity
  3410. * @returns the new matrix
  3411. */
  3412. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3413. /**
  3414. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3415. * This function works in right handed mode
  3416. * @param eye defines the final position of the entity
  3417. * @param target defines where the entity should look at
  3418. * @param up defines the up vector for the entity
  3419. * @param result defines the target matrix
  3420. */
  3421. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3422. /**
  3423. * Create a left-handed orthographic projection matrix
  3424. * @param width defines the viewport width
  3425. * @param height defines the viewport height
  3426. * @param znear defines the near clip plane
  3427. * @param zfar defines the far clip plane
  3428. * @returns a new matrix as a left-handed orthographic projection matrix
  3429. */
  3430. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3431. /**
  3432. * Store a left-handed orthographic projection to a given matrix
  3433. * @param width defines the viewport width
  3434. * @param height defines the viewport height
  3435. * @param znear defines the near clip plane
  3436. * @param zfar defines the far clip plane
  3437. * @param result defines the target matrix
  3438. */
  3439. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3440. /**
  3441. * Create a left-handed orthographic projection matrix
  3442. * @param left defines the viewport left coordinate
  3443. * @param right defines the viewport right coordinate
  3444. * @param bottom defines the viewport bottom coordinate
  3445. * @param top defines the viewport top coordinate
  3446. * @param znear defines the near clip plane
  3447. * @param zfar defines the far clip plane
  3448. * @returns a new matrix as a left-handed orthographic projection matrix
  3449. */
  3450. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3451. /**
  3452. * Stores a left-handed orthographic projection into a given matrix
  3453. * @param left defines the viewport left coordinate
  3454. * @param right defines the viewport right coordinate
  3455. * @param bottom defines the viewport bottom coordinate
  3456. * @param top defines the viewport top coordinate
  3457. * @param znear defines the near clip plane
  3458. * @param zfar defines the far clip plane
  3459. * @param result defines the target matrix
  3460. */
  3461. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3462. /**
  3463. * Creates a right-handed orthographic projection matrix
  3464. * @param left defines the viewport left coordinate
  3465. * @param right defines the viewport right coordinate
  3466. * @param bottom defines the viewport bottom coordinate
  3467. * @param top defines the viewport top coordinate
  3468. * @param znear defines the near clip plane
  3469. * @param zfar defines the far clip plane
  3470. * @returns a new matrix as a right-handed orthographic projection matrix
  3471. */
  3472. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3473. /**
  3474. * Stores a right-handed orthographic projection into a given matrix
  3475. * @param left defines the viewport left coordinate
  3476. * @param right defines the viewport right coordinate
  3477. * @param bottom defines the viewport bottom coordinate
  3478. * @param top defines the viewport top coordinate
  3479. * @param znear defines the near clip plane
  3480. * @param zfar defines the far clip plane
  3481. * @param result defines the target matrix
  3482. */
  3483. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3484. /**
  3485. * Creates a left-handed perspective projection matrix
  3486. * @param width defines the viewport width
  3487. * @param height defines the viewport height
  3488. * @param znear defines the near clip plane
  3489. * @param zfar defines the far clip plane
  3490. * @returns a new matrix as a left-handed perspective projection matrix
  3491. */
  3492. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3493. /**
  3494. * Creates a left-handed perspective projection matrix
  3495. * @param fov defines the horizontal field of view
  3496. * @param aspect defines the aspect ratio
  3497. * @param znear defines the near clip plane
  3498. * @param zfar defines the far clip plane
  3499. * @returns a new matrix as a left-handed perspective projection matrix
  3500. */
  3501. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3502. /**
  3503. * Stores a left-handed perspective projection into a given matrix
  3504. * @param fov defines the horizontal field of view
  3505. * @param aspect defines the aspect ratio
  3506. * @param znear defines the near clip plane
  3507. * @param zfar defines the far clip plane
  3508. * @param result defines the target matrix
  3509. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3510. */
  3511. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3512. /**
  3513. * Creates a right-handed perspective projection matrix
  3514. * @param fov defines the horizontal field of view
  3515. * @param aspect defines the aspect ratio
  3516. * @param znear defines the near clip plane
  3517. * @param zfar defines the far clip plane
  3518. * @returns a new matrix as a right-handed perspective projection matrix
  3519. */
  3520. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3521. /**
  3522. * Stores a right-handed perspective projection into a given matrix
  3523. * @param fov defines the horizontal field of view
  3524. * @param aspect defines the aspect ratio
  3525. * @param znear defines the near clip plane
  3526. * @param zfar defines the far clip plane
  3527. * @param result defines the target matrix
  3528. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3529. */
  3530. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3531. /**
  3532. * Stores a perspective projection for WebVR info a given matrix
  3533. * @param fov defines the field of view
  3534. * @param znear defines the near clip plane
  3535. * @param zfar defines the far clip plane
  3536. * @param result defines the target matrix
  3537. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3538. */
  3539. static PerspectiveFovWebVRToRef(fov: {
  3540. upDegrees: number;
  3541. downDegrees: number;
  3542. leftDegrees: number;
  3543. rightDegrees: number;
  3544. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3545. /**
  3546. * Computes a complete transformation matrix
  3547. * @param viewport defines the viewport to use
  3548. * @param world defines the world matrix
  3549. * @param view defines the view matrix
  3550. * @param projection defines the projection matrix
  3551. * @param zmin defines the near clip plane
  3552. * @param zmax defines the far clip plane
  3553. * @returns the transformation matrix
  3554. */
  3555. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3556. /**
  3557. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3558. * @param matrix defines the matrix to use
  3559. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3560. */
  3561. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3562. /**
  3563. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3564. * @param matrix defines the matrix to use
  3565. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3566. */
  3567. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3568. /**
  3569. * Compute the transpose of a given matrix
  3570. * @param matrix defines the matrix to transpose
  3571. * @returns the new matrix
  3572. */
  3573. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3574. /**
  3575. * Compute the transpose of a matrix and store it in a target matrix
  3576. * @param matrix defines the matrix to transpose
  3577. * @param result defines the target matrix
  3578. */
  3579. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3580. /**
  3581. * Computes a reflection matrix from a plane
  3582. * @param plane defines the reflection plane
  3583. * @returns a new matrix
  3584. */
  3585. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3586. /**
  3587. * Computes a reflection matrix from a plane
  3588. * @param plane defines the reflection plane
  3589. * @param result defines the target matrix
  3590. */
  3591. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3592. /**
  3593. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3594. * @param xaxis defines the value of the 1st axis
  3595. * @param yaxis defines the value of the 2nd axis
  3596. * @param zaxis defines the value of the 3rd axis
  3597. * @param result defines the target matrix
  3598. */
  3599. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3600. /**
  3601. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3602. * @param quat defines the quaternion to use
  3603. * @param result defines the target matrix
  3604. */
  3605. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3606. }
  3607. /**
  3608. * Represens a plane by the equation ax + by + cz + d = 0
  3609. */
  3610. export class Plane {
  3611. /**
  3612. * Normal of the plane (a,b,c)
  3613. */
  3614. normal: Vector3;
  3615. /**
  3616. * d component of the plane
  3617. */
  3618. d: number;
  3619. /**
  3620. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3621. * @param a a component of the plane
  3622. * @param b b component of the plane
  3623. * @param c c component of the plane
  3624. * @param d d component of the plane
  3625. */
  3626. constructor(a: number, b: number, c: number, d: number);
  3627. /**
  3628. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3629. */
  3630. asArray(): number[];
  3631. /**
  3632. * @returns a new plane copied from the current Plane.
  3633. */
  3634. clone(): Plane;
  3635. /**
  3636. * @returns the string "Plane".
  3637. */
  3638. getClassName(): string;
  3639. /**
  3640. * @returns the Plane hash code.
  3641. */
  3642. getHashCode(): number;
  3643. /**
  3644. * Normalize the current Plane in place.
  3645. * @returns the updated Plane.
  3646. */
  3647. normalize(): Plane;
  3648. /**
  3649. * Applies a transformation the plane and returns the result
  3650. * @param transformation the transformation matrix to be applied to the plane
  3651. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3652. */
  3653. transform(transformation: DeepImmutable<Matrix>): Plane;
  3654. /**
  3655. * Calcualtte the dot product between the point and the plane normal
  3656. * @param point point to calculate the dot product with
  3657. * @returns the dot product (float) of the point coordinates and the plane normal.
  3658. */
  3659. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3660. /**
  3661. * Updates the current Plane from the plane defined by the three given points.
  3662. * @param point1 one of the points used to contruct the plane
  3663. * @param point2 one of the points used to contruct the plane
  3664. * @param point3 one of the points used to contruct the plane
  3665. * @returns the updated Plane.
  3666. */
  3667. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3668. /**
  3669. * Checks if the plane is facing a given direction
  3670. * @param direction the direction to check if the plane is facing
  3671. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3672. * @returns True is the vector "direction" is the same side than the plane normal.
  3673. */
  3674. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3675. /**
  3676. * Calculates the distance to a point
  3677. * @param point point to calculate distance to
  3678. * @returns the signed distance (float) from the given point to the Plane.
  3679. */
  3680. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3681. /**
  3682. * Creates a plane from an array
  3683. * @param array the array to create a plane from
  3684. * @returns a new Plane from the given array.
  3685. */
  3686. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3687. /**
  3688. * Creates a plane from three points
  3689. * @param point1 point used to create the plane
  3690. * @param point2 point used to create the plane
  3691. * @param point3 point used to create the plane
  3692. * @returns a new Plane defined by the three given points.
  3693. */
  3694. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3695. /**
  3696. * Creates a plane from an origin point and a normal
  3697. * @param origin origin of the plane to be constructed
  3698. * @param normal normal of the plane to be constructed
  3699. * @returns a new Plane the normal vector to this plane at the given origin point.
  3700. * Note : the vector "normal" is updated because normalized.
  3701. */
  3702. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3703. /**
  3704. * Calculates the distance from a plane and a point
  3705. * @param origin origin of the plane to be constructed
  3706. * @param normal normal of the plane to be constructed
  3707. * @param point point to calculate distance to
  3708. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3709. */
  3710. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3711. }
  3712. /**
  3713. * Class used to represent a viewport on screen
  3714. */
  3715. export class Viewport {
  3716. /** viewport left coordinate */
  3717. x: number;
  3718. /** viewport top coordinate */
  3719. y: number;
  3720. /**viewport width */
  3721. width: number;
  3722. /** viewport height */
  3723. height: number;
  3724. /**
  3725. * Creates a Viewport object located at (x, y) and sized (width, height)
  3726. * @param x defines viewport left coordinate
  3727. * @param y defines viewport top coordinate
  3728. * @param width defines the viewport width
  3729. * @param height defines the viewport height
  3730. */
  3731. constructor(
  3732. /** viewport left coordinate */
  3733. x: number,
  3734. /** viewport top coordinate */
  3735. y: number,
  3736. /**viewport width */
  3737. width: number,
  3738. /** viewport height */
  3739. height: number);
  3740. /**
  3741. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3742. * @param renderWidth defines the rendering width
  3743. * @param renderHeight defines the rendering height
  3744. * @returns a new Viewport
  3745. */
  3746. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3747. /**
  3748. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3749. * @param renderWidth defines the rendering width
  3750. * @param renderHeight defines the rendering height
  3751. * @param ref defines the target viewport
  3752. * @returns the current viewport
  3753. */
  3754. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3755. /**
  3756. * Returns a new Viewport copied from the current one
  3757. * @returns a new Viewport
  3758. */
  3759. clone(): Viewport;
  3760. }
  3761. /**
  3762. * Reprasents a camera frustum
  3763. */
  3764. export class Frustum {
  3765. /**
  3766. * Gets the planes representing the frustum
  3767. * @param transform matrix to be applied to the returned planes
  3768. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3769. */
  3770. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3771. /**
  3772. * Gets the near frustum plane transformed by the transform matrix
  3773. * @param transform transformation matrix to be applied to the resulting frustum plane
  3774. * @param frustumPlane the resuling frustum plane
  3775. */
  3776. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3777. /**
  3778. * Gets the far frustum plane transformed by the transform matrix
  3779. * @param transform transformation matrix to be applied to the resulting frustum plane
  3780. * @param frustumPlane the resuling frustum plane
  3781. */
  3782. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3783. /**
  3784. * Gets the left frustum plane transformed by the transform matrix
  3785. * @param transform transformation matrix to be applied to the resulting frustum plane
  3786. * @param frustumPlane the resuling frustum plane
  3787. */
  3788. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3789. /**
  3790. * Gets the right frustum plane transformed by the transform matrix
  3791. * @param transform transformation matrix to be applied to the resulting frustum plane
  3792. * @param frustumPlane the resuling frustum plane
  3793. */
  3794. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3795. /**
  3796. * Gets the top frustum plane transformed by the transform matrix
  3797. * @param transform transformation matrix to be applied to the resulting frustum plane
  3798. * @param frustumPlane the resuling frustum plane
  3799. */
  3800. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3801. /**
  3802. * Gets the bottom frustum plane transformed by the transform matrix
  3803. * @param transform transformation matrix to be applied to the resulting frustum plane
  3804. * @param frustumPlane the resuling frustum plane
  3805. */
  3806. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3807. /**
  3808. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3809. * @param transform transformation matrix to be applied to the resulting frustum planes
  3810. * @param frustumPlanes the resuling frustum planes
  3811. */
  3812. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3813. }
  3814. /** Defines supported spaces */
  3815. export enum Space {
  3816. /** Local (object) space */
  3817. LOCAL = 0,
  3818. /** World space */
  3819. WORLD = 1,
  3820. /** Bone space */
  3821. BONE = 2
  3822. }
  3823. /** Defines the 3 main axes */
  3824. export class Axis {
  3825. /** X axis */
  3826. static X: Vector3;
  3827. /** Y axis */
  3828. static Y: Vector3;
  3829. /** Z axis */
  3830. static Z: Vector3;
  3831. }
  3832. /** Class used to represent a Bezier curve */
  3833. export class BezierCurve {
  3834. /**
  3835. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3836. * @param t defines the time
  3837. * @param x1 defines the left coordinate on X axis
  3838. * @param y1 defines the left coordinate on Y axis
  3839. * @param x2 defines the right coordinate on X axis
  3840. * @param y2 defines the right coordinate on Y axis
  3841. * @returns the interpolated value
  3842. */
  3843. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3844. }
  3845. /**
  3846. * Defines potential orientation for back face culling
  3847. */
  3848. export enum Orientation {
  3849. /**
  3850. * Clockwise
  3851. */
  3852. CW = 0,
  3853. /** Counter clockwise */
  3854. CCW = 1
  3855. }
  3856. /**
  3857. * Defines angle representation
  3858. */
  3859. export class Angle {
  3860. private _radians;
  3861. /**
  3862. * Creates an Angle object of "radians" radians (float).
  3863. * @param radians the angle in radians
  3864. */
  3865. constructor(radians: number);
  3866. /**
  3867. * Get value in degrees
  3868. * @returns the Angle value in degrees (float)
  3869. */
  3870. degrees(): number;
  3871. /**
  3872. * Get value in radians
  3873. * @returns the Angle value in radians (float)
  3874. */
  3875. radians(): number;
  3876. /**
  3877. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3878. * @param a defines first vector
  3879. * @param b defines second vector
  3880. * @returns a new Angle
  3881. */
  3882. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3883. /**
  3884. * Gets a new Angle object from the given float in radians
  3885. * @param radians defines the angle value in radians
  3886. * @returns a new Angle
  3887. */
  3888. static FromRadians(radians: number): Angle;
  3889. /**
  3890. * Gets a new Angle object from the given float in degrees
  3891. * @param degrees defines the angle value in degrees
  3892. * @returns a new Angle
  3893. */
  3894. static FromDegrees(degrees: number): Angle;
  3895. }
  3896. /**
  3897. * This represents an arc in a 2d space.
  3898. */
  3899. export class Arc2 {
  3900. /** Defines the start point of the arc */
  3901. startPoint: Vector2;
  3902. /** Defines the mid point of the arc */
  3903. midPoint: Vector2;
  3904. /** Defines the end point of the arc */
  3905. endPoint: Vector2;
  3906. /**
  3907. * Defines the center point of the arc.
  3908. */
  3909. centerPoint: Vector2;
  3910. /**
  3911. * Defines the radius of the arc.
  3912. */
  3913. radius: number;
  3914. /**
  3915. * Defines the angle of the arc (from mid point to end point).
  3916. */
  3917. angle: Angle;
  3918. /**
  3919. * Defines the start angle of the arc (from start point to middle point).
  3920. */
  3921. startAngle: Angle;
  3922. /**
  3923. * Defines the orientation of the arc (clock wise/counter clock wise).
  3924. */
  3925. orientation: Orientation;
  3926. /**
  3927. * Creates an Arc object from the three given points : start, middle and end.
  3928. * @param startPoint Defines the start point of the arc
  3929. * @param midPoint Defines the midlle point of the arc
  3930. * @param endPoint Defines the end point of the arc
  3931. */
  3932. constructor(
  3933. /** Defines the start point of the arc */
  3934. startPoint: Vector2,
  3935. /** Defines the mid point of the arc */
  3936. midPoint: Vector2,
  3937. /** Defines the end point of the arc */
  3938. endPoint: Vector2);
  3939. }
  3940. /**
  3941. * Represents a 2D path made up of multiple 2D points
  3942. */
  3943. export class Path2 {
  3944. private _points;
  3945. private _length;
  3946. /**
  3947. * If the path start and end point are the same
  3948. */
  3949. closed: boolean;
  3950. /**
  3951. * Creates a Path2 object from the starting 2D coordinates x and y.
  3952. * @param x the starting points x value
  3953. * @param y the starting points y value
  3954. */
  3955. constructor(x: number, y: number);
  3956. /**
  3957. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3958. * @param x the added points x value
  3959. * @param y the added points y value
  3960. * @returns the updated Path2.
  3961. */
  3962. addLineTo(x: number, y: number): Path2;
  3963. /**
  3964. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3965. * @param midX middle point x value
  3966. * @param midY middle point y value
  3967. * @param endX end point x value
  3968. * @param endY end point y value
  3969. * @param numberOfSegments (default: 36)
  3970. * @returns the updated Path2.
  3971. */
  3972. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3973. /**
  3974. * Closes the Path2.
  3975. * @returns the Path2.
  3976. */
  3977. close(): Path2;
  3978. /**
  3979. * Gets the sum of the distance between each sequential point in the path
  3980. * @returns the Path2 total length (float).
  3981. */
  3982. length(): number;
  3983. /**
  3984. * Gets the points which construct the path
  3985. * @returns the Path2 internal array of points.
  3986. */
  3987. getPoints(): Vector2[];
  3988. /**
  3989. * Retreives the point at the distance aways from the starting point
  3990. * @param normalizedLengthPosition the length along the path to retreive the point from
  3991. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3992. */
  3993. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3994. /**
  3995. * Creates a new path starting from an x and y position
  3996. * @param x starting x value
  3997. * @param y starting y value
  3998. * @returns a new Path2 starting at the coordinates (x, y).
  3999. */
  4000. static StartingAt(x: number, y: number): Path2;
  4001. }
  4002. /**
  4003. * Represents a 3D path made up of multiple 3D points
  4004. */
  4005. export class Path3D {
  4006. /**
  4007. * an array of Vector3, the curve axis of the Path3D
  4008. */
  4009. path: Vector3[];
  4010. private _curve;
  4011. private _distances;
  4012. private _tangents;
  4013. private _normals;
  4014. private _binormals;
  4015. private _raw;
  4016. /**
  4017. * new Path3D(path, normal, raw)
  4018. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  4019. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  4020. * @param path an array of Vector3, the curve axis of the Path3D
  4021. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  4022. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4023. */
  4024. constructor(
  4025. /**
  4026. * an array of Vector3, the curve axis of the Path3D
  4027. */
  4028. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4029. /**
  4030. * Returns the Path3D array of successive Vector3 designing its curve.
  4031. * @returns the Path3D array of successive Vector3 designing its curve.
  4032. */
  4033. getCurve(): Vector3[];
  4034. /**
  4035. * Returns an array populated with tangent vectors on each Path3D curve point.
  4036. * @returns an array populated with tangent vectors on each Path3D curve point.
  4037. */
  4038. getTangents(): Vector3[];
  4039. /**
  4040. * Returns an array populated with normal vectors on each Path3D curve point.
  4041. * @returns an array populated with normal vectors on each Path3D curve point.
  4042. */
  4043. getNormals(): Vector3[];
  4044. /**
  4045. * Returns an array populated with binormal vectors on each Path3D curve point.
  4046. * @returns an array populated with binormal vectors on each Path3D curve point.
  4047. */
  4048. getBinormals(): Vector3[];
  4049. /**
  4050. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4051. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4052. */
  4053. getDistances(): number[];
  4054. /**
  4055. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4056. * @param path path which all values are copied into the curves points
  4057. * @param firstNormal which should be projected onto the curve
  4058. * @returns the same object updated.
  4059. */
  4060. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4061. private _compute;
  4062. private _getFirstNonNullVector;
  4063. private _getLastNonNullVector;
  4064. private _normalVector;
  4065. }
  4066. /**
  4067. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4068. * A Curve3 is designed from a series of successive Vector3.
  4069. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4070. */
  4071. export class Curve3 {
  4072. private _points;
  4073. private _length;
  4074. /**
  4075. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4076. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4077. * @param v1 (Vector3) the control point
  4078. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4079. * @param nbPoints (integer) the wanted number of points in the curve
  4080. * @returns the created Curve3
  4081. */
  4082. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4083. /**
  4084. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4085. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4086. * @param v1 (Vector3) the first control point
  4087. * @param v2 (Vector3) the second control point
  4088. * @param v3 (Vector3) the end point of the Cubic Bezier
  4089. * @param nbPoints (integer) the wanted number of points in the curve
  4090. * @returns the created Curve3
  4091. */
  4092. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4093. /**
  4094. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4095. * @param p1 (Vector3) the origin point of the Hermite Spline
  4096. * @param t1 (Vector3) the tangent vector at the origin point
  4097. * @param p2 (Vector3) the end point of the Hermite Spline
  4098. * @param t2 (Vector3) the tangent vector at the end point
  4099. * @param nbPoints (integer) the wanted number of points in the curve
  4100. * @returns the created Curve3
  4101. */
  4102. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4103. /**
  4104. * Returns a Curve3 object along a CatmullRom Spline curve :
  4105. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4106. * @param nbPoints (integer) the wanted number of points between each curve control points
  4107. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4108. * @returns the created Curve3
  4109. */
  4110. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4111. /**
  4112. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4113. * A Curve3 is designed from a series of successive Vector3.
  4114. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4115. * @param points points which make up the curve
  4116. */
  4117. constructor(points: Vector3[]);
  4118. /**
  4119. * @returns the Curve3 stored array of successive Vector3
  4120. */
  4121. getPoints(): Vector3[];
  4122. /**
  4123. * @returns the computed length (float) of the curve.
  4124. */
  4125. length(): number;
  4126. /**
  4127. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4128. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4129. * curveA and curveB keep unchanged.
  4130. * @param curve the curve to continue from this curve
  4131. * @returns the newly constructed curve
  4132. */
  4133. continue(curve: DeepImmutable<Curve3>): Curve3;
  4134. private _computeLength;
  4135. }
  4136. /**
  4137. * Contains position and normal vectors for a vertex
  4138. */
  4139. export class PositionNormalVertex {
  4140. /** the position of the vertex (defaut: 0,0,0) */
  4141. position: Vector3;
  4142. /** the normal of the vertex (defaut: 0,1,0) */
  4143. normal: Vector3;
  4144. /**
  4145. * Creates a PositionNormalVertex
  4146. * @param position the position of the vertex (defaut: 0,0,0)
  4147. * @param normal the normal of the vertex (defaut: 0,1,0)
  4148. */
  4149. constructor(
  4150. /** the position of the vertex (defaut: 0,0,0) */
  4151. position?: Vector3,
  4152. /** the normal of the vertex (defaut: 0,1,0) */
  4153. normal?: Vector3);
  4154. /**
  4155. * Clones the PositionNormalVertex
  4156. * @returns the cloned PositionNormalVertex
  4157. */
  4158. clone(): PositionNormalVertex;
  4159. }
  4160. /**
  4161. * Contains position, normal and uv vectors for a vertex
  4162. */
  4163. export class PositionNormalTextureVertex {
  4164. /** the position of the vertex (defaut: 0,0,0) */
  4165. position: Vector3;
  4166. /** the normal of the vertex (defaut: 0,1,0) */
  4167. normal: Vector3;
  4168. /** the uv of the vertex (default: 0,0) */
  4169. uv: Vector2;
  4170. /**
  4171. * Creates a PositionNormalTextureVertex
  4172. * @param position the position of the vertex (defaut: 0,0,0)
  4173. * @param normal the normal of the vertex (defaut: 0,1,0)
  4174. * @param uv the uv of the vertex (default: 0,0)
  4175. */
  4176. constructor(
  4177. /** the position of the vertex (defaut: 0,0,0) */
  4178. position?: Vector3,
  4179. /** the normal of the vertex (defaut: 0,1,0) */
  4180. normal?: Vector3,
  4181. /** the uv of the vertex (default: 0,0) */
  4182. uv?: Vector2);
  4183. /**
  4184. * Clones the PositionNormalTextureVertex
  4185. * @returns the cloned PositionNormalTextureVertex
  4186. */
  4187. clone(): PositionNormalTextureVertex;
  4188. }
  4189. /**
  4190. * @hidden
  4191. */
  4192. export class Tmp {
  4193. static Color3: Color3[];
  4194. static Color4: Color4[];
  4195. static Vector2: Vector2[];
  4196. static Vector3: Vector3[];
  4197. static Vector4: Vector4[];
  4198. static Quaternion: Quaternion[];
  4199. static Matrix: Matrix[];
  4200. }
  4201. }
  4202. declare module "babylonjs/Offline/IOfflineProvider" {
  4203. /**
  4204. * Class used to enable access to offline support
  4205. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4206. */
  4207. export interface IOfflineProvider {
  4208. /**
  4209. * Gets a boolean indicating if scene must be saved in the database
  4210. */
  4211. enableSceneOffline: boolean;
  4212. /**
  4213. * Gets a boolean indicating if textures must be saved in the database
  4214. */
  4215. enableTexturesOffline: boolean;
  4216. /**
  4217. * Open the offline support and make it available
  4218. * @param successCallback defines the callback to call on success
  4219. * @param errorCallback defines the callback to call on error
  4220. */
  4221. open(successCallback: () => void, errorCallback: () => void): void;
  4222. /**
  4223. * Loads an image from the offline support
  4224. * @param url defines the url to load from
  4225. * @param image defines the target DOM image
  4226. */
  4227. loadImage(url: string, image: HTMLImageElement): void;
  4228. /**
  4229. * Loads a file from offline support
  4230. * @param url defines the URL to load from
  4231. * @param sceneLoaded defines a callback to call on success
  4232. * @param progressCallBack defines a callback to call when progress changed
  4233. * @param errorCallback defines a callback to call on error
  4234. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4235. */
  4236. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4237. }
  4238. }
  4239. declare module "babylonjs/Misc/observable" {
  4240. import { Nullable } from "babylonjs/types";
  4241. /**
  4242. * A class serves as a medium between the observable and its observers
  4243. */
  4244. export class EventState {
  4245. /**
  4246. * Create a new EventState
  4247. * @param mask defines the mask associated with this state
  4248. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4249. * @param target defines the original target of the state
  4250. * @param currentTarget defines the current target of the state
  4251. */
  4252. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4253. /**
  4254. * Initialize the current event state
  4255. * @param mask defines the mask associated with this state
  4256. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4257. * @param target defines the original target of the state
  4258. * @param currentTarget defines the current target of the state
  4259. * @returns the current event state
  4260. */
  4261. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4262. /**
  4263. * An Observer can set this property to true to prevent subsequent observers of being notified
  4264. */
  4265. skipNextObservers: boolean;
  4266. /**
  4267. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4268. */
  4269. mask: number;
  4270. /**
  4271. * The object that originally notified the event
  4272. */
  4273. target?: any;
  4274. /**
  4275. * The current object in the bubbling phase
  4276. */
  4277. currentTarget?: any;
  4278. /**
  4279. * This will be populated with the return value of the last function that was executed.
  4280. * If it is the first function in the callback chain it will be the event data.
  4281. */
  4282. lastReturnValue?: any;
  4283. }
  4284. /**
  4285. * Represent an Observer registered to a given Observable object.
  4286. */
  4287. export class Observer<T> {
  4288. /**
  4289. * Defines the callback to call when the observer is notified
  4290. */
  4291. callback: (eventData: T, eventState: EventState) => void;
  4292. /**
  4293. * Defines the mask of the observer (used to filter notifications)
  4294. */
  4295. mask: number;
  4296. /**
  4297. * Defines the current scope used to restore the JS context
  4298. */
  4299. scope: any;
  4300. /** @hidden */
  4301. _willBeUnregistered: boolean;
  4302. /**
  4303. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4304. */
  4305. unregisterOnNextCall: boolean;
  4306. /**
  4307. * Creates a new observer
  4308. * @param callback defines the callback to call when the observer is notified
  4309. * @param mask defines the mask of the observer (used to filter notifications)
  4310. * @param scope defines the current scope used to restore the JS context
  4311. */
  4312. constructor(
  4313. /**
  4314. * Defines the callback to call when the observer is notified
  4315. */
  4316. callback: (eventData: T, eventState: EventState) => void,
  4317. /**
  4318. * Defines the mask of the observer (used to filter notifications)
  4319. */
  4320. mask: number,
  4321. /**
  4322. * Defines the current scope used to restore the JS context
  4323. */
  4324. scope?: any);
  4325. }
  4326. /**
  4327. * Represent a list of observers registered to multiple Observables object.
  4328. */
  4329. export class MultiObserver<T> {
  4330. private _observers;
  4331. private _observables;
  4332. /**
  4333. * Release associated resources
  4334. */
  4335. dispose(): void;
  4336. /**
  4337. * Raise a callback when one of the observable will notify
  4338. * @param observables defines a list of observables to watch
  4339. * @param callback defines the callback to call on notification
  4340. * @param mask defines the mask used to filter notifications
  4341. * @param scope defines the current scope used to restore the JS context
  4342. * @returns the new MultiObserver
  4343. */
  4344. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4345. }
  4346. /**
  4347. * The Observable class is a simple implementation of the Observable pattern.
  4348. *
  4349. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4350. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4351. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4352. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4353. */
  4354. export class Observable<T> {
  4355. private _observers;
  4356. private _eventState;
  4357. private _onObserverAdded;
  4358. /**
  4359. * Creates a new observable
  4360. * @param onObserverAdded defines a callback to call when a new observer is added
  4361. */
  4362. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4363. /**
  4364. * Create a new Observer with the specified callback
  4365. * @param callback the callback that will be executed for that Observer
  4366. * @param mask the mask used to filter observers
  4367. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4368. * @param scope optional scope for the callback to be called from
  4369. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4370. * @returns the new observer created for the callback
  4371. */
  4372. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4373. /**
  4374. * Create a new Observer with the specified callback and unregisters after the next notification
  4375. * @param callback the callback that will be executed for that Observer
  4376. * @returns the new observer created for the callback
  4377. */
  4378. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4379. /**
  4380. * Remove an Observer from the Observable object
  4381. * @param observer the instance of the Observer to remove
  4382. * @returns false if it doesn't belong to this Observable
  4383. */
  4384. remove(observer: Nullable<Observer<T>>): boolean;
  4385. /**
  4386. * Remove a callback from the Observable object
  4387. * @param callback the callback to remove
  4388. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4389. * @returns false if it doesn't belong to this Observable
  4390. */
  4391. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4392. private _deferUnregister;
  4393. private _remove;
  4394. /**
  4395. * Moves the observable to the top of the observer list making it get called first when notified
  4396. * @param observer the observer to move
  4397. */
  4398. makeObserverTopPriority(observer: Observer<T>): void;
  4399. /**
  4400. * Moves the observable to the bottom of the observer list making it get called last when notified
  4401. * @param observer the observer to move
  4402. */
  4403. makeObserverBottomPriority(observer: Observer<T>): void;
  4404. /**
  4405. * Notify all Observers by calling their respective callback with the given data
  4406. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4407. * @param eventData defines the data to send to all observers
  4408. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4409. * @param target defines the original target of the state
  4410. * @param currentTarget defines the current target of the state
  4411. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4412. */
  4413. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4414. /**
  4415. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4416. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4417. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4418. * and it is crucial that all callbacks will be executed.
  4419. * The order of the callbacks is kept, callbacks are not executed parallel.
  4420. *
  4421. * @param eventData The data to be sent to each callback
  4422. * @param mask is used to filter observers defaults to -1
  4423. * @param target defines the callback target (see EventState)
  4424. * @param currentTarget defines he current object in the bubbling phase
  4425. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4426. */
  4427. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4428. /**
  4429. * Notify a specific observer
  4430. * @param observer defines the observer to notify
  4431. * @param eventData defines the data to be sent to each callback
  4432. * @param mask is used to filter observers defaults to -1
  4433. */
  4434. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4435. /**
  4436. * Gets a boolean indicating if the observable has at least one observer
  4437. * @returns true is the Observable has at least one Observer registered
  4438. */
  4439. hasObservers(): boolean;
  4440. /**
  4441. * Clear the list of observers
  4442. */
  4443. clear(): void;
  4444. /**
  4445. * Clone the current observable
  4446. * @returns a new observable
  4447. */
  4448. clone(): Observable<T>;
  4449. /**
  4450. * Does this observable handles observer registered with a given mask
  4451. * @param mask defines the mask to be tested
  4452. * @return whether or not one observer registered with the given mask is handeled
  4453. **/
  4454. hasSpecificMask(mask?: number): boolean;
  4455. }
  4456. }
  4457. declare module "babylonjs/Misc/filesInputStore" {
  4458. /**
  4459. * Class used to help managing file picking and drag'n'drop
  4460. * File Storage
  4461. */
  4462. export class FilesInputStore {
  4463. /**
  4464. * List of files ready to be loaded
  4465. */
  4466. static FilesToLoad: {
  4467. [key: string]: File;
  4468. };
  4469. }
  4470. }
  4471. declare module "babylonjs/Engines/constants" {
  4472. /** Defines the cross module used constants to avoid circular dependncies */
  4473. export class Constants {
  4474. /** Defines that alpha blending is disabled */
  4475. static readonly ALPHA_DISABLE: number;
  4476. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4477. static readonly ALPHA_ADD: number;
  4478. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4479. static readonly ALPHA_COMBINE: number;
  4480. /** Defines that alpha blending to DEST - SRC * DEST */
  4481. static readonly ALPHA_SUBTRACT: number;
  4482. /** Defines that alpha blending to SRC * DEST */
  4483. static readonly ALPHA_MULTIPLY: number;
  4484. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4485. static readonly ALPHA_MAXIMIZED: number;
  4486. /** Defines that alpha blending to SRC + DEST */
  4487. static readonly ALPHA_ONEONE: number;
  4488. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4489. static readonly ALPHA_PREMULTIPLIED: number;
  4490. /**
  4491. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4492. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4493. */
  4494. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4495. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4496. static readonly ALPHA_INTERPOLATE: number;
  4497. /**
  4498. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4499. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4500. */
  4501. static readonly ALPHA_SCREENMODE: number;
  4502. /** Defines that the ressource is not delayed*/
  4503. static readonly DELAYLOADSTATE_NONE: number;
  4504. /** Defines that the ressource was successfully delay loaded */
  4505. static readonly DELAYLOADSTATE_LOADED: number;
  4506. /** Defines that the ressource is currently delay loading */
  4507. static readonly DELAYLOADSTATE_LOADING: number;
  4508. /** Defines that the ressource is delayed and has not started loading */
  4509. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4510. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4511. static readonly NEVER: number;
  4512. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4513. static readonly ALWAYS: number;
  4514. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4515. static readonly LESS: number;
  4516. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4517. static readonly EQUAL: number;
  4518. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4519. static readonly LEQUAL: number;
  4520. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4521. static readonly GREATER: number;
  4522. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4523. static readonly GEQUAL: number;
  4524. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4525. static readonly NOTEQUAL: number;
  4526. /** Passed to stencilOperation to specify that stencil value must be kept */
  4527. static readonly KEEP: number;
  4528. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4529. static readonly REPLACE: number;
  4530. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4531. static readonly INCR: number;
  4532. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4533. static readonly DECR: number;
  4534. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4535. static readonly INVERT: number;
  4536. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4537. static readonly INCR_WRAP: number;
  4538. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4539. static readonly DECR_WRAP: number;
  4540. /** Texture is not repeating outside of 0..1 UVs */
  4541. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4542. /** Texture is repeating outside of 0..1 UVs */
  4543. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4544. /** Texture is repeating and mirrored */
  4545. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4546. /** ALPHA */
  4547. static readonly TEXTUREFORMAT_ALPHA: number;
  4548. /** LUMINANCE */
  4549. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4550. /** LUMINANCE_ALPHA */
  4551. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4552. /** RGB */
  4553. static readonly TEXTUREFORMAT_RGB: number;
  4554. /** RGBA */
  4555. static readonly TEXTUREFORMAT_RGBA: number;
  4556. /** RED */
  4557. static readonly TEXTUREFORMAT_RED: number;
  4558. /** RED (2nd reference) */
  4559. static readonly TEXTUREFORMAT_R: number;
  4560. /** RG */
  4561. static readonly TEXTUREFORMAT_RG: number;
  4562. /** RED_INTEGER */
  4563. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4564. /** RED_INTEGER (2nd reference) */
  4565. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4566. /** RG_INTEGER */
  4567. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4568. /** RGB_INTEGER */
  4569. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4570. /** RGBA_INTEGER */
  4571. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4572. /** UNSIGNED_BYTE */
  4573. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4574. /** UNSIGNED_BYTE (2nd reference) */
  4575. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4576. /** FLOAT */
  4577. static readonly TEXTURETYPE_FLOAT: number;
  4578. /** HALF_FLOAT */
  4579. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4580. /** BYTE */
  4581. static readonly TEXTURETYPE_BYTE: number;
  4582. /** SHORT */
  4583. static readonly TEXTURETYPE_SHORT: number;
  4584. /** UNSIGNED_SHORT */
  4585. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4586. /** INT */
  4587. static readonly TEXTURETYPE_INT: number;
  4588. /** UNSIGNED_INT */
  4589. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4590. /** UNSIGNED_SHORT_4_4_4_4 */
  4591. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4592. /** UNSIGNED_SHORT_5_5_5_1 */
  4593. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4594. /** UNSIGNED_SHORT_5_6_5 */
  4595. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4596. /** UNSIGNED_INT_2_10_10_10_REV */
  4597. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4598. /** UNSIGNED_INT_24_8 */
  4599. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4600. /** UNSIGNED_INT_10F_11F_11F_REV */
  4601. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4602. /** UNSIGNED_INT_5_9_9_9_REV */
  4603. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4604. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4605. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4606. /** nearest is mag = nearest and min = nearest and mip = linear */
  4607. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4608. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4609. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4610. /** Trilinear is mag = linear and min = linear and mip = linear */
  4611. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4612. /** nearest is mag = nearest and min = nearest and mip = linear */
  4613. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4614. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4615. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4616. /** Trilinear is mag = linear and min = linear and mip = linear */
  4617. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4618. /** mag = nearest and min = nearest and mip = nearest */
  4619. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4620. /** mag = nearest and min = linear and mip = nearest */
  4621. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4622. /** mag = nearest and min = linear and mip = linear */
  4623. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4624. /** mag = nearest and min = linear and mip = none */
  4625. static readonly TEXTURE_NEAREST_LINEAR: number;
  4626. /** mag = nearest and min = nearest and mip = none */
  4627. static readonly TEXTURE_NEAREST_NEAREST: number;
  4628. /** mag = linear and min = nearest and mip = nearest */
  4629. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4630. /** mag = linear and min = nearest and mip = linear */
  4631. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4632. /** mag = linear and min = linear and mip = none */
  4633. static readonly TEXTURE_LINEAR_LINEAR: number;
  4634. /** mag = linear and min = nearest and mip = none */
  4635. static readonly TEXTURE_LINEAR_NEAREST: number;
  4636. /** Explicit coordinates mode */
  4637. static readonly TEXTURE_EXPLICIT_MODE: number;
  4638. /** Spherical coordinates mode */
  4639. static readonly TEXTURE_SPHERICAL_MODE: number;
  4640. /** Planar coordinates mode */
  4641. static readonly TEXTURE_PLANAR_MODE: number;
  4642. /** Cubic coordinates mode */
  4643. static readonly TEXTURE_CUBIC_MODE: number;
  4644. /** Projection coordinates mode */
  4645. static readonly TEXTURE_PROJECTION_MODE: number;
  4646. /** Skybox coordinates mode */
  4647. static readonly TEXTURE_SKYBOX_MODE: number;
  4648. /** Inverse Cubic coordinates mode */
  4649. static readonly TEXTURE_INVCUBIC_MODE: number;
  4650. /** Equirectangular coordinates mode */
  4651. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4652. /** Equirectangular Fixed coordinates mode */
  4653. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4654. /** Equirectangular Fixed Mirrored coordinates mode */
  4655. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4656. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4657. static readonly SCALEMODE_FLOOR: number;
  4658. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4659. static readonly SCALEMODE_NEAREST: number;
  4660. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4661. static readonly SCALEMODE_CEILING: number;
  4662. /**
  4663. * The dirty texture flag value
  4664. */
  4665. static readonly MATERIAL_TextureDirtyFlag: number;
  4666. /**
  4667. * The dirty light flag value
  4668. */
  4669. static readonly MATERIAL_LightDirtyFlag: number;
  4670. /**
  4671. * The dirty fresnel flag value
  4672. */
  4673. static readonly MATERIAL_FresnelDirtyFlag: number;
  4674. /**
  4675. * The dirty attribute flag value
  4676. */
  4677. static readonly MATERIAL_AttributesDirtyFlag: number;
  4678. /**
  4679. * The dirty misc flag value
  4680. */
  4681. static readonly MATERIAL_MiscDirtyFlag: number;
  4682. /**
  4683. * The all dirty flag value
  4684. */
  4685. static readonly MATERIAL_AllDirtyFlag: number;
  4686. /**
  4687. * Returns the triangle fill mode
  4688. */
  4689. static readonly MATERIAL_TriangleFillMode: number;
  4690. /**
  4691. * Returns the wireframe mode
  4692. */
  4693. static readonly MATERIAL_WireFrameFillMode: number;
  4694. /**
  4695. * Returns the point fill mode
  4696. */
  4697. static readonly MATERIAL_PointFillMode: number;
  4698. /**
  4699. * Returns the point list draw mode
  4700. */
  4701. static readonly MATERIAL_PointListDrawMode: number;
  4702. /**
  4703. * Returns the line list draw mode
  4704. */
  4705. static readonly MATERIAL_LineListDrawMode: number;
  4706. /**
  4707. * Returns the line loop draw mode
  4708. */
  4709. static readonly MATERIAL_LineLoopDrawMode: number;
  4710. /**
  4711. * Returns the line strip draw mode
  4712. */
  4713. static readonly MATERIAL_LineStripDrawMode: number;
  4714. /**
  4715. * Returns the triangle strip draw mode
  4716. */
  4717. static readonly MATERIAL_TriangleStripDrawMode: number;
  4718. /**
  4719. * Returns the triangle fan draw mode
  4720. */
  4721. static readonly MATERIAL_TriangleFanDrawMode: number;
  4722. /**
  4723. * Stores the clock-wise side orientation
  4724. */
  4725. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4726. /**
  4727. * Stores the counter clock-wise side orientation
  4728. */
  4729. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4730. /**
  4731. * Nothing
  4732. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4733. */
  4734. static readonly ACTION_NothingTrigger: number;
  4735. /**
  4736. * On pick
  4737. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4738. */
  4739. static readonly ACTION_OnPickTrigger: number;
  4740. /**
  4741. * On left pick
  4742. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4743. */
  4744. static readonly ACTION_OnLeftPickTrigger: number;
  4745. /**
  4746. * On right pick
  4747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4748. */
  4749. static readonly ACTION_OnRightPickTrigger: number;
  4750. /**
  4751. * On center pick
  4752. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4753. */
  4754. static readonly ACTION_OnCenterPickTrigger: number;
  4755. /**
  4756. * On pick down
  4757. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4758. */
  4759. static readonly ACTION_OnPickDownTrigger: number;
  4760. /**
  4761. * On double pick
  4762. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4763. */
  4764. static readonly ACTION_OnDoublePickTrigger: number;
  4765. /**
  4766. * On pick up
  4767. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4768. */
  4769. static readonly ACTION_OnPickUpTrigger: number;
  4770. /**
  4771. * On pick out.
  4772. * This trigger will only be raised if you also declared a OnPickDown
  4773. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4774. */
  4775. static readonly ACTION_OnPickOutTrigger: number;
  4776. /**
  4777. * On long press
  4778. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4779. */
  4780. static readonly ACTION_OnLongPressTrigger: number;
  4781. /**
  4782. * On pointer over
  4783. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4784. */
  4785. static readonly ACTION_OnPointerOverTrigger: number;
  4786. /**
  4787. * On pointer out
  4788. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4789. */
  4790. static readonly ACTION_OnPointerOutTrigger: number;
  4791. /**
  4792. * On every frame
  4793. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4794. */
  4795. static readonly ACTION_OnEveryFrameTrigger: number;
  4796. /**
  4797. * On intersection enter
  4798. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4799. */
  4800. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4801. /**
  4802. * On intersection exit
  4803. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4804. */
  4805. static readonly ACTION_OnIntersectionExitTrigger: number;
  4806. /**
  4807. * On key down
  4808. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4809. */
  4810. static readonly ACTION_OnKeyDownTrigger: number;
  4811. /**
  4812. * On key up
  4813. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4814. */
  4815. static readonly ACTION_OnKeyUpTrigger: number;
  4816. /**
  4817. * Billboard mode will only apply to Y axis
  4818. */
  4819. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4820. /**
  4821. * Billboard mode will apply to all axes
  4822. */
  4823. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4824. /**
  4825. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4826. */
  4827. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4828. /**
  4829. * Gets or sets base Assets URL
  4830. */
  4831. static readonly PARTICLES_BaseAssetsUrl: string;
  4832. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4833. * Test order :
  4834. * Is the bounding sphere outside the frustum ?
  4835. * If not, are the bounding box vertices outside the frustum ?
  4836. * It not, then the cullable object is in the frustum.
  4837. */
  4838. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4839. /** Culling strategy : Bounding Sphere Only.
  4840. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4841. * It's also less accurate than the standard because some not visible objects can still be selected.
  4842. * Test : is the bounding sphere outside the frustum ?
  4843. * If not, then the cullable object is in the frustum.
  4844. */
  4845. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4846. /** Culling strategy : Optimistic Inclusion.
  4847. * This in an inclusion test first, then the standard exclusion test.
  4848. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4849. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4850. * Anyway, it's as accurate as the standard strategy.
  4851. * Test :
  4852. * Is the cullable object bounding sphere center in the frustum ?
  4853. * If not, apply the default culling strategy.
  4854. */
  4855. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4856. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4857. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4858. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4859. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4860. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4861. * Test :
  4862. * Is the cullable object bounding sphere center in the frustum ?
  4863. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4864. */
  4865. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4866. /**
  4867. * No logging while loading
  4868. */
  4869. static readonly SCENELOADER_NO_LOGGING: number;
  4870. /**
  4871. * Minimal logging while loading
  4872. */
  4873. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4874. /**
  4875. * Summary logging while loading
  4876. */
  4877. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4878. /**
  4879. * Detailled logging while loading
  4880. */
  4881. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4882. }
  4883. }
  4884. declare module "babylonjs/Misc/domManagement" {
  4885. /**
  4886. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4887. * Babylon.js
  4888. */
  4889. export class DomManagement {
  4890. /**
  4891. * Checks if the window object exists
  4892. * @returns true if the window object exists
  4893. */
  4894. static IsWindowObjectExist(): boolean;
  4895. /**
  4896. * Extracts text content from a DOM element hierarchy
  4897. * @param element defines the root element
  4898. * @returns a string
  4899. */
  4900. static GetDOMTextContent(element: HTMLElement): string;
  4901. }
  4902. }
  4903. declare module "babylonjs/Misc/logger" {
  4904. /**
  4905. * Logger used througouht the application to allow configuration of
  4906. * the log level required for the messages.
  4907. */
  4908. export class Logger {
  4909. /**
  4910. * No log
  4911. */
  4912. static readonly NoneLogLevel: number;
  4913. /**
  4914. * Only message logs
  4915. */
  4916. static readonly MessageLogLevel: number;
  4917. /**
  4918. * Only warning logs
  4919. */
  4920. static readonly WarningLogLevel: number;
  4921. /**
  4922. * Only error logs
  4923. */
  4924. static readonly ErrorLogLevel: number;
  4925. /**
  4926. * All logs
  4927. */
  4928. static readonly AllLogLevel: number;
  4929. private static _LogCache;
  4930. /**
  4931. * Gets a value indicating the number of loading errors
  4932. * @ignorenaming
  4933. */
  4934. static errorsCount: number;
  4935. /**
  4936. * Callback called when a new log is added
  4937. */
  4938. static OnNewCacheEntry: (entry: string) => void;
  4939. private static _AddLogEntry;
  4940. private static _FormatMessage;
  4941. private static _LogDisabled;
  4942. private static _LogEnabled;
  4943. private static _WarnDisabled;
  4944. private static _WarnEnabled;
  4945. private static _ErrorDisabled;
  4946. private static _ErrorEnabled;
  4947. /**
  4948. * Log a message to the console
  4949. */
  4950. static Log: (message: string) => void;
  4951. /**
  4952. * Write a warning message to the console
  4953. */
  4954. static Warn: (message: string) => void;
  4955. /**
  4956. * Write an error message to the console
  4957. */
  4958. static Error: (message: string) => void;
  4959. /**
  4960. * Gets current log cache (list of logs)
  4961. */
  4962. static readonly LogCache: string;
  4963. /**
  4964. * Clears the log cache
  4965. */
  4966. static ClearLogCache(): void;
  4967. /**
  4968. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4969. */
  4970. static LogLevels: number;
  4971. }
  4972. }
  4973. declare module "babylonjs/Misc/typeStore" {
  4974. /** @hidden */
  4975. export class _TypeStore {
  4976. /** @hidden */
  4977. static RegisteredTypes: {
  4978. [key: string]: Object;
  4979. };
  4980. /** @hidden */
  4981. static GetClass(fqdn: string): any;
  4982. }
  4983. }
  4984. declare module "babylonjs/Misc/deepCopier" {
  4985. /**
  4986. * Class containing a set of static utilities functions for deep copy.
  4987. */
  4988. export class DeepCopier {
  4989. /**
  4990. * Tries to copy an object by duplicating every property
  4991. * @param source defines the source object
  4992. * @param destination defines the target object
  4993. * @param doNotCopyList defines a list of properties to avoid
  4994. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4995. */
  4996. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4997. }
  4998. }
  4999. declare module "babylonjs/Misc/precisionDate" {
  5000. /**
  5001. * Class containing a set of static utilities functions for precision date
  5002. */
  5003. export class PrecisionDate {
  5004. /**
  5005. * Gets either window.performance.now() if supported or Date.now() else
  5006. */
  5007. static readonly Now: number;
  5008. }
  5009. }
  5010. declare module "babylonjs/Misc/devTools" {
  5011. /** @hidden */
  5012. export class _DevTools {
  5013. static WarnImport(name: string): string;
  5014. }
  5015. }
  5016. declare module "babylonjs/Misc/webRequest" {
  5017. /**
  5018. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  5019. */
  5020. export class WebRequest {
  5021. private _xhr;
  5022. /**
  5023. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5024. * i.e. when loading files, where the server/service expects an Authorization header
  5025. */
  5026. static CustomRequestHeaders: {
  5027. [key: string]: string;
  5028. };
  5029. /**
  5030. * Add callback functions in this array to update all the requests before they get sent to the network
  5031. */
  5032. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5033. private _injectCustomRequestHeaders;
  5034. /**
  5035. * Gets or sets a function to be called when loading progress changes
  5036. */
  5037. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5038. /**
  5039. * Returns client's state
  5040. */
  5041. readonly readyState: number;
  5042. /**
  5043. * Returns client's status
  5044. */
  5045. readonly status: number;
  5046. /**
  5047. * Returns client's status as a text
  5048. */
  5049. readonly statusText: string;
  5050. /**
  5051. * Returns client's response
  5052. */
  5053. readonly response: any;
  5054. /**
  5055. * Returns client's response url
  5056. */
  5057. readonly responseURL: string;
  5058. /**
  5059. * Returns client's response as text
  5060. */
  5061. readonly responseText: string;
  5062. /**
  5063. * Gets or sets the expected response type
  5064. */
  5065. responseType: XMLHttpRequestResponseType;
  5066. /** @hidden */
  5067. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5068. /** @hidden */
  5069. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5070. /**
  5071. * Cancels any network activity
  5072. */
  5073. abort(): void;
  5074. /**
  5075. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5076. * @param body defines an optional request body
  5077. */
  5078. send(body?: Document | BodyInit | null): void;
  5079. /**
  5080. * Sets the request method, request URL
  5081. * @param method defines the method to use (GET, POST, etc..)
  5082. * @param url defines the url to connect with
  5083. */
  5084. open(method: string, url: string): void;
  5085. }
  5086. }
  5087. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5088. /**
  5089. * Class used to evalaute queries containing `and` and `or` operators
  5090. */
  5091. export class AndOrNotEvaluator {
  5092. /**
  5093. * Evaluate a query
  5094. * @param query defines the query to evaluate
  5095. * @param evaluateCallback defines the callback used to filter result
  5096. * @returns true if the query matches
  5097. */
  5098. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5099. private static _HandleParenthesisContent;
  5100. private static _SimplifyNegation;
  5101. }
  5102. }
  5103. declare module "babylonjs/Misc/tags" {
  5104. /**
  5105. * Class used to store custom tags
  5106. */
  5107. export class Tags {
  5108. /**
  5109. * Adds support for tags on the given object
  5110. * @param obj defines the object to use
  5111. */
  5112. static EnableFor(obj: any): void;
  5113. /**
  5114. * Removes tags support
  5115. * @param obj defines the object to use
  5116. */
  5117. static DisableFor(obj: any): void;
  5118. /**
  5119. * Gets a boolean indicating if the given object has tags
  5120. * @param obj defines the object to use
  5121. * @returns a boolean
  5122. */
  5123. static HasTags(obj: any): boolean;
  5124. /**
  5125. * Gets the tags available on a given object
  5126. * @param obj defines the object to use
  5127. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5128. * @returns the tags
  5129. */
  5130. static GetTags(obj: any, asString?: boolean): any;
  5131. /**
  5132. * Adds tags to an object
  5133. * @param obj defines the object to use
  5134. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5135. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5136. */
  5137. static AddTagsTo(obj: any, tagsString: string): void;
  5138. /**
  5139. * @hidden
  5140. */
  5141. static _AddTagTo(obj: any, tag: string): void;
  5142. /**
  5143. * Removes specific tags from a specific object
  5144. * @param obj defines the object to use
  5145. * @param tagsString defines the tags to remove
  5146. */
  5147. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5148. /**
  5149. * @hidden
  5150. */
  5151. static _RemoveTagFrom(obj: any, tag: string): void;
  5152. /**
  5153. * Defines if tags hosted on an object match a given query
  5154. * @param obj defines the object to use
  5155. * @param tagsQuery defines the tag query
  5156. * @returns a boolean
  5157. */
  5158. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5159. }
  5160. }
  5161. declare module "babylonjs/Materials/materialDefines" {
  5162. /**
  5163. * Manages the defines for the Material
  5164. */
  5165. export class MaterialDefines {
  5166. /** @hidden */
  5167. protected _keys: string[];
  5168. private _isDirty;
  5169. /** @hidden */
  5170. _renderId: number;
  5171. /** @hidden */
  5172. _areLightsDirty: boolean;
  5173. /** @hidden */
  5174. _areAttributesDirty: boolean;
  5175. /** @hidden */
  5176. _areTexturesDirty: boolean;
  5177. /** @hidden */
  5178. _areFresnelDirty: boolean;
  5179. /** @hidden */
  5180. _areMiscDirty: boolean;
  5181. /** @hidden */
  5182. _areImageProcessingDirty: boolean;
  5183. /** @hidden */
  5184. _normals: boolean;
  5185. /** @hidden */
  5186. _uvs: boolean;
  5187. /** @hidden */
  5188. _needNormals: boolean;
  5189. /** @hidden */
  5190. _needUVs: boolean;
  5191. [id: string]: any;
  5192. /**
  5193. * Specifies if the material needs to be re-calculated
  5194. */
  5195. readonly isDirty: boolean;
  5196. /**
  5197. * Marks the material to indicate that it has been re-calculated
  5198. */
  5199. markAsProcessed(): void;
  5200. /**
  5201. * Marks the material to indicate that it needs to be re-calculated
  5202. */
  5203. markAsUnprocessed(): void;
  5204. /**
  5205. * Marks the material to indicate all of its defines need to be re-calculated
  5206. */
  5207. markAllAsDirty(): void;
  5208. /**
  5209. * Marks the material to indicate that image processing needs to be re-calculated
  5210. */
  5211. markAsImageProcessingDirty(): void;
  5212. /**
  5213. * Marks the material to indicate the lights need to be re-calculated
  5214. */
  5215. markAsLightDirty(): void;
  5216. /**
  5217. * Marks the attribute state as changed
  5218. */
  5219. markAsAttributesDirty(): void;
  5220. /**
  5221. * Marks the texture state as changed
  5222. */
  5223. markAsTexturesDirty(): void;
  5224. /**
  5225. * Marks the fresnel state as changed
  5226. */
  5227. markAsFresnelDirty(): void;
  5228. /**
  5229. * Marks the misc state as changed
  5230. */
  5231. markAsMiscDirty(): void;
  5232. /**
  5233. * Rebuilds the material defines
  5234. */
  5235. rebuild(): void;
  5236. /**
  5237. * Specifies if two material defines are equal
  5238. * @param other - A material define instance to compare to
  5239. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5240. */
  5241. isEqual(other: MaterialDefines): boolean;
  5242. /**
  5243. * Clones this instance's defines to another instance
  5244. * @param other - material defines to clone values to
  5245. */
  5246. cloneTo(other: MaterialDefines): void;
  5247. /**
  5248. * Resets the material define values
  5249. */
  5250. reset(): void;
  5251. /**
  5252. * Converts the material define values to a string
  5253. * @returns - String of material define information
  5254. */
  5255. toString(): string;
  5256. }
  5257. }
  5258. declare module "babylonjs/Engines/IPipelineContext" {
  5259. /**
  5260. * Class used to store and describe the pipeline context associated with an effect
  5261. */
  5262. export interface IPipelineContext {
  5263. /**
  5264. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  5265. */
  5266. isAsync: boolean;
  5267. /**
  5268. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  5269. */
  5270. isReady: boolean;
  5271. /** @hidden */
  5272. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  5273. }
  5274. }
  5275. declare module "babylonjs/Meshes/dataBuffer" {
  5276. /**
  5277. * Class used to store gfx data (like WebGLBuffer)
  5278. */
  5279. export class DataBuffer {
  5280. /**
  5281. * Gets or sets the number of objects referencing this buffer
  5282. */
  5283. references: number;
  5284. /** Gets or sets the size of the underlying buffer */
  5285. capacity: number;
  5286. /**
  5287. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  5288. */
  5289. is32Bits: boolean;
  5290. /**
  5291. * Gets the underlying buffer
  5292. */
  5293. readonly underlyingResource: any;
  5294. }
  5295. }
  5296. declare module "babylonjs/Misc/performanceMonitor" {
  5297. /**
  5298. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5299. */
  5300. export class PerformanceMonitor {
  5301. private _enabled;
  5302. private _rollingFrameTime;
  5303. private _lastFrameTimeMs;
  5304. /**
  5305. * constructor
  5306. * @param frameSampleSize The number of samples required to saturate the sliding window
  5307. */
  5308. constructor(frameSampleSize?: number);
  5309. /**
  5310. * Samples current frame
  5311. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5312. */
  5313. sampleFrame(timeMs?: number): void;
  5314. /**
  5315. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5316. */
  5317. readonly averageFrameTime: number;
  5318. /**
  5319. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5320. */
  5321. readonly averageFrameTimeVariance: number;
  5322. /**
  5323. * Returns the frame time of the most recent frame
  5324. */
  5325. readonly instantaneousFrameTime: number;
  5326. /**
  5327. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5328. */
  5329. readonly averageFPS: number;
  5330. /**
  5331. * Returns the average framerate in frames per second using the most recent frame time
  5332. */
  5333. readonly instantaneousFPS: number;
  5334. /**
  5335. * Returns true if enough samples have been taken to completely fill the sliding window
  5336. */
  5337. readonly isSaturated: boolean;
  5338. /**
  5339. * Enables contributions to the sliding window sample set
  5340. */
  5341. enable(): void;
  5342. /**
  5343. * Disables contributions to the sliding window sample set
  5344. * Samples will not be interpolated over the disabled period
  5345. */
  5346. disable(): void;
  5347. /**
  5348. * Returns true if sampling is enabled
  5349. */
  5350. readonly isEnabled: boolean;
  5351. /**
  5352. * Resets performance monitor
  5353. */
  5354. reset(): void;
  5355. }
  5356. /**
  5357. * RollingAverage
  5358. *
  5359. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5360. */
  5361. export class RollingAverage {
  5362. /**
  5363. * Current average
  5364. */
  5365. average: number;
  5366. /**
  5367. * Current variance
  5368. */
  5369. variance: number;
  5370. protected _samples: Array<number>;
  5371. protected _sampleCount: number;
  5372. protected _pos: number;
  5373. protected _m2: number;
  5374. /**
  5375. * constructor
  5376. * @param length The number of samples required to saturate the sliding window
  5377. */
  5378. constructor(length: number);
  5379. /**
  5380. * Adds a sample to the sample set
  5381. * @param v The sample value
  5382. */
  5383. add(v: number): void;
  5384. /**
  5385. * Returns previously added values or null if outside of history or outside the sliding window domain
  5386. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5387. * @return Value previously recorded with add() or null if outside of range
  5388. */
  5389. history(i: number): number;
  5390. /**
  5391. * Returns true if enough samples have been taken to completely fill the sliding window
  5392. * @return true if sample-set saturated
  5393. */
  5394. isSaturated(): boolean;
  5395. /**
  5396. * Resets the rolling average (equivalent to 0 samples taken so far)
  5397. */
  5398. reset(): void;
  5399. /**
  5400. * Wraps a value around the sample range boundaries
  5401. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5402. * @return Wrapped position in sample range
  5403. */
  5404. protected _wrapPosition(i: number): number;
  5405. }
  5406. }
  5407. declare module "babylonjs/Misc/stringDictionary" {
  5408. import { Nullable } from "babylonjs/types";
  5409. /**
  5410. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5411. * The underlying implementation relies on an associative array to ensure the best performances.
  5412. * The value can be anything including 'null' but except 'undefined'
  5413. */
  5414. export class StringDictionary<T> {
  5415. /**
  5416. * This will clear this dictionary and copy the content from the 'source' one.
  5417. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5418. * @param source the dictionary to take the content from and copy to this dictionary
  5419. */
  5420. copyFrom(source: StringDictionary<T>): void;
  5421. /**
  5422. * Get a value based from its key
  5423. * @param key the given key to get the matching value from
  5424. * @return the value if found, otherwise undefined is returned
  5425. */
  5426. get(key: string): T | undefined;
  5427. /**
  5428. * Get a value from its key or add it if it doesn't exist.
  5429. * This method will ensure you that a given key/data will be present in the dictionary.
  5430. * @param key the given key to get the matching value from
  5431. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5432. * The factory will only be invoked if there's no data for the given key.
  5433. * @return the value corresponding to the key.
  5434. */
  5435. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5436. /**
  5437. * Get a value from its key if present in the dictionary otherwise add it
  5438. * @param key the key to get the value from
  5439. * @param val if there's no such key/value pair in the dictionary add it with this value
  5440. * @return the value corresponding to the key
  5441. */
  5442. getOrAdd(key: string, val: T): T;
  5443. /**
  5444. * Check if there's a given key in the dictionary
  5445. * @param key the key to check for
  5446. * @return true if the key is present, false otherwise
  5447. */
  5448. contains(key: string): boolean;
  5449. /**
  5450. * Add a new key and its corresponding value
  5451. * @param key the key to add
  5452. * @param value the value corresponding to the key
  5453. * @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
  5454. */
  5455. add(key: string, value: T): boolean;
  5456. /**
  5457. * Update a specific value associated to a key
  5458. * @param key defines the key to use
  5459. * @param value defines the value to store
  5460. * @returns true if the value was updated (or false if the key was not found)
  5461. */
  5462. set(key: string, value: T): boolean;
  5463. /**
  5464. * Get the element of the given key and remove it from the dictionary
  5465. * @param key defines the key to search
  5466. * @returns the value associated with the key or null if not found
  5467. */
  5468. getAndRemove(key: string): Nullable<T>;
  5469. /**
  5470. * Remove a key/value from the dictionary.
  5471. * @param key the key to remove
  5472. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5473. */
  5474. remove(key: string): boolean;
  5475. /**
  5476. * Clear the whole content of the dictionary
  5477. */
  5478. clear(): void;
  5479. /**
  5480. * Gets the current count
  5481. */
  5482. readonly count: number;
  5483. /**
  5484. * Execute a callback on each key/val of the dictionary.
  5485. * Note that you can remove any element in this dictionary in the callback implementation
  5486. * @param callback the callback to execute on a given key/value pair
  5487. */
  5488. forEach(callback: (key: string, val: T) => void): void;
  5489. /**
  5490. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5491. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5492. * Note that you can remove any element in this dictionary in the callback implementation
  5493. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5494. * @returns the first item
  5495. */
  5496. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5497. private _count;
  5498. private _data;
  5499. }
  5500. }
  5501. declare module "babylonjs/Misc/promise" {
  5502. /**
  5503. * Helper class that provides a small promise polyfill
  5504. */
  5505. export class PromisePolyfill {
  5506. /**
  5507. * Static function used to check if the polyfill is required
  5508. * If this is the case then the function will inject the polyfill to window.Promise
  5509. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5510. */
  5511. static Apply(force?: boolean): void;
  5512. }
  5513. }
  5514. declare module "babylonjs/Meshes/buffer" {
  5515. import { Nullable, DataArray } from "babylonjs/types";
  5516. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  5517. /**
  5518. * Class used to store data that will be store in GPU memory
  5519. */
  5520. export class Buffer {
  5521. private _engine;
  5522. private _buffer;
  5523. /** @hidden */
  5524. _data: Nullable<DataArray>;
  5525. private _updatable;
  5526. private _instanced;
  5527. /**
  5528. * Gets the byte stride.
  5529. */
  5530. readonly byteStride: number;
  5531. /**
  5532. * Constructor
  5533. * @param engine the engine
  5534. * @param data the data to use for this buffer
  5535. * @param updatable whether the data is updatable
  5536. * @param stride the stride (optional)
  5537. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5538. * @param instanced whether the buffer is instanced (optional)
  5539. * @param useBytes set to true if the stride in in bytes (optional)
  5540. */
  5541. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5542. /**
  5543. * Create a new VertexBuffer based on the current buffer
  5544. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5545. * @param offset defines offset in the buffer (0 by default)
  5546. * @param size defines the size in floats of attributes (position is 3 for instance)
  5547. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5548. * @param instanced defines if the vertex buffer contains indexed data
  5549. * @param useBytes defines if the offset and stride are in bytes
  5550. * @returns the new vertex buffer
  5551. */
  5552. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5553. /**
  5554. * Gets a boolean indicating if the Buffer is updatable?
  5555. * @returns true if the buffer is updatable
  5556. */
  5557. isUpdatable(): boolean;
  5558. /**
  5559. * Gets current buffer's data
  5560. * @returns a DataArray or null
  5561. */
  5562. getData(): Nullable<DataArray>;
  5563. /**
  5564. * Gets underlying native buffer
  5565. * @returns underlying native buffer
  5566. */
  5567. getBuffer(): Nullable<DataBuffer>;
  5568. /**
  5569. * Gets the stride in float32 units (i.e. byte stride / 4).
  5570. * May not be an integer if the byte stride is not divisible by 4.
  5571. * DEPRECATED. Use byteStride instead.
  5572. * @returns the stride in float32 units
  5573. */
  5574. getStrideSize(): number;
  5575. /**
  5576. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5577. * @param data defines the data to store
  5578. */
  5579. create(data?: Nullable<DataArray>): void;
  5580. /** @hidden */
  5581. _rebuild(): void;
  5582. /**
  5583. * Update current buffer data
  5584. * @param data defines the data to store
  5585. */
  5586. update(data: DataArray): void;
  5587. /**
  5588. * Updates the data directly.
  5589. * @param data the new data
  5590. * @param offset the new offset
  5591. * @param vertexCount the vertex count (optional)
  5592. * @param useBytes set to true if the offset is in bytes
  5593. */
  5594. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5595. /**
  5596. * Release all resources
  5597. */
  5598. dispose(): void;
  5599. }
  5600. /**
  5601. * Specialized buffer used to store vertex data
  5602. */
  5603. export class VertexBuffer {
  5604. /** @hidden */
  5605. _buffer: Buffer;
  5606. private _kind;
  5607. private _size;
  5608. private _ownsBuffer;
  5609. private _instanced;
  5610. private _instanceDivisor;
  5611. /**
  5612. * The byte type.
  5613. */
  5614. static readonly BYTE: number;
  5615. /**
  5616. * The unsigned byte type.
  5617. */
  5618. static readonly UNSIGNED_BYTE: number;
  5619. /**
  5620. * The short type.
  5621. */
  5622. static readonly SHORT: number;
  5623. /**
  5624. * The unsigned short type.
  5625. */
  5626. static readonly UNSIGNED_SHORT: number;
  5627. /**
  5628. * The integer type.
  5629. */
  5630. static readonly INT: number;
  5631. /**
  5632. * The unsigned integer type.
  5633. */
  5634. static readonly UNSIGNED_INT: number;
  5635. /**
  5636. * The float type.
  5637. */
  5638. static readonly FLOAT: number;
  5639. /**
  5640. * Gets or sets the instance divisor when in instanced mode
  5641. */
  5642. instanceDivisor: number;
  5643. /**
  5644. * Gets the byte stride.
  5645. */
  5646. readonly byteStride: number;
  5647. /**
  5648. * Gets the byte offset.
  5649. */
  5650. readonly byteOffset: number;
  5651. /**
  5652. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5653. */
  5654. readonly normalized: boolean;
  5655. /**
  5656. * Gets the data type of each component in the array.
  5657. */
  5658. readonly type: number;
  5659. /**
  5660. * Constructor
  5661. * @param engine the engine
  5662. * @param data the data to use for this vertex buffer
  5663. * @param kind the vertex buffer kind
  5664. * @param updatable whether the data is updatable
  5665. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5666. * @param stride the stride (optional)
  5667. * @param instanced whether the buffer is instanced (optional)
  5668. * @param offset the offset of the data (optional)
  5669. * @param size the number of components (optional)
  5670. * @param type the type of the component (optional)
  5671. * @param normalized whether the data contains normalized data (optional)
  5672. * @param useBytes set to true if stride and offset are in bytes (optional)
  5673. */
  5674. 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);
  5675. /** @hidden */
  5676. _rebuild(): void;
  5677. /**
  5678. * Returns the kind of the VertexBuffer (string)
  5679. * @returns a string
  5680. */
  5681. getKind(): string;
  5682. /**
  5683. * Gets a boolean indicating if the VertexBuffer is updatable?
  5684. * @returns true if the buffer is updatable
  5685. */
  5686. isUpdatable(): boolean;
  5687. /**
  5688. * Gets current buffer's data
  5689. * @returns a DataArray or null
  5690. */
  5691. getData(): Nullable<DataArray>;
  5692. /**
  5693. * Gets underlying native buffer
  5694. * @returns underlying native buffer
  5695. */
  5696. getBuffer(): Nullable<DataBuffer>;
  5697. /**
  5698. * Gets the stride in float32 units (i.e. byte stride / 4).
  5699. * May not be an integer if the byte stride is not divisible by 4.
  5700. * DEPRECATED. Use byteStride instead.
  5701. * @returns the stride in float32 units
  5702. */
  5703. getStrideSize(): number;
  5704. /**
  5705. * Returns the offset as a multiple of the type byte length.
  5706. * DEPRECATED. Use byteOffset instead.
  5707. * @returns the offset in bytes
  5708. */
  5709. getOffset(): number;
  5710. /**
  5711. * Returns the number of components per vertex attribute (integer)
  5712. * @returns the size in float
  5713. */
  5714. getSize(): number;
  5715. /**
  5716. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5717. * @returns true if this buffer is instanced
  5718. */
  5719. getIsInstanced(): boolean;
  5720. /**
  5721. * Returns the instancing divisor, zero for non-instanced (integer).
  5722. * @returns a number
  5723. */
  5724. getInstanceDivisor(): number;
  5725. /**
  5726. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5727. * @param data defines the data to store
  5728. */
  5729. create(data?: DataArray): void;
  5730. /**
  5731. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5732. * This function will create a new buffer if the current one is not updatable
  5733. * @param data defines the data to store
  5734. */
  5735. update(data: DataArray): void;
  5736. /**
  5737. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5738. * Returns the directly updated WebGLBuffer.
  5739. * @param data the new data
  5740. * @param offset the new offset
  5741. * @param useBytes set to true if the offset is in bytes
  5742. */
  5743. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5744. /**
  5745. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5746. */
  5747. dispose(): void;
  5748. /**
  5749. * Enumerates each value of this vertex buffer as numbers.
  5750. * @param count the number of values to enumerate
  5751. * @param callback the callback function called for each value
  5752. */
  5753. forEach(count: number, callback: (value: number, index: number) => void): void;
  5754. /**
  5755. * Positions
  5756. */
  5757. static readonly PositionKind: string;
  5758. /**
  5759. * Normals
  5760. */
  5761. static readonly NormalKind: string;
  5762. /**
  5763. * Tangents
  5764. */
  5765. static readonly TangentKind: string;
  5766. /**
  5767. * Texture coordinates
  5768. */
  5769. static readonly UVKind: string;
  5770. /**
  5771. * Texture coordinates 2
  5772. */
  5773. static readonly UV2Kind: string;
  5774. /**
  5775. * Texture coordinates 3
  5776. */
  5777. static readonly UV3Kind: string;
  5778. /**
  5779. * Texture coordinates 4
  5780. */
  5781. static readonly UV4Kind: string;
  5782. /**
  5783. * Texture coordinates 5
  5784. */
  5785. static readonly UV5Kind: string;
  5786. /**
  5787. * Texture coordinates 6
  5788. */
  5789. static readonly UV6Kind: string;
  5790. /**
  5791. * Colors
  5792. */
  5793. static readonly ColorKind: string;
  5794. /**
  5795. * Matrix indices (for bones)
  5796. */
  5797. static readonly MatricesIndicesKind: string;
  5798. /**
  5799. * Matrix weights (for bones)
  5800. */
  5801. static readonly MatricesWeightsKind: string;
  5802. /**
  5803. * Additional matrix indices (for bones)
  5804. */
  5805. static readonly MatricesIndicesExtraKind: string;
  5806. /**
  5807. * Additional matrix weights (for bones)
  5808. */
  5809. static readonly MatricesWeightsExtraKind: string;
  5810. /**
  5811. * Deduces the stride given a kind.
  5812. * @param kind The kind string to deduce
  5813. * @returns The deduced stride
  5814. */
  5815. static DeduceStride(kind: string): number;
  5816. /**
  5817. * Gets the byte length of the given type.
  5818. * @param type the type
  5819. * @returns the number of bytes
  5820. */
  5821. static GetTypeByteLength(type: number): number;
  5822. /**
  5823. * Enumerates each value of the given parameters as numbers.
  5824. * @param data the data to enumerate
  5825. * @param byteOffset the byte offset of the data
  5826. * @param byteStride the byte stride of the data
  5827. * @param componentCount the number of components per element
  5828. * @param componentType the type of the component
  5829. * @param count the total number of components
  5830. * @param normalized whether the data is normalized
  5831. * @param callback the callback function called for each value
  5832. */
  5833. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5834. private static _GetFloatValue;
  5835. }
  5836. }
  5837. declare module "babylonjs/Maths/sphericalPolynomial" {
  5838. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5839. /**
  5840. * Class representing spherical harmonics coefficients to the 3rd degree
  5841. */
  5842. export class SphericalHarmonics {
  5843. /**
  5844. * Defines whether or not the harmonics have been prescaled for rendering.
  5845. */
  5846. preScaled: boolean;
  5847. /**
  5848. * The l0,0 coefficients of the spherical harmonics
  5849. */
  5850. l00: Vector3;
  5851. /**
  5852. * The l1,-1 coefficients of the spherical harmonics
  5853. */
  5854. l1_1: Vector3;
  5855. /**
  5856. * The l1,0 coefficients of the spherical harmonics
  5857. */
  5858. l10: Vector3;
  5859. /**
  5860. * The l1,1 coefficients of the spherical harmonics
  5861. */
  5862. l11: Vector3;
  5863. /**
  5864. * The l2,-2 coefficients of the spherical harmonics
  5865. */
  5866. l2_2: Vector3;
  5867. /**
  5868. * The l2,-1 coefficients of the spherical harmonics
  5869. */
  5870. l2_1: Vector3;
  5871. /**
  5872. * The l2,0 coefficients of the spherical harmonics
  5873. */
  5874. l20: Vector3;
  5875. /**
  5876. * The l2,1 coefficients of the spherical harmonics
  5877. */
  5878. l21: Vector3;
  5879. /**
  5880. * The l2,2 coefficients of the spherical harmonics
  5881. */
  5882. l22: Vector3;
  5883. /**
  5884. * Adds a light to the spherical harmonics
  5885. * @param direction the direction of the light
  5886. * @param color the color of the light
  5887. * @param deltaSolidAngle the delta solid angle of the light
  5888. */
  5889. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5890. /**
  5891. * Scales the spherical harmonics by the given amount
  5892. * @param scale the amount to scale
  5893. */
  5894. scaleInPlace(scale: number): void;
  5895. /**
  5896. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5897. *
  5898. * ```
  5899. * E_lm = A_l * L_lm
  5900. * ```
  5901. *
  5902. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5903. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5904. * the scaling factors are given in equation 9.
  5905. */
  5906. convertIncidentRadianceToIrradiance(): void;
  5907. /**
  5908. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5909. *
  5910. * ```
  5911. * L = (1/pi) * E * rho
  5912. * ```
  5913. *
  5914. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5915. */
  5916. convertIrradianceToLambertianRadiance(): void;
  5917. /**
  5918. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5919. * required operations at run time.
  5920. *
  5921. * This is simply done by scaling back the SH with Ylm constants parameter.
  5922. * The trigonometric part being applied by the shader at run time.
  5923. */
  5924. preScaleForRendering(): void;
  5925. /**
  5926. * Constructs a spherical harmonics from an array.
  5927. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5928. * @returns the spherical harmonics
  5929. */
  5930. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5931. /**
  5932. * Gets the spherical harmonics from polynomial
  5933. * @param polynomial the spherical polynomial
  5934. * @returns the spherical harmonics
  5935. */
  5936. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5937. }
  5938. /**
  5939. * Class representing spherical polynomial coefficients to the 3rd degree
  5940. */
  5941. export class SphericalPolynomial {
  5942. private _harmonics;
  5943. /**
  5944. * The spherical harmonics used to create the polynomials.
  5945. */
  5946. readonly preScaledHarmonics: SphericalHarmonics;
  5947. /**
  5948. * The x coefficients of the spherical polynomial
  5949. */
  5950. x: Vector3;
  5951. /**
  5952. * The y coefficients of the spherical polynomial
  5953. */
  5954. y: Vector3;
  5955. /**
  5956. * The z coefficients of the spherical polynomial
  5957. */
  5958. z: Vector3;
  5959. /**
  5960. * The xx coefficients of the spherical polynomial
  5961. */
  5962. xx: Vector3;
  5963. /**
  5964. * The yy coefficients of the spherical polynomial
  5965. */
  5966. yy: Vector3;
  5967. /**
  5968. * The zz coefficients of the spherical polynomial
  5969. */
  5970. zz: Vector3;
  5971. /**
  5972. * The xy coefficients of the spherical polynomial
  5973. */
  5974. xy: Vector3;
  5975. /**
  5976. * The yz coefficients of the spherical polynomial
  5977. */
  5978. yz: Vector3;
  5979. /**
  5980. * The zx coefficients of the spherical polynomial
  5981. */
  5982. zx: Vector3;
  5983. /**
  5984. * Adds an ambient color to the spherical polynomial
  5985. * @param color the color to add
  5986. */
  5987. addAmbient(color: Color3): void;
  5988. /**
  5989. * Scales the spherical polynomial by the given amount
  5990. * @param scale the amount to scale
  5991. */
  5992. scaleInPlace(scale: number): void;
  5993. /**
  5994. * Gets the spherical polynomial from harmonics
  5995. * @param harmonics the spherical harmonics
  5996. * @returns the spherical polynomial
  5997. */
  5998. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5999. /**
  6000. * Constructs a spherical polynomial from an array.
  6001. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  6002. * @returns the spherical polynomial
  6003. */
  6004. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  6005. }
  6006. }
  6007. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  6008. import { Nullable } from "babylonjs/types";
  6009. /**
  6010. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  6011. */
  6012. export interface CubeMapInfo {
  6013. /**
  6014. * The pixel array for the front face.
  6015. * This is stored in format, left to right, up to down format.
  6016. */
  6017. front: Nullable<ArrayBufferView>;
  6018. /**
  6019. * The pixel array for the back face.
  6020. * This is stored in format, left to right, up to down format.
  6021. */
  6022. back: Nullable<ArrayBufferView>;
  6023. /**
  6024. * The pixel array for the left face.
  6025. * This is stored in format, left to right, up to down format.
  6026. */
  6027. left: Nullable<ArrayBufferView>;
  6028. /**
  6029. * The pixel array for the right face.
  6030. * This is stored in format, left to right, up to down format.
  6031. */
  6032. right: Nullable<ArrayBufferView>;
  6033. /**
  6034. * The pixel array for the up face.
  6035. * This is stored in format, left to right, up to down format.
  6036. */
  6037. up: Nullable<ArrayBufferView>;
  6038. /**
  6039. * The pixel array for the down face.
  6040. * This is stored in format, left to right, up to down format.
  6041. */
  6042. down: Nullable<ArrayBufferView>;
  6043. /**
  6044. * The size of the cubemap stored.
  6045. *
  6046. * Each faces will be size * size pixels.
  6047. */
  6048. size: number;
  6049. /**
  6050. * The format of the texture.
  6051. *
  6052. * RGBA, RGB.
  6053. */
  6054. format: number;
  6055. /**
  6056. * The type of the texture data.
  6057. *
  6058. * UNSIGNED_INT, FLOAT.
  6059. */
  6060. type: number;
  6061. /**
  6062. * Specifies whether the texture is in gamma space.
  6063. */
  6064. gammaSpace: boolean;
  6065. }
  6066. /**
  6067. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  6068. */
  6069. export class PanoramaToCubeMapTools {
  6070. private static FACE_FRONT;
  6071. private static FACE_BACK;
  6072. private static FACE_RIGHT;
  6073. private static FACE_LEFT;
  6074. private static FACE_DOWN;
  6075. private static FACE_UP;
  6076. /**
  6077. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  6078. *
  6079. * @param float32Array The source data.
  6080. * @param inputWidth The width of the input panorama.
  6081. * @param inputHeight The height of the input panorama.
  6082. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6083. * @return The cubemap data
  6084. */
  6085. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6086. private static CreateCubemapTexture;
  6087. private static CalcProjectionSpherical;
  6088. }
  6089. }
  6090. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6091. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6092. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6093. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6094. /**
  6095. * Helper class dealing with the extraction of spherical polynomial dataArray
  6096. * from a cube map.
  6097. */
  6098. export class CubeMapToSphericalPolynomialTools {
  6099. private static FileFaces;
  6100. /**
  6101. * Converts a texture to the according Spherical Polynomial data.
  6102. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6103. *
  6104. * @param texture The texture to extract the information from.
  6105. * @return The Spherical Polynomial data.
  6106. */
  6107. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6108. /**
  6109. * Converts a cubemap to the according Spherical Polynomial data.
  6110. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6111. *
  6112. * @param cubeInfo The Cube map to extract the information from.
  6113. * @return The Spherical Polynomial data.
  6114. */
  6115. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6116. }
  6117. }
  6118. declare module "babylonjs/Engines/engineStore" {
  6119. import { Nullable } from "babylonjs/types";
  6120. import { Engine } from "babylonjs/Engines/engine";
  6121. import { Scene } from "babylonjs/scene";
  6122. /**
  6123. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6124. * during the life time of the application.
  6125. */
  6126. export class EngineStore {
  6127. /** Gets the list of created engines */
  6128. static Instances: import("babylonjs/Engines/engine").Engine[];
  6129. /** @hidden */
  6130. static _LastCreatedScene: Nullable<Scene>;
  6131. /**
  6132. * Gets the latest created engine
  6133. */
  6134. static readonly LastCreatedEngine: Nullable<Engine>;
  6135. /**
  6136. * Gets the latest created scene
  6137. */
  6138. static readonly LastCreatedScene: Nullable<Scene>;
  6139. }
  6140. }
  6141. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6142. /**
  6143. * Define options used to create a render target texture
  6144. */
  6145. export class RenderTargetCreationOptions {
  6146. /**
  6147. * Specifies is mipmaps must be generated
  6148. */
  6149. generateMipMaps?: boolean;
  6150. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6151. generateDepthBuffer?: boolean;
  6152. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6153. generateStencilBuffer?: boolean;
  6154. /** Defines texture type (int by default) */
  6155. type?: number;
  6156. /** Defines sampling mode (trilinear by default) */
  6157. samplingMode?: number;
  6158. /** Defines format (RGBA by default) */
  6159. format?: number;
  6160. }
  6161. }
  6162. declare module "babylonjs/States/alphaCullingState" {
  6163. /**
  6164. * @hidden
  6165. **/
  6166. export class _AlphaState {
  6167. private _isAlphaBlendDirty;
  6168. private _isBlendFunctionParametersDirty;
  6169. private _isBlendEquationParametersDirty;
  6170. private _isBlendConstantsDirty;
  6171. private _alphaBlend;
  6172. private _blendFunctionParameters;
  6173. private _blendEquationParameters;
  6174. private _blendConstants;
  6175. /**
  6176. * Initializes the state.
  6177. */
  6178. constructor();
  6179. readonly isDirty: boolean;
  6180. alphaBlend: boolean;
  6181. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6182. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6183. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6184. reset(): void;
  6185. apply(gl: WebGLRenderingContext): void;
  6186. }
  6187. }
  6188. declare module "babylonjs/States/depthCullingState" {
  6189. import { Nullable } from "babylonjs/types";
  6190. /**
  6191. * @hidden
  6192. **/
  6193. export class _DepthCullingState {
  6194. private _isDepthTestDirty;
  6195. private _isDepthMaskDirty;
  6196. private _isDepthFuncDirty;
  6197. private _isCullFaceDirty;
  6198. private _isCullDirty;
  6199. private _isZOffsetDirty;
  6200. private _isFrontFaceDirty;
  6201. private _depthTest;
  6202. private _depthMask;
  6203. private _depthFunc;
  6204. private _cull;
  6205. private _cullFace;
  6206. private _zOffset;
  6207. private _frontFace;
  6208. /**
  6209. * Initializes the state.
  6210. */
  6211. constructor();
  6212. readonly isDirty: boolean;
  6213. zOffset: number;
  6214. cullFace: Nullable<number>;
  6215. cull: Nullable<boolean>;
  6216. depthFunc: Nullable<number>;
  6217. depthMask: boolean;
  6218. depthTest: boolean;
  6219. frontFace: Nullable<number>;
  6220. reset(): void;
  6221. apply(gl: WebGLRenderingContext): void;
  6222. }
  6223. }
  6224. declare module "babylonjs/States/stencilState" {
  6225. /**
  6226. * @hidden
  6227. **/
  6228. export class _StencilState {
  6229. /** 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 */
  6230. static readonly ALWAYS: number;
  6231. /** Passed to stencilOperation to specify that stencil value must be kept */
  6232. static readonly KEEP: number;
  6233. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6234. static readonly REPLACE: number;
  6235. private _isStencilTestDirty;
  6236. private _isStencilMaskDirty;
  6237. private _isStencilFuncDirty;
  6238. private _isStencilOpDirty;
  6239. private _stencilTest;
  6240. private _stencilMask;
  6241. private _stencilFunc;
  6242. private _stencilFuncRef;
  6243. private _stencilFuncMask;
  6244. private _stencilOpStencilFail;
  6245. private _stencilOpDepthFail;
  6246. private _stencilOpStencilDepthPass;
  6247. readonly isDirty: boolean;
  6248. stencilFunc: number;
  6249. stencilFuncRef: number;
  6250. stencilFuncMask: number;
  6251. stencilOpStencilFail: number;
  6252. stencilOpDepthFail: number;
  6253. stencilOpStencilDepthPass: number;
  6254. stencilMask: number;
  6255. stencilTest: boolean;
  6256. constructor();
  6257. reset(): void;
  6258. apply(gl: WebGLRenderingContext): void;
  6259. }
  6260. }
  6261. declare module "babylonjs/States/index" {
  6262. export * from "babylonjs/States/alphaCullingState";
  6263. export * from "babylonjs/States/depthCullingState";
  6264. export * from "babylonjs/States/stencilState";
  6265. }
  6266. declare module "babylonjs/Instrumentation/timeToken" {
  6267. import { Nullable } from "babylonjs/types";
  6268. /**
  6269. * @hidden
  6270. **/
  6271. export class _TimeToken {
  6272. _startTimeQuery: Nullable<WebGLQuery>;
  6273. _endTimeQuery: Nullable<WebGLQuery>;
  6274. _timeElapsedQuery: Nullable<WebGLQuery>;
  6275. _timeElapsedQueryEnded: boolean;
  6276. }
  6277. }
  6278. declare module "babylonjs/Materials/Textures/internalTexture" {
  6279. import { Observable } from "babylonjs/Misc/observable";
  6280. import { Nullable, int } from "babylonjs/types";
  6281. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6282. import { Engine } from "babylonjs/Engines/engine";
  6283. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6284. /**
  6285. * Class used to store data associated with WebGL texture data for the engine
  6286. * This class should not be used directly
  6287. */
  6288. export class InternalTexture {
  6289. /** hidden */
  6290. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6291. /**
  6292. * The source of the texture data is unknown
  6293. */
  6294. static DATASOURCE_UNKNOWN: number;
  6295. /**
  6296. * Texture data comes from an URL
  6297. */
  6298. static DATASOURCE_URL: number;
  6299. /**
  6300. * Texture data is only used for temporary storage
  6301. */
  6302. static DATASOURCE_TEMP: number;
  6303. /**
  6304. * Texture data comes from raw data (ArrayBuffer)
  6305. */
  6306. static DATASOURCE_RAW: number;
  6307. /**
  6308. * Texture content is dynamic (video or dynamic texture)
  6309. */
  6310. static DATASOURCE_DYNAMIC: number;
  6311. /**
  6312. * Texture content is generated by rendering to it
  6313. */
  6314. static DATASOURCE_RENDERTARGET: number;
  6315. /**
  6316. * Texture content is part of a multi render target process
  6317. */
  6318. static DATASOURCE_MULTIRENDERTARGET: number;
  6319. /**
  6320. * Texture data comes from a cube data file
  6321. */
  6322. static DATASOURCE_CUBE: number;
  6323. /**
  6324. * Texture data comes from a raw cube data
  6325. */
  6326. static DATASOURCE_CUBERAW: number;
  6327. /**
  6328. * Texture data come from a prefiltered cube data file
  6329. */
  6330. static DATASOURCE_CUBEPREFILTERED: number;
  6331. /**
  6332. * Texture content is raw 3D data
  6333. */
  6334. static DATASOURCE_RAW3D: number;
  6335. /**
  6336. * Texture content is a depth texture
  6337. */
  6338. static DATASOURCE_DEPTHTEXTURE: number;
  6339. /**
  6340. * Texture data comes from a raw cube data encoded with RGBD
  6341. */
  6342. static DATASOURCE_CUBERAW_RGBD: number;
  6343. /**
  6344. * Defines if the texture is ready
  6345. */
  6346. isReady: boolean;
  6347. /**
  6348. * Defines if the texture is a cube texture
  6349. */
  6350. isCube: boolean;
  6351. /**
  6352. * Defines if the texture contains 3D data
  6353. */
  6354. is3D: boolean;
  6355. /**
  6356. * Defines if the texture contains multiview data
  6357. */
  6358. isMultiview: boolean;
  6359. /**
  6360. * Gets the URL used to load this texture
  6361. */
  6362. url: string;
  6363. /**
  6364. * Gets the sampling mode of the texture
  6365. */
  6366. samplingMode: number;
  6367. /**
  6368. * Gets a boolean indicating if the texture needs mipmaps generation
  6369. */
  6370. generateMipMaps: boolean;
  6371. /**
  6372. * Gets the number of samples used by the texture (WebGL2+ only)
  6373. */
  6374. samples: number;
  6375. /**
  6376. * Gets the type of the texture (int, float...)
  6377. */
  6378. type: number;
  6379. /**
  6380. * Gets the format of the texture (RGB, RGBA...)
  6381. */
  6382. format: number;
  6383. /**
  6384. * Observable called when the texture is loaded
  6385. */
  6386. onLoadedObservable: Observable<InternalTexture>;
  6387. /**
  6388. * Gets the width of the texture
  6389. */
  6390. width: number;
  6391. /**
  6392. * Gets the height of the texture
  6393. */
  6394. height: number;
  6395. /**
  6396. * Gets the depth of the texture
  6397. */
  6398. depth: number;
  6399. /**
  6400. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6401. */
  6402. baseWidth: number;
  6403. /**
  6404. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6405. */
  6406. baseHeight: number;
  6407. /**
  6408. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6409. */
  6410. baseDepth: number;
  6411. /**
  6412. * Gets a boolean indicating if the texture is inverted on Y axis
  6413. */
  6414. invertY: boolean;
  6415. /** @hidden */
  6416. _invertVScale: boolean;
  6417. /** @hidden */
  6418. _associatedChannel: number;
  6419. /** @hidden */
  6420. _dataSource: number;
  6421. /** @hidden */
  6422. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6423. /** @hidden */
  6424. _bufferView: Nullable<ArrayBufferView>;
  6425. /** @hidden */
  6426. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6427. /** @hidden */
  6428. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6429. /** @hidden */
  6430. _size: number;
  6431. /** @hidden */
  6432. _extension: string;
  6433. /** @hidden */
  6434. _files: Nullable<string[]>;
  6435. /** @hidden */
  6436. _workingCanvas: Nullable<HTMLCanvasElement>;
  6437. /** @hidden */
  6438. _workingContext: Nullable<CanvasRenderingContext2D>;
  6439. /** @hidden */
  6440. _framebuffer: Nullable<WebGLFramebuffer>;
  6441. /** @hidden */
  6442. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6443. /** @hidden */
  6444. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6445. /** @hidden */
  6446. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6447. /** @hidden */
  6448. _attachments: Nullable<number[]>;
  6449. /** @hidden */
  6450. _cachedCoordinatesMode: Nullable<number>;
  6451. /** @hidden */
  6452. _cachedWrapU: Nullable<number>;
  6453. /** @hidden */
  6454. _cachedWrapV: Nullable<number>;
  6455. /** @hidden */
  6456. _cachedWrapR: Nullable<number>;
  6457. /** @hidden */
  6458. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6459. /** @hidden */
  6460. _isDisabled: boolean;
  6461. /** @hidden */
  6462. _compression: Nullable<string>;
  6463. /** @hidden */
  6464. _generateStencilBuffer: boolean;
  6465. /** @hidden */
  6466. _generateDepthBuffer: boolean;
  6467. /** @hidden */
  6468. _comparisonFunction: number;
  6469. /** @hidden */
  6470. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6471. /** @hidden */
  6472. _lodGenerationScale: number;
  6473. /** @hidden */
  6474. _lodGenerationOffset: number;
  6475. /** @hidden */
  6476. _colorTextureArray: Nullable<WebGLTexture>;
  6477. /** @hidden */
  6478. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6479. /** @hidden */
  6480. _lodTextureHigh: Nullable<BaseTexture>;
  6481. /** @hidden */
  6482. _lodTextureMid: Nullable<BaseTexture>;
  6483. /** @hidden */
  6484. _lodTextureLow: Nullable<BaseTexture>;
  6485. /** @hidden */
  6486. _isRGBD: boolean;
  6487. /** @hidden */
  6488. _webGLTexture: Nullable<WebGLTexture>;
  6489. /** @hidden */
  6490. _references: number;
  6491. private _engine;
  6492. /**
  6493. * Gets the Engine the texture belongs to.
  6494. * @returns The babylon engine
  6495. */
  6496. getEngine(): Engine;
  6497. /**
  6498. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6499. */
  6500. readonly dataSource: number;
  6501. /**
  6502. * Creates a new InternalTexture
  6503. * @param engine defines the engine to use
  6504. * @param dataSource defines the type of data that will be used
  6505. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6506. */
  6507. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6508. /**
  6509. * Increments the number of references (ie. the number of Texture that point to it)
  6510. */
  6511. incrementReferences(): void;
  6512. /**
  6513. * Change the size of the texture (not the size of the content)
  6514. * @param width defines the new width
  6515. * @param height defines the new height
  6516. * @param depth defines the new depth (1 by default)
  6517. */
  6518. updateSize(width: int, height: int, depth?: int): void;
  6519. /** @hidden */
  6520. _rebuild(): void;
  6521. /** @hidden */
  6522. _swapAndDie(target: InternalTexture): void;
  6523. /**
  6524. * Dispose the current allocated resources
  6525. */
  6526. dispose(): void;
  6527. }
  6528. }
  6529. declare module "babylonjs/Animations/easing" {
  6530. /**
  6531. * This represents the main contract an easing function should follow.
  6532. * Easing functions are used throughout the animation system.
  6533. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6534. */
  6535. export interface IEasingFunction {
  6536. /**
  6537. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6538. * of the easing function.
  6539. * The link below provides some of the most common examples of easing functions.
  6540. * @see https://easings.net/
  6541. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6542. * @returns the corresponding value on the curve defined by the easing function
  6543. */
  6544. ease(gradient: number): number;
  6545. }
  6546. /**
  6547. * Base class used for every default easing function.
  6548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6549. */
  6550. export class EasingFunction implements IEasingFunction {
  6551. /**
  6552. * Interpolation follows the mathematical formula associated with the easing function.
  6553. */
  6554. static readonly EASINGMODE_EASEIN: number;
  6555. /**
  6556. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6557. */
  6558. static readonly EASINGMODE_EASEOUT: number;
  6559. /**
  6560. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6561. */
  6562. static readonly EASINGMODE_EASEINOUT: number;
  6563. private _easingMode;
  6564. /**
  6565. * Sets the easing mode of the current function.
  6566. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6567. */
  6568. setEasingMode(easingMode: number): void;
  6569. /**
  6570. * Gets the current easing mode.
  6571. * @returns the easing mode
  6572. */
  6573. getEasingMode(): number;
  6574. /**
  6575. * @hidden
  6576. */
  6577. easeInCore(gradient: number): number;
  6578. /**
  6579. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6580. * of the easing function.
  6581. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6582. * @returns the corresponding value on the curve defined by the easing function
  6583. */
  6584. ease(gradient: number): number;
  6585. }
  6586. /**
  6587. * Easing function with a circle shape (see link below).
  6588. * @see https://easings.net/#easeInCirc
  6589. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6590. */
  6591. export class CircleEase extends EasingFunction implements IEasingFunction {
  6592. /** @hidden */
  6593. easeInCore(gradient: number): number;
  6594. }
  6595. /**
  6596. * Easing function with a ease back shape (see link below).
  6597. * @see https://easings.net/#easeInBack
  6598. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6599. */
  6600. export class BackEase extends EasingFunction implements IEasingFunction {
  6601. /** Defines the amplitude of the function */
  6602. amplitude: number;
  6603. /**
  6604. * Instantiates a back ease easing
  6605. * @see https://easings.net/#easeInBack
  6606. * @param amplitude Defines the amplitude of the function
  6607. */
  6608. constructor(
  6609. /** Defines the amplitude of the function */
  6610. amplitude?: number);
  6611. /** @hidden */
  6612. easeInCore(gradient: number): number;
  6613. }
  6614. /**
  6615. * Easing function with a bouncing shape (see link below).
  6616. * @see https://easings.net/#easeInBounce
  6617. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6618. */
  6619. export class BounceEase extends EasingFunction implements IEasingFunction {
  6620. /** Defines the number of bounces */
  6621. bounces: number;
  6622. /** Defines the amplitude of the bounce */
  6623. bounciness: number;
  6624. /**
  6625. * Instantiates a bounce easing
  6626. * @see https://easings.net/#easeInBounce
  6627. * @param bounces Defines the number of bounces
  6628. * @param bounciness Defines the amplitude of the bounce
  6629. */
  6630. constructor(
  6631. /** Defines the number of bounces */
  6632. bounces?: number,
  6633. /** Defines the amplitude of the bounce */
  6634. bounciness?: number);
  6635. /** @hidden */
  6636. easeInCore(gradient: number): number;
  6637. }
  6638. /**
  6639. * Easing function with a power of 3 shape (see link below).
  6640. * @see https://easings.net/#easeInCubic
  6641. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6642. */
  6643. export class CubicEase extends EasingFunction implements IEasingFunction {
  6644. /** @hidden */
  6645. easeInCore(gradient: number): number;
  6646. }
  6647. /**
  6648. * Easing function with an elastic shape (see link below).
  6649. * @see https://easings.net/#easeInElastic
  6650. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6651. */
  6652. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6653. /** Defines the number of oscillations*/
  6654. oscillations: number;
  6655. /** Defines the amplitude of the oscillations*/
  6656. springiness: number;
  6657. /**
  6658. * Instantiates an elastic easing function
  6659. * @see https://easings.net/#easeInElastic
  6660. * @param oscillations Defines the number of oscillations
  6661. * @param springiness Defines the amplitude of the oscillations
  6662. */
  6663. constructor(
  6664. /** Defines the number of oscillations*/
  6665. oscillations?: number,
  6666. /** Defines the amplitude of the oscillations*/
  6667. springiness?: number);
  6668. /** @hidden */
  6669. easeInCore(gradient: number): number;
  6670. }
  6671. /**
  6672. * Easing function with an exponential shape (see link below).
  6673. * @see https://easings.net/#easeInExpo
  6674. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6675. */
  6676. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6677. /** Defines the exponent of the function */
  6678. exponent: number;
  6679. /**
  6680. * Instantiates an exponential easing function
  6681. * @see https://easings.net/#easeInExpo
  6682. * @param exponent Defines the exponent of the function
  6683. */
  6684. constructor(
  6685. /** Defines the exponent of the function */
  6686. exponent?: number);
  6687. /** @hidden */
  6688. easeInCore(gradient: number): number;
  6689. }
  6690. /**
  6691. * Easing function with a power shape (see link below).
  6692. * @see https://easings.net/#easeInQuad
  6693. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6694. */
  6695. export class PowerEase extends EasingFunction implements IEasingFunction {
  6696. /** Defines the power of the function */
  6697. power: number;
  6698. /**
  6699. * Instantiates an power base easing function
  6700. * @see https://easings.net/#easeInQuad
  6701. * @param power Defines the power of the function
  6702. */
  6703. constructor(
  6704. /** Defines the power of the function */
  6705. power?: number);
  6706. /** @hidden */
  6707. easeInCore(gradient: number): number;
  6708. }
  6709. /**
  6710. * Easing function with a power of 2 shape (see link below).
  6711. * @see https://easings.net/#easeInQuad
  6712. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6713. */
  6714. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6715. /** @hidden */
  6716. easeInCore(gradient: number): number;
  6717. }
  6718. /**
  6719. * Easing function with a power of 4 shape (see link below).
  6720. * @see https://easings.net/#easeInQuart
  6721. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6722. */
  6723. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6724. /** @hidden */
  6725. easeInCore(gradient: number): number;
  6726. }
  6727. /**
  6728. * Easing function with a power of 5 shape (see link below).
  6729. * @see https://easings.net/#easeInQuint
  6730. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6731. */
  6732. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6733. /** @hidden */
  6734. easeInCore(gradient: number): number;
  6735. }
  6736. /**
  6737. * Easing function with a sin shape (see link below).
  6738. * @see https://easings.net/#easeInSine
  6739. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6740. */
  6741. export class SineEase extends EasingFunction implements IEasingFunction {
  6742. /** @hidden */
  6743. easeInCore(gradient: number): number;
  6744. }
  6745. /**
  6746. * Easing function with a bezier shape (see link below).
  6747. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6748. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6749. */
  6750. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6751. /** Defines the x component of the start tangent in the bezier curve */
  6752. x1: number;
  6753. /** Defines the y component of the start tangent in the bezier curve */
  6754. y1: number;
  6755. /** Defines the x component of the end tangent in the bezier curve */
  6756. x2: number;
  6757. /** Defines the y component of the end tangent in the bezier curve */
  6758. y2: number;
  6759. /**
  6760. * Instantiates a bezier function
  6761. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6762. * @param x1 Defines the x component of the start tangent in the bezier curve
  6763. * @param y1 Defines the y component of the start tangent in the bezier curve
  6764. * @param x2 Defines the x component of the end tangent in the bezier curve
  6765. * @param y2 Defines the y component of the end tangent in the bezier curve
  6766. */
  6767. constructor(
  6768. /** Defines the x component of the start tangent in the bezier curve */
  6769. x1?: number,
  6770. /** Defines the y component of the start tangent in the bezier curve */
  6771. y1?: number,
  6772. /** Defines the x component of the end tangent in the bezier curve */
  6773. x2?: number,
  6774. /** Defines the y component of the end tangent in the bezier curve */
  6775. y2?: number);
  6776. /** @hidden */
  6777. easeInCore(gradient: number): number;
  6778. }
  6779. }
  6780. declare module "babylonjs/Animations/animationKey" {
  6781. /**
  6782. * Defines an interface which represents an animation key frame
  6783. */
  6784. export interface IAnimationKey {
  6785. /**
  6786. * Frame of the key frame
  6787. */
  6788. frame: number;
  6789. /**
  6790. * Value at the specifies key frame
  6791. */
  6792. value: any;
  6793. /**
  6794. * The input tangent for the cubic hermite spline
  6795. */
  6796. inTangent?: any;
  6797. /**
  6798. * The output tangent for the cubic hermite spline
  6799. */
  6800. outTangent?: any;
  6801. /**
  6802. * The animation interpolation type
  6803. */
  6804. interpolation?: AnimationKeyInterpolation;
  6805. }
  6806. /**
  6807. * Enum for the animation key frame interpolation type
  6808. */
  6809. export enum AnimationKeyInterpolation {
  6810. /**
  6811. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6812. */
  6813. STEP = 1
  6814. }
  6815. }
  6816. declare module "babylonjs/Animations/animationRange" {
  6817. /**
  6818. * Represents the range of an animation
  6819. */
  6820. export class AnimationRange {
  6821. /**The name of the animation range**/
  6822. name: string;
  6823. /**The starting frame of the animation */
  6824. from: number;
  6825. /**The ending frame of the animation*/
  6826. to: number;
  6827. /**
  6828. * Initializes the range of an animation
  6829. * @param name The name of the animation range
  6830. * @param from The starting frame of the animation
  6831. * @param to The ending frame of the animation
  6832. */
  6833. constructor(
  6834. /**The name of the animation range**/
  6835. name: string,
  6836. /**The starting frame of the animation */
  6837. from: number,
  6838. /**The ending frame of the animation*/
  6839. to: number);
  6840. /**
  6841. * Makes a copy of the animation range
  6842. * @returns A copy of the animation range
  6843. */
  6844. clone(): AnimationRange;
  6845. }
  6846. }
  6847. declare module "babylonjs/Animations/animationEvent" {
  6848. /**
  6849. * Composed of a frame, and an action function
  6850. */
  6851. export class AnimationEvent {
  6852. /** The frame for which the event is triggered **/
  6853. frame: number;
  6854. /** The event to perform when triggered **/
  6855. action: (currentFrame: number) => void;
  6856. /** Specifies if the event should be triggered only once**/
  6857. onlyOnce?: boolean | undefined;
  6858. /**
  6859. * Specifies if the animation event is done
  6860. */
  6861. isDone: boolean;
  6862. /**
  6863. * Initializes the animation event
  6864. * @param frame The frame for which the event is triggered
  6865. * @param action The event to perform when triggered
  6866. * @param onlyOnce Specifies if the event should be triggered only once
  6867. */
  6868. constructor(
  6869. /** The frame for which the event is triggered **/
  6870. frame: number,
  6871. /** The event to perform when triggered **/
  6872. action: (currentFrame: number) => void,
  6873. /** Specifies if the event should be triggered only once**/
  6874. onlyOnce?: boolean | undefined);
  6875. /** @hidden */
  6876. _clone(): AnimationEvent;
  6877. }
  6878. }
  6879. declare module "babylonjs/Behaviors/behavior" {
  6880. import { Nullable } from "babylonjs/types";
  6881. /**
  6882. * Interface used to define a behavior
  6883. */
  6884. export interface Behavior<T> {
  6885. /** gets or sets behavior's name */
  6886. name: string;
  6887. /**
  6888. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6889. */
  6890. init(): void;
  6891. /**
  6892. * Called when the behavior is attached to a target
  6893. * @param target defines the target where the behavior is attached to
  6894. */
  6895. attach(target: T): void;
  6896. /**
  6897. * Called when the behavior is detached from its target
  6898. */
  6899. detach(): void;
  6900. }
  6901. /**
  6902. * Interface implemented by classes supporting behaviors
  6903. */
  6904. export interface IBehaviorAware<T> {
  6905. /**
  6906. * Attach a behavior
  6907. * @param behavior defines the behavior to attach
  6908. * @returns the current host
  6909. */
  6910. addBehavior(behavior: Behavior<T>): T;
  6911. /**
  6912. * Remove a behavior from the current object
  6913. * @param behavior defines the behavior to detach
  6914. * @returns the current host
  6915. */
  6916. removeBehavior(behavior: Behavior<T>): T;
  6917. /**
  6918. * Gets a behavior using its name to search
  6919. * @param name defines the name to search
  6920. * @returns the behavior or null if not found
  6921. */
  6922. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/intersectionInfo" {
  6926. import { Nullable } from "babylonjs/types";
  6927. /**
  6928. * @hidden
  6929. */
  6930. export class IntersectionInfo {
  6931. bu: Nullable<number>;
  6932. bv: Nullable<number>;
  6933. distance: number;
  6934. faceId: number;
  6935. subMeshId: number;
  6936. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6937. }
  6938. }
  6939. declare module "babylonjs/Culling/boundingSphere" {
  6940. import { DeepImmutable } from "babylonjs/types";
  6941. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6942. /**
  6943. * Class used to store bounding sphere information
  6944. */
  6945. export class BoundingSphere {
  6946. /**
  6947. * Gets the center of the bounding sphere in local space
  6948. */
  6949. readonly center: Vector3;
  6950. /**
  6951. * Radius of the bounding sphere in local space
  6952. */
  6953. radius: number;
  6954. /**
  6955. * Gets the center of the bounding sphere in world space
  6956. */
  6957. readonly centerWorld: Vector3;
  6958. /**
  6959. * Radius of the bounding sphere in world space
  6960. */
  6961. radiusWorld: number;
  6962. /**
  6963. * Gets the minimum vector in local space
  6964. */
  6965. readonly minimum: Vector3;
  6966. /**
  6967. * Gets the maximum vector in local space
  6968. */
  6969. readonly maximum: Vector3;
  6970. private _worldMatrix;
  6971. private static readonly TmpVector3;
  6972. /**
  6973. * Creates a new bounding sphere
  6974. * @param min defines the minimum vector (in local space)
  6975. * @param max defines the maximum vector (in local space)
  6976. * @param worldMatrix defines the new world matrix
  6977. */
  6978. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6979. /**
  6980. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6981. * @param min defines the new minimum vector (in local space)
  6982. * @param max defines the new maximum vector (in local space)
  6983. * @param worldMatrix defines the new world matrix
  6984. */
  6985. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6986. /**
  6987. * Scale the current bounding sphere by applying a scale factor
  6988. * @param factor defines the scale factor to apply
  6989. * @returns the current bounding box
  6990. */
  6991. scale(factor: number): BoundingSphere;
  6992. /**
  6993. * Gets the world matrix of the bounding box
  6994. * @returns a matrix
  6995. */
  6996. getWorldMatrix(): DeepImmutable<Matrix>;
  6997. /** @hidden */
  6998. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6999. /**
  7000. * Tests if the bounding sphere is intersecting the frustum planes
  7001. * @param frustumPlanes defines the frustum planes to test
  7002. * @returns true if there is an intersection
  7003. */
  7004. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7005. /**
  7006. * Tests if the bounding sphere center is in between the frustum planes.
  7007. * Used for optimistic fast inclusion.
  7008. * @param frustumPlanes defines the frustum planes to test
  7009. * @returns true if the sphere center is in between the frustum planes
  7010. */
  7011. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7012. /**
  7013. * Tests if a point is inside the bounding sphere
  7014. * @param point defines the point to test
  7015. * @returns true if the point is inside the bounding sphere
  7016. */
  7017. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7018. /**
  7019. * Checks if two sphere intersct
  7020. * @param sphere0 sphere 0
  7021. * @param sphere1 sphere 1
  7022. * @returns true if the speres intersect
  7023. */
  7024. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7025. }
  7026. }
  7027. declare module "babylonjs/Culling/boundingBox" {
  7028. import { DeepImmutable } from "babylonjs/types";
  7029. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7030. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7031. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7032. /**
  7033. * Class used to store bounding box information
  7034. */
  7035. export class BoundingBox implements ICullable {
  7036. /**
  7037. * Gets the 8 vectors representing the bounding box in local space
  7038. */
  7039. readonly vectors: Vector3[];
  7040. /**
  7041. * Gets the center of the bounding box in local space
  7042. */
  7043. readonly center: Vector3;
  7044. /**
  7045. * Gets the center of the bounding box in world space
  7046. */
  7047. readonly centerWorld: Vector3;
  7048. /**
  7049. * Gets the extend size in local space
  7050. */
  7051. readonly extendSize: Vector3;
  7052. /**
  7053. * Gets the extend size in world space
  7054. */
  7055. readonly extendSizeWorld: Vector3;
  7056. /**
  7057. * Gets the OBB (object bounding box) directions
  7058. */
  7059. readonly directions: Vector3[];
  7060. /**
  7061. * Gets the 8 vectors representing the bounding box in world space
  7062. */
  7063. readonly vectorsWorld: Vector3[];
  7064. /**
  7065. * Gets the minimum vector in world space
  7066. */
  7067. readonly minimumWorld: Vector3;
  7068. /**
  7069. * Gets the maximum vector in world space
  7070. */
  7071. readonly maximumWorld: Vector3;
  7072. /**
  7073. * Gets the minimum vector in local space
  7074. */
  7075. readonly minimum: Vector3;
  7076. /**
  7077. * Gets the maximum vector in local space
  7078. */
  7079. readonly maximum: Vector3;
  7080. private _worldMatrix;
  7081. private static readonly TmpVector3;
  7082. /**
  7083. * @hidden
  7084. */
  7085. _tag: number;
  7086. /**
  7087. * Creates a new bounding box
  7088. * @param min defines the minimum vector (in local space)
  7089. * @param max defines the maximum vector (in local space)
  7090. * @param worldMatrix defines the new world matrix
  7091. */
  7092. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7093. /**
  7094. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7095. * @param min defines the new minimum vector (in local space)
  7096. * @param max defines the new maximum vector (in local space)
  7097. * @param worldMatrix defines the new world matrix
  7098. */
  7099. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7100. /**
  7101. * Scale the current bounding box by applying a scale factor
  7102. * @param factor defines the scale factor to apply
  7103. * @returns the current bounding box
  7104. */
  7105. scale(factor: number): BoundingBox;
  7106. /**
  7107. * Gets the world matrix of the bounding box
  7108. * @returns a matrix
  7109. */
  7110. getWorldMatrix(): DeepImmutable<Matrix>;
  7111. /** @hidden */
  7112. _update(world: DeepImmutable<Matrix>): void;
  7113. /**
  7114. * Tests if the bounding box is intersecting the frustum planes
  7115. * @param frustumPlanes defines the frustum planes to test
  7116. * @returns true if there is an intersection
  7117. */
  7118. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7119. /**
  7120. * Tests if the bounding box is entirely inside the frustum planes
  7121. * @param frustumPlanes defines the frustum planes to test
  7122. * @returns true if there is an inclusion
  7123. */
  7124. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7125. /**
  7126. * Tests if a point is inside the bounding box
  7127. * @param point defines the point to test
  7128. * @returns true if the point is inside the bounding box
  7129. */
  7130. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7131. /**
  7132. * Tests if the bounding box intersects with a bounding sphere
  7133. * @param sphere defines the sphere to test
  7134. * @returns true if there is an intersection
  7135. */
  7136. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7137. /**
  7138. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7139. * @param min defines the min vector to use
  7140. * @param max defines the max vector to use
  7141. * @returns true if there is an intersection
  7142. */
  7143. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7144. /**
  7145. * Tests if two bounding boxes are intersections
  7146. * @param box0 defines the first box to test
  7147. * @param box1 defines the second box to test
  7148. * @returns true if there is an intersection
  7149. */
  7150. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7151. /**
  7152. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7153. * @param minPoint defines the minimum vector of the bounding box
  7154. * @param maxPoint defines the maximum vector of the bounding box
  7155. * @param sphereCenter defines the sphere center
  7156. * @param sphereRadius defines the sphere radius
  7157. * @returns true if there is an intersection
  7158. */
  7159. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7160. /**
  7161. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7162. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7163. * @param frustumPlanes defines the frustum planes to test
  7164. * @return true if there is an inclusion
  7165. */
  7166. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7167. /**
  7168. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7169. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7170. * @param frustumPlanes defines the frustum planes to test
  7171. * @return true if there is an intersection
  7172. */
  7173. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7174. }
  7175. }
  7176. declare module "babylonjs/Collisions/collider" {
  7177. import { Nullable, IndicesArray } from "babylonjs/types";
  7178. import { Vector3, Plane } from "babylonjs/Maths/math";
  7179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7180. /** @hidden */
  7181. export class Collider {
  7182. /** Define if a collision was found */
  7183. collisionFound: boolean;
  7184. /**
  7185. * Define last intersection point in local space
  7186. */
  7187. intersectionPoint: Vector3;
  7188. /**
  7189. * Define last collided mesh
  7190. */
  7191. collidedMesh: Nullable<AbstractMesh>;
  7192. private _collisionPoint;
  7193. private _planeIntersectionPoint;
  7194. private _tempVector;
  7195. private _tempVector2;
  7196. private _tempVector3;
  7197. private _tempVector4;
  7198. private _edge;
  7199. private _baseToVertex;
  7200. private _destinationPoint;
  7201. private _slidePlaneNormal;
  7202. private _displacementVector;
  7203. /** @hidden */
  7204. _radius: Vector3;
  7205. /** @hidden */
  7206. _retry: number;
  7207. private _velocity;
  7208. private _basePoint;
  7209. private _epsilon;
  7210. /** @hidden */
  7211. _velocityWorldLength: number;
  7212. /** @hidden */
  7213. _basePointWorld: Vector3;
  7214. private _velocityWorld;
  7215. private _normalizedVelocity;
  7216. /** @hidden */
  7217. _initialVelocity: Vector3;
  7218. /** @hidden */
  7219. _initialPosition: Vector3;
  7220. private _nearestDistance;
  7221. private _collisionMask;
  7222. collisionMask: number;
  7223. /**
  7224. * Gets the plane normal used to compute the sliding response (in local space)
  7225. */
  7226. readonly slidePlaneNormal: Vector3;
  7227. /** @hidden */
  7228. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7229. /** @hidden */
  7230. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7231. /** @hidden */
  7232. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7233. /** @hidden */
  7234. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7235. /** @hidden */
  7236. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7237. /** @hidden */
  7238. _getResponse(pos: Vector3, vel: Vector3): void;
  7239. }
  7240. }
  7241. declare module "babylonjs/Culling/boundingInfo" {
  7242. import { DeepImmutable } from "babylonjs/types";
  7243. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7244. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7245. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7246. import { Collider } from "babylonjs/Collisions/collider";
  7247. /**
  7248. * Interface for cullable objects
  7249. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7250. */
  7251. export interface ICullable {
  7252. /**
  7253. * Checks if the object or part of the object is in the frustum
  7254. * @param frustumPlanes Camera near/planes
  7255. * @returns true if the object is in frustum otherwise false
  7256. */
  7257. isInFrustum(frustumPlanes: Plane[]): boolean;
  7258. /**
  7259. * Checks if a cullable object (mesh...) is in the camera frustum
  7260. * Unlike isInFrustum this cheks the full bounding box
  7261. * @param frustumPlanes Camera near/planes
  7262. * @returns true if the object is in frustum otherwise false
  7263. */
  7264. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7265. }
  7266. /**
  7267. * Info for a bounding data of a mesh
  7268. */
  7269. export class BoundingInfo implements ICullable {
  7270. /**
  7271. * Bounding box for the mesh
  7272. */
  7273. readonly boundingBox: BoundingBox;
  7274. /**
  7275. * Bounding sphere for the mesh
  7276. */
  7277. readonly boundingSphere: BoundingSphere;
  7278. private _isLocked;
  7279. private static readonly TmpVector3;
  7280. /**
  7281. * Constructs bounding info
  7282. * @param minimum min vector of the bounding box/sphere
  7283. * @param maximum max vector of the bounding box/sphere
  7284. * @param worldMatrix defines the new world matrix
  7285. */
  7286. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7287. /**
  7288. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7289. * @param min defines the new minimum vector (in local space)
  7290. * @param max defines the new maximum vector (in local space)
  7291. * @param worldMatrix defines the new world matrix
  7292. */
  7293. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7294. /**
  7295. * min vector of the bounding box/sphere
  7296. */
  7297. readonly minimum: Vector3;
  7298. /**
  7299. * max vector of the bounding box/sphere
  7300. */
  7301. readonly maximum: Vector3;
  7302. /**
  7303. * If the info is locked and won't be updated to avoid perf overhead
  7304. */
  7305. isLocked: boolean;
  7306. /**
  7307. * Updates the bounding sphere and box
  7308. * @param world world matrix to be used to update
  7309. */
  7310. update(world: DeepImmutable<Matrix>): void;
  7311. /**
  7312. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7313. * @param center New center of the bounding info
  7314. * @param extend New extend of the bounding info
  7315. * @returns the current bounding info
  7316. */
  7317. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7318. /**
  7319. * Scale the current bounding info by applying a scale factor
  7320. * @param factor defines the scale factor to apply
  7321. * @returns the current bounding info
  7322. */
  7323. scale(factor: number): BoundingInfo;
  7324. /**
  7325. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7326. * @param frustumPlanes defines the frustum to test
  7327. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7328. * @returns true if the bounding info is in the frustum planes
  7329. */
  7330. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7331. /**
  7332. * Gets the world distance between the min and max points of the bounding box
  7333. */
  7334. readonly diagonalLength: number;
  7335. /**
  7336. * Checks if a cullable object (mesh...) is in the camera frustum
  7337. * Unlike isInFrustum this cheks the full bounding box
  7338. * @param frustumPlanes Camera near/planes
  7339. * @returns true if the object is in frustum otherwise false
  7340. */
  7341. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7342. /** @hidden */
  7343. _checkCollision(collider: Collider): boolean;
  7344. /**
  7345. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7346. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7347. * @param point the point to check intersection with
  7348. * @returns if the point intersects
  7349. */
  7350. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7351. /**
  7352. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7353. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7354. * @param boundingInfo the bounding info to check intersection with
  7355. * @param precise if the intersection should be done using OBB
  7356. * @returns if the bounding info intersects
  7357. */
  7358. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7359. }
  7360. }
  7361. declare module "babylonjs/Misc/smartArray" {
  7362. /**
  7363. * Defines an array and its length.
  7364. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7365. */
  7366. export interface ISmartArrayLike<T> {
  7367. /**
  7368. * The data of the array.
  7369. */
  7370. data: Array<T>;
  7371. /**
  7372. * The active length of the array.
  7373. */
  7374. length: number;
  7375. }
  7376. /**
  7377. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7378. */
  7379. export class SmartArray<T> implements ISmartArrayLike<T> {
  7380. /**
  7381. * The full set of data from the array.
  7382. */
  7383. data: Array<T>;
  7384. /**
  7385. * The active length of the array.
  7386. */
  7387. length: number;
  7388. protected _id: number;
  7389. /**
  7390. * Instantiates a Smart Array.
  7391. * @param capacity defines the default capacity of the array.
  7392. */
  7393. constructor(capacity: number);
  7394. /**
  7395. * Pushes a value at the end of the active data.
  7396. * @param value defines the object to push in the array.
  7397. */
  7398. push(value: T): void;
  7399. /**
  7400. * Iterates over the active data and apply the lambda to them.
  7401. * @param func defines the action to apply on each value.
  7402. */
  7403. forEach(func: (content: T) => void): void;
  7404. /**
  7405. * Sorts the full sets of data.
  7406. * @param compareFn defines the comparison function to apply.
  7407. */
  7408. sort(compareFn: (a: T, b: T) => number): void;
  7409. /**
  7410. * Resets the active data to an empty array.
  7411. */
  7412. reset(): void;
  7413. /**
  7414. * Releases all the data from the array as well as the array.
  7415. */
  7416. dispose(): void;
  7417. /**
  7418. * Concats the active data with a given array.
  7419. * @param array defines the data to concatenate with.
  7420. */
  7421. concat(array: any): void;
  7422. /**
  7423. * Returns the position of a value in the active data.
  7424. * @param value defines the value to find the index for
  7425. * @returns the index if found in the active data otherwise -1
  7426. */
  7427. indexOf(value: T): number;
  7428. /**
  7429. * Returns whether an element is part of the active data.
  7430. * @param value defines the value to look for
  7431. * @returns true if found in the active data otherwise false
  7432. */
  7433. contains(value: T): boolean;
  7434. private static _GlobalId;
  7435. }
  7436. /**
  7437. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7438. * The data in this array can only be present once
  7439. */
  7440. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7441. private _duplicateId;
  7442. /**
  7443. * Pushes a value at the end of the active data.
  7444. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7445. * @param value defines the object to push in the array.
  7446. */
  7447. push(value: T): void;
  7448. /**
  7449. * Pushes a value at the end of the active data.
  7450. * If the data is already present, it won t be added again
  7451. * @param value defines the object to push in the array.
  7452. * @returns true if added false if it was already present
  7453. */
  7454. pushNoDuplicate(value: T): boolean;
  7455. /**
  7456. * Resets the active data to an empty array.
  7457. */
  7458. reset(): void;
  7459. /**
  7460. * Concats the active data with a given array.
  7461. * This ensures no dupplicate will be present in the result.
  7462. * @param array defines the data to concatenate with.
  7463. */
  7464. concatWithNoDuplicate(array: any): void;
  7465. }
  7466. }
  7467. declare module "babylonjs/Materials/multiMaterial" {
  7468. import { Nullable } from "babylonjs/types";
  7469. import { Scene } from "babylonjs/scene";
  7470. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7471. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7472. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7473. import { Material } from "babylonjs/Materials/material";
  7474. /**
  7475. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7476. * separate meshes. This can be use to improve performances.
  7477. * @see http://doc.babylonjs.com/how_to/multi_materials
  7478. */
  7479. export class MultiMaterial extends Material {
  7480. private _subMaterials;
  7481. /**
  7482. * Gets or Sets the list of Materials used within the multi material.
  7483. * They need to be ordered according to the submeshes order in the associated mesh
  7484. */
  7485. subMaterials: Nullable<Material>[];
  7486. /**
  7487. * Function used to align with Node.getChildren()
  7488. * @returns the list of Materials used within the multi material
  7489. */
  7490. getChildren(): Nullable<Material>[];
  7491. /**
  7492. * Instantiates a new Multi Material
  7493. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7494. * separate meshes. This can be use to improve performances.
  7495. * @see http://doc.babylonjs.com/how_to/multi_materials
  7496. * @param name Define the name in the scene
  7497. * @param scene Define the scene the material belongs to
  7498. */
  7499. constructor(name: string, scene: Scene);
  7500. private _hookArray;
  7501. /**
  7502. * Get one of the submaterial by its index in the submaterials array
  7503. * @param index The index to look the sub material at
  7504. * @returns The Material if the index has been defined
  7505. */
  7506. getSubMaterial(index: number): Nullable<Material>;
  7507. /**
  7508. * Get the list of active textures for the whole sub materials list.
  7509. * @returns All the textures that will be used during the rendering
  7510. */
  7511. getActiveTextures(): BaseTexture[];
  7512. /**
  7513. * Gets the current class name of the material e.g. "MultiMaterial"
  7514. * Mainly use in serialization.
  7515. * @returns the class name
  7516. */
  7517. getClassName(): string;
  7518. /**
  7519. * Checks if the material is ready to render the requested sub mesh
  7520. * @param mesh Define the mesh the submesh belongs to
  7521. * @param subMesh Define the sub mesh to look readyness for
  7522. * @param useInstances Define whether or not the material is used with instances
  7523. * @returns true if ready, otherwise false
  7524. */
  7525. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7526. /**
  7527. * Clones the current material and its related sub materials
  7528. * @param name Define the name of the newly cloned material
  7529. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7530. * @returns the cloned material
  7531. */
  7532. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7533. /**
  7534. * Serializes the materials into a JSON representation.
  7535. * @returns the JSON representation
  7536. */
  7537. serialize(): any;
  7538. /**
  7539. * Dispose the material and release its associated resources
  7540. * @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)
  7541. * @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)
  7542. * @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)
  7543. */
  7544. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7545. /**
  7546. * Creates a MultiMaterial from parsed MultiMaterial data.
  7547. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7548. * @param scene defines the hosting scene
  7549. * @returns a new MultiMaterial
  7550. */
  7551. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7552. }
  7553. }
  7554. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7555. /**
  7556. * Class used to represent data loading progression
  7557. */
  7558. export class SceneLoaderFlags {
  7559. private static _ForceFullSceneLoadingForIncremental;
  7560. private static _ShowLoadingScreen;
  7561. private static _CleanBoneMatrixWeights;
  7562. private static _loggingLevel;
  7563. /**
  7564. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7565. */
  7566. static ForceFullSceneLoadingForIncremental: boolean;
  7567. /**
  7568. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7569. */
  7570. static ShowLoadingScreen: boolean;
  7571. /**
  7572. * Defines the current logging level (while loading the scene)
  7573. * @ignorenaming
  7574. */
  7575. static loggingLevel: number;
  7576. /**
  7577. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7578. */
  7579. static CleanBoneMatrixWeights: boolean;
  7580. }
  7581. }
  7582. declare module "babylonjs/Meshes/transformNode" {
  7583. import { DeepImmutable } from "babylonjs/types";
  7584. import { Observable } from "babylonjs/Misc/observable";
  7585. import { Nullable } from "babylonjs/types";
  7586. import { Camera } from "babylonjs/Cameras/camera";
  7587. import { Scene } from "babylonjs/scene";
  7588. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7589. import { Node } from "babylonjs/node";
  7590. import { Bone } from "babylonjs/Bones/bone";
  7591. /**
  7592. * 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.
  7593. * @see https://doc.babylonjs.com/how_to/transformnode
  7594. */
  7595. export class TransformNode extends Node {
  7596. /**
  7597. * Object will not rotate to face the camera
  7598. */
  7599. static BILLBOARDMODE_NONE: number;
  7600. /**
  7601. * Object will rotate to face the camera but only on the x axis
  7602. */
  7603. static BILLBOARDMODE_X: number;
  7604. /**
  7605. * Object will rotate to face the camera but only on the y axis
  7606. */
  7607. static BILLBOARDMODE_Y: number;
  7608. /**
  7609. * Object will rotate to face the camera but only on the z axis
  7610. */
  7611. static BILLBOARDMODE_Z: number;
  7612. /**
  7613. * Object will rotate to face the camera
  7614. */
  7615. static BILLBOARDMODE_ALL: number;
  7616. private _forward;
  7617. private _forwardInverted;
  7618. private _up;
  7619. private _right;
  7620. private _rightInverted;
  7621. private _position;
  7622. private _rotation;
  7623. private _rotationQuaternion;
  7624. protected _scaling: Vector3;
  7625. protected _isDirty: boolean;
  7626. private _transformToBoneReferal;
  7627. private _billboardMode;
  7628. /**
  7629. * Gets or sets the billboard mode. Default is 0.
  7630. *
  7631. * | Value | Type | Description |
  7632. * | --- | --- | --- |
  7633. * | 0 | BILLBOARDMODE_NONE | |
  7634. * | 1 | BILLBOARDMODE_X | |
  7635. * | 2 | BILLBOARDMODE_Y | |
  7636. * | 4 | BILLBOARDMODE_Z | |
  7637. * | 7 | BILLBOARDMODE_ALL | |
  7638. *
  7639. */
  7640. billboardMode: number;
  7641. private _preserveParentRotationForBillboard;
  7642. /**
  7643. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7644. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7645. */
  7646. preserveParentRotationForBillboard: boolean;
  7647. /**
  7648. * 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
  7649. */
  7650. scalingDeterminant: number;
  7651. private _infiniteDistance;
  7652. /**
  7653. * Gets or sets the distance of the object to max, often used by skybox
  7654. */
  7655. infiniteDistance: boolean;
  7656. /**
  7657. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7658. * By default the system will update normals to compensate
  7659. */
  7660. ignoreNonUniformScaling: boolean;
  7661. /**
  7662. * 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
  7663. */
  7664. reIntegrateRotationIntoRotationQuaternion: boolean;
  7665. /** @hidden */
  7666. _poseMatrix: Nullable<Matrix>;
  7667. /** @hidden */
  7668. _localMatrix: Matrix;
  7669. private _usePivotMatrix;
  7670. private _absolutePosition;
  7671. private _pivotMatrix;
  7672. private _pivotMatrixInverse;
  7673. protected _postMultiplyPivotMatrix: boolean;
  7674. protected _isWorldMatrixFrozen: boolean;
  7675. /** @hidden */
  7676. _indexInSceneTransformNodesArray: number;
  7677. /**
  7678. * An event triggered after the world matrix is updated
  7679. */
  7680. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7681. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7682. /**
  7683. * Gets a string identifying the name of the class
  7684. * @returns "TransformNode" string
  7685. */
  7686. getClassName(): string;
  7687. /**
  7688. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7689. */
  7690. position: Vector3;
  7691. /**
  7692. * 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)).
  7693. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7694. */
  7695. rotation: Vector3;
  7696. /**
  7697. * 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)).
  7698. */
  7699. scaling: Vector3;
  7700. /**
  7701. * 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).
  7702. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7703. */
  7704. rotationQuaternion: Nullable<Quaternion>;
  7705. /**
  7706. * The forward direction of that transform in world space.
  7707. */
  7708. readonly forward: Vector3;
  7709. /**
  7710. * The up direction of that transform in world space.
  7711. */
  7712. readonly up: Vector3;
  7713. /**
  7714. * The right direction of that transform in world space.
  7715. */
  7716. readonly right: Vector3;
  7717. /**
  7718. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7719. * @param matrix the matrix to copy the pose from
  7720. * @returns this TransformNode.
  7721. */
  7722. updatePoseMatrix(matrix: Matrix): TransformNode;
  7723. /**
  7724. * Returns the mesh Pose matrix.
  7725. * @returns the pose matrix
  7726. */
  7727. getPoseMatrix(): Matrix;
  7728. /** @hidden */
  7729. _isSynchronized(): boolean;
  7730. /** @hidden */
  7731. _initCache(): void;
  7732. /**
  7733. * Flag the transform node as dirty (Forcing it to update everything)
  7734. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7735. * @returns this transform node
  7736. */
  7737. markAsDirty(property: string): TransformNode;
  7738. /**
  7739. * Returns the current mesh absolute position.
  7740. * Returns a Vector3.
  7741. */
  7742. readonly absolutePosition: Vector3;
  7743. /**
  7744. * Sets a new matrix to apply before all other transformation
  7745. * @param matrix defines the transform matrix
  7746. * @returns the current TransformNode
  7747. */
  7748. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7749. /**
  7750. * Sets a new pivot matrix to the current node
  7751. * @param matrix defines the new pivot matrix to use
  7752. * @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
  7753. * @returns the current TransformNode
  7754. */
  7755. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7756. /**
  7757. * Returns the mesh pivot matrix.
  7758. * Default : Identity.
  7759. * @returns the matrix
  7760. */
  7761. getPivotMatrix(): Matrix;
  7762. /**
  7763. * Prevents the World matrix to be computed any longer.
  7764. * @returns the TransformNode.
  7765. */
  7766. freezeWorldMatrix(): TransformNode;
  7767. /**
  7768. * Allows back the World matrix computation.
  7769. * @returns the TransformNode.
  7770. */
  7771. unfreezeWorldMatrix(): this;
  7772. /**
  7773. * True if the World matrix has been frozen.
  7774. */
  7775. readonly isWorldMatrixFrozen: boolean;
  7776. /**
  7777. * Retuns the mesh absolute position in the World.
  7778. * @returns a Vector3.
  7779. */
  7780. getAbsolutePosition(): Vector3;
  7781. /**
  7782. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7783. * @param absolutePosition the absolute position to set
  7784. * @returns the TransformNode.
  7785. */
  7786. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7787. /**
  7788. * Sets the mesh position in its local space.
  7789. * @param vector3 the position to set in localspace
  7790. * @returns the TransformNode.
  7791. */
  7792. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7793. /**
  7794. * Returns the mesh position in the local space from the current World matrix values.
  7795. * @returns a new Vector3.
  7796. */
  7797. getPositionExpressedInLocalSpace(): Vector3;
  7798. /**
  7799. * Translates the mesh along the passed Vector3 in its local space.
  7800. * @param vector3 the distance to translate in localspace
  7801. * @returns the TransformNode.
  7802. */
  7803. locallyTranslate(vector3: Vector3): TransformNode;
  7804. private static _lookAtVectorCache;
  7805. /**
  7806. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7807. * @param targetPoint the position (must be in same space as current mesh) to look at
  7808. * @param yawCor optional yaw (y-axis) correction in radians
  7809. * @param pitchCor optional pitch (x-axis) correction in radians
  7810. * @param rollCor optional roll (z-axis) correction in radians
  7811. * @param space the choosen space of the target
  7812. * @returns the TransformNode.
  7813. */
  7814. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7815. /**
  7816. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7817. * This Vector3 is expressed in the World space.
  7818. * @param localAxis axis to rotate
  7819. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7820. */
  7821. getDirection(localAxis: Vector3): Vector3;
  7822. /**
  7823. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7824. * localAxis is expressed in the mesh local space.
  7825. * result is computed in the Wordl space from the mesh World matrix.
  7826. * @param localAxis axis to rotate
  7827. * @param result the resulting transformnode
  7828. * @returns this TransformNode.
  7829. */
  7830. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7831. /**
  7832. * Sets this transform node rotation to the given local axis.
  7833. * @param localAxis the axis in local space
  7834. * @param yawCor optional yaw (y-axis) correction in radians
  7835. * @param pitchCor optional pitch (x-axis) correction in radians
  7836. * @param rollCor optional roll (z-axis) correction in radians
  7837. * @returns this TransformNode
  7838. */
  7839. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7840. /**
  7841. * Sets a new pivot point to the current node
  7842. * @param point defines the new pivot point to use
  7843. * @param space defines if the point is in world or local space (local by default)
  7844. * @returns the current TransformNode
  7845. */
  7846. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7847. /**
  7848. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7849. * @returns the pivot point
  7850. */
  7851. getPivotPoint(): Vector3;
  7852. /**
  7853. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7854. * @param result the vector3 to store the result
  7855. * @returns this TransformNode.
  7856. */
  7857. getPivotPointToRef(result: Vector3): TransformNode;
  7858. /**
  7859. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7860. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7861. */
  7862. getAbsolutePivotPoint(): Vector3;
  7863. /**
  7864. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7865. * @param result vector3 to store the result
  7866. * @returns this TransformNode.
  7867. */
  7868. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7869. /**
  7870. * Defines the passed node as the parent of the current node.
  7871. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7872. * @see https://doc.babylonjs.com/how_to/parenting
  7873. * @param node the node ot set as the parent
  7874. * @returns this TransformNode.
  7875. */
  7876. setParent(node: Nullable<Node>): TransformNode;
  7877. private _nonUniformScaling;
  7878. /**
  7879. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7880. */
  7881. readonly nonUniformScaling: boolean;
  7882. /** @hidden */
  7883. _updateNonUniformScalingState(value: boolean): boolean;
  7884. /**
  7885. * Attach the current TransformNode to another TransformNode associated with a bone
  7886. * @param bone Bone affecting the TransformNode
  7887. * @param affectedTransformNode TransformNode associated with the bone
  7888. * @returns this object
  7889. */
  7890. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7891. /**
  7892. * Detach the transform node if its associated with a bone
  7893. * @returns this object
  7894. */
  7895. detachFromBone(): TransformNode;
  7896. private static _rotationAxisCache;
  7897. /**
  7898. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7899. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7900. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7901. * The passed axis is also normalized.
  7902. * @param axis the axis to rotate around
  7903. * @param amount the amount to rotate in radians
  7904. * @param space Space to rotate in (Default: local)
  7905. * @returns the TransformNode.
  7906. */
  7907. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7908. /**
  7909. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7910. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7911. * The passed axis is also normalized. .
  7912. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7913. * @param point the point to rotate around
  7914. * @param axis the axis to rotate around
  7915. * @param amount the amount to rotate in radians
  7916. * @returns the TransformNode
  7917. */
  7918. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7919. /**
  7920. * Translates the mesh along the axis vector for the passed distance in the given space.
  7921. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7922. * @param axis the axis to translate in
  7923. * @param distance the distance to translate
  7924. * @param space Space to rotate in (Default: local)
  7925. * @returns the TransformNode.
  7926. */
  7927. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7928. /**
  7929. * Adds a rotation step to the mesh current rotation.
  7930. * x, y, z are Euler angles expressed in radians.
  7931. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7932. * This means this rotation is made in the mesh local space only.
  7933. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7934. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7935. * ```javascript
  7936. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7937. * ```
  7938. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7939. * 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.
  7940. * @param x Rotation to add
  7941. * @param y Rotation to add
  7942. * @param z Rotation to add
  7943. * @returns the TransformNode.
  7944. */
  7945. addRotation(x: number, y: number, z: number): TransformNode;
  7946. /**
  7947. * @hidden
  7948. */
  7949. protected _getEffectiveParent(): Nullable<Node>;
  7950. /**
  7951. * Computes the world matrix of the node
  7952. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7953. * @returns the world matrix
  7954. */
  7955. computeWorldMatrix(force?: boolean): Matrix;
  7956. protected _afterComputeWorldMatrix(): void;
  7957. /**
  7958. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7959. * @param func callback function to add
  7960. *
  7961. * @returns the TransformNode.
  7962. */
  7963. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7964. /**
  7965. * Removes a registered callback function.
  7966. * @param func callback function to remove
  7967. * @returns the TransformNode.
  7968. */
  7969. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7970. /**
  7971. * Gets the position of the current mesh in camera space
  7972. * @param camera defines the camera to use
  7973. * @returns a position
  7974. */
  7975. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7976. /**
  7977. * Returns the distance from the mesh to the active camera
  7978. * @param camera defines the camera to use
  7979. * @returns the distance
  7980. */
  7981. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7982. /**
  7983. * Clone the current transform node
  7984. * @param name Name of the new clone
  7985. * @param newParent New parent for the clone
  7986. * @param doNotCloneChildren Do not clone children hierarchy
  7987. * @returns the new transform node
  7988. */
  7989. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7990. /**
  7991. * Serializes the objects information.
  7992. * @param currentSerializationObject defines the object to serialize in
  7993. * @returns the serialized object
  7994. */
  7995. serialize(currentSerializationObject?: any): any;
  7996. /**
  7997. * Returns a new TransformNode object parsed from the source provided.
  7998. * @param parsedTransformNode is the source.
  7999. * @param scene the scne the object belongs to
  8000. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  8001. * @returns a new TransformNode object parsed from the source provided.
  8002. */
  8003. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  8004. /**
  8005. * Get all child-transformNodes of this node
  8006. * @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
  8007. * @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
  8008. * @returns an array of TransformNode
  8009. */
  8010. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  8011. /**
  8012. * Releases resources associated with this transform node.
  8013. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  8014. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  8015. */
  8016. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  8017. }
  8018. }
  8019. declare module "babylonjs/Animations/animationPropertiesOverride" {
  8020. /**
  8021. * Class used to override all child animations of a given target
  8022. */
  8023. export class AnimationPropertiesOverride {
  8024. /**
  8025. * Gets or sets a value indicating if animation blending must be used
  8026. */
  8027. enableBlending: boolean;
  8028. /**
  8029. * Gets or sets the blending speed to use when enableBlending is true
  8030. */
  8031. blendingSpeed: number;
  8032. /**
  8033. * Gets or sets the default loop mode to use
  8034. */
  8035. loopMode: number;
  8036. }
  8037. }
  8038. declare module "babylonjs/Bones/bone" {
  8039. import { Skeleton } from "babylonjs/Bones/skeleton";
  8040. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  8041. import { Nullable } from "babylonjs/types";
  8042. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8043. import { TransformNode } from "babylonjs/Meshes/transformNode";
  8044. import { Node } from "babylonjs/node";
  8045. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  8046. /**
  8047. * Class used to store bone information
  8048. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  8049. */
  8050. export class Bone extends Node {
  8051. /**
  8052. * defines the bone name
  8053. */
  8054. name: string;
  8055. private static _tmpVecs;
  8056. private static _tmpQuat;
  8057. private static _tmpMats;
  8058. /**
  8059. * Gets the list of child bones
  8060. */
  8061. children: Bone[];
  8062. /** Gets the animations associated with this bone */
  8063. animations: import("babylonjs/Animations/animation").Animation[];
  8064. /**
  8065. * Gets or sets bone length
  8066. */
  8067. length: number;
  8068. /**
  8069. * @hidden Internal only
  8070. * Set this value to map this bone to a different index in the transform matrices
  8071. * Set this value to -1 to exclude the bone from the transform matrices
  8072. */
  8073. _index: Nullable<number>;
  8074. private _skeleton;
  8075. private _localMatrix;
  8076. private _restPose;
  8077. private _baseMatrix;
  8078. private _absoluteTransform;
  8079. private _invertedAbsoluteTransform;
  8080. private _parent;
  8081. private _scalingDeterminant;
  8082. private _worldTransform;
  8083. private _localScaling;
  8084. private _localRotation;
  8085. private _localPosition;
  8086. private _needToDecompose;
  8087. private _needToCompose;
  8088. /** @hidden */
  8089. _linkedTransformNode: Nullable<TransformNode>;
  8090. /** @hidden */
  8091. _waitingTransformNodeId: Nullable<string>;
  8092. /** @hidden */
  8093. /** @hidden */
  8094. _matrix: Matrix;
  8095. /**
  8096. * Create a new bone
  8097. * @param name defines the bone name
  8098. * @param skeleton defines the parent skeleton
  8099. * @param parentBone defines the parent (can be null if the bone is the root)
  8100. * @param localMatrix defines the local matrix
  8101. * @param restPose defines the rest pose matrix
  8102. * @param baseMatrix defines the base matrix
  8103. * @param index defines index of the bone in the hiearchy
  8104. */
  8105. constructor(
  8106. /**
  8107. * defines the bone name
  8108. */
  8109. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8110. /**
  8111. * Gets the current object class name.
  8112. * @return the class name
  8113. */
  8114. getClassName(): string;
  8115. /**
  8116. * Gets the parent skeleton
  8117. * @returns a skeleton
  8118. */
  8119. getSkeleton(): Skeleton;
  8120. /**
  8121. * Gets parent bone
  8122. * @returns a bone or null if the bone is the root of the bone hierarchy
  8123. */
  8124. getParent(): Nullable<Bone>;
  8125. /**
  8126. * Returns an array containing the root bones
  8127. * @returns an array containing the root bones
  8128. */
  8129. getChildren(): Array<Bone>;
  8130. /**
  8131. * Sets the parent bone
  8132. * @param parent defines the parent (can be null if the bone is the root)
  8133. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8134. */
  8135. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8136. /**
  8137. * Gets the local matrix
  8138. * @returns a matrix
  8139. */
  8140. getLocalMatrix(): Matrix;
  8141. /**
  8142. * Gets the base matrix (initial matrix which remains unchanged)
  8143. * @returns a matrix
  8144. */
  8145. getBaseMatrix(): Matrix;
  8146. /**
  8147. * Gets the rest pose matrix
  8148. * @returns a matrix
  8149. */
  8150. getRestPose(): Matrix;
  8151. /**
  8152. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8153. */
  8154. getWorldMatrix(): Matrix;
  8155. /**
  8156. * Sets the local matrix to rest pose matrix
  8157. */
  8158. returnToRest(): void;
  8159. /**
  8160. * Gets the inverse of the absolute transform matrix.
  8161. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8162. * @returns a matrix
  8163. */
  8164. getInvertedAbsoluteTransform(): Matrix;
  8165. /**
  8166. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8167. * @returns a matrix
  8168. */
  8169. getAbsoluteTransform(): Matrix;
  8170. /**
  8171. * Links with the given transform node.
  8172. * The local matrix of this bone is copied from the transform node every frame.
  8173. * @param transformNode defines the transform node to link to
  8174. */
  8175. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8176. /** Gets or sets current position (in local space) */
  8177. position: Vector3;
  8178. /** Gets or sets current rotation (in local space) */
  8179. rotation: Vector3;
  8180. /** Gets or sets current rotation quaternion (in local space) */
  8181. rotationQuaternion: Quaternion;
  8182. /** Gets or sets current scaling (in local space) */
  8183. scaling: Vector3;
  8184. /**
  8185. * Gets the animation properties override
  8186. */
  8187. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8188. private _decompose;
  8189. private _compose;
  8190. /**
  8191. * Update the base and local matrices
  8192. * @param matrix defines the new base or local matrix
  8193. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8194. * @param updateLocalMatrix defines if the local matrix should be updated
  8195. */
  8196. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8197. /** @hidden */
  8198. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8199. /**
  8200. * Flag the bone as dirty (Forcing it to update everything)
  8201. */
  8202. markAsDirty(): void;
  8203. private _markAsDirtyAndCompose;
  8204. private _markAsDirtyAndDecompose;
  8205. /**
  8206. * Translate the bone in local or world space
  8207. * @param vec The amount to translate the bone
  8208. * @param space The space that the translation is in
  8209. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8210. */
  8211. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8212. /**
  8213. * Set the postion of the bone in local or world space
  8214. * @param position The position to set the bone
  8215. * @param space The space that the position is in
  8216. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8217. */
  8218. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8219. /**
  8220. * Set the absolute position of the bone (world space)
  8221. * @param position The position to set the bone
  8222. * @param mesh The mesh that this bone is attached to
  8223. */
  8224. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8225. /**
  8226. * Scale the bone on the x, y and z axes (in local space)
  8227. * @param x The amount to scale the bone on the x axis
  8228. * @param y The amount to scale the bone on the y axis
  8229. * @param z The amount to scale the bone on the z axis
  8230. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8231. */
  8232. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8233. /**
  8234. * Set the bone scaling in local space
  8235. * @param scale defines the scaling vector
  8236. */
  8237. setScale(scale: Vector3): void;
  8238. /**
  8239. * Gets the current scaling in local space
  8240. * @returns the current scaling vector
  8241. */
  8242. getScale(): Vector3;
  8243. /**
  8244. * Gets the current scaling in local space and stores it in a target vector
  8245. * @param result defines the target vector
  8246. */
  8247. getScaleToRef(result: Vector3): void;
  8248. /**
  8249. * Set the yaw, pitch, and roll of the bone in local or world space
  8250. * @param yaw The rotation of the bone on the y axis
  8251. * @param pitch The rotation of the bone on the x axis
  8252. * @param roll The rotation of the bone on the z axis
  8253. * @param space The space that the axes of rotation are in
  8254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8255. */
  8256. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8257. /**
  8258. * Add a rotation to the bone on an axis in local or world space
  8259. * @param axis The axis to rotate the bone on
  8260. * @param amount The amount to rotate the bone
  8261. * @param space The space that the axis is in
  8262. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8263. */
  8264. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8265. /**
  8266. * Set the rotation of the bone to a particular axis angle in local or world space
  8267. * @param axis The axis to rotate the bone on
  8268. * @param angle The angle that the bone should be rotated to
  8269. * @param space The space that the axis is in
  8270. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8271. */
  8272. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8273. /**
  8274. * Set the euler rotation of the bone in local of world space
  8275. * @param rotation The euler rotation that the bone should be set to
  8276. * @param space The space that the rotation is in
  8277. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8278. */
  8279. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8280. /**
  8281. * Set the quaternion rotation of the bone in local of world space
  8282. * @param quat The quaternion rotation that the bone should be set to
  8283. * @param space The space that the rotation is in
  8284. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8285. */
  8286. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8287. /**
  8288. * Set the rotation matrix of the bone in local of world space
  8289. * @param rotMat The rotation matrix that the bone should be set to
  8290. * @param space The space that the rotation is in
  8291. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8292. */
  8293. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8294. private _rotateWithMatrix;
  8295. private _getNegativeRotationToRef;
  8296. /**
  8297. * Get the position of the bone in local or world space
  8298. * @param space The space that the returned position is in
  8299. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8300. * @returns The position of the bone
  8301. */
  8302. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8303. /**
  8304. * Copy the position of the bone to a vector3 in local or world space
  8305. * @param space The space that the returned position is in
  8306. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8307. * @param result The vector3 to copy the position to
  8308. */
  8309. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8310. /**
  8311. * Get the absolute position of the bone (world space)
  8312. * @param mesh The mesh that this bone is attached to
  8313. * @returns The absolute position of the bone
  8314. */
  8315. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8316. /**
  8317. * Copy the absolute position of the bone (world space) to the result param
  8318. * @param mesh The mesh that this bone is attached to
  8319. * @param result The vector3 to copy the absolute position to
  8320. */
  8321. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8322. /**
  8323. * Compute the absolute transforms of this bone and its children
  8324. */
  8325. computeAbsoluteTransforms(): void;
  8326. /**
  8327. * Get the world direction from an axis that is in the local space of the bone
  8328. * @param localAxis The local direction that is used to compute the world direction
  8329. * @param mesh The mesh that this bone is attached to
  8330. * @returns The world direction
  8331. */
  8332. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8333. /**
  8334. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8335. * @param localAxis The local direction that is used to compute the world direction
  8336. * @param mesh The mesh that this bone is attached to
  8337. * @param result The vector3 that the world direction will be copied to
  8338. */
  8339. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8340. /**
  8341. * Get the euler rotation of the bone in local or world space
  8342. * @param space The space that the rotation should be in
  8343. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8344. * @returns The euler rotation
  8345. */
  8346. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8347. /**
  8348. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8349. * @param space The space that the rotation should be in
  8350. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8351. * @param result The vector3 that the rotation should be copied to
  8352. */
  8353. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8354. /**
  8355. * Get the quaternion rotation of the bone in either local or world space
  8356. * @param space The space that the rotation should be in
  8357. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8358. * @returns The quaternion rotation
  8359. */
  8360. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8361. /**
  8362. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8363. * @param space The space that the rotation should be in
  8364. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8365. * @param result The quaternion that the rotation should be copied to
  8366. */
  8367. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8368. /**
  8369. * Get the rotation matrix of the bone in local or world space
  8370. * @param space The space that the rotation should be in
  8371. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8372. * @returns The rotation matrix
  8373. */
  8374. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8375. /**
  8376. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8377. * @param space The space that the rotation should be in
  8378. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8379. * @param result The quaternion that the rotation should be copied to
  8380. */
  8381. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8382. /**
  8383. * Get the world position of a point that is in the local space of the bone
  8384. * @param position The local position
  8385. * @param mesh The mesh that this bone is attached to
  8386. * @returns The world position
  8387. */
  8388. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8389. /**
  8390. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8391. * @param position The local position
  8392. * @param mesh The mesh that this bone is attached to
  8393. * @param result The vector3 that the world position should be copied to
  8394. */
  8395. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8396. /**
  8397. * Get the local position of a point that is in world space
  8398. * @param position The world position
  8399. * @param mesh The mesh that this bone is attached to
  8400. * @returns The local position
  8401. */
  8402. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8403. /**
  8404. * Get the local position of a point that is in world space and copy it to the result param
  8405. * @param position The world position
  8406. * @param mesh The mesh that this bone is attached to
  8407. * @param result The vector3 that the local position should be copied to
  8408. */
  8409. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8410. }
  8411. }
  8412. declare module "babylonjs/Misc/iInspectable" {
  8413. /**
  8414. * Enum that determines the text-wrapping mode to use.
  8415. */
  8416. export enum InspectableType {
  8417. /**
  8418. * Checkbox for booleans
  8419. */
  8420. Checkbox = 0,
  8421. /**
  8422. * Sliders for numbers
  8423. */
  8424. Slider = 1,
  8425. /**
  8426. * Vector3
  8427. */
  8428. Vector3 = 2,
  8429. /**
  8430. * Quaternions
  8431. */
  8432. Quaternion = 3,
  8433. /**
  8434. * Color3
  8435. */
  8436. Color3 = 4
  8437. }
  8438. /**
  8439. * Interface used to define custom inspectable properties.
  8440. * This interface is used by the inspector to display custom property grids
  8441. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8442. */
  8443. export interface IInspectable {
  8444. /**
  8445. * Gets the label to display
  8446. */
  8447. label: string;
  8448. /**
  8449. * Gets the name of the property to edit
  8450. */
  8451. propertyName: string;
  8452. /**
  8453. * Gets the type of the editor to use
  8454. */
  8455. type: InspectableType;
  8456. /**
  8457. * Gets the minimum value of the property when using in "slider" mode
  8458. */
  8459. min?: number;
  8460. /**
  8461. * Gets the maximum value of the property when using in "slider" mode
  8462. */
  8463. max?: number;
  8464. /**
  8465. * Gets the setp to use when using in "slider" mode
  8466. */
  8467. step?: number;
  8468. }
  8469. }
  8470. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  8471. import { Nullable } from "babylonjs/types";
  8472. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8473. /**
  8474. * This represents the required contract to create a new type of texture loader.
  8475. */
  8476. export interface IInternalTextureLoader {
  8477. /**
  8478. * Defines wether the loader supports cascade loading the different faces.
  8479. */
  8480. supportCascades: boolean;
  8481. /**
  8482. * This returns if the loader support the current file information.
  8483. * @param extension defines the file extension of the file being loaded
  8484. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8485. * @param fallback defines the fallback internal texture if any
  8486. * @param isBase64 defines whether the texture is encoded as a base64
  8487. * @param isBuffer defines whether the texture data are stored as a buffer
  8488. * @returns true if the loader can load the specified file
  8489. */
  8490. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  8491. /**
  8492. * Transform the url before loading if required.
  8493. * @param rootUrl the url of the texture
  8494. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8495. * @returns the transformed texture
  8496. */
  8497. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  8498. /**
  8499. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  8500. * @param rootUrl the url of the texture
  8501. * @param textureFormatInUse defines the current compressed format in use iun the engine
  8502. * @returns the fallback texture
  8503. */
  8504. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  8505. /**
  8506. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  8507. * @param data contains the texture data
  8508. * @param texture defines the BabylonJS internal texture
  8509. * @param createPolynomials will be true if polynomials have been requested
  8510. * @param onLoad defines the callback to trigger once the texture is ready
  8511. * @param onError defines the callback to trigger in case of error
  8512. */
  8513. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  8514. /**
  8515. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  8516. * @param data contains the texture data
  8517. * @param texture defines the BabylonJS internal texture
  8518. * @param callback defines the method to call once ready to upload
  8519. */
  8520. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  8521. }
  8522. }
  8523. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  8524. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8525. import { Nullable } from "babylonjs/types";
  8526. import { Scene } from "babylonjs/scene";
  8527. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  8528. module "babylonjs/Engines/engine" {
  8529. interface Engine {
  8530. /**
  8531. * Creates a depth stencil cube texture.
  8532. * This is only available in WebGL 2.
  8533. * @param size The size of face edge in the cube texture.
  8534. * @param options The options defining the cube texture.
  8535. * @returns The cube texture
  8536. */
  8537. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  8538. /**
  8539. * Creates a cube texture
  8540. * @param rootUrl defines the url where the files to load is located
  8541. * @param scene defines the current scene
  8542. * @param files defines the list of files to load (1 per face)
  8543. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8544. * @param onLoad defines an optional callback raised when the texture is loaded
  8545. * @param onError defines an optional callback raised if there is an issue to load the texture
  8546. * @param format defines the format of the data
  8547. * @param forcedExtension defines the extension to use to pick the right loader
  8548. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8549. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8550. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8551. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  8552. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  8553. * @returns the cube texture as an InternalTexture
  8554. */
  8555. 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;
  8556. /**
  8557. * Creates a cube texture
  8558. * @param rootUrl defines the url where the files to load is located
  8559. * @param scene defines the current scene
  8560. * @param files defines the list of files to load (1 per face)
  8561. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8562. * @param onLoad defines an optional callback raised when the texture is loaded
  8563. * @param onError defines an optional callback raised if there is an issue to load the texture
  8564. * @param format defines the format of the data
  8565. * @param forcedExtension defines the extension to use to pick the right loader
  8566. * @returns the cube texture as an InternalTexture
  8567. */
  8568. 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;
  8569. /**
  8570. * Creates a cube texture
  8571. * @param rootUrl defines the url where the files to load is located
  8572. * @param scene defines the current scene
  8573. * @param files defines the list of files to load (1 per face)
  8574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  8575. * @param onLoad defines an optional callback raised when the texture is loaded
  8576. * @param onError defines an optional callback raised if there is an issue to load the texture
  8577. * @param format defines the format of the data
  8578. * @param forcedExtension defines the extension to use to pick the right loader
  8579. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  8580. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8581. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8582. * @returns the cube texture as an InternalTexture
  8583. */
  8584. 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;
  8585. /** @hidden */
  8586. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8587. /** @hidden */
  8588. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8589. /** @hidden */
  8590. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  8591. /** @hidden */
  8592. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  8593. }
  8594. }
  8595. }
  8596. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8597. import { Nullable } from "babylonjs/types";
  8598. import { Scene } from "babylonjs/scene";
  8599. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8600. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8601. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  8602. /**
  8603. * Class for creating a cube texture
  8604. */
  8605. export class CubeTexture extends BaseTexture {
  8606. private _delayedOnLoad;
  8607. /**
  8608. * The url of the texture
  8609. */
  8610. url: string;
  8611. /**
  8612. * Gets or sets the center of the bounding box associated with the cube texture.
  8613. * It must define where the camera used to render the texture was set
  8614. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8615. */
  8616. boundingBoxPosition: Vector3;
  8617. private _boundingBoxSize;
  8618. /**
  8619. * Gets or sets the size of the bounding box associated with the cube texture
  8620. * When defined, the cubemap will switch to local mode
  8621. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8622. * @example https://www.babylonjs-playground.com/#RNASML
  8623. */
  8624. /**
  8625. * Returns the bounding box size
  8626. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8627. */
  8628. boundingBoxSize: Vector3;
  8629. protected _rotationY: number;
  8630. /**
  8631. * Sets texture matrix rotation angle around Y axis in radians.
  8632. */
  8633. /**
  8634. * Gets texture matrix rotation angle around Y axis radians.
  8635. */
  8636. rotationY: number;
  8637. /**
  8638. * Are mip maps generated for this texture or not.
  8639. */
  8640. readonly noMipmap: boolean;
  8641. private _noMipmap;
  8642. private _files;
  8643. private _extensions;
  8644. private _textureMatrix;
  8645. private _format;
  8646. private _createPolynomials;
  8647. /** @hidden */
  8648. _prefiltered: boolean;
  8649. /**
  8650. * Creates a cube texture from an array of image urls
  8651. * @param files defines an array of image urls
  8652. * @param scene defines the hosting scene
  8653. * @param noMipmap specifies if mip maps are not used
  8654. * @returns a cube texture
  8655. */
  8656. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8657. /**
  8658. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8659. * @param url defines the url of the prefiltered texture
  8660. * @param scene defines the scene the texture is attached to
  8661. * @param forcedExtension defines the extension of the file if different from the url
  8662. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8663. * @return the prefiltered texture
  8664. */
  8665. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8666. /**
  8667. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8668. * as prefiltered data.
  8669. * @param rootUrl defines the url of the texture or the root name of the six images
  8670. * @param scene defines the scene the texture is attached to
  8671. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8672. * @param noMipmap defines if mipmaps should be created or not
  8673. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8674. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8675. * @param onError defines a callback triggered in case of error during load
  8676. * @param format defines the internal format to use for the texture once loaded
  8677. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8678. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8679. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8680. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8681. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8682. * @return the cube texture
  8683. */
  8684. 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);
  8685. /**
  8686. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  8687. */
  8688. readonly isPrefiltered: boolean;
  8689. /**
  8690. * Get the current class name of the texture useful for serialization or dynamic coding.
  8691. * @returns "CubeTexture"
  8692. */
  8693. getClassName(): string;
  8694. /**
  8695. * Update the url (and optional buffer) of this texture if url was null during construction.
  8696. * @param url the url of the texture
  8697. * @param forcedExtension defines the extension to use
  8698. * @param onLoad callback called when the texture is loaded (defaults to null)
  8699. */
  8700. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8701. /**
  8702. * Delays loading of the cube texture
  8703. * @param forcedExtension defines the extension to use
  8704. */
  8705. delayLoad(forcedExtension?: string): void;
  8706. /**
  8707. * Returns the reflection texture matrix
  8708. * @returns the reflection texture matrix
  8709. */
  8710. getReflectionTextureMatrix(): Matrix;
  8711. /**
  8712. * Sets the reflection texture matrix
  8713. * @param value Reflection texture matrix
  8714. */
  8715. setReflectionTextureMatrix(value: Matrix): void;
  8716. /**
  8717. * Parses text to create a cube texture
  8718. * @param parsedTexture define the serialized text to read from
  8719. * @param scene defines the hosting scene
  8720. * @param rootUrl defines the root url of the cube texture
  8721. * @returns a cube texture
  8722. */
  8723. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8724. /**
  8725. * Makes a clone, or deep copy, of the cube texture
  8726. * @returns a new cube texture
  8727. */
  8728. clone(): CubeTexture;
  8729. }
  8730. }
  8731. declare module "babylonjs/Shaders/postprocess.vertex" {
  8732. /** @hidden */
  8733. export var postprocessVertexShader: {
  8734. name: string;
  8735. shader: string;
  8736. };
  8737. }
  8738. declare module "babylonjs/Cameras/targetCamera" {
  8739. import { Nullable } from "babylonjs/types";
  8740. import { Camera } from "babylonjs/Cameras/camera";
  8741. import { Scene } from "babylonjs/scene";
  8742. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8743. /**
  8744. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8745. * This is the base of the follow, arc rotate cameras and Free camera
  8746. * @see http://doc.babylonjs.com/features/cameras
  8747. */
  8748. export class TargetCamera extends Camera {
  8749. private static _RigCamTransformMatrix;
  8750. private static _TargetTransformMatrix;
  8751. private static _TargetFocalPoint;
  8752. /**
  8753. * Define the current direction the camera is moving to
  8754. */
  8755. cameraDirection: Vector3;
  8756. /**
  8757. * Define the current rotation the camera is rotating to
  8758. */
  8759. cameraRotation: Vector2;
  8760. /**
  8761. * When set, the up vector of the camera will be updated by the rotation of the camera
  8762. */
  8763. updateUpVectorFromRotation: boolean;
  8764. private _tmpQuaternion;
  8765. /**
  8766. * Define the current rotation of the camera
  8767. */
  8768. rotation: Vector3;
  8769. /**
  8770. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8771. */
  8772. rotationQuaternion: Quaternion;
  8773. /**
  8774. * Define the current speed of the camera
  8775. */
  8776. speed: number;
  8777. /**
  8778. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8779. * around all axis.
  8780. */
  8781. noRotationConstraint: boolean;
  8782. /**
  8783. * Define the current target of the camera as an object or a position.
  8784. */
  8785. lockedTarget: any;
  8786. /** @hidden */
  8787. _currentTarget: Vector3;
  8788. /** @hidden */
  8789. _initialFocalDistance: number;
  8790. /** @hidden */
  8791. _viewMatrix: Matrix;
  8792. /** @hidden */
  8793. _camMatrix: Matrix;
  8794. /** @hidden */
  8795. _cameraTransformMatrix: Matrix;
  8796. /** @hidden */
  8797. _cameraRotationMatrix: Matrix;
  8798. /** @hidden */
  8799. _referencePoint: Vector3;
  8800. /** @hidden */
  8801. _transformedReferencePoint: Vector3;
  8802. protected _globalCurrentTarget: Vector3;
  8803. protected _globalCurrentUpVector: Vector3;
  8804. /** @hidden */
  8805. _reset: () => void;
  8806. private _defaultUp;
  8807. /**
  8808. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8809. * This is the base of the follow, arc rotate cameras and Free camera
  8810. * @see http://doc.babylonjs.com/features/cameras
  8811. * @param name Defines the name of the camera in the scene
  8812. * @param position Defines the start position of the camera in the scene
  8813. * @param scene Defines the scene the camera belongs to
  8814. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8815. */
  8816. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8817. /**
  8818. * Gets the position in front of the camera at a given distance.
  8819. * @param distance The distance from the camera we want the position to be
  8820. * @returns the position
  8821. */
  8822. getFrontPosition(distance: number): Vector3;
  8823. /** @hidden */
  8824. _getLockedTargetPosition(): Nullable<Vector3>;
  8825. private _storedPosition;
  8826. private _storedRotation;
  8827. private _storedRotationQuaternion;
  8828. /**
  8829. * Store current camera state of the camera (fov, position, rotation, etc..)
  8830. * @returns the camera
  8831. */
  8832. storeState(): Camera;
  8833. /**
  8834. * Restored camera state. You must call storeState() first
  8835. * @returns whether it was successful or not
  8836. * @hidden
  8837. */
  8838. _restoreStateValues(): boolean;
  8839. /** @hidden */
  8840. _initCache(): void;
  8841. /** @hidden */
  8842. _updateCache(ignoreParentClass?: boolean): void;
  8843. /** @hidden */
  8844. _isSynchronizedViewMatrix(): boolean;
  8845. /** @hidden */
  8846. _computeLocalCameraSpeed(): number;
  8847. /**
  8848. * Defines the target the camera should look at.
  8849. * This will automatically adapt alpha beta and radius to fit within the new target.
  8850. * @param target Defines the new target as a Vector or a mesh
  8851. */
  8852. setTarget(target: Vector3): void;
  8853. /**
  8854. * Return the current target position of the camera. This value is expressed in local space.
  8855. * @returns the target position
  8856. */
  8857. getTarget(): Vector3;
  8858. /** @hidden */
  8859. _decideIfNeedsToMove(): boolean;
  8860. /** @hidden */
  8861. _updatePosition(): void;
  8862. /** @hidden */
  8863. _checkInputs(): void;
  8864. protected _updateCameraRotationMatrix(): void;
  8865. /**
  8866. * 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)
  8867. * @returns the current camera
  8868. */
  8869. private _rotateUpVectorWithCameraRotationMatrix;
  8870. private _cachedRotationZ;
  8871. private _cachedQuaternionRotationZ;
  8872. /** @hidden */
  8873. _getViewMatrix(): Matrix;
  8874. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8875. /**
  8876. * @hidden
  8877. */
  8878. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8879. /**
  8880. * @hidden
  8881. */
  8882. _updateRigCameras(): void;
  8883. private _getRigCamPositionAndTarget;
  8884. /**
  8885. * Gets the current object class name.
  8886. * @return the class name
  8887. */
  8888. getClassName(): string;
  8889. }
  8890. }
  8891. declare module "babylonjs/Cameras/cameraInputsManager" {
  8892. import { Nullable } from "babylonjs/types";
  8893. import { Camera } from "babylonjs/Cameras/camera";
  8894. /**
  8895. * @ignore
  8896. * This is a list of all the different input types that are available in the application.
  8897. * Fo instance: ArcRotateCameraGamepadInput...
  8898. */
  8899. export var CameraInputTypes: {};
  8900. /**
  8901. * This is the contract to implement in order to create a new input class.
  8902. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8903. */
  8904. export interface ICameraInput<TCamera extends Camera> {
  8905. /**
  8906. * Defines the camera the input is attached to.
  8907. */
  8908. camera: Nullable<TCamera>;
  8909. /**
  8910. * Gets the class name of the current intput.
  8911. * @returns the class name
  8912. */
  8913. getClassName(): string;
  8914. /**
  8915. * Get the friendly name associated with the input class.
  8916. * @returns the input friendly name
  8917. */
  8918. getSimpleName(): string;
  8919. /**
  8920. * Attach the input controls to a specific dom element to get the input from.
  8921. * @param element Defines the element the controls should be listened from
  8922. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8923. */
  8924. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8925. /**
  8926. * Detach the current controls from the specified dom element.
  8927. * @param element Defines the element to stop listening the inputs from
  8928. */
  8929. detachControl(element: Nullable<HTMLElement>): void;
  8930. /**
  8931. * Update the current camera state depending on the inputs that have been used this frame.
  8932. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8933. */
  8934. checkInputs?: () => void;
  8935. }
  8936. /**
  8937. * Represents a map of input types to input instance or input index to input instance.
  8938. */
  8939. export interface CameraInputsMap<TCamera extends Camera> {
  8940. /**
  8941. * Accessor to the input by input type.
  8942. */
  8943. [name: string]: ICameraInput<TCamera>;
  8944. /**
  8945. * Accessor to the input by input index.
  8946. */
  8947. [idx: number]: ICameraInput<TCamera>;
  8948. }
  8949. /**
  8950. * This represents the input manager used within a camera.
  8951. * It helps dealing with all the different kind of input attached to a camera.
  8952. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8953. */
  8954. export class CameraInputsManager<TCamera extends Camera> {
  8955. /**
  8956. * Defines the list of inputs attahed to the camera.
  8957. */
  8958. attached: CameraInputsMap<TCamera>;
  8959. /**
  8960. * Defines the dom element the camera is collecting inputs from.
  8961. * This is null if the controls have not been attached.
  8962. */
  8963. attachedElement: Nullable<HTMLElement>;
  8964. /**
  8965. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8966. */
  8967. noPreventDefault: boolean;
  8968. /**
  8969. * Defined the camera the input manager belongs to.
  8970. */
  8971. camera: TCamera;
  8972. /**
  8973. * Update the current camera state depending on the inputs that have been used this frame.
  8974. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8975. */
  8976. checkInputs: () => void;
  8977. /**
  8978. * Instantiate a new Camera Input Manager.
  8979. * @param camera Defines the camera the input manager blongs to
  8980. */
  8981. constructor(camera: TCamera);
  8982. /**
  8983. * Add an input method to a camera
  8984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8985. * @param input camera input method
  8986. */
  8987. add(input: ICameraInput<TCamera>): void;
  8988. /**
  8989. * Remove a specific input method from a camera
  8990. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8991. * @param inputToRemove camera input method
  8992. */
  8993. remove(inputToRemove: ICameraInput<TCamera>): void;
  8994. /**
  8995. * Remove a specific input type from a camera
  8996. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8997. * @param inputType the type of the input to remove
  8998. */
  8999. removeByType(inputType: string): void;
  9000. private _addCheckInputs;
  9001. /**
  9002. * Attach the input controls to the currently attached dom element to listen the events from.
  9003. * @param input Defines the input to attach
  9004. */
  9005. attachInput(input: ICameraInput<TCamera>): void;
  9006. /**
  9007. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  9008. * @param element Defines the dom element to collect the events from
  9009. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9010. */
  9011. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  9012. /**
  9013. * Detach the current manager inputs controls from a specific dom element.
  9014. * @param element Defines the dom element to collect the events from
  9015. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  9016. */
  9017. detachElement(element: HTMLElement, disconnect?: boolean): void;
  9018. /**
  9019. * Rebuild the dynamic inputCheck function from the current list of
  9020. * defined inputs in the manager.
  9021. */
  9022. rebuildInputCheck(): void;
  9023. /**
  9024. * Remove all attached input methods from a camera
  9025. */
  9026. clear(): void;
  9027. /**
  9028. * Serialize the current input manager attached to a camera.
  9029. * This ensures than once parsed,
  9030. * the input associated to the camera will be identical to the current ones
  9031. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  9032. */
  9033. serialize(serializedCamera: any): void;
  9034. /**
  9035. * Parses an input manager serialized JSON to restore the previous list of inputs
  9036. * and states associated to a camera.
  9037. * @param parsedCamera Defines the JSON to parse
  9038. */
  9039. parse(parsedCamera: any): void;
  9040. }
  9041. }
  9042. declare module "babylonjs/Events/keyboardEvents" {
  9043. /**
  9044. * Gather the list of keyboard event types as constants.
  9045. */
  9046. export class KeyboardEventTypes {
  9047. /**
  9048. * The keydown event is fired when a key becomes active (pressed).
  9049. */
  9050. static readonly KEYDOWN: number;
  9051. /**
  9052. * The keyup event is fired when a key has been released.
  9053. */
  9054. static readonly KEYUP: number;
  9055. }
  9056. /**
  9057. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9058. */
  9059. export class KeyboardInfo {
  9060. /**
  9061. * Defines the type of event (KeyboardEventTypes)
  9062. */
  9063. type: number;
  9064. /**
  9065. * Defines the related dom event
  9066. */
  9067. event: KeyboardEvent;
  9068. /**
  9069. * Instantiates a new keyboard info.
  9070. * This class is used to store keyboard related info for the onKeyboardObservable event.
  9071. * @param type Defines the type of event (KeyboardEventTypes)
  9072. * @param event Defines the related dom event
  9073. */
  9074. constructor(
  9075. /**
  9076. * Defines the type of event (KeyboardEventTypes)
  9077. */
  9078. type: number,
  9079. /**
  9080. * Defines the related dom event
  9081. */
  9082. event: KeyboardEvent);
  9083. }
  9084. /**
  9085. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9086. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  9087. */
  9088. export class KeyboardInfoPre extends KeyboardInfo {
  9089. /**
  9090. * Defines the type of event (KeyboardEventTypes)
  9091. */
  9092. type: number;
  9093. /**
  9094. * Defines the related dom event
  9095. */
  9096. event: KeyboardEvent;
  9097. /**
  9098. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  9099. */
  9100. skipOnPointerObservable: boolean;
  9101. /**
  9102. * Instantiates a new keyboard pre info.
  9103. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  9104. * @param type Defines the type of event (KeyboardEventTypes)
  9105. * @param event Defines the related dom event
  9106. */
  9107. constructor(
  9108. /**
  9109. * Defines the type of event (KeyboardEventTypes)
  9110. */
  9111. type: number,
  9112. /**
  9113. * Defines the related dom event
  9114. */
  9115. event: KeyboardEvent);
  9116. }
  9117. }
  9118. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  9119. import { Nullable } from "babylonjs/types";
  9120. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  9121. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  9122. /**
  9123. * Manage the keyboard inputs to control the movement of a free camera.
  9124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  9125. */
  9126. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  9127. /**
  9128. * Defines the camera the input is attached to.
  9129. */
  9130. camera: FreeCamera;
  9131. /**
  9132. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  9133. */
  9134. keysUp: number[];
  9135. /**
  9136. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  9137. */
  9138. keysDown: number[];
  9139. /**
  9140. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  9141. */
  9142. keysLeft: number[];
  9143. /**
  9144. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  9145. */
  9146. keysRight: number[];
  9147. private _keys;
  9148. private _onCanvasBlurObserver;
  9149. private _onKeyboardObserver;
  9150. private _engine;
  9151. private _scene;
  9152. /**
  9153. * Attach the input controls to a specific dom element to get the input from.
  9154. * @param element Defines the element the controls should be listened from
  9155. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  9156. */
  9157. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  9158. /**
  9159. * Detach the current controls from the specified dom element.
  9160. * @param element Defines the element to stop listening the inputs from
  9161. */
  9162. detachControl(element: Nullable<HTMLElement>): void;
  9163. /**
  9164. * Update the current camera state depending on the inputs that have been used this frame.
  9165. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  9166. */
  9167. checkInputs(): void;
  9168. /**
  9169. * Gets the class name of the current intput.
  9170. * @returns the class name
  9171. */
  9172. getClassName(): string;
  9173. /** @hidden */
  9174. _onLostFocus(): void;
  9175. /**
  9176. * Get the friendly name associated with the input class.
  9177. * @returns the input friendly name
  9178. */
  9179. getSimpleName(): string;
  9180. }
  9181. }
  9182. declare module "babylonjs/Lights/shadowLight" {
  9183. import { Camera } from "babylonjs/Cameras/camera";
  9184. import { Scene } from "babylonjs/scene";
  9185. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  9186. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9187. import { Light } from "babylonjs/Lights/light";
  9188. /**
  9189. * Interface describing all the common properties and methods a shadow light needs to implement.
  9190. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9191. * as well as binding the different shadow properties to the effects.
  9192. */
  9193. export interface IShadowLight extends Light {
  9194. /**
  9195. * The light id in the scene (used in scene.findLighById for instance)
  9196. */
  9197. id: string;
  9198. /**
  9199. * The position the shdow will be casted from.
  9200. */
  9201. position: Vector3;
  9202. /**
  9203. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9204. */
  9205. direction: Vector3;
  9206. /**
  9207. * The transformed position. Position of the light in world space taking parenting in account.
  9208. */
  9209. transformedPosition: Vector3;
  9210. /**
  9211. * The transformed direction. Direction of the light in world space taking parenting in account.
  9212. */
  9213. transformedDirection: Vector3;
  9214. /**
  9215. * The friendly name of the light in the scene.
  9216. */
  9217. name: string;
  9218. /**
  9219. * Defines the shadow projection clipping minimum z value.
  9220. */
  9221. shadowMinZ: number;
  9222. /**
  9223. * Defines the shadow projection clipping maximum z value.
  9224. */
  9225. shadowMaxZ: number;
  9226. /**
  9227. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9228. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9229. */
  9230. computeTransformedInformation(): boolean;
  9231. /**
  9232. * Gets the scene the light belongs to.
  9233. * @returns The scene
  9234. */
  9235. getScene(): Scene;
  9236. /**
  9237. * Callback defining a custom Projection Matrix Builder.
  9238. * This can be used to override the default projection matrix computation.
  9239. */
  9240. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9241. /**
  9242. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9243. * @param matrix The materix to updated with the projection information
  9244. * @param viewMatrix The transform matrix of the light
  9245. * @param renderList The list of mesh to render in the map
  9246. * @returns The current light
  9247. */
  9248. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9249. /**
  9250. * Gets the current depth scale used in ESM.
  9251. * @returns The scale
  9252. */
  9253. getDepthScale(): number;
  9254. /**
  9255. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9256. * @returns true if a cube texture needs to be use
  9257. */
  9258. needCube(): boolean;
  9259. /**
  9260. * Detects if the projection matrix requires to be recomputed this frame.
  9261. * @returns true if it requires to be recomputed otherwise, false.
  9262. */
  9263. needProjectionMatrixCompute(): boolean;
  9264. /**
  9265. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9266. */
  9267. forceProjectionMatrixCompute(): void;
  9268. /**
  9269. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9270. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9271. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9272. */
  9273. getShadowDirection(faceIndex?: number): Vector3;
  9274. /**
  9275. * Gets the minZ used for shadow according to both the scene and the light.
  9276. * @param activeCamera The camera we are returning the min for
  9277. * @returns the depth min z
  9278. */
  9279. getDepthMinZ(activeCamera: Camera): number;
  9280. /**
  9281. * Gets the maxZ used for shadow according to both the scene and the light.
  9282. * @param activeCamera The camera we are returning the max for
  9283. * @returns the depth max z
  9284. */
  9285. getDepthMaxZ(activeCamera: Camera): number;
  9286. }
  9287. /**
  9288. * Base implementation IShadowLight
  9289. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9290. */
  9291. export abstract class ShadowLight extends Light implements IShadowLight {
  9292. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9293. protected _position: Vector3;
  9294. protected _setPosition(value: Vector3): void;
  9295. /**
  9296. * Sets the position the shadow will be casted from. Also use as the light position for both
  9297. * point and spot lights.
  9298. */
  9299. /**
  9300. * Sets the position the shadow will be casted from. Also use as the light position for both
  9301. * point and spot lights.
  9302. */
  9303. position: Vector3;
  9304. protected _direction: Vector3;
  9305. protected _setDirection(value: Vector3): void;
  9306. /**
  9307. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9308. * Also use as the light direction on spot and directional lights.
  9309. */
  9310. /**
  9311. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9312. * Also use as the light direction on spot and directional lights.
  9313. */
  9314. direction: Vector3;
  9315. private _shadowMinZ;
  9316. /**
  9317. * Gets the shadow projection clipping minimum z value.
  9318. */
  9319. /**
  9320. * Sets the shadow projection clipping minimum z value.
  9321. */
  9322. shadowMinZ: number;
  9323. private _shadowMaxZ;
  9324. /**
  9325. * Sets the shadow projection clipping maximum z value.
  9326. */
  9327. /**
  9328. * Gets the shadow projection clipping maximum z value.
  9329. */
  9330. shadowMaxZ: number;
  9331. /**
  9332. * Callback defining a custom Projection Matrix Builder.
  9333. * This can be used to override the default projection matrix computation.
  9334. */
  9335. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9336. /**
  9337. * The transformed position. Position of the light in world space taking parenting in account.
  9338. */
  9339. transformedPosition: Vector3;
  9340. /**
  9341. * The transformed direction. Direction of the light in world space taking parenting in account.
  9342. */
  9343. transformedDirection: Vector3;
  9344. private _needProjectionMatrixCompute;
  9345. /**
  9346. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9347. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9348. */
  9349. computeTransformedInformation(): boolean;
  9350. /**
  9351. * Return the depth scale used for the shadow map.
  9352. * @returns the depth scale.
  9353. */
  9354. getDepthScale(): number;
  9355. /**
  9356. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9357. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9358. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9359. */
  9360. getShadowDirection(faceIndex?: number): Vector3;
  9361. /**
  9362. * Returns the ShadowLight absolute position in the World.
  9363. * @returns the position vector in world space
  9364. */
  9365. getAbsolutePosition(): Vector3;
  9366. /**
  9367. * Sets the ShadowLight direction toward the passed target.
  9368. * @param target The point to target in local space
  9369. * @returns the updated ShadowLight direction
  9370. */
  9371. setDirectionToTarget(target: Vector3): Vector3;
  9372. /**
  9373. * Returns the light rotation in euler definition.
  9374. * @returns the x y z rotation in local space.
  9375. */
  9376. getRotation(): Vector3;
  9377. /**
  9378. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9379. * @returns true if a cube texture needs to be use
  9380. */
  9381. needCube(): boolean;
  9382. /**
  9383. * Detects if the projection matrix requires to be recomputed this frame.
  9384. * @returns true if it requires to be recomputed otherwise, false.
  9385. */
  9386. needProjectionMatrixCompute(): boolean;
  9387. /**
  9388. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9389. */
  9390. forceProjectionMatrixCompute(): void;
  9391. /** @hidden */
  9392. _initCache(): void;
  9393. /** @hidden */
  9394. _isSynchronized(): boolean;
  9395. /**
  9396. * Computes the world matrix of the node
  9397. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9398. * @returns the world matrix
  9399. */
  9400. computeWorldMatrix(force?: boolean): Matrix;
  9401. /**
  9402. * Gets the minZ used for shadow according to both the scene and the light.
  9403. * @param activeCamera The camera we are returning the min for
  9404. * @returns the depth min z
  9405. */
  9406. getDepthMinZ(activeCamera: Camera): number;
  9407. /**
  9408. * Gets the maxZ used for shadow according to both the scene and the light.
  9409. * @param activeCamera The camera we are returning the max for
  9410. * @returns the depth max z
  9411. */
  9412. getDepthMaxZ(activeCamera: Camera): number;
  9413. /**
  9414. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9415. * @param matrix The materix to updated with the projection information
  9416. * @param viewMatrix The transform matrix of the light
  9417. * @param renderList The list of mesh to render in the map
  9418. * @returns The current light
  9419. */
  9420. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9421. }
  9422. }
  9423. declare module "babylonjs/Materials/materialHelper" {
  9424. import { Nullable } from "babylonjs/types";
  9425. import { Scene } from "babylonjs/scene";
  9426. import { Engine } from "babylonjs/Engines/engine";
  9427. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9428. import { Light } from "babylonjs/Lights/light";
  9429. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9430. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9431. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9432. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9433. /**
  9434. * "Static Class" containing the most commonly used helper while dealing with material for
  9435. * rendering purpose.
  9436. *
  9437. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9438. *
  9439. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9440. */
  9441. export class MaterialHelper {
  9442. /**
  9443. * Bind the current view position to an effect.
  9444. * @param effect The effect to be bound
  9445. * @param scene The scene the eyes position is used from
  9446. */
  9447. static BindEyePosition(effect: Effect, scene: Scene): void;
  9448. /**
  9449. * Helps preparing the defines values about the UVs in used in the effect.
  9450. * UVs are shared as much as we can accross channels in the shaders.
  9451. * @param texture The texture we are preparing the UVs for
  9452. * @param defines The defines to update
  9453. * @param key The channel key "diffuse", "specular"... used in the shader
  9454. */
  9455. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9456. /**
  9457. * Binds a texture matrix value to its corrsponding uniform
  9458. * @param texture The texture to bind the matrix for
  9459. * @param uniformBuffer The uniform buffer receivin the data
  9460. * @param key The channel key "diffuse", "specular"... used in the shader
  9461. */
  9462. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9463. /**
  9464. * Gets the current status of the fog (should it be enabled?)
  9465. * @param mesh defines the mesh to evaluate for fog support
  9466. * @param scene defines the hosting scene
  9467. * @returns true if fog must be enabled
  9468. */
  9469. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9470. /**
  9471. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9472. * @param mesh defines the current mesh
  9473. * @param scene defines the current scene
  9474. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9475. * @param pointsCloud defines if point cloud rendering has to be turned on
  9476. * @param fogEnabled defines if fog has to be turned on
  9477. * @param alphaTest defines if alpha testing has to be turned on
  9478. * @param defines defines the current list of defines
  9479. */
  9480. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9481. /**
  9482. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9483. * @param scene defines the current scene
  9484. * @param engine defines the current engine
  9485. * @param defines specifies the list of active defines
  9486. * @param useInstances defines if instances have to be turned on
  9487. * @param useClipPlane defines if clip plane have to be turned on
  9488. */
  9489. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9490. /**
  9491. * Prepares the defines for bones
  9492. * @param mesh The mesh containing the geometry data we will draw
  9493. * @param defines The defines to update
  9494. */
  9495. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9496. /**
  9497. * Prepares the defines for morph targets
  9498. * @param mesh The mesh containing the geometry data we will draw
  9499. * @param defines The defines to update
  9500. */
  9501. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9502. /**
  9503. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9504. * @param mesh The mesh containing the geometry data we will draw
  9505. * @param defines The defines to update
  9506. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9507. * @param useBones Precise whether bones should be used or not (override mesh info)
  9508. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9509. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9510. * @returns false if defines are considered not dirty and have not been checked
  9511. */
  9512. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9513. /**
  9514. * Prepares the defines related to multiview
  9515. * @param scene The scene we are intending to draw
  9516. * @param defines The defines to update
  9517. */
  9518. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9519. /**
  9520. * Prepares the defines related to the light information passed in parameter
  9521. * @param scene The scene we are intending to draw
  9522. * @param mesh The mesh the effect is compiling for
  9523. * @param defines The defines to update
  9524. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9525. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9526. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9527. * @returns true if normals will be required for the rest of the effect
  9528. */
  9529. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9530. /**
  9531. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9532. * that won t be acctive due to defines being turned off.
  9533. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9534. * @param samplersList The samplers list
  9535. * @param defines The defines helping in the list generation
  9536. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9537. */
  9538. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9539. /**
  9540. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9541. * @param defines The defines to update while falling back
  9542. * @param fallbacks The authorized effect fallbacks
  9543. * @param maxSimultaneousLights The maximum number of lights allowed
  9544. * @param rank the current rank of the Effect
  9545. * @returns The newly affected rank
  9546. */
  9547. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9548. /**
  9549. * Prepares the list of attributes required for morph targets according to the effect defines.
  9550. * @param attribs The current list of supported attribs
  9551. * @param mesh The mesh to prepare the morph targets attributes for
  9552. * @param defines The current Defines of the effect
  9553. */
  9554. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9555. /**
  9556. * Prepares the list of attributes required for bones according to the effect defines.
  9557. * @param attribs The current list of supported attribs
  9558. * @param mesh The mesh to prepare the bones attributes for
  9559. * @param defines The current Defines of the effect
  9560. * @param fallbacks The current efffect fallback strategy
  9561. */
  9562. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9563. /**
  9564. * Check and prepare the list of attributes required for instances according to the effect defines.
  9565. * @param attribs The current list of supported attribs
  9566. * @param defines The current MaterialDefines of the effect
  9567. */
  9568. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9569. /**
  9570. * Add the list of attributes required for instances to the attribs array.
  9571. * @param attribs The current list of supported attribs
  9572. */
  9573. static PushAttributesForInstances(attribs: string[]): void;
  9574. /**
  9575. * Binds the light shadow information to the effect for the given mesh.
  9576. * @param light The light containing the generator
  9577. * @param scene The scene the lights belongs to
  9578. * @param mesh The mesh we are binding the information to render
  9579. * @param lightIndex The light index in the effect used to render the mesh
  9580. * @param effect The effect we are binding the data to
  9581. */
  9582. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9583. /**
  9584. * Binds the light information to the effect.
  9585. * @param light The light containing the generator
  9586. * @param effect The effect we are binding the data to
  9587. * @param lightIndex The light index in the effect used to render
  9588. */
  9589. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9590. /**
  9591. * Binds the lights information from the scene to the effect for the given mesh.
  9592. * @param scene The scene the lights belongs to
  9593. * @param mesh The mesh we are binding the information to render
  9594. * @param effect The effect we are binding the data to
  9595. * @param defines The generated defines for the effect
  9596. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9597. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9598. */
  9599. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9600. private static _tempFogColor;
  9601. /**
  9602. * Binds the fog information from the scene to the effect for the given mesh.
  9603. * @param scene The scene the lights belongs to
  9604. * @param mesh The mesh we are binding the information to render
  9605. * @param effect The effect we are binding the data to
  9606. * @param linearSpace Defines if the fog effect is applied in linear space
  9607. */
  9608. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9609. /**
  9610. * Binds the bones information from the mesh to the effect.
  9611. * @param mesh The mesh we are binding the information to render
  9612. * @param effect The effect we are binding the data to
  9613. */
  9614. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9615. /**
  9616. * Binds the morph targets information from the mesh to the effect.
  9617. * @param abstractMesh The mesh we are binding the information to render
  9618. * @param effect The effect we are binding the data to
  9619. */
  9620. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9621. /**
  9622. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9623. * @param defines The generated defines used in the effect
  9624. * @param effect The effect we are binding the data to
  9625. * @param scene The scene we are willing to render with logarithmic scale for
  9626. */
  9627. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9628. /**
  9629. * Binds the clip plane information from the scene to the effect.
  9630. * @param scene The scene the clip plane information are extracted from
  9631. * @param effect The effect we are binding the data to
  9632. */
  9633. static BindClipPlane(effect: Effect, scene: Scene): void;
  9634. }
  9635. }
  9636. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9637. /** @hidden */
  9638. export var kernelBlurVaryingDeclaration: {
  9639. name: string;
  9640. shader: string;
  9641. };
  9642. }
  9643. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9644. /** @hidden */
  9645. export var kernelBlurFragment: {
  9646. name: string;
  9647. shader: string;
  9648. };
  9649. }
  9650. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9651. /** @hidden */
  9652. export var kernelBlurFragment2: {
  9653. name: string;
  9654. shader: string;
  9655. };
  9656. }
  9657. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9658. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9659. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9660. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9661. /** @hidden */
  9662. export var kernelBlurPixelShader: {
  9663. name: string;
  9664. shader: string;
  9665. };
  9666. }
  9667. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9668. /** @hidden */
  9669. export var kernelBlurVertex: {
  9670. name: string;
  9671. shader: string;
  9672. };
  9673. }
  9674. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9675. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9676. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9677. /** @hidden */
  9678. export var kernelBlurVertexShader: {
  9679. name: string;
  9680. shader: string;
  9681. };
  9682. }
  9683. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9684. import { Vector2 } from "babylonjs/Maths/math";
  9685. import { Nullable } from "babylonjs/types";
  9686. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9687. import { Camera } from "babylonjs/Cameras/camera";
  9688. import { Effect } from "babylonjs/Materials/effect";
  9689. import { Engine } from "babylonjs/Engines/engine";
  9690. import "babylonjs/Shaders/kernelBlur.fragment";
  9691. import "babylonjs/Shaders/kernelBlur.vertex";
  9692. /**
  9693. * The Blur Post Process which blurs an image based on a kernel and direction.
  9694. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9695. */
  9696. export class BlurPostProcess extends PostProcess {
  9697. /** The direction in which to blur the image. */
  9698. direction: Vector2;
  9699. private blockCompilation;
  9700. protected _kernel: number;
  9701. protected _idealKernel: number;
  9702. protected _packedFloat: boolean;
  9703. private _staticDefines;
  9704. /**
  9705. * Sets the length in pixels of the blur sample region
  9706. */
  9707. /**
  9708. * Gets the length in pixels of the blur sample region
  9709. */
  9710. kernel: number;
  9711. /**
  9712. * Sets wether or not the blur needs to unpack/repack floats
  9713. */
  9714. /**
  9715. * Gets wether or not the blur is unpacking/repacking floats
  9716. */
  9717. packedFloat: boolean;
  9718. /**
  9719. * Creates a new instance BlurPostProcess
  9720. * @param name The name of the effect.
  9721. * @param direction The direction in which to blur the image.
  9722. * @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.
  9723. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9724. * @param camera The camera to apply the render pass to.
  9725. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9726. * @param engine The engine which the post process will be applied. (default: current engine)
  9727. * @param reusable If the post process can be reused on the same frame. (default: false)
  9728. * @param textureType Type of textures used when performing the post process. (default: 0)
  9729. * @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)
  9730. */
  9731. constructor(name: string,
  9732. /** The direction in which to blur the image. */
  9733. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9734. /**
  9735. * Updates the effect with the current post process compile time values and recompiles the shader.
  9736. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9737. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9738. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9739. * @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
  9740. * @param onCompiled Called when the shader has been compiled.
  9741. * @param onError Called if there is an error when compiling a shader.
  9742. */
  9743. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9744. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9745. /**
  9746. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9747. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9748. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9749. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9750. * The gaps between physical kernels are compensated for in the weighting of the samples
  9751. * @param idealKernel Ideal blur kernel.
  9752. * @return Nearest best kernel.
  9753. */
  9754. protected _nearestBestKernel(idealKernel: number): number;
  9755. /**
  9756. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9757. * @param x The point on the Gaussian distribution to sample.
  9758. * @return the value of the Gaussian function at x.
  9759. */
  9760. protected _gaussianWeight(x: number): number;
  9761. /**
  9762. * Generates a string that can be used as a floating point number in GLSL.
  9763. * @param x Value to print.
  9764. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9765. * @return GLSL float string.
  9766. */
  9767. protected _glslFloat(x: number, decimalFigures?: number): string;
  9768. }
  9769. }
  9770. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9771. /** @hidden */
  9772. export var shadowMapPixelShader: {
  9773. name: string;
  9774. shader: string;
  9775. };
  9776. }
  9777. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9778. /** @hidden */
  9779. export var bonesDeclaration: {
  9780. name: string;
  9781. shader: string;
  9782. };
  9783. }
  9784. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9785. /** @hidden */
  9786. export var morphTargetsVertexGlobalDeclaration: {
  9787. name: string;
  9788. shader: string;
  9789. };
  9790. }
  9791. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9792. /** @hidden */
  9793. export var morphTargetsVertexDeclaration: {
  9794. name: string;
  9795. shader: string;
  9796. };
  9797. }
  9798. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9799. /** @hidden */
  9800. export var instancesDeclaration: {
  9801. name: string;
  9802. shader: string;
  9803. };
  9804. }
  9805. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9806. /** @hidden */
  9807. export var helperFunctions: {
  9808. name: string;
  9809. shader: string;
  9810. };
  9811. }
  9812. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9813. /** @hidden */
  9814. export var morphTargetsVertex: {
  9815. name: string;
  9816. shader: string;
  9817. };
  9818. }
  9819. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9820. /** @hidden */
  9821. export var instancesVertex: {
  9822. name: string;
  9823. shader: string;
  9824. };
  9825. }
  9826. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9827. /** @hidden */
  9828. export var bonesVertex: {
  9829. name: string;
  9830. shader: string;
  9831. };
  9832. }
  9833. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9834. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9835. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9836. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9837. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9838. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9839. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9840. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9841. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9842. /** @hidden */
  9843. export var shadowMapVertexShader: {
  9844. name: string;
  9845. shader: string;
  9846. };
  9847. }
  9848. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9849. /** @hidden */
  9850. export var depthBoxBlurPixelShader: {
  9851. name: string;
  9852. shader: string;
  9853. };
  9854. }
  9855. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9856. import { Nullable } from "babylonjs/types";
  9857. import { Scene } from "babylonjs/scene";
  9858. import { Matrix } from "babylonjs/Maths/math";
  9859. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9860. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9861. import { Mesh } from "babylonjs/Meshes/mesh";
  9862. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9863. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9864. import { Effect } from "babylonjs/Materials/effect";
  9865. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9866. import "babylonjs/Shaders/shadowMap.fragment";
  9867. import "babylonjs/Shaders/shadowMap.vertex";
  9868. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9869. import { Observable } from "babylonjs/Misc/observable";
  9870. /**
  9871. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9872. */
  9873. export interface ICustomShaderOptions {
  9874. /**
  9875. * Gets or sets the custom shader name to use
  9876. */
  9877. shaderName: string;
  9878. /**
  9879. * The list of attribute names used in the shader
  9880. */
  9881. attributes?: string[];
  9882. /**
  9883. * The list of unifrom names used in the shader
  9884. */
  9885. uniforms?: string[];
  9886. /**
  9887. * The list of sampler names used in the shader
  9888. */
  9889. samplers?: string[];
  9890. /**
  9891. * The list of defines used in the shader
  9892. */
  9893. defines?: string[];
  9894. }
  9895. /**
  9896. * Interface to implement to create a shadow generator compatible with BJS.
  9897. */
  9898. export interface IShadowGenerator {
  9899. /**
  9900. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9901. * @returns The render target texture if present otherwise, null
  9902. */
  9903. getShadowMap(): Nullable<RenderTargetTexture>;
  9904. /**
  9905. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9906. * @returns The render target texture if the shadow map is present otherwise, null
  9907. */
  9908. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9909. /**
  9910. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9911. * @param subMesh The submesh we want to render in the shadow map
  9912. * @param useInstances Defines wether will draw in the map using instances
  9913. * @returns true if ready otherwise, false
  9914. */
  9915. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9916. /**
  9917. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9918. * @param defines Defines of the material we want to update
  9919. * @param lightIndex Index of the light in the enabled light list of the material
  9920. */
  9921. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9922. /**
  9923. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9924. * defined in the generator but impacting the effect).
  9925. * It implies the unifroms available on the materials are the standard BJS ones.
  9926. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9927. * @param effect The effect we are binfing the information for
  9928. */
  9929. bindShadowLight(lightIndex: string, effect: Effect): void;
  9930. /**
  9931. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9932. * (eq to shadow prjection matrix * light transform matrix)
  9933. * @returns The transform matrix used to create the shadow map
  9934. */
  9935. getTransformMatrix(): Matrix;
  9936. /**
  9937. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9938. * Cube and 2D textures for instance.
  9939. */
  9940. recreateShadowMap(): void;
  9941. /**
  9942. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9943. * @param onCompiled Callback triggered at the and of the effects compilation
  9944. * @param options Sets of optional options forcing the compilation with different modes
  9945. */
  9946. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9947. useInstances: boolean;
  9948. }>): void;
  9949. /**
  9950. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9951. * @param options Sets of optional options forcing the compilation with different modes
  9952. * @returns A promise that resolves when the compilation completes
  9953. */
  9954. forceCompilationAsync(options?: Partial<{
  9955. useInstances: boolean;
  9956. }>): Promise<void>;
  9957. /**
  9958. * Serializes the shadow generator setup to a json object.
  9959. * @returns The serialized JSON object
  9960. */
  9961. serialize(): any;
  9962. /**
  9963. * Disposes the Shadow map and related Textures and effects.
  9964. */
  9965. dispose(): void;
  9966. }
  9967. /**
  9968. * Default implementation IShadowGenerator.
  9969. * This is the main object responsible of generating shadows in the framework.
  9970. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9971. */
  9972. export class ShadowGenerator implements IShadowGenerator {
  9973. /**
  9974. * Shadow generator mode None: no filtering applied.
  9975. */
  9976. static readonly FILTER_NONE: number;
  9977. /**
  9978. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9979. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9980. */
  9981. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9982. /**
  9983. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9984. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9985. */
  9986. static readonly FILTER_POISSONSAMPLING: number;
  9987. /**
  9988. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9989. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9990. */
  9991. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9992. /**
  9993. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9994. * edge artifacts on steep falloff.
  9995. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9996. */
  9997. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9998. /**
  9999. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  10000. * edge artifacts on steep falloff.
  10001. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  10002. */
  10003. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  10004. /**
  10005. * Shadow generator mode PCF: Percentage Closer Filtering
  10006. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10007. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  10008. */
  10009. static readonly FILTER_PCF: number;
  10010. /**
  10011. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  10012. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  10013. * Contact Hardening
  10014. */
  10015. static readonly FILTER_PCSS: number;
  10016. /**
  10017. * Reserved for PCF and PCSS
  10018. * Highest Quality.
  10019. *
  10020. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  10021. *
  10022. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  10023. */
  10024. static readonly QUALITY_HIGH: number;
  10025. /**
  10026. * Reserved for PCF and PCSS
  10027. * Good tradeoff for quality/perf cross devices
  10028. *
  10029. * Execute PCF on a 3*3 kernel.
  10030. *
  10031. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  10032. */
  10033. static readonly QUALITY_MEDIUM: number;
  10034. /**
  10035. * Reserved for PCF and PCSS
  10036. * The lowest quality but the fastest.
  10037. *
  10038. * Execute PCF on a 1*1 kernel.
  10039. *
  10040. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  10041. */
  10042. static readonly QUALITY_LOW: number;
  10043. /** Gets or sets the custom shader name to use */
  10044. customShaderOptions: ICustomShaderOptions;
  10045. /**
  10046. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  10047. */
  10048. onBeforeShadowMapRenderObservable: Observable<Effect>;
  10049. /**
  10050. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  10051. */
  10052. onAfterShadowMapRenderObservable: Observable<Effect>;
  10053. /**
  10054. * Observable triggered before a mesh is rendered in the shadow map.
  10055. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  10056. */
  10057. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  10058. /**
  10059. * Observable triggered after a mesh is rendered in the shadow map.
  10060. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  10061. */
  10062. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  10063. private _bias;
  10064. /**
  10065. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  10066. */
  10067. /**
  10068. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  10069. */
  10070. bias: number;
  10071. private _normalBias;
  10072. /**
  10073. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10074. */
  10075. /**
  10076. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  10077. */
  10078. normalBias: number;
  10079. private _blurBoxOffset;
  10080. /**
  10081. * Gets the blur box offset: offset applied during the blur pass.
  10082. * Only useful if useKernelBlur = false
  10083. */
  10084. /**
  10085. * Sets the blur box offset: offset applied during the blur pass.
  10086. * Only useful if useKernelBlur = false
  10087. */
  10088. blurBoxOffset: number;
  10089. private _blurScale;
  10090. /**
  10091. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  10092. * 2 means half of the size.
  10093. */
  10094. /**
  10095. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  10096. * 2 means half of the size.
  10097. */
  10098. blurScale: number;
  10099. private _blurKernel;
  10100. /**
  10101. * Gets the blur kernel: kernel size of the blur pass.
  10102. * Only useful if useKernelBlur = true
  10103. */
  10104. /**
  10105. * Sets the blur kernel: kernel size of the blur pass.
  10106. * Only useful if useKernelBlur = true
  10107. */
  10108. blurKernel: number;
  10109. private _useKernelBlur;
  10110. /**
  10111. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  10112. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10113. */
  10114. /**
  10115. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  10116. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  10117. */
  10118. useKernelBlur: boolean;
  10119. private _depthScale;
  10120. /**
  10121. * Gets the depth scale used in ESM mode.
  10122. */
  10123. /**
  10124. * Sets the depth scale used in ESM mode.
  10125. * This can override the scale stored on the light.
  10126. */
  10127. depthScale: number;
  10128. private _filter;
  10129. /**
  10130. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  10131. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10132. */
  10133. /**
  10134. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  10135. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  10136. */
  10137. filter: number;
  10138. /**
  10139. * Gets if the current filter is set to Poisson Sampling.
  10140. */
  10141. /**
  10142. * Sets the current filter to Poisson Sampling.
  10143. */
  10144. usePoissonSampling: boolean;
  10145. /**
  10146. * Gets if the current filter is set to ESM.
  10147. */
  10148. /**
  10149. * Sets the current filter is to ESM.
  10150. */
  10151. useExponentialShadowMap: boolean;
  10152. /**
  10153. * Gets if the current filter is set to filtered ESM.
  10154. */
  10155. /**
  10156. * Gets if the current filter is set to filtered ESM.
  10157. */
  10158. useBlurExponentialShadowMap: boolean;
  10159. /**
  10160. * Gets if the current filter is set to "close ESM" (using the inverse of the
  10161. * exponential to prevent steep falloff artifacts).
  10162. */
  10163. /**
  10164. * Sets the current filter to "close ESM" (using the inverse of the
  10165. * exponential to prevent steep falloff artifacts).
  10166. */
  10167. useCloseExponentialShadowMap: boolean;
  10168. /**
  10169. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  10170. * exponential to prevent steep falloff artifacts).
  10171. */
  10172. /**
  10173. * Sets the current filter to filtered "close ESM" (using the inverse of the
  10174. * exponential to prevent steep falloff artifacts).
  10175. */
  10176. useBlurCloseExponentialShadowMap: boolean;
  10177. /**
  10178. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  10179. */
  10180. /**
  10181. * Sets the current filter to "PCF" (percentage closer filtering).
  10182. */
  10183. usePercentageCloserFiltering: boolean;
  10184. private _filteringQuality;
  10185. /**
  10186. * Gets the PCF or PCSS Quality.
  10187. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10188. */
  10189. /**
  10190. * Sets the PCF or PCSS Quality.
  10191. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  10192. */
  10193. filteringQuality: number;
  10194. /**
  10195. * Gets if the current filter is set to "PCSS" (contact hardening).
  10196. */
  10197. /**
  10198. * Sets the current filter to "PCSS" (contact hardening).
  10199. */
  10200. useContactHardeningShadow: boolean;
  10201. private _contactHardeningLightSizeUVRatio;
  10202. /**
  10203. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10204. * Using a ratio helps keeping shape stability independently of the map size.
  10205. *
  10206. * It does not account for the light projection as it was having too much
  10207. * instability during the light setup or during light position changes.
  10208. *
  10209. * Only valid if useContactHardeningShadow is true.
  10210. */
  10211. /**
  10212. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  10213. * Using a ratio helps keeping shape stability independently of the map size.
  10214. *
  10215. * It does not account for the light projection as it was having too much
  10216. * instability during the light setup or during light position changes.
  10217. *
  10218. * Only valid if useContactHardeningShadow is true.
  10219. */
  10220. contactHardeningLightSizeUVRatio: number;
  10221. private _darkness;
  10222. /** Gets or sets the actual darkness of a shadow */
  10223. darkness: number;
  10224. /**
  10225. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  10226. * 0 means strongest and 1 would means no shadow.
  10227. * @returns the darkness.
  10228. */
  10229. getDarkness(): number;
  10230. /**
  10231. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  10232. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  10233. * @returns the shadow generator allowing fluent coding.
  10234. */
  10235. setDarkness(darkness: number): ShadowGenerator;
  10236. private _transparencyShadow;
  10237. /** Gets or sets the ability to have transparent shadow */
  10238. transparencyShadow: boolean;
  10239. /**
  10240. * Sets the ability to have transparent shadow (boolean).
  10241. * @param transparent True if transparent else False
  10242. * @returns the shadow generator allowing fluent coding
  10243. */
  10244. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  10245. private _shadowMap;
  10246. private _shadowMap2;
  10247. /**
  10248. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  10249. * @returns The render target texture if present otherwise, null
  10250. */
  10251. getShadowMap(): Nullable<RenderTargetTexture>;
  10252. /**
  10253. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10254. * @returns The render target texture if the shadow map is present otherwise, null
  10255. */
  10256. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10257. /**
  10258. * Gets the class name of that object
  10259. * @returns "ShadowGenerator"
  10260. */
  10261. getClassName(): string;
  10262. /**
  10263. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10264. * @param mesh Mesh to add
  10265. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10266. * @returns the Shadow Generator itself
  10267. */
  10268. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10269. /**
  10270. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10271. * @param mesh Mesh to remove
  10272. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10273. * @returns the Shadow Generator itself
  10274. */
  10275. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10276. /**
  10277. * Controls the extent to which the shadows fade out at the edge of the frustum
  10278. * Used only by directionals and spots
  10279. */
  10280. frustumEdgeFalloff: number;
  10281. private _light;
  10282. /**
  10283. * Returns the associated light object.
  10284. * @returns the light generating the shadow
  10285. */
  10286. getLight(): IShadowLight;
  10287. /**
  10288. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10289. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10290. * It might on the other hand introduce peter panning.
  10291. */
  10292. forceBackFacesOnly: boolean;
  10293. private _scene;
  10294. private _lightDirection;
  10295. private _effect;
  10296. private _viewMatrix;
  10297. private _projectionMatrix;
  10298. private _transformMatrix;
  10299. private _cachedPosition;
  10300. private _cachedDirection;
  10301. private _cachedDefines;
  10302. private _currentRenderID;
  10303. private _boxBlurPostprocess;
  10304. private _kernelBlurXPostprocess;
  10305. private _kernelBlurYPostprocess;
  10306. private _blurPostProcesses;
  10307. private _mapSize;
  10308. private _currentFaceIndex;
  10309. private _currentFaceIndexCache;
  10310. private _textureType;
  10311. private _defaultTextureMatrix;
  10312. /** @hidden */
  10313. static _SceneComponentInitialization: (scene: Scene) => void;
  10314. /**
  10315. * Creates a ShadowGenerator object.
  10316. * A ShadowGenerator is the required tool to use the shadows.
  10317. * Each light casting shadows needs to use its own ShadowGenerator.
  10318. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10319. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10320. * @param light The light object generating the shadows.
  10321. * @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.
  10322. */
  10323. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10324. private _initializeGenerator;
  10325. private _initializeShadowMap;
  10326. private _initializeBlurRTTAndPostProcesses;
  10327. private _renderForShadowMap;
  10328. private _renderSubMeshForShadowMap;
  10329. private _applyFilterValues;
  10330. /**
  10331. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10332. * @param onCompiled Callback triggered at the and of the effects compilation
  10333. * @param options Sets of optional options forcing the compilation with different modes
  10334. */
  10335. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10336. useInstances: boolean;
  10337. }>): void;
  10338. /**
  10339. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10340. * @param options Sets of optional options forcing the compilation with different modes
  10341. * @returns A promise that resolves when the compilation completes
  10342. */
  10343. forceCompilationAsync(options?: Partial<{
  10344. useInstances: boolean;
  10345. }>): Promise<void>;
  10346. /**
  10347. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10348. * @param subMesh The submesh we want to render in the shadow map
  10349. * @param useInstances Defines wether will draw in the map using instances
  10350. * @returns true if ready otherwise, false
  10351. */
  10352. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10353. /**
  10354. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10355. * @param defines Defines of the material we want to update
  10356. * @param lightIndex Index of the light in the enabled light list of the material
  10357. */
  10358. prepareDefines(defines: any, lightIndex: number): void;
  10359. /**
  10360. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10361. * defined in the generator but impacting the effect).
  10362. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10363. * @param effect The effect we are binfing the information for
  10364. */
  10365. bindShadowLight(lightIndex: string, effect: Effect): void;
  10366. /**
  10367. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10368. * (eq to shadow prjection matrix * light transform matrix)
  10369. * @returns The transform matrix used to create the shadow map
  10370. */
  10371. getTransformMatrix(): Matrix;
  10372. /**
  10373. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10374. * Cube and 2D textures for instance.
  10375. */
  10376. recreateShadowMap(): void;
  10377. private _disposeBlurPostProcesses;
  10378. private _disposeRTTandPostProcesses;
  10379. /**
  10380. * Disposes the ShadowGenerator.
  10381. * Returns nothing.
  10382. */
  10383. dispose(): void;
  10384. /**
  10385. * Serializes the shadow generator setup to a json object.
  10386. * @returns The serialized JSON object
  10387. */
  10388. serialize(): any;
  10389. /**
  10390. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10391. * @param parsedShadowGenerator The JSON object to parse
  10392. * @param scene The scene to create the shadow map for
  10393. * @returns The parsed shadow generator
  10394. */
  10395. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10396. }
  10397. }
  10398. declare module "babylonjs/Lights/light" {
  10399. import { Nullable } from "babylonjs/types";
  10400. import { Scene } from "babylonjs/scene";
  10401. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10402. import { Node } from "babylonjs/node";
  10403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10404. import { Effect } from "babylonjs/Materials/effect";
  10405. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10406. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10407. /**
  10408. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10409. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10410. * 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.
  10411. */
  10412. export abstract class Light extends Node {
  10413. /**
  10414. * Falloff Default: light is falling off following the material specification:
  10415. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10416. */
  10417. static readonly FALLOFF_DEFAULT: number;
  10418. /**
  10419. * Falloff Physical: light is falling off following the inverse squared distance law.
  10420. */
  10421. static readonly FALLOFF_PHYSICAL: number;
  10422. /**
  10423. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10424. * to enhance interoperability with other engines.
  10425. */
  10426. static readonly FALLOFF_GLTF: number;
  10427. /**
  10428. * Falloff Standard: light is falling off like in the standard material
  10429. * to enhance interoperability with other materials.
  10430. */
  10431. static readonly FALLOFF_STANDARD: number;
  10432. /**
  10433. * If every light affecting the material is in this lightmapMode,
  10434. * material.lightmapTexture adds or multiplies
  10435. * (depends on material.useLightmapAsShadowmap)
  10436. * after every other light calculations.
  10437. */
  10438. static readonly LIGHTMAP_DEFAULT: number;
  10439. /**
  10440. * material.lightmapTexture as only diffuse lighting from this light
  10441. * adds only specular lighting from this light
  10442. * adds dynamic shadows
  10443. */
  10444. static readonly LIGHTMAP_SPECULAR: number;
  10445. /**
  10446. * material.lightmapTexture as only lighting
  10447. * no light calculation from this light
  10448. * only adds dynamic shadows from this light
  10449. */
  10450. static readonly LIGHTMAP_SHADOWSONLY: number;
  10451. /**
  10452. * Each light type uses the default quantity according to its type:
  10453. * point/spot lights use luminous intensity
  10454. * directional lights use illuminance
  10455. */
  10456. static readonly INTENSITYMODE_AUTOMATIC: number;
  10457. /**
  10458. * lumen (lm)
  10459. */
  10460. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10461. /**
  10462. * candela (lm/sr)
  10463. */
  10464. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10465. /**
  10466. * lux (lm/m^2)
  10467. */
  10468. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10469. /**
  10470. * nit (cd/m^2)
  10471. */
  10472. static readonly INTENSITYMODE_LUMINANCE: number;
  10473. /**
  10474. * Light type const id of the point light.
  10475. */
  10476. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10477. /**
  10478. * Light type const id of the directional light.
  10479. */
  10480. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10481. /**
  10482. * Light type const id of the spot light.
  10483. */
  10484. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10485. /**
  10486. * Light type const id of the hemispheric light.
  10487. */
  10488. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10489. /**
  10490. * Diffuse gives the basic color to an object.
  10491. */
  10492. diffuse: Color3;
  10493. /**
  10494. * Specular produces a highlight color on an object.
  10495. * Note: This is note affecting PBR materials.
  10496. */
  10497. specular: Color3;
  10498. /**
  10499. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10500. * falling off base on range or angle.
  10501. * This can be set to any values in Light.FALLOFF_x.
  10502. *
  10503. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10504. * other types of materials.
  10505. */
  10506. falloffType: number;
  10507. /**
  10508. * Strength of the light.
  10509. * Note: By default it is define in the framework own unit.
  10510. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10511. */
  10512. intensity: number;
  10513. private _range;
  10514. protected _inverseSquaredRange: number;
  10515. /**
  10516. * Defines how far from the source the light is impacting in scene units.
  10517. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10518. */
  10519. /**
  10520. * Defines how far from the source the light is impacting in scene units.
  10521. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10522. */
  10523. range: number;
  10524. /**
  10525. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10526. * of light.
  10527. */
  10528. private _photometricScale;
  10529. private _intensityMode;
  10530. /**
  10531. * Gets the photometric scale used to interpret the intensity.
  10532. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10533. */
  10534. /**
  10535. * Sets the photometric scale used to interpret the intensity.
  10536. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10537. */
  10538. intensityMode: number;
  10539. private _radius;
  10540. /**
  10541. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10542. */
  10543. /**
  10544. * sets the light radius used by PBR Materials to simulate soft area lights.
  10545. */
  10546. radius: number;
  10547. private _renderPriority;
  10548. /**
  10549. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10550. * exceeding the number allowed of the materials.
  10551. */
  10552. renderPriority: number;
  10553. private _shadowEnabled;
  10554. /**
  10555. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10556. * the current shadow generator.
  10557. */
  10558. /**
  10559. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10560. * the current shadow generator.
  10561. */
  10562. shadowEnabled: boolean;
  10563. private _includedOnlyMeshes;
  10564. /**
  10565. * Gets the only meshes impacted by this light.
  10566. */
  10567. /**
  10568. * Sets the only meshes impacted by this light.
  10569. */
  10570. includedOnlyMeshes: AbstractMesh[];
  10571. private _excludedMeshes;
  10572. /**
  10573. * Gets the meshes not impacted by this light.
  10574. */
  10575. /**
  10576. * Sets the meshes not impacted by this light.
  10577. */
  10578. excludedMeshes: AbstractMesh[];
  10579. private _excludeWithLayerMask;
  10580. /**
  10581. * Gets the layer id use to find what meshes are not impacted by the light.
  10582. * Inactive if 0
  10583. */
  10584. /**
  10585. * Sets the layer id use to find what meshes are not impacted by the light.
  10586. * Inactive if 0
  10587. */
  10588. excludeWithLayerMask: number;
  10589. private _includeOnlyWithLayerMask;
  10590. /**
  10591. * Gets the layer id use to find what meshes are impacted by the light.
  10592. * Inactive if 0
  10593. */
  10594. /**
  10595. * Sets the layer id use to find what meshes are impacted by the light.
  10596. * Inactive if 0
  10597. */
  10598. includeOnlyWithLayerMask: number;
  10599. private _lightmapMode;
  10600. /**
  10601. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10602. */
  10603. /**
  10604. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10605. */
  10606. lightmapMode: number;
  10607. /**
  10608. * Shadow generator associted to the light.
  10609. * @hidden Internal use only.
  10610. */
  10611. _shadowGenerator: Nullable<IShadowGenerator>;
  10612. /**
  10613. * @hidden Internal use only.
  10614. */
  10615. _excludedMeshesIds: string[];
  10616. /**
  10617. * @hidden Internal use only.
  10618. */
  10619. _includedOnlyMeshesIds: string[];
  10620. /**
  10621. * The current light unifom buffer.
  10622. * @hidden Internal use only.
  10623. */
  10624. _uniformBuffer: UniformBuffer;
  10625. /**
  10626. * Creates a Light object in the scene.
  10627. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10628. * @param name The firendly name of the light
  10629. * @param scene The scene the light belongs too
  10630. */
  10631. constructor(name: string, scene: Scene);
  10632. protected abstract _buildUniformLayout(): void;
  10633. /**
  10634. * Sets the passed Effect "effect" with the Light information.
  10635. * @param effect The effect to update
  10636. * @param lightIndex The index of the light in the effect to update
  10637. * @returns The light
  10638. */
  10639. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10640. /**
  10641. * Returns the string "Light".
  10642. * @returns the class name
  10643. */
  10644. getClassName(): string;
  10645. /** @hidden */
  10646. readonly _isLight: boolean;
  10647. /**
  10648. * Converts the light information to a readable string for debug purpose.
  10649. * @param fullDetails Supports for multiple levels of logging within scene loading
  10650. * @returns the human readable light info
  10651. */
  10652. toString(fullDetails?: boolean): string;
  10653. /** @hidden */
  10654. protected _syncParentEnabledState(): void;
  10655. /**
  10656. * Set the enabled state of this node.
  10657. * @param value - the new enabled state
  10658. */
  10659. setEnabled(value: boolean): void;
  10660. /**
  10661. * Returns the Light associated shadow generator if any.
  10662. * @return the associated shadow generator.
  10663. */
  10664. getShadowGenerator(): Nullable<IShadowGenerator>;
  10665. /**
  10666. * Returns a Vector3, the absolute light position in the World.
  10667. * @returns the world space position of the light
  10668. */
  10669. getAbsolutePosition(): Vector3;
  10670. /**
  10671. * Specifies if the light will affect the passed mesh.
  10672. * @param mesh The mesh to test against the light
  10673. * @return true the mesh is affected otherwise, false.
  10674. */
  10675. canAffectMesh(mesh: AbstractMesh): boolean;
  10676. /**
  10677. * Sort function to order lights for rendering.
  10678. * @param a First Light object to compare to second.
  10679. * @param b Second Light object to compare first.
  10680. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10681. */
  10682. static CompareLightsPriority(a: Light, b: Light): number;
  10683. /**
  10684. * Releases resources associated with this node.
  10685. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10686. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10687. */
  10688. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10689. /**
  10690. * Returns the light type ID (integer).
  10691. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10692. */
  10693. getTypeID(): number;
  10694. /**
  10695. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10696. * @returns the scaled intensity in intensity mode unit
  10697. */
  10698. getScaledIntensity(): number;
  10699. /**
  10700. * Returns a new Light object, named "name", from the current one.
  10701. * @param name The name of the cloned light
  10702. * @returns the new created light
  10703. */
  10704. clone(name: string): Nullable<Light>;
  10705. /**
  10706. * Serializes the current light into a Serialization object.
  10707. * @returns the serialized object.
  10708. */
  10709. serialize(): any;
  10710. /**
  10711. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10712. * This new light is named "name" and added to the passed scene.
  10713. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10714. * @param name The friendly name of the light
  10715. * @param scene The scene the new light will belong to
  10716. * @returns the constructor function
  10717. */
  10718. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10719. /**
  10720. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10721. * @param parsedLight The JSON representation of the light
  10722. * @param scene The scene to create the parsed light in
  10723. * @returns the created light after parsing
  10724. */
  10725. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10726. private _hookArrayForExcluded;
  10727. private _hookArrayForIncludedOnly;
  10728. private _resyncMeshes;
  10729. /**
  10730. * Forces the meshes to update their light related information in their rendering used effects
  10731. * @hidden Internal Use Only
  10732. */
  10733. _markMeshesAsLightDirty(): void;
  10734. /**
  10735. * Recomputes the cached photometric scale if needed.
  10736. */
  10737. private _computePhotometricScale;
  10738. /**
  10739. * Returns the Photometric Scale according to the light type and intensity mode.
  10740. */
  10741. private _getPhotometricScale;
  10742. /**
  10743. * Reorder the light in the scene according to their defined priority.
  10744. * @hidden Internal Use Only
  10745. */
  10746. _reorderLightsInScene(): void;
  10747. /**
  10748. * Prepares the list of defines specific to the light type.
  10749. * @param defines the list of defines
  10750. * @param lightIndex defines the index of the light for the effect
  10751. */
  10752. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10753. }
  10754. }
  10755. declare module "babylonjs/Actions/action" {
  10756. import { Observable } from "babylonjs/Misc/observable";
  10757. import { Condition } from "babylonjs/Actions/condition";
  10758. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10759. import { ActionManager } from "babylonjs/Actions/actionManager";
  10760. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10761. /**
  10762. * Interface used to define Action
  10763. */
  10764. export interface IAction {
  10765. /**
  10766. * Trigger for the action
  10767. */
  10768. trigger: number;
  10769. /** Options of the trigger */
  10770. triggerOptions: any;
  10771. /**
  10772. * Gets the trigger parameters
  10773. * @returns the trigger parameters
  10774. */
  10775. getTriggerParameter(): any;
  10776. /**
  10777. * Internal only - executes current action event
  10778. * @hidden
  10779. */
  10780. _executeCurrent(evt?: ActionEvent): void;
  10781. /**
  10782. * Serialize placeholder for child classes
  10783. * @param parent of child
  10784. * @returns the serialized object
  10785. */
  10786. serialize(parent: any): any;
  10787. /**
  10788. * Internal only
  10789. * @hidden
  10790. */
  10791. _prepare(): void;
  10792. /**
  10793. * Internal only - manager for action
  10794. * @hidden
  10795. */
  10796. _actionManager: AbstractActionManager;
  10797. /**
  10798. * Adds action to chain of actions, may be a DoNothingAction
  10799. * @param action defines the next action to execute
  10800. * @returns The action passed in
  10801. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10802. */
  10803. then(action: IAction): IAction;
  10804. }
  10805. /**
  10806. * The action to be carried out following a trigger
  10807. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10808. */
  10809. export class Action implements IAction {
  10810. /** the trigger, with or without parameters, for the action */
  10811. triggerOptions: any;
  10812. /**
  10813. * Trigger for the action
  10814. */
  10815. trigger: number;
  10816. /**
  10817. * Internal only - manager for action
  10818. * @hidden
  10819. */
  10820. _actionManager: ActionManager;
  10821. private _nextActiveAction;
  10822. private _child;
  10823. private _condition?;
  10824. private _triggerParameter;
  10825. /**
  10826. * An event triggered prior to action being executed.
  10827. */
  10828. onBeforeExecuteObservable: Observable<Action>;
  10829. /**
  10830. * Creates a new Action
  10831. * @param triggerOptions the trigger, with or without parameters, for the action
  10832. * @param condition an optional determinant of action
  10833. */
  10834. constructor(
  10835. /** the trigger, with or without parameters, for the action */
  10836. triggerOptions: any, condition?: Condition);
  10837. /**
  10838. * Internal only
  10839. * @hidden
  10840. */
  10841. _prepare(): void;
  10842. /**
  10843. * Gets the trigger parameters
  10844. * @returns the trigger parameters
  10845. */
  10846. getTriggerParameter(): any;
  10847. /**
  10848. * Internal only - executes current action event
  10849. * @hidden
  10850. */
  10851. _executeCurrent(evt?: ActionEvent): void;
  10852. /**
  10853. * Execute placeholder for child classes
  10854. * @param evt optional action event
  10855. */
  10856. execute(evt?: ActionEvent): void;
  10857. /**
  10858. * Skips to next active action
  10859. */
  10860. skipToNextActiveAction(): void;
  10861. /**
  10862. * Adds action to chain of actions, may be a DoNothingAction
  10863. * @param action defines the next action to execute
  10864. * @returns The action passed in
  10865. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10866. */
  10867. then(action: Action): Action;
  10868. /**
  10869. * Internal only
  10870. * @hidden
  10871. */
  10872. _getProperty(propertyPath: string): string;
  10873. /**
  10874. * Internal only
  10875. * @hidden
  10876. */
  10877. _getEffectiveTarget(target: any, propertyPath: string): any;
  10878. /**
  10879. * Serialize placeholder for child classes
  10880. * @param parent of child
  10881. * @returns the serialized object
  10882. */
  10883. serialize(parent: any): any;
  10884. /**
  10885. * Internal only called by serialize
  10886. * @hidden
  10887. */
  10888. protected _serialize(serializedAction: any, parent?: any): any;
  10889. /**
  10890. * Internal only
  10891. * @hidden
  10892. */
  10893. static _SerializeValueAsString: (value: any) => string;
  10894. /**
  10895. * Internal only
  10896. * @hidden
  10897. */
  10898. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10899. name: string;
  10900. targetType: string;
  10901. value: string;
  10902. };
  10903. }
  10904. }
  10905. declare module "babylonjs/Actions/condition" {
  10906. import { ActionManager } from "babylonjs/Actions/actionManager";
  10907. /**
  10908. * A Condition applied to an Action
  10909. */
  10910. export class Condition {
  10911. /**
  10912. * Internal only - manager for action
  10913. * @hidden
  10914. */
  10915. _actionManager: ActionManager;
  10916. /**
  10917. * Internal only
  10918. * @hidden
  10919. */
  10920. _evaluationId: number;
  10921. /**
  10922. * Internal only
  10923. * @hidden
  10924. */
  10925. _currentResult: boolean;
  10926. /**
  10927. * Creates a new Condition
  10928. * @param actionManager the manager of the action the condition is applied to
  10929. */
  10930. constructor(actionManager: ActionManager);
  10931. /**
  10932. * Check if the current condition is valid
  10933. * @returns a boolean
  10934. */
  10935. isValid(): boolean;
  10936. /**
  10937. * Internal only
  10938. * @hidden
  10939. */
  10940. _getProperty(propertyPath: string): string;
  10941. /**
  10942. * Internal only
  10943. * @hidden
  10944. */
  10945. _getEffectiveTarget(target: any, propertyPath: string): any;
  10946. /**
  10947. * Serialize placeholder for child classes
  10948. * @returns the serialized object
  10949. */
  10950. serialize(): any;
  10951. /**
  10952. * Internal only
  10953. * @hidden
  10954. */
  10955. protected _serialize(serializedCondition: any): any;
  10956. }
  10957. /**
  10958. * Defines specific conditional operators as extensions of Condition
  10959. */
  10960. export class ValueCondition extends Condition {
  10961. /** path to specify the property of the target the conditional operator uses */
  10962. propertyPath: string;
  10963. /** the value compared by the conditional operator against the current value of the property */
  10964. value: any;
  10965. /** the conditional operator, default ValueCondition.IsEqual */
  10966. operator: number;
  10967. /**
  10968. * Internal only
  10969. * @hidden
  10970. */
  10971. private static _IsEqual;
  10972. /**
  10973. * Internal only
  10974. * @hidden
  10975. */
  10976. private static _IsDifferent;
  10977. /**
  10978. * Internal only
  10979. * @hidden
  10980. */
  10981. private static _IsGreater;
  10982. /**
  10983. * Internal only
  10984. * @hidden
  10985. */
  10986. private static _IsLesser;
  10987. /**
  10988. * returns the number for IsEqual
  10989. */
  10990. static readonly IsEqual: number;
  10991. /**
  10992. * Returns the number for IsDifferent
  10993. */
  10994. static readonly IsDifferent: number;
  10995. /**
  10996. * Returns the number for IsGreater
  10997. */
  10998. static readonly IsGreater: number;
  10999. /**
  11000. * Returns the number for IsLesser
  11001. */
  11002. static readonly IsLesser: number;
  11003. /**
  11004. * Internal only The action manager for the condition
  11005. * @hidden
  11006. */
  11007. _actionManager: ActionManager;
  11008. /**
  11009. * Internal only
  11010. * @hidden
  11011. */
  11012. private _target;
  11013. /**
  11014. * Internal only
  11015. * @hidden
  11016. */
  11017. private _effectiveTarget;
  11018. /**
  11019. * Internal only
  11020. * @hidden
  11021. */
  11022. private _property;
  11023. /**
  11024. * Creates a new ValueCondition
  11025. * @param actionManager manager for the action the condition applies to
  11026. * @param target for the action
  11027. * @param propertyPath path to specify the property of the target the conditional operator uses
  11028. * @param value the value compared by the conditional operator against the current value of the property
  11029. * @param operator the conditional operator, default ValueCondition.IsEqual
  11030. */
  11031. constructor(actionManager: ActionManager, target: any,
  11032. /** path to specify the property of the target the conditional operator uses */
  11033. propertyPath: string,
  11034. /** the value compared by the conditional operator against the current value of the property */
  11035. value: any,
  11036. /** the conditional operator, default ValueCondition.IsEqual */
  11037. operator?: number);
  11038. /**
  11039. * Compares the given value with the property value for the specified conditional operator
  11040. * @returns the result of the comparison
  11041. */
  11042. isValid(): boolean;
  11043. /**
  11044. * Serialize the ValueCondition into a JSON compatible object
  11045. * @returns serialization object
  11046. */
  11047. serialize(): any;
  11048. /**
  11049. * Gets the name of the conditional operator for the ValueCondition
  11050. * @param operator the conditional operator
  11051. * @returns the name
  11052. */
  11053. static GetOperatorName(operator: number): string;
  11054. }
  11055. /**
  11056. * Defines a predicate condition as an extension of Condition
  11057. */
  11058. export class PredicateCondition extends Condition {
  11059. /** defines the predicate function used to validate the condition */
  11060. predicate: () => boolean;
  11061. /**
  11062. * Internal only - manager for action
  11063. * @hidden
  11064. */
  11065. _actionManager: ActionManager;
  11066. /**
  11067. * Creates a new PredicateCondition
  11068. * @param actionManager manager for the action the condition applies to
  11069. * @param predicate defines the predicate function used to validate the condition
  11070. */
  11071. constructor(actionManager: ActionManager,
  11072. /** defines the predicate function used to validate the condition */
  11073. predicate: () => boolean);
  11074. /**
  11075. * @returns the validity of the predicate condition
  11076. */
  11077. isValid(): boolean;
  11078. }
  11079. /**
  11080. * Defines a state condition as an extension of Condition
  11081. */
  11082. export class StateCondition extends Condition {
  11083. /** Value to compare with target state */
  11084. value: string;
  11085. /**
  11086. * Internal only - manager for action
  11087. * @hidden
  11088. */
  11089. _actionManager: ActionManager;
  11090. /**
  11091. * Internal only
  11092. * @hidden
  11093. */
  11094. private _target;
  11095. /**
  11096. * Creates a new StateCondition
  11097. * @param actionManager manager for the action the condition applies to
  11098. * @param target of the condition
  11099. * @param value to compare with target state
  11100. */
  11101. constructor(actionManager: ActionManager, target: any,
  11102. /** Value to compare with target state */
  11103. value: string);
  11104. /**
  11105. * Gets a boolean indicating if the current condition is met
  11106. * @returns the validity of the state
  11107. */
  11108. isValid(): boolean;
  11109. /**
  11110. * Serialize the StateCondition into a JSON compatible object
  11111. * @returns serialization object
  11112. */
  11113. serialize(): any;
  11114. }
  11115. }
  11116. declare module "babylonjs/Actions/directActions" {
  11117. import { Action } from "babylonjs/Actions/action";
  11118. import { Condition } from "babylonjs/Actions/condition";
  11119. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  11120. /**
  11121. * This defines an action responsible to toggle a boolean once triggered.
  11122. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11123. */
  11124. export class SwitchBooleanAction extends Action {
  11125. /**
  11126. * The path to the boolean property in the target object
  11127. */
  11128. propertyPath: string;
  11129. private _target;
  11130. private _effectiveTarget;
  11131. private _property;
  11132. /**
  11133. * Instantiate the action
  11134. * @param triggerOptions defines the trigger options
  11135. * @param target defines the object containing the boolean
  11136. * @param propertyPath defines the path to the boolean property in the target object
  11137. * @param condition defines the trigger related conditions
  11138. */
  11139. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  11140. /** @hidden */
  11141. _prepare(): void;
  11142. /**
  11143. * Execute the action toggle the boolean value.
  11144. */
  11145. execute(): void;
  11146. /**
  11147. * Serializes the actions and its related information.
  11148. * @param parent defines the object to serialize in
  11149. * @returns the serialized object
  11150. */
  11151. serialize(parent: any): any;
  11152. }
  11153. /**
  11154. * This defines an action responsible to set a the state field of the target
  11155. * to a desired value once triggered.
  11156. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11157. */
  11158. export class SetStateAction extends Action {
  11159. /**
  11160. * The value to store in the state field.
  11161. */
  11162. value: string;
  11163. private _target;
  11164. /**
  11165. * Instantiate the action
  11166. * @param triggerOptions defines the trigger options
  11167. * @param target defines the object containing the state property
  11168. * @param value defines the value to store in the state field
  11169. * @param condition defines the trigger related conditions
  11170. */
  11171. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  11172. /**
  11173. * Execute the action and store the value on the target state property.
  11174. */
  11175. execute(): void;
  11176. /**
  11177. * Serializes the actions and its related information.
  11178. * @param parent defines the object to serialize in
  11179. * @returns the serialized object
  11180. */
  11181. serialize(parent: any): any;
  11182. }
  11183. /**
  11184. * This defines an action responsible to set a property of the target
  11185. * to a desired value once triggered.
  11186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11187. */
  11188. export class SetValueAction extends Action {
  11189. /**
  11190. * The path of the property to set in the target.
  11191. */
  11192. propertyPath: string;
  11193. /**
  11194. * The value to set in the property
  11195. */
  11196. value: any;
  11197. private _target;
  11198. private _effectiveTarget;
  11199. private _property;
  11200. /**
  11201. * Instantiate the action
  11202. * @param triggerOptions defines the trigger options
  11203. * @param target defines the object containing the property
  11204. * @param propertyPath defines the path of the property to set in the target
  11205. * @param value defines the value to set in the property
  11206. * @param condition defines the trigger related conditions
  11207. */
  11208. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11209. /** @hidden */
  11210. _prepare(): void;
  11211. /**
  11212. * Execute the action and set the targetted property to the desired value.
  11213. */
  11214. execute(): void;
  11215. /**
  11216. * Serializes the actions and its related information.
  11217. * @param parent defines the object to serialize in
  11218. * @returns the serialized object
  11219. */
  11220. serialize(parent: any): any;
  11221. }
  11222. /**
  11223. * This defines an action responsible to increment the target value
  11224. * to a desired value once triggered.
  11225. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11226. */
  11227. export class IncrementValueAction extends Action {
  11228. /**
  11229. * The path of the property to increment in the target.
  11230. */
  11231. propertyPath: string;
  11232. /**
  11233. * The value we should increment the property by.
  11234. */
  11235. value: any;
  11236. private _target;
  11237. private _effectiveTarget;
  11238. private _property;
  11239. /**
  11240. * Instantiate the action
  11241. * @param triggerOptions defines the trigger options
  11242. * @param target defines the object containing the property
  11243. * @param propertyPath defines the path of the property to increment in the target
  11244. * @param value defines the value value we should increment the property by
  11245. * @param condition defines the trigger related conditions
  11246. */
  11247. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  11248. /** @hidden */
  11249. _prepare(): void;
  11250. /**
  11251. * Execute the action and increment the target of the value amount.
  11252. */
  11253. execute(): void;
  11254. /**
  11255. * Serializes the actions and its related information.
  11256. * @param parent defines the object to serialize in
  11257. * @returns the serialized object
  11258. */
  11259. serialize(parent: any): any;
  11260. }
  11261. /**
  11262. * This defines an action responsible to start an animation once triggered.
  11263. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11264. */
  11265. export class PlayAnimationAction extends Action {
  11266. /**
  11267. * Where the animation should start (animation frame)
  11268. */
  11269. from: number;
  11270. /**
  11271. * Where the animation should stop (animation frame)
  11272. */
  11273. to: number;
  11274. /**
  11275. * Define if the animation should loop or stop after the first play.
  11276. */
  11277. loop?: boolean;
  11278. private _target;
  11279. /**
  11280. * Instantiate the action
  11281. * @param triggerOptions defines the trigger options
  11282. * @param target defines the target animation or animation name
  11283. * @param from defines from where the animation should start (animation frame)
  11284. * @param end defines where the animation should stop (animation frame)
  11285. * @param loop defines if the animation should loop or stop after the first play
  11286. * @param condition defines the trigger related conditions
  11287. */
  11288. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11289. /** @hidden */
  11290. _prepare(): void;
  11291. /**
  11292. * Execute the action and play the animation.
  11293. */
  11294. execute(): void;
  11295. /**
  11296. * Serializes the actions and its related information.
  11297. * @param parent defines the object to serialize in
  11298. * @returns the serialized object
  11299. */
  11300. serialize(parent: any): any;
  11301. }
  11302. /**
  11303. * This defines an action responsible to stop an animation once triggered.
  11304. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11305. */
  11306. export class StopAnimationAction extends Action {
  11307. private _target;
  11308. /**
  11309. * Instantiate the action
  11310. * @param triggerOptions defines the trigger options
  11311. * @param target defines the target animation or animation name
  11312. * @param condition defines the trigger related conditions
  11313. */
  11314. constructor(triggerOptions: any, target: any, condition?: Condition);
  11315. /** @hidden */
  11316. _prepare(): void;
  11317. /**
  11318. * Execute the action and stop the animation.
  11319. */
  11320. execute(): void;
  11321. /**
  11322. * Serializes the actions and its related information.
  11323. * @param parent defines the object to serialize in
  11324. * @returns the serialized object
  11325. */
  11326. serialize(parent: any): any;
  11327. }
  11328. /**
  11329. * This defines an action responsible that does nothing once triggered.
  11330. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11331. */
  11332. export class DoNothingAction extends Action {
  11333. /**
  11334. * Instantiate the action
  11335. * @param triggerOptions defines the trigger options
  11336. * @param condition defines the trigger related conditions
  11337. */
  11338. constructor(triggerOptions?: any, condition?: Condition);
  11339. /**
  11340. * Execute the action and do nothing.
  11341. */
  11342. execute(): void;
  11343. /**
  11344. * Serializes the actions and its related information.
  11345. * @param parent defines the object to serialize in
  11346. * @returns the serialized object
  11347. */
  11348. serialize(parent: any): any;
  11349. }
  11350. /**
  11351. * This defines an action responsible to trigger several actions once triggered.
  11352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11353. */
  11354. export class CombineAction extends Action {
  11355. /**
  11356. * The list of aggregated animations to run.
  11357. */
  11358. children: Action[];
  11359. /**
  11360. * Instantiate the action
  11361. * @param triggerOptions defines the trigger options
  11362. * @param children defines the list of aggregated animations to run
  11363. * @param condition defines the trigger related conditions
  11364. */
  11365. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11366. /** @hidden */
  11367. _prepare(): void;
  11368. /**
  11369. * Execute the action and executes all the aggregated actions.
  11370. */
  11371. execute(evt: ActionEvent): void;
  11372. /**
  11373. * Serializes the actions and its related information.
  11374. * @param parent defines the object to serialize in
  11375. * @returns the serialized object
  11376. */
  11377. serialize(parent: any): any;
  11378. }
  11379. /**
  11380. * This defines an action responsible to run code (external event) once triggered.
  11381. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11382. */
  11383. export class ExecuteCodeAction extends Action {
  11384. /**
  11385. * The callback function to run.
  11386. */
  11387. func: (evt: ActionEvent) => void;
  11388. /**
  11389. * Instantiate the action
  11390. * @param triggerOptions defines the trigger options
  11391. * @param func defines the callback function to run
  11392. * @param condition defines the trigger related conditions
  11393. */
  11394. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11395. /**
  11396. * Execute the action and run the attached code.
  11397. */
  11398. execute(evt: ActionEvent): void;
  11399. }
  11400. /**
  11401. * This defines an action responsible to set the parent property of the target once triggered.
  11402. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11403. */
  11404. export class SetParentAction extends Action {
  11405. private _parent;
  11406. private _target;
  11407. /**
  11408. * Instantiate the action
  11409. * @param triggerOptions defines the trigger options
  11410. * @param target defines the target containing the parent property
  11411. * @param parent defines from where the animation should start (animation frame)
  11412. * @param condition defines the trigger related conditions
  11413. */
  11414. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11415. /** @hidden */
  11416. _prepare(): void;
  11417. /**
  11418. * Execute the action and set the parent property.
  11419. */
  11420. execute(): void;
  11421. /**
  11422. * Serializes the actions and its related information.
  11423. * @param parent defines the object to serialize in
  11424. * @returns the serialized object
  11425. */
  11426. serialize(parent: any): any;
  11427. }
  11428. }
  11429. declare module "babylonjs/Actions/actionManager" {
  11430. import { Nullable } from "babylonjs/types";
  11431. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11432. import { Scene } from "babylonjs/scene";
  11433. import { IAction } from "babylonjs/Actions/action";
  11434. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11435. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11436. /**
  11437. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11438. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11440. */
  11441. export class ActionManager extends AbstractActionManager {
  11442. /**
  11443. * Nothing
  11444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11445. */
  11446. static readonly NothingTrigger: number;
  11447. /**
  11448. * On pick
  11449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11450. */
  11451. static readonly OnPickTrigger: number;
  11452. /**
  11453. * On left pick
  11454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11455. */
  11456. static readonly OnLeftPickTrigger: number;
  11457. /**
  11458. * On right pick
  11459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11460. */
  11461. static readonly OnRightPickTrigger: number;
  11462. /**
  11463. * On center pick
  11464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11465. */
  11466. static readonly OnCenterPickTrigger: number;
  11467. /**
  11468. * On pick down
  11469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11470. */
  11471. static readonly OnPickDownTrigger: number;
  11472. /**
  11473. * On double pick
  11474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11475. */
  11476. static readonly OnDoublePickTrigger: number;
  11477. /**
  11478. * On pick up
  11479. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11480. */
  11481. static readonly OnPickUpTrigger: number;
  11482. /**
  11483. * On pick out.
  11484. * This trigger will only be raised if you also declared a OnPickDown
  11485. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11486. */
  11487. static readonly OnPickOutTrigger: number;
  11488. /**
  11489. * On long press
  11490. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11491. */
  11492. static readonly OnLongPressTrigger: number;
  11493. /**
  11494. * On pointer over
  11495. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11496. */
  11497. static readonly OnPointerOverTrigger: number;
  11498. /**
  11499. * On pointer out
  11500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11501. */
  11502. static readonly OnPointerOutTrigger: number;
  11503. /**
  11504. * On every frame
  11505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11506. */
  11507. static readonly OnEveryFrameTrigger: number;
  11508. /**
  11509. * On intersection enter
  11510. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11511. */
  11512. static readonly OnIntersectionEnterTrigger: number;
  11513. /**
  11514. * On intersection exit
  11515. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11516. */
  11517. static readonly OnIntersectionExitTrigger: number;
  11518. /**
  11519. * On key down
  11520. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11521. */
  11522. static readonly OnKeyDownTrigger: number;
  11523. /**
  11524. * On key up
  11525. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11526. */
  11527. static readonly OnKeyUpTrigger: number;
  11528. private _scene;
  11529. /**
  11530. * Creates a new action manager
  11531. * @param scene defines the hosting scene
  11532. */
  11533. constructor(scene: Scene);
  11534. /**
  11535. * Releases all associated resources
  11536. */
  11537. dispose(): void;
  11538. /**
  11539. * Gets hosting scene
  11540. * @returns the hosting scene
  11541. */
  11542. getScene(): Scene;
  11543. /**
  11544. * Does this action manager handles actions of any of the given triggers
  11545. * @param triggers defines the triggers to be tested
  11546. * @return a boolean indicating whether one (or more) of the triggers is handled
  11547. */
  11548. hasSpecificTriggers(triggers: number[]): boolean;
  11549. /**
  11550. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11551. * speed.
  11552. * @param triggerA defines the trigger to be tested
  11553. * @param triggerB defines the trigger to be tested
  11554. * @return a boolean indicating whether one (or more) of the triggers is handled
  11555. */
  11556. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11557. /**
  11558. * Does this action manager handles actions of a given trigger
  11559. * @param trigger defines the trigger to be tested
  11560. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11561. * @return whether the trigger is handled
  11562. */
  11563. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11564. /**
  11565. * Does this action manager has pointer triggers
  11566. */
  11567. readonly hasPointerTriggers: boolean;
  11568. /**
  11569. * Does this action manager has pick triggers
  11570. */
  11571. readonly hasPickTriggers: boolean;
  11572. /**
  11573. * Registers an action to this action manager
  11574. * @param action defines the action to be registered
  11575. * @return the action amended (prepared) after registration
  11576. */
  11577. registerAction(action: IAction): Nullable<IAction>;
  11578. /**
  11579. * Unregisters an action to this action manager
  11580. * @param action defines the action to be unregistered
  11581. * @return a boolean indicating whether the action has been unregistered
  11582. */
  11583. unregisterAction(action: IAction): Boolean;
  11584. /**
  11585. * Process a specific trigger
  11586. * @param trigger defines the trigger to process
  11587. * @param evt defines the event details to be processed
  11588. */
  11589. processTrigger(trigger: number, evt?: IActionEvent): void;
  11590. /** @hidden */
  11591. _getEffectiveTarget(target: any, propertyPath: string): any;
  11592. /** @hidden */
  11593. _getProperty(propertyPath: string): string;
  11594. /**
  11595. * Serialize this manager to a JSON object
  11596. * @param name defines the property name to store this manager
  11597. * @returns a JSON representation of this manager
  11598. */
  11599. serialize(name: string): any;
  11600. /**
  11601. * Creates a new ActionManager from a JSON data
  11602. * @param parsedActions defines the JSON data to read from
  11603. * @param object defines the hosting mesh
  11604. * @param scene defines the hosting scene
  11605. */
  11606. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11607. /**
  11608. * Get a trigger name by index
  11609. * @param trigger defines the trigger index
  11610. * @returns a trigger name
  11611. */
  11612. static GetTriggerName(trigger: number): string;
  11613. }
  11614. }
  11615. declare module "babylonjs/Culling/ray" {
  11616. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11617. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11618. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11619. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11620. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11621. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11622. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11623. /**
  11624. * Class representing a ray with position and direction
  11625. */
  11626. export class Ray {
  11627. /** origin point */
  11628. origin: Vector3;
  11629. /** direction */
  11630. direction: Vector3;
  11631. /** length of the ray */
  11632. length: number;
  11633. private static readonly TmpVector3;
  11634. private _tmpRay;
  11635. /**
  11636. * Creates a new ray
  11637. * @param origin origin point
  11638. * @param direction direction
  11639. * @param length length of the ray
  11640. */
  11641. constructor(
  11642. /** origin point */
  11643. origin: Vector3,
  11644. /** direction */
  11645. direction: Vector3,
  11646. /** length of the ray */
  11647. length?: number);
  11648. /**
  11649. * Checks if the ray intersects a box
  11650. * @param minimum bound of the box
  11651. * @param maximum bound of the box
  11652. * @param intersectionTreshold extra extend to be added to the box in all direction
  11653. * @returns if the box was hit
  11654. */
  11655. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11656. /**
  11657. * Checks if the ray intersects a box
  11658. * @param box the bounding box to check
  11659. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11660. * @returns if the box was hit
  11661. */
  11662. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11663. /**
  11664. * If the ray hits a sphere
  11665. * @param sphere the bounding sphere to check
  11666. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11667. * @returns true if it hits the sphere
  11668. */
  11669. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11670. /**
  11671. * If the ray hits a triange
  11672. * @param vertex0 triangle vertex
  11673. * @param vertex1 triangle vertex
  11674. * @param vertex2 triangle vertex
  11675. * @returns intersection information if hit
  11676. */
  11677. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11678. /**
  11679. * Checks if ray intersects a plane
  11680. * @param plane the plane to check
  11681. * @returns the distance away it was hit
  11682. */
  11683. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11684. /**
  11685. * Checks if ray intersects a mesh
  11686. * @param mesh the mesh to check
  11687. * @param fastCheck if only the bounding box should checked
  11688. * @returns picking info of the intersecton
  11689. */
  11690. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11691. /**
  11692. * Checks if ray intersects a mesh
  11693. * @param meshes the meshes to check
  11694. * @param fastCheck if only the bounding box should checked
  11695. * @param results array to store result in
  11696. * @returns Array of picking infos
  11697. */
  11698. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11699. private _comparePickingInfo;
  11700. private static smallnum;
  11701. private static rayl;
  11702. /**
  11703. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11704. * @param sega the first point of the segment to test the intersection against
  11705. * @param segb the second point of the segment to test the intersection against
  11706. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11707. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11708. */
  11709. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11710. /**
  11711. * Update the ray from viewport position
  11712. * @param x position
  11713. * @param y y position
  11714. * @param viewportWidth viewport width
  11715. * @param viewportHeight viewport height
  11716. * @param world world matrix
  11717. * @param view view matrix
  11718. * @param projection projection matrix
  11719. * @returns this ray updated
  11720. */
  11721. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11722. /**
  11723. * Creates a ray with origin and direction of 0,0,0
  11724. * @returns the new ray
  11725. */
  11726. static Zero(): Ray;
  11727. /**
  11728. * Creates a new ray from screen space and viewport
  11729. * @param x position
  11730. * @param y y position
  11731. * @param viewportWidth viewport width
  11732. * @param viewportHeight viewport height
  11733. * @param world world matrix
  11734. * @param view view matrix
  11735. * @param projection projection matrix
  11736. * @returns new ray
  11737. */
  11738. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11739. /**
  11740. * 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
  11741. * transformed to the given world matrix.
  11742. * @param origin The origin point
  11743. * @param end The end point
  11744. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11745. * @returns the new ray
  11746. */
  11747. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11748. /**
  11749. * Transforms a ray by a matrix
  11750. * @param ray ray to transform
  11751. * @param matrix matrix to apply
  11752. * @returns the resulting new ray
  11753. */
  11754. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11755. /**
  11756. * Transforms a ray by a matrix
  11757. * @param ray ray to transform
  11758. * @param matrix matrix to apply
  11759. * @param result ray to store result in
  11760. */
  11761. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11762. /**
  11763. * Unproject a ray from screen space to object space
  11764. * @param sourceX defines the screen space x coordinate to use
  11765. * @param sourceY defines the screen space y coordinate to use
  11766. * @param viewportWidth defines the current width of the viewport
  11767. * @param viewportHeight defines the current height of the viewport
  11768. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11769. * @param view defines the view matrix to use
  11770. * @param projection defines the projection matrix to use
  11771. */
  11772. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11773. }
  11774. /**
  11775. * Type used to define predicate used to select faces when a mesh intersection is detected
  11776. */
  11777. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11778. module "babylonjs/scene" {
  11779. interface Scene {
  11780. /** @hidden */
  11781. _tempPickingRay: Nullable<Ray>;
  11782. /** @hidden */
  11783. _cachedRayForTransform: Ray;
  11784. /** @hidden */
  11785. _pickWithRayInverseMatrix: Matrix;
  11786. /** @hidden */
  11787. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11788. /** @hidden */
  11789. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11790. }
  11791. }
  11792. }
  11793. declare module "babylonjs/sceneComponent" {
  11794. import { Scene } from "babylonjs/scene";
  11795. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11796. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11797. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11798. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11799. import { Nullable } from "babylonjs/types";
  11800. import { Camera } from "babylonjs/Cameras/camera";
  11801. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11802. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11803. import { AbstractScene } from "babylonjs/abstractScene";
  11804. /**
  11805. * Groups all the scene component constants in one place to ease maintenance.
  11806. * @hidden
  11807. */
  11808. export class SceneComponentConstants {
  11809. static readonly NAME_EFFECTLAYER: string;
  11810. static readonly NAME_LAYER: string;
  11811. static readonly NAME_LENSFLARESYSTEM: string;
  11812. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11813. static readonly NAME_PARTICLESYSTEM: string;
  11814. static readonly NAME_GAMEPAD: string;
  11815. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11816. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11817. static readonly NAME_DEPTHRENDERER: string;
  11818. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11819. static readonly NAME_SPRITE: string;
  11820. static readonly NAME_OUTLINERENDERER: string;
  11821. static readonly NAME_PROCEDURALTEXTURE: string;
  11822. static readonly NAME_SHADOWGENERATOR: string;
  11823. static readonly NAME_OCTREE: string;
  11824. static readonly NAME_PHYSICSENGINE: string;
  11825. static readonly NAME_AUDIO: string;
  11826. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11827. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11828. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11829. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11830. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11831. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11832. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11833. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11834. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11835. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11836. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11837. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11838. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11839. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11840. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11841. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11842. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11843. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11844. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11845. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11846. static readonly STEP_AFTERRENDER_AUDIO: number;
  11847. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11848. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11849. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11850. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11851. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11852. static readonly STEP_POINTERMOVE_SPRITE: number;
  11853. static readonly STEP_POINTERDOWN_SPRITE: number;
  11854. static readonly STEP_POINTERUP_SPRITE: number;
  11855. }
  11856. /**
  11857. * This represents a scene component.
  11858. *
  11859. * This is used to decouple the dependency the scene is having on the different workloads like
  11860. * layers, post processes...
  11861. */
  11862. export interface ISceneComponent {
  11863. /**
  11864. * The name of the component. Each component must have a unique name.
  11865. */
  11866. name: string;
  11867. /**
  11868. * The scene the component belongs to.
  11869. */
  11870. scene: Scene;
  11871. /**
  11872. * Register the component to one instance of a scene.
  11873. */
  11874. register(): void;
  11875. /**
  11876. * Rebuilds the elements related to this component in case of
  11877. * context lost for instance.
  11878. */
  11879. rebuild(): void;
  11880. /**
  11881. * Disposes the component and the associated ressources.
  11882. */
  11883. dispose(): void;
  11884. }
  11885. /**
  11886. * This represents a SERIALIZABLE scene component.
  11887. *
  11888. * This extends Scene Component to add Serialization methods on top.
  11889. */
  11890. export interface ISceneSerializableComponent extends ISceneComponent {
  11891. /**
  11892. * Adds all the elements from the container to the scene
  11893. * @param container the container holding the elements
  11894. */
  11895. addFromContainer(container: AbstractScene): void;
  11896. /**
  11897. * Removes all the elements in the container from the scene
  11898. * @param container contains the elements to remove
  11899. * @param dispose if the removed element should be disposed (default: false)
  11900. */
  11901. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11902. /**
  11903. * Serializes the component data to the specified json object
  11904. * @param serializationObject The object to serialize to
  11905. */
  11906. serialize(serializationObject: any): void;
  11907. }
  11908. /**
  11909. * Strong typing of a Mesh related stage step action
  11910. */
  11911. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11912. /**
  11913. * Strong typing of a Evaluate Sub Mesh related stage step action
  11914. */
  11915. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11916. /**
  11917. * Strong typing of a Active Mesh related stage step action
  11918. */
  11919. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11920. /**
  11921. * Strong typing of a Camera related stage step action
  11922. */
  11923. export type CameraStageAction = (camera: Camera) => void;
  11924. /**
  11925. * Strong typing of a Camera Frame buffer related stage step action
  11926. */
  11927. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11928. /**
  11929. * Strong typing of a Render Target related stage step action
  11930. */
  11931. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11932. /**
  11933. * Strong typing of a RenderingGroup related stage step action
  11934. */
  11935. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11936. /**
  11937. * Strong typing of a Mesh Render related stage step action
  11938. */
  11939. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11940. /**
  11941. * Strong typing of a simple stage step action
  11942. */
  11943. export type SimpleStageAction = () => void;
  11944. /**
  11945. * Strong typing of a render target action.
  11946. */
  11947. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11948. /**
  11949. * Strong typing of a pointer move action.
  11950. */
  11951. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11952. /**
  11953. * Strong typing of a pointer up/down action.
  11954. */
  11955. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11956. /**
  11957. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11958. * @hidden
  11959. */
  11960. export class Stage<T extends Function> extends Array<{
  11961. index: number;
  11962. component: ISceneComponent;
  11963. action: T;
  11964. }> {
  11965. /**
  11966. * Hide ctor from the rest of the world.
  11967. * @param items The items to add.
  11968. */
  11969. private constructor();
  11970. /**
  11971. * Creates a new Stage.
  11972. * @returns A new instance of a Stage
  11973. */
  11974. static Create<T extends Function>(): Stage<T>;
  11975. /**
  11976. * Registers a step in an ordered way in the targeted stage.
  11977. * @param index Defines the position to register the step in
  11978. * @param component Defines the component attached to the step
  11979. * @param action Defines the action to launch during the step
  11980. */
  11981. registerStep(index: number, component: ISceneComponent, action: T): void;
  11982. /**
  11983. * Clears all the steps from the stage.
  11984. */
  11985. clear(): void;
  11986. }
  11987. }
  11988. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11989. import { Nullable } from "babylonjs/types";
  11990. import { Observable } from "babylonjs/Misc/observable";
  11991. import { Scene } from "babylonjs/scene";
  11992. import { Sprite } from "babylonjs/Sprites/sprite";
  11993. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11994. import { Ray } from "babylonjs/Culling/ray";
  11995. import { Camera } from "babylonjs/Cameras/camera";
  11996. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11997. import { ISceneComponent } from "babylonjs/sceneComponent";
  11998. module "babylonjs/scene" {
  11999. interface Scene {
  12000. /** @hidden */
  12001. _pointerOverSprite: Nullable<Sprite>;
  12002. /** @hidden */
  12003. _pickedDownSprite: Nullable<Sprite>;
  12004. /** @hidden */
  12005. _tempSpritePickingRay: Nullable<Ray>;
  12006. /**
  12007. * All of the sprite managers added to this scene
  12008. * @see http://doc.babylonjs.com/babylon101/sprites
  12009. */
  12010. spriteManagers: Array<ISpriteManager>;
  12011. /**
  12012. * An event triggered when sprites rendering is about to start
  12013. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12014. */
  12015. onBeforeSpritesRenderingObservable: Observable<Scene>;
  12016. /**
  12017. * An event triggered when sprites rendering is done
  12018. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  12019. */
  12020. onAfterSpritesRenderingObservable: Observable<Scene>;
  12021. /** @hidden */
  12022. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12023. /** Launch a ray to try to pick a sprite in the scene
  12024. * @param x position on screen
  12025. * @param y position on screen
  12026. * @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
  12027. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12028. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  12029. * @returns a PickingInfo
  12030. */
  12031. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12032. /** Use the given ray to pick a sprite in the scene
  12033. * @param ray The ray (in world space) to use to pick meshes
  12034. * @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
  12035. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  12036. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  12037. * @returns a PickingInfo
  12038. */
  12039. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  12040. /**
  12041. * Force the sprite under the pointer
  12042. * @param sprite defines the sprite to use
  12043. */
  12044. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  12045. /**
  12046. * Gets the sprite under the pointer
  12047. * @returns a Sprite or null if no sprite is under the pointer
  12048. */
  12049. getPointerOverSprite(): Nullable<Sprite>;
  12050. }
  12051. }
  12052. /**
  12053. * Defines the sprite scene component responsible to manage sprites
  12054. * in a given scene.
  12055. */
  12056. export class SpriteSceneComponent implements ISceneComponent {
  12057. /**
  12058. * The component name helpfull to identify the component in the list of scene components.
  12059. */
  12060. readonly name: string;
  12061. /**
  12062. * The scene the component belongs to.
  12063. */
  12064. scene: Scene;
  12065. /** @hidden */
  12066. private _spritePredicate;
  12067. /**
  12068. * Creates a new instance of the component for the given scene
  12069. * @param scene Defines the scene to register the component in
  12070. */
  12071. constructor(scene: Scene);
  12072. /**
  12073. * Registers the component in a given scene
  12074. */
  12075. register(): void;
  12076. /**
  12077. * Rebuilds the elements related to this component in case of
  12078. * context lost for instance.
  12079. */
  12080. rebuild(): void;
  12081. /**
  12082. * Disposes the component and the associated ressources.
  12083. */
  12084. dispose(): void;
  12085. private _pickSpriteButKeepRay;
  12086. private _pointerMove;
  12087. private _pointerDown;
  12088. private _pointerUp;
  12089. }
  12090. }
  12091. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  12092. /** @hidden */
  12093. export var fogFragmentDeclaration: {
  12094. name: string;
  12095. shader: string;
  12096. };
  12097. }
  12098. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  12099. /** @hidden */
  12100. export var fogFragment: {
  12101. name: string;
  12102. shader: string;
  12103. };
  12104. }
  12105. declare module "babylonjs/Shaders/sprites.fragment" {
  12106. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  12107. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  12108. /** @hidden */
  12109. export var spritesPixelShader: {
  12110. name: string;
  12111. shader: string;
  12112. };
  12113. }
  12114. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  12115. /** @hidden */
  12116. export var fogVertexDeclaration: {
  12117. name: string;
  12118. shader: string;
  12119. };
  12120. }
  12121. declare module "babylonjs/Shaders/sprites.vertex" {
  12122. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  12123. /** @hidden */
  12124. export var spritesVertexShader: {
  12125. name: string;
  12126. shader: string;
  12127. };
  12128. }
  12129. declare module "babylonjs/Sprites/spriteManager" {
  12130. import { IDisposable, Scene } from "babylonjs/scene";
  12131. import { Nullable } from "babylonjs/types";
  12132. import { Observable } from "babylonjs/Misc/observable";
  12133. import { Sprite } from "babylonjs/Sprites/sprite";
  12134. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12135. import { Camera } from "babylonjs/Cameras/camera";
  12136. import { Texture } from "babylonjs/Materials/Textures/texture";
  12137. import "babylonjs/Shaders/sprites.fragment";
  12138. import "babylonjs/Shaders/sprites.vertex";
  12139. import { Ray } from "babylonjs/Culling/ray";
  12140. /**
  12141. * Defines the minimum interface to fullfil in order to be a sprite manager.
  12142. */
  12143. export interface ISpriteManager extends IDisposable {
  12144. /**
  12145. * Restricts the camera to viewing objects with the same layerMask.
  12146. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  12147. */
  12148. layerMask: number;
  12149. /**
  12150. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  12151. */
  12152. isPickable: boolean;
  12153. /**
  12154. * Specifies the rendering group id for this mesh (0 by default)
  12155. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  12156. */
  12157. renderingGroupId: number;
  12158. /**
  12159. * Defines the list of sprites managed by the manager.
  12160. */
  12161. sprites: Array<Sprite>;
  12162. /**
  12163. * Tests the intersection of a sprite with a specific ray.
  12164. * @param ray The ray we are sending to test the collision
  12165. * @param camera The camera space we are sending rays in
  12166. * @param predicate A predicate allowing excluding sprites from the list of object to test
  12167. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  12168. * @returns picking info or null.
  12169. */
  12170. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12171. /**
  12172. * Renders the list of sprites on screen.
  12173. */
  12174. render(): void;
  12175. }
  12176. /**
  12177. * Class used to manage multiple sprites on the same spritesheet
  12178. * @see http://doc.babylonjs.com/babylon101/sprites
  12179. */
  12180. export class SpriteManager implements ISpriteManager {
  12181. /** defines the manager's name */
  12182. name: string;
  12183. /** Gets the list of sprites */
  12184. sprites: Sprite[];
  12185. /** Gets or sets the rendering group id (0 by default) */
  12186. renderingGroupId: number;
  12187. /** Gets or sets camera layer mask */
  12188. layerMask: number;
  12189. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  12190. fogEnabled: boolean;
  12191. /** Gets or sets a boolean indicating if the sprites are pickable */
  12192. isPickable: boolean;
  12193. /** Defines the default width of a cell in the spritesheet */
  12194. cellWidth: number;
  12195. /** Defines the default height of a cell in the spritesheet */
  12196. cellHeight: number;
  12197. /**
  12198. * An event triggered when the manager is disposed.
  12199. */
  12200. onDisposeObservable: Observable<SpriteManager>;
  12201. private _onDisposeObserver;
  12202. /**
  12203. * Callback called when the manager is disposed
  12204. */
  12205. onDispose: () => void;
  12206. private _capacity;
  12207. private _spriteTexture;
  12208. private _epsilon;
  12209. private _scene;
  12210. private _vertexData;
  12211. private _buffer;
  12212. private _vertexBuffers;
  12213. private _indexBuffer;
  12214. private _effectBase;
  12215. private _effectFog;
  12216. /**
  12217. * Gets or sets the spritesheet texture
  12218. */
  12219. texture: Texture;
  12220. /**
  12221. * Creates a new sprite manager
  12222. * @param name defines the manager's name
  12223. * @param imgUrl defines the sprite sheet url
  12224. * @param capacity defines the maximum allowed number of sprites
  12225. * @param cellSize defines the size of a sprite cell
  12226. * @param scene defines the hosting scene
  12227. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  12228. * @param samplingMode defines the smapling mode to use with spritesheet
  12229. */
  12230. constructor(
  12231. /** defines the manager's name */
  12232. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  12233. private _appendSpriteVertex;
  12234. /**
  12235. * Intersects the sprites with a ray
  12236. * @param ray defines the ray to intersect with
  12237. * @param camera defines the current active camera
  12238. * @param predicate defines a predicate used to select candidate sprites
  12239. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  12240. * @returns null if no hit or a PickingInfo
  12241. */
  12242. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  12243. /**
  12244. * Render all child sprites
  12245. */
  12246. render(): void;
  12247. /**
  12248. * Release associated resources
  12249. */
  12250. dispose(): void;
  12251. }
  12252. }
  12253. declare module "babylonjs/Sprites/sprite" {
  12254. import { Vector3, Color4 } from "babylonjs/Maths/math";
  12255. import { Nullable } from "babylonjs/types";
  12256. import { ActionManager } from "babylonjs/Actions/actionManager";
  12257. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  12258. /**
  12259. * Class used to represent a sprite
  12260. * @see http://doc.babylonjs.com/babylon101/sprites
  12261. */
  12262. export class Sprite {
  12263. /** defines the name */
  12264. name: string;
  12265. /** Gets or sets the current world position */
  12266. position: Vector3;
  12267. /** Gets or sets the main color */
  12268. color: Color4;
  12269. /** Gets or sets the width */
  12270. width: number;
  12271. /** Gets or sets the height */
  12272. height: number;
  12273. /** Gets or sets rotation angle */
  12274. angle: number;
  12275. /** Gets or sets the cell index in the sprite sheet */
  12276. cellIndex: number;
  12277. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12278. invertU: number;
  12279. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12280. invertV: number;
  12281. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12282. disposeWhenFinishedAnimating: boolean;
  12283. /** Gets the list of attached animations */
  12284. animations: Animation[];
  12285. /** Gets or sets a boolean indicating if the sprite can be picked */
  12286. isPickable: boolean;
  12287. /**
  12288. * Gets or sets the associated action manager
  12289. */
  12290. actionManager: Nullable<ActionManager>;
  12291. private _animationStarted;
  12292. private _loopAnimation;
  12293. private _fromIndex;
  12294. private _toIndex;
  12295. private _delay;
  12296. private _direction;
  12297. private _manager;
  12298. private _time;
  12299. private _onAnimationEnd;
  12300. /**
  12301. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12302. */
  12303. isVisible: boolean;
  12304. /**
  12305. * Gets or sets the sprite size
  12306. */
  12307. size: number;
  12308. /**
  12309. * Creates a new Sprite
  12310. * @param name defines the name
  12311. * @param manager defines the manager
  12312. */
  12313. constructor(
  12314. /** defines the name */
  12315. name: string, manager: ISpriteManager);
  12316. /**
  12317. * Starts an animation
  12318. * @param from defines the initial key
  12319. * @param to defines the end key
  12320. * @param loop defines if the animation must loop
  12321. * @param delay defines the start delay (in ms)
  12322. * @param onAnimationEnd defines a callback to call when animation ends
  12323. */
  12324. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12325. /** Stops current animation (if any) */
  12326. stopAnimation(): void;
  12327. /** @hidden */
  12328. _animate(deltaTime: number): void;
  12329. /** Release associated resources */
  12330. dispose(): void;
  12331. }
  12332. }
  12333. declare module "babylonjs/Collisions/pickingInfo" {
  12334. import { Nullable } from "babylonjs/types";
  12335. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12336. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12337. import { Sprite } from "babylonjs/Sprites/sprite";
  12338. import { Ray } from "babylonjs/Culling/ray";
  12339. /**
  12340. * Information about the result of picking within a scene
  12341. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12342. */
  12343. export class PickingInfo {
  12344. /** @hidden */
  12345. _pickingUnavailable: boolean;
  12346. /**
  12347. * If the pick collided with an object
  12348. */
  12349. hit: boolean;
  12350. /**
  12351. * Distance away where the pick collided
  12352. */
  12353. distance: number;
  12354. /**
  12355. * The location of pick collision
  12356. */
  12357. pickedPoint: Nullable<Vector3>;
  12358. /**
  12359. * The mesh corresponding the the pick collision
  12360. */
  12361. pickedMesh: Nullable<AbstractMesh>;
  12362. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12363. bu: number;
  12364. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12365. bv: number;
  12366. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12367. faceId: number;
  12368. /** Id of the the submesh that was picked */
  12369. subMeshId: number;
  12370. /** If a sprite was picked, this will be the sprite the pick collided with */
  12371. pickedSprite: Nullable<Sprite>;
  12372. /**
  12373. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12374. */
  12375. originMesh: Nullable<AbstractMesh>;
  12376. /**
  12377. * The ray that was used to perform the picking.
  12378. */
  12379. ray: Nullable<Ray>;
  12380. /**
  12381. * Gets the normal correspodning to the face the pick collided with
  12382. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12383. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12384. * @returns The normal correspodning to the face the pick collided with
  12385. */
  12386. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12387. /**
  12388. * Gets the texture coordinates of where the pick occured
  12389. * @returns the vector containing the coordnates of the texture
  12390. */
  12391. getTextureCoordinates(): Nullable<Vector2>;
  12392. }
  12393. }
  12394. declare module "babylonjs/Events/pointerEvents" {
  12395. import { Nullable } from "babylonjs/types";
  12396. import { Vector2 } from "babylonjs/Maths/math";
  12397. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12398. import { Ray } from "babylonjs/Culling/ray";
  12399. /**
  12400. * Gather the list of pointer event types as constants.
  12401. */
  12402. export class PointerEventTypes {
  12403. /**
  12404. * 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.
  12405. */
  12406. static readonly POINTERDOWN: number;
  12407. /**
  12408. * The pointerup event is fired when a pointer is no longer active.
  12409. */
  12410. static readonly POINTERUP: number;
  12411. /**
  12412. * The pointermove event is fired when a pointer changes coordinates.
  12413. */
  12414. static readonly POINTERMOVE: number;
  12415. /**
  12416. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12417. */
  12418. static readonly POINTERWHEEL: number;
  12419. /**
  12420. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12421. */
  12422. static readonly POINTERPICK: number;
  12423. /**
  12424. * The pointertap event is fired when a the object has been touched and released without drag.
  12425. */
  12426. static readonly POINTERTAP: number;
  12427. /**
  12428. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12429. */
  12430. static readonly POINTERDOUBLETAP: number;
  12431. }
  12432. /**
  12433. * Base class of pointer info types.
  12434. */
  12435. export class PointerInfoBase {
  12436. /**
  12437. * Defines the type of event (PointerEventTypes)
  12438. */
  12439. type: number;
  12440. /**
  12441. * Defines the related dom event
  12442. */
  12443. event: PointerEvent | MouseWheelEvent;
  12444. /**
  12445. * Instantiates the base class of pointers info.
  12446. * @param type Defines the type of event (PointerEventTypes)
  12447. * @param event Defines the related dom event
  12448. */
  12449. constructor(
  12450. /**
  12451. * Defines the type of event (PointerEventTypes)
  12452. */
  12453. type: number,
  12454. /**
  12455. * Defines the related dom event
  12456. */
  12457. event: PointerEvent | MouseWheelEvent);
  12458. }
  12459. /**
  12460. * This class is used to store pointer related info for the onPrePointerObservable event.
  12461. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12462. */
  12463. export class PointerInfoPre extends PointerInfoBase {
  12464. /**
  12465. * Ray from a pointer if availible (eg. 6dof controller)
  12466. */
  12467. ray: Nullable<Ray>;
  12468. /**
  12469. * Defines the local position of the pointer on the canvas.
  12470. */
  12471. localPosition: Vector2;
  12472. /**
  12473. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12474. */
  12475. skipOnPointerObservable: boolean;
  12476. /**
  12477. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12478. * @param type Defines the type of event (PointerEventTypes)
  12479. * @param event Defines the related dom event
  12480. * @param localX Defines the local x coordinates of the pointer when the event occured
  12481. * @param localY Defines the local y coordinates of the pointer when the event occured
  12482. */
  12483. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12484. }
  12485. /**
  12486. * This type contains all the data related to a pointer event in Babylon.js.
  12487. * 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.
  12488. */
  12489. export class PointerInfo extends PointerInfoBase {
  12490. /**
  12491. * Defines the picking info associated to the info (if any)\
  12492. */
  12493. pickInfo: Nullable<PickingInfo>;
  12494. /**
  12495. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12496. * @param type Defines the type of event (PointerEventTypes)
  12497. * @param event Defines the related dom event
  12498. * @param pickInfo Defines the picking info associated to the info (if any)\
  12499. */
  12500. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12501. /**
  12502. * Defines the picking info associated to the info (if any)\
  12503. */
  12504. pickInfo: Nullable<PickingInfo>);
  12505. }
  12506. /**
  12507. * Data relating to a touch event on the screen.
  12508. */
  12509. export interface PointerTouch {
  12510. /**
  12511. * X coordinate of touch.
  12512. */
  12513. x: number;
  12514. /**
  12515. * Y coordinate of touch.
  12516. */
  12517. y: number;
  12518. /**
  12519. * Id of touch. Unique for each finger.
  12520. */
  12521. pointerId: number;
  12522. /**
  12523. * Event type passed from DOM.
  12524. */
  12525. type: any;
  12526. }
  12527. }
  12528. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12529. import { Observable } from "babylonjs/Misc/observable";
  12530. import { Nullable } from "babylonjs/types";
  12531. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12532. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12533. /**
  12534. * Manage the mouse inputs to control the movement of a free camera.
  12535. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12536. */
  12537. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12538. /**
  12539. * Define if touch is enabled in the mouse input
  12540. */
  12541. touchEnabled: boolean;
  12542. /**
  12543. * Defines the camera the input is attached to.
  12544. */
  12545. camera: FreeCamera;
  12546. /**
  12547. * Defines the buttons associated with the input to handle camera move.
  12548. */
  12549. buttons: number[];
  12550. /**
  12551. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12552. */
  12553. angularSensibility: number;
  12554. private _pointerInput;
  12555. private _onMouseMove;
  12556. private _observer;
  12557. private previousPosition;
  12558. /**
  12559. * Observable for when a pointer move event occurs containing the move offset
  12560. */
  12561. onPointerMovedObservable: Observable<{
  12562. offsetX: number;
  12563. offsetY: number;
  12564. }>;
  12565. /**
  12566. * @hidden
  12567. * If the camera should be rotated automatically based on pointer movement
  12568. */
  12569. _allowCameraRotation: boolean;
  12570. /**
  12571. * Manage the mouse inputs to control the movement of a free camera.
  12572. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12573. * @param touchEnabled Defines if touch is enabled or not
  12574. */
  12575. constructor(
  12576. /**
  12577. * Define if touch is enabled in the mouse input
  12578. */
  12579. touchEnabled?: boolean);
  12580. /**
  12581. * Attach the input controls to a specific dom element to get the input from.
  12582. * @param element Defines the element the controls should be listened from
  12583. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12584. */
  12585. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12586. /**
  12587. * Called on JS contextmenu event.
  12588. * Override this method to provide functionality.
  12589. */
  12590. protected onContextMenu(evt: PointerEvent): void;
  12591. /**
  12592. * Detach the current controls from the specified dom element.
  12593. * @param element Defines the element to stop listening the inputs from
  12594. */
  12595. detachControl(element: Nullable<HTMLElement>): void;
  12596. /**
  12597. * Gets the class name of the current intput.
  12598. * @returns the class name
  12599. */
  12600. getClassName(): string;
  12601. /**
  12602. * Get the friendly name associated with the input class.
  12603. * @returns the input friendly name
  12604. */
  12605. getSimpleName(): string;
  12606. }
  12607. }
  12608. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12609. import { Nullable } from "babylonjs/types";
  12610. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12611. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12612. /**
  12613. * Manage the touch inputs to control the movement of a free camera.
  12614. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12615. */
  12616. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12617. /**
  12618. * Defines the camera the input is attached to.
  12619. */
  12620. camera: FreeCamera;
  12621. /**
  12622. * Defines the touch sensibility for rotation.
  12623. * The higher the faster.
  12624. */
  12625. touchAngularSensibility: number;
  12626. /**
  12627. * Defines the touch sensibility for move.
  12628. * The higher the faster.
  12629. */
  12630. touchMoveSensibility: number;
  12631. private _offsetX;
  12632. private _offsetY;
  12633. private _pointerPressed;
  12634. private _pointerInput;
  12635. private _observer;
  12636. private _onLostFocus;
  12637. /**
  12638. * Attach the input controls to a specific dom element to get the input from.
  12639. * @param element Defines the element the controls should be listened from
  12640. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12641. */
  12642. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12643. /**
  12644. * Detach the current controls from the specified dom element.
  12645. * @param element Defines the element to stop listening the inputs from
  12646. */
  12647. detachControl(element: Nullable<HTMLElement>): void;
  12648. /**
  12649. * Update the current camera state depending on the inputs that have been used this frame.
  12650. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12651. */
  12652. checkInputs(): void;
  12653. /**
  12654. * Gets the class name of the current intput.
  12655. * @returns the class name
  12656. */
  12657. getClassName(): string;
  12658. /**
  12659. * Get the friendly name associated with the input class.
  12660. * @returns the input friendly name
  12661. */
  12662. getSimpleName(): string;
  12663. }
  12664. }
  12665. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12666. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12667. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12668. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12669. import { Nullable } from "babylonjs/types";
  12670. /**
  12671. * Default Inputs manager for the FreeCamera.
  12672. * It groups all the default supported inputs for ease of use.
  12673. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12674. */
  12675. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12676. /**
  12677. * @hidden
  12678. */
  12679. _mouseInput: Nullable<FreeCameraMouseInput>;
  12680. /**
  12681. * Instantiates a new FreeCameraInputsManager.
  12682. * @param camera Defines the camera the inputs belong to
  12683. */
  12684. constructor(camera: FreeCamera);
  12685. /**
  12686. * Add keyboard input support to the input manager.
  12687. * @returns the current input manager
  12688. */
  12689. addKeyboard(): FreeCameraInputsManager;
  12690. /**
  12691. * Add mouse input support to the input manager.
  12692. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12693. * @returns the current input manager
  12694. */
  12695. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12696. /**
  12697. * Removes the mouse input support from the manager
  12698. * @returns the current input manager
  12699. */
  12700. removeMouse(): FreeCameraInputsManager;
  12701. /**
  12702. * Add touch input support to the input manager.
  12703. * @returns the current input manager
  12704. */
  12705. addTouch(): FreeCameraInputsManager;
  12706. /**
  12707. * Remove all attached input methods from a camera
  12708. */
  12709. clear(): void;
  12710. }
  12711. }
  12712. declare module "babylonjs/Cameras/freeCamera" {
  12713. import { Vector3 } from "babylonjs/Maths/math";
  12714. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12715. import { Scene } from "babylonjs/scene";
  12716. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12717. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12718. /**
  12719. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12720. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12721. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12722. */
  12723. export class FreeCamera extends TargetCamera {
  12724. /**
  12725. * Define the collision ellipsoid of the camera.
  12726. * This is helpful to simulate a camera body like the player body around the camera
  12727. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12728. */
  12729. ellipsoid: Vector3;
  12730. /**
  12731. * Define an offset for the position of the ellipsoid around the camera.
  12732. * This can be helpful to determine the center of the body near the gravity center of the body
  12733. * instead of its head.
  12734. */
  12735. ellipsoidOffset: Vector3;
  12736. /**
  12737. * Enable or disable collisions of the camera with the rest of the scene objects.
  12738. */
  12739. checkCollisions: boolean;
  12740. /**
  12741. * Enable or disable gravity on the camera.
  12742. */
  12743. applyGravity: boolean;
  12744. /**
  12745. * Define the input manager associated to the camera.
  12746. */
  12747. inputs: FreeCameraInputsManager;
  12748. /**
  12749. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12750. * Higher values reduce sensitivity.
  12751. */
  12752. /**
  12753. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12754. * Higher values reduce sensitivity.
  12755. */
  12756. angularSensibility: number;
  12757. /**
  12758. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12759. */
  12760. keysUp: number[];
  12761. /**
  12762. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12763. */
  12764. keysDown: number[];
  12765. /**
  12766. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12767. */
  12768. keysLeft: number[];
  12769. /**
  12770. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12771. */
  12772. keysRight: number[];
  12773. /**
  12774. * Event raised when the camera collide with a mesh in the scene.
  12775. */
  12776. onCollide: (collidedMesh: AbstractMesh) => void;
  12777. private _collider;
  12778. private _needMoveForGravity;
  12779. private _oldPosition;
  12780. private _diffPosition;
  12781. private _newPosition;
  12782. /** @hidden */
  12783. _localDirection: Vector3;
  12784. /** @hidden */
  12785. _transformedDirection: Vector3;
  12786. /**
  12787. * Instantiates a Free Camera.
  12788. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12789. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12790. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12791. * @param name Define the name of the camera in the scene
  12792. * @param position Define the start position of the camera in the scene
  12793. * @param scene Define the scene the camera belongs to
  12794. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12795. */
  12796. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12797. /**
  12798. * Attached controls to the current camera.
  12799. * @param element Defines the element the controls should be listened from
  12800. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12801. */
  12802. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12803. /**
  12804. * Detach the current controls from the camera.
  12805. * The camera will stop reacting to inputs.
  12806. * @param element Defines the element to stop listening the inputs from
  12807. */
  12808. detachControl(element: HTMLElement): void;
  12809. private _collisionMask;
  12810. /**
  12811. * Define a collision mask to limit the list of object the camera can collide with
  12812. */
  12813. collisionMask: number;
  12814. /** @hidden */
  12815. _collideWithWorld(displacement: Vector3): void;
  12816. private _onCollisionPositionChange;
  12817. /** @hidden */
  12818. _checkInputs(): void;
  12819. /** @hidden */
  12820. _decideIfNeedsToMove(): boolean;
  12821. /** @hidden */
  12822. _updatePosition(): void;
  12823. /**
  12824. * Destroy the camera and release the current resources hold by it.
  12825. */
  12826. dispose(): void;
  12827. /**
  12828. * Gets the current object class name.
  12829. * @return the class name
  12830. */
  12831. getClassName(): string;
  12832. }
  12833. }
  12834. declare module "babylonjs/Gamepads/gamepad" {
  12835. import { Observable } from "babylonjs/Misc/observable";
  12836. /**
  12837. * Represents a gamepad control stick position
  12838. */
  12839. export class StickValues {
  12840. /**
  12841. * The x component of the control stick
  12842. */
  12843. x: number;
  12844. /**
  12845. * The y component of the control stick
  12846. */
  12847. y: number;
  12848. /**
  12849. * Initializes the gamepad x and y control stick values
  12850. * @param x The x component of the gamepad control stick value
  12851. * @param y The y component of the gamepad control stick value
  12852. */
  12853. constructor(
  12854. /**
  12855. * The x component of the control stick
  12856. */
  12857. x: number,
  12858. /**
  12859. * The y component of the control stick
  12860. */
  12861. y: number);
  12862. }
  12863. /**
  12864. * An interface which manages callbacks for gamepad button changes
  12865. */
  12866. export interface GamepadButtonChanges {
  12867. /**
  12868. * Called when a gamepad has been changed
  12869. */
  12870. changed: boolean;
  12871. /**
  12872. * Called when a gamepad press event has been triggered
  12873. */
  12874. pressChanged: boolean;
  12875. /**
  12876. * Called when a touch event has been triggered
  12877. */
  12878. touchChanged: boolean;
  12879. /**
  12880. * Called when a value has changed
  12881. */
  12882. valueChanged: boolean;
  12883. }
  12884. /**
  12885. * Represents a gamepad
  12886. */
  12887. export class Gamepad {
  12888. /**
  12889. * The id of the gamepad
  12890. */
  12891. id: string;
  12892. /**
  12893. * The index of the gamepad
  12894. */
  12895. index: number;
  12896. /**
  12897. * The browser gamepad
  12898. */
  12899. browserGamepad: any;
  12900. /**
  12901. * Specifies what type of gamepad this represents
  12902. */
  12903. type: number;
  12904. private _leftStick;
  12905. private _rightStick;
  12906. /** @hidden */
  12907. _isConnected: boolean;
  12908. private _leftStickAxisX;
  12909. private _leftStickAxisY;
  12910. private _rightStickAxisX;
  12911. private _rightStickAxisY;
  12912. /**
  12913. * Triggered when the left control stick has been changed
  12914. */
  12915. private _onleftstickchanged;
  12916. /**
  12917. * Triggered when the right control stick has been changed
  12918. */
  12919. private _onrightstickchanged;
  12920. /**
  12921. * Represents a gamepad controller
  12922. */
  12923. static GAMEPAD: number;
  12924. /**
  12925. * Represents a generic controller
  12926. */
  12927. static GENERIC: number;
  12928. /**
  12929. * Represents an XBox controller
  12930. */
  12931. static XBOX: number;
  12932. /**
  12933. * Represents a pose-enabled controller
  12934. */
  12935. static POSE_ENABLED: number;
  12936. /**
  12937. * Specifies whether the left control stick should be Y-inverted
  12938. */
  12939. protected _invertLeftStickY: boolean;
  12940. /**
  12941. * Specifies if the gamepad has been connected
  12942. */
  12943. readonly isConnected: boolean;
  12944. /**
  12945. * Initializes the gamepad
  12946. * @param id The id of the gamepad
  12947. * @param index The index of the gamepad
  12948. * @param browserGamepad The browser gamepad
  12949. * @param leftStickX The x component of the left joystick
  12950. * @param leftStickY The y component of the left joystick
  12951. * @param rightStickX The x component of the right joystick
  12952. * @param rightStickY The y component of the right joystick
  12953. */
  12954. constructor(
  12955. /**
  12956. * The id of the gamepad
  12957. */
  12958. id: string,
  12959. /**
  12960. * The index of the gamepad
  12961. */
  12962. index: number,
  12963. /**
  12964. * The browser gamepad
  12965. */
  12966. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12967. /**
  12968. * Callback triggered when the left joystick has changed
  12969. * @param callback
  12970. */
  12971. onleftstickchanged(callback: (values: StickValues) => void): void;
  12972. /**
  12973. * Callback triggered when the right joystick has changed
  12974. * @param callback
  12975. */
  12976. onrightstickchanged(callback: (values: StickValues) => void): void;
  12977. /**
  12978. * Gets the left joystick
  12979. */
  12980. /**
  12981. * Sets the left joystick values
  12982. */
  12983. leftStick: StickValues;
  12984. /**
  12985. * Gets the right joystick
  12986. */
  12987. /**
  12988. * Sets the right joystick value
  12989. */
  12990. rightStick: StickValues;
  12991. /**
  12992. * Updates the gamepad joystick positions
  12993. */
  12994. update(): void;
  12995. /**
  12996. * Disposes the gamepad
  12997. */
  12998. dispose(): void;
  12999. }
  13000. /**
  13001. * Represents a generic gamepad
  13002. */
  13003. export class GenericPad extends Gamepad {
  13004. private _buttons;
  13005. private _onbuttondown;
  13006. private _onbuttonup;
  13007. /**
  13008. * Observable triggered when a button has been pressed
  13009. */
  13010. onButtonDownObservable: Observable<number>;
  13011. /**
  13012. * Observable triggered when a button has been released
  13013. */
  13014. onButtonUpObservable: Observable<number>;
  13015. /**
  13016. * Callback triggered when a button has been pressed
  13017. * @param callback Called when a button has been pressed
  13018. */
  13019. onbuttondown(callback: (buttonPressed: number) => void): void;
  13020. /**
  13021. * Callback triggered when a button has been released
  13022. * @param callback Called when a button has been released
  13023. */
  13024. onbuttonup(callback: (buttonReleased: number) => void): void;
  13025. /**
  13026. * Initializes the generic gamepad
  13027. * @param id The id of the generic gamepad
  13028. * @param index The index of the generic gamepad
  13029. * @param browserGamepad The browser gamepad
  13030. */
  13031. constructor(id: string, index: number, browserGamepad: any);
  13032. private _setButtonValue;
  13033. /**
  13034. * Updates the generic gamepad
  13035. */
  13036. update(): void;
  13037. /**
  13038. * Disposes the generic gamepad
  13039. */
  13040. dispose(): void;
  13041. }
  13042. }
  13043. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  13044. import { Observable } from "babylonjs/Misc/observable";
  13045. import { Nullable } from "babylonjs/types";
  13046. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13047. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13048. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13049. import { Ray } from "babylonjs/Culling/ray";
  13050. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  13051. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  13052. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  13053. /**
  13054. * Defines the types of pose enabled controllers that are supported
  13055. */
  13056. export enum PoseEnabledControllerType {
  13057. /**
  13058. * HTC Vive
  13059. */
  13060. VIVE = 0,
  13061. /**
  13062. * Oculus Rift
  13063. */
  13064. OCULUS = 1,
  13065. /**
  13066. * Windows mixed reality
  13067. */
  13068. WINDOWS = 2,
  13069. /**
  13070. * Samsung gear VR
  13071. */
  13072. GEAR_VR = 3,
  13073. /**
  13074. * Google Daydream
  13075. */
  13076. DAYDREAM = 4,
  13077. /**
  13078. * Generic
  13079. */
  13080. GENERIC = 5
  13081. }
  13082. /**
  13083. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13084. */
  13085. export interface MutableGamepadButton {
  13086. /**
  13087. * Value of the button/trigger
  13088. */
  13089. value: number;
  13090. /**
  13091. * If the button/trigger is currently touched
  13092. */
  13093. touched: boolean;
  13094. /**
  13095. * If the button/trigger is currently pressed
  13096. */
  13097. pressed: boolean;
  13098. }
  13099. /**
  13100. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13101. * @hidden
  13102. */
  13103. export interface ExtendedGamepadButton extends GamepadButton {
  13104. /**
  13105. * If the button/trigger is currently pressed
  13106. */
  13107. readonly pressed: boolean;
  13108. /**
  13109. * If the button/trigger is currently touched
  13110. */
  13111. readonly touched: boolean;
  13112. /**
  13113. * Value of the button/trigger
  13114. */
  13115. readonly value: number;
  13116. }
  13117. /** @hidden */
  13118. export interface _GamePadFactory {
  13119. /**
  13120. * Returns wether or not the current gamepad can be created for this type of controller.
  13121. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13122. * @returns true if it can be created, otherwise false
  13123. */
  13124. canCreate(gamepadInfo: any): boolean;
  13125. /**
  13126. * Creates a new instance of the Gamepad.
  13127. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  13128. * @returns the new gamepad instance
  13129. */
  13130. create(gamepadInfo: any): Gamepad;
  13131. }
  13132. /**
  13133. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13134. */
  13135. export class PoseEnabledControllerHelper {
  13136. /** @hidden */
  13137. static _ControllerFactories: _GamePadFactory[];
  13138. /** @hidden */
  13139. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  13140. /**
  13141. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  13142. * @param vrGamepad the gamepad to initialized
  13143. * @returns a vr controller of the type the gamepad identified as
  13144. */
  13145. static InitiateController(vrGamepad: any): Gamepad;
  13146. }
  13147. /**
  13148. * Defines the PoseEnabledController object that contains state of a vr capable controller
  13149. */
  13150. export class PoseEnabledController extends Gamepad implements PoseControlled {
  13151. private _deviceRoomPosition;
  13152. private _deviceRoomRotationQuaternion;
  13153. /**
  13154. * The device position in babylon space
  13155. */
  13156. devicePosition: Vector3;
  13157. /**
  13158. * The device rotation in babylon space
  13159. */
  13160. deviceRotationQuaternion: Quaternion;
  13161. /**
  13162. * The scale factor of the device in babylon space
  13163. */
  13164. deviceScaleFactor: number;
  13165. /**
  13166. * (Likely devicePosition should be used instead) The device position in its room space
  13167. */
  13168. position: Vector3;
  13169. /**
  13170. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  13171. */
  13172. rotationQuaternion: Quaternion;
  13173. /**
  13174. * The type of controller (Eg. Windows mixed reality)
  13175. */
  13176. controllerType: PoseEnabledControllerType;
  13177. protected _calculatedPosition: Vector3;
  13178. private _calculatedRotation;
  13179. /**
  13180. * The raw pose from the device
  13181. */
  13182. rawPose: DevicePose;
  13183. private _trackPosition;
  13184. private _maxRotationDistFromHeadset;
  13185. private _draggedRoomRotation;
  13186. /**
  13187. * @hidden
  13188. */
  13189. _disableTrackPosition(fixedPosition: Vector3): void;
  13190. /**
  13191. * Internal, the mesh attached to the controller
  13192. * @hidden
  13193. */
  13194. _mesh: Nullable<AbstractMesh>;
  13195. private _poseControlledCamera;
  13196. private _leftHandSystemQuaternion;
  13197. /**
  13198. * Internal, matrix used to convert room space to babylon space
  13199. * @hidden
  13200. */
  13201. _deviceToWorld: Matrix;
  13202. /**
  13203. * Node to be used when casting a ray from the controller
  13204. * @hidden
  13205. */
  13206. _pointingPoseNode: Nullable<TransformNode>;
  13207. /**
  13208. * Name of the child mesh that can be used to cast a ray from the controller
  13209. */
  13210. static readonly POINTING_POSE: string;
  13211. /**
  13212. * Creates a new PoseEnabledController from a gamepad
  13213. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  13214. */
  13215. constructor(browserGamepad: any);
  13216. private _workingMatrix;
  13217. /**
  13218. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  13219. */
  13220. update(): void;
  13221. /**
  13222. * Updates only the pose device and mesh without doing any button event checking
  13223. */
  13224. protected _updatePoseAndMesh(): void;
  13225. /**
  13226. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  13227. * @param poseData raw pose fromthe device
  13228. */
  13229. updateFromDevice(poseData: DevicePose): void;
  13230. /**
  13231. * @hidden
  13232. */
  13233. _meshAttachedObservable: Observable<AbstractMesh>;
  13234. /**
  13235. * Attaches a mesh to the controller
  13236. * @param mesh the mesh to be attached
  13237. */
  13238. attachToMesh(mesh: AbstractMesh): void;
  13239. /**
  13240. * Attaches the controllers mesh to a camera
  13241. * @param camera the camera the mesh should be attached to
  13242. */
  13243. attachToPoseControlledCamera(camera: TargetCamera): void;
  13244. /**
  13245. * Disposes of the controller
  13246. */
  13247. dispose(): void;
  13248. /**
  13249. * The mesh that is attached to the controller
  13250. */
  13251. readonly mesh: Nullable<AbstractMesh>;
  13252. /**
  13253. * Gets the ray of the controller in the direction the controller is pointing
  13254. * @param length the length the resulting ray should be
  13255. * @returns a ray in the direction the controller is pointing
  13256. */
  13257. getForwardRay(length?: number): Ray;
  13258. }
  13259. }
  13260. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  13261. import { Observable } from "babylonjs/Misc/observable";
  13262. import { Scene } from "babylonjs/scene";
  13263. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13264. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13265. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13266. /**
  13267. * Defines the WebVRController object that represents controllers tracked in 3D space
  13268. */
  13269. export abstract class WebVRController extends PoseEnabledController {
  13270. /**
  13271. * Internal, the default controller model for the controller
  13272. */
  13273. protected _defaultModel: AbstractMesh;
  13274. /**
  13275. * Fired when the trigger state has changed
  13276. */
  13277. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13278. /**
  13279. * Fired when the main button state has changed
  13280. */
  13281. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13282. /**
  13283. * Fired when the secondary button state has changed
  13284. */
  13285. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13286. /**
  13287. * Fired when the pad state has changed
  13288. */
  13289. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13290. /**
  13291. * Fired when controllers stick values have changed
  13292. */
  13293. onPadValuesChangedObservable: Observable<StickValues>;
  13294. /**
  13295. * Array of button availible on the controller
  13296. */
  13297. protected _buttons: Array<MutableGamepadButton>;
  13298. private _onButtonStateChange;
  13299. /**
  13300. * Fired when a controller button's state has changed
  13301. * @param callback the callback containing the button that was modified
  13302. */
  13303. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13304. /**
  13305. * X and Y axis corrisponding to the controllers joystick
  13306. */
  13307. pad: StickValues;
  13308. /**
  13309. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13310. */
  13311. hand: string;
  13312. /**
  13313. * The default controller model for the controller
  13314. */
  13315. readonly defaultModel: AbstractMesh;
  13316. /**
  13317. * Creates a new WebVRController from a gamepad
  13318. * @param vrGamepad the gamepad that the WebVRController should be created from
  13319. */
  13320. constructor(vrGamepad: any);
  13321. /**
  13322. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13323. */
  13324. update(): void;
  13325. /**
  13326. * Function to be called when a button is modified
  13327. */
  13328. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13329. /**
  13330. * Loads a mesh and attaches it to the controller
  13331. * @param scene the scene the mesh should be added to
  13332. * @param meshLoaded callback for when the mesh has been loaded
  13333. */
  13334. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13335. private _setButtonValue;
  13336. private _changes;
  13337. private _checkChanges;
  13338. /**
  13339. * Disposes of th webVRCOntroller
  13340. */
  13341. dispose(): void;
  13342. }
  13343. }
  13344. declare module "babylonjs/Lights/hemisphericLight" {
  13345. import { Nullable } from "babylonjs/types";
  13346. import { Scene } from "babylonjs/scene";
  13347. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13348. import { Effect } from "babylonjs/Materials/effect";
  13349. import { Light } from "babylonjs/Lights/light";
  13350. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13351. /**
  13352. * The HemisphericLight simulates the ambient environment light,
  13353. * so the passed direction is the light reflection direction, not the incoming direction.
  13354. */
  13355. export class HemisphericLight extends Light {
  13356. /**
  13357. * The groundColor is the light in the opposite direction to the one specified during creation.
  13358. * 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.
  13359. */
  13360. groundColor: Color3;
  13361. /**
  13362. * The light reflection direction, not the incoming direction.
  13363. */
  13364. direction: Vector3;
  13365. /**
  13366. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13367. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13368. * The HemisphericLight can't cast shadows.
  13369. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13370. * @param name The friendly name of the light
  13371. * @param direction The direction of the light reflection
  13372. * @param scene The scene the light belongs to
  13373. */
  13374. constructor(name: string, direction: Vector3, scene: Scene);
  13375. protected _buildUniformLayout(): void;
  13376. /**
  13377. * Returns the string "HemisphericLight".
  13378. * @return The class name
  13379. */
  13380. getClassName(): string;
  13381. /**
  13382. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13383. * Returns the updated direction.
  13384. * @param target The target the direction should point to
  13385. * @return The computed direction
  13386. */
  13387. setDirectionToTarget(target: Vector3): Vector3;
  13388. /**
  13389. * Returns the shadow generator associated to the light.
  13390. * @returns Always null for hemispheric lights because it does not support shadows.
  13391. */
  13392. getShadowGenerator(): Nullable<IShadowGenerator>;
  13393. /**
  13394. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13395. * @param effect The effect to update
  13396. * @param lightIndex The index of the light in the effect to update
  13397. * @returns The hemispheric light
  13398. */
  13399. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13400. /**
  13401. * Computes the world matrix of the node
  13402. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13403. * @param useWasUpdatedFlag defines a reserved property
  13404. * @returns the world matrix
  13405. */
  13406. computeWorldMatrix(): Matrix;
  13407. /**
  13408. * Returns the integer 3.
  13409. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13410. */
  13411. getTypeID(): number;
  13412. /**
  13413. * Prepares the list of defines specific to the light type.
  13414. * @param defines the list of defines
  13415. * @param lightIndex defines the index of the light for the effect
  13416. */
  13417. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13418. }
  13419. }
  13420. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13421. /** @hidden */
  13422. export var vrMultiviewToSingleviewPixelShader: {
  13423. name: string;
  13424. shader: string;
  13425. };
  13426. }
  13427. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13428. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13429. import { Scene } from "babylonjs/scene";
  13430. /**
  13431. * Renders to multiple views with a single draw call
  13432. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13433. */
  13434. export class MultiviewRenderTarget extends RenderTargetTexture {
  13435. /**
  13436. * Creates a multiview render target
  13437. * @param scene scene used with the render target
  13438. * @param size the size of the render target (used for each view)
  13439. */
  13440. constructor(scene: Scene, size?: number | {
  13441. width: number;
  13442. height: number;
  13443. } | {
  13444. ratio: number;
  13445. });
  13446. /**
  13447. * @hidden
  13448. * @param faceIndex the face index, if its a cube texture
  13449. */
  13450. _bindFrameBuffer(faceIndex?: number): void;
  13451. /**
  13452. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13453. * @returns the view count
  13454. */
  13455. getViewCount(): number;
  13456. }
  13457. }
  13458. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13459. import { Camera } from "babylonjs/Cameras/camera";
  13460. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13461. import { Nullable } from "babylonjs/types";
  13462. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13463. import { Matrix } from "babylonjs/Maths/math";
  13464. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13465. module "babylonjs/Engines/engine" {
  13466. interface Engine {
  13467. /**
  13468. * Creates a new multiview render target
  13469. * @param width defines the width of the texture
  13470. * @param height defines the height of the texture
  13471. * @returns the created multiview texture
  13472. */
  13473. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13474. /**
  13475. * Binds a multiview framebuffer to be drawn to
  13476. * @param multiviewTexture texture to bind
  13477. */
  13478. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13479. }
  13480. }
  13481. module "babylonjs/Cameras/camera" {
  13482. interface Camera {
  13483. /**
  13484. * @hidden
  13485. * 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)
  13486. */
  13487. _useMultiviewToSingleView: boolean;
  13488. /**
  13489. * @hidden
  13490. * 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)
  13491. */
  13492. _multiviewTexture: Nullable<RenderTargetTexture>;
  13493. /**
  13494. * @hidden
  13495. * ensures the multiview texture of the camera exists and has the specified width/height
  13496. * @param width height to set on the multiview texture
  13497. * @param height width to set on the multiview texture
  13498. */
  13499. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13500. }
  13501. }
  13502. module "babylonjs/scene" {
  13503. interface Scene {
  13504. /** @hidden */
  13505. _transformMatrixR: Matrix;
  13506. /** @hidden */
  13507. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13508. /** @hidden */
  13509. _createMultiviewUbo(): void;
  13510. /** @hidden */
  13511. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13512. /** @hidden */
  13513. _renderMultiviewToSingleView(camera: Camera): void;
  13514. }
  13515. }
  13516. }
  13517. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13518. import { Camera } from "babylonjs/Cameras/camera";
  13519. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13520. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13521. import "babylonjs/Engines/Extensions/engine.multiview";
  13522. /**
  13523. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13524. * This will not be used for webXR as it supports displaying texture arrays directly
  13525. */
  13526. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13527. /**
  13528. * Initializes a VRMultiviewToSingleview
  13529. * @param name name of the post process
  13530. * @param camera camera to be applied to
  13531. * @param scaleFactor scaling factor to the size of the output texture
  13532. */
  13533. constructor(name: string, camera: Camera, scaleFactor: number);
  13534. }
  13535. }
  13536. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13537. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  13538. import { Nullable } from "babylonjs/types";
  13539. import { Size } from "babylonjs/Maths/math";
  13540. import { Observable } from "babylonjs/Misc/observable";
  13541. module "babylonjs/Engines/engine" {
  13542. /**
  13543. * Defines the interface used by display changed events
  13544. */
  13545. interface IDisplayChangedEventArgs {
  13546. /** Gets the vrDisplay object (if any) */
  13547. vrDisplay: Nullable<any>;
  13548. /** Gets a boolean indicating if webVR is supported */
  13549. vrSupported: boolean;
  13550. }
  13551. interface Engine {
  13552. /** @hidden */
  13553. _vrDisplay: any;
  13554. /** @hidden */
  13555. _vrSupported: boolean;
  13556. /** @hidden */
  13557. _oldSize: Size;
  13558. /** @hidden */
  13559. _oldHardwareScaleFactor: number;
  13560. /** @hidden */
  13561. _vrExclusivePointerMode: boolean;
  13562. /** @hidden */
  13563. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  13564. /** @hidden */
  13565. _onVRDisplayPointerRestricted: () => void;
  13566. /** @hidden */
  13567. _onVRDisplayPointerUnrestricted: () => void;
  13568. /** @hidden */
  13569. _onVrDisplayConnect: Nullable<(display: any) => void>;
  13570. /** @hidden */
  13571. _onVrDisplayDisconnect: Nullable<() => void>;
  13572. /** @hidden */
  13573. _onVrDisplayPresentChange: Nullable<() => void>;
  13574. /**
  13575. * Observable signaled when VR display mode changes
  13576. */
  13577. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  13578. /**
  13579. * Observable signaled when VR request present is complete
  13580. */
  13581. onVRRequestPresentComplete: Observable<boolean>;
  13582. /**
  13583. * Observable signaled when VR request present starts
  13584. */
  13585. onVRRequestPresentStart: Observable<Engine>;
  13586. /**
  13587. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  13588. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  13589. */
  13590. isInVRExclusivePointerMode: boolean;
  13591. /**
  13592. * Gets a boolean indicating if a webVR device was detected
  13593. * @returns true if a webVR device was detected
  13594. */
  13595. isVRDevicePresent(): boolean;
  13596. /**
  13597. * Gets the current webVR device
  13598. * @returns the current webVR device (or null)
  13599. */
  13600. getVRDevice(): any;
  13601. /**
  13602. * Initializes a webVR display and starts listening to display change events
  13603. * The onVRDisplayChangedObservable will be notified upon these changes
  13604. * @returns A promise containing a VRDisplay and if vr is supported
  13605. */
  13606. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  13607. /** @hidden */
  13608. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  13609. /**
  13610. * Call this function to switch to webVR mode
  13611. * Will do nothing if webVR is not supported or if there is no webVR device
  13612. * @see http://doc.babylonjs.com/how_to/webvr_camera
  13613. */
  13614. enableVR(): void;
  13615. /** @hidden */
  13616. _onVRFullScreenTriggered(): void;
  13617. }
  13618. }
  13619. }
  13620. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13621. import { Nullable } from "babylonjs/types";
  13622. import { Observable } from "babylonjs/Misc/observable";
  13623. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13624. import { Scene } from "babylonjs/scene";
  13625. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13626. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13627. import { Node } from "babylonjs/node";
  13628. import { Ray } from "babylonjs/Culling/ray";
  13629. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13630. import "babylonjs/Engines/Extensions/engine.webVR";
  13631. /**
  13632. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13633. * IMPORTANT!! The data is right-hand data.
  13634. * @export
  13635. * @interface DevicePose
  13636. */
  13637. export interface DevicePose {
  13638. /**
  13639. * The position of the device, values in array are [x,y,z].
  13640. */
  13641. readonly position: Nullable<Float32Array>;
  13642. /**
  13643. * The linearVelocity of the device, values in array are [x,y,z].
  13644. */
  13645. readonly linearVelocity: Nullable<Float32Array>;
  13646. /**
  13647. * The linearAcceleration of the device, values in array are [x,y,z].
  13648. */
  13649. readonly linearAcceleration: Nullable<Float32Array>;
  13650. /**
  13651. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13652. */
  13653. readonly orientation: Nullable<Float32Array>;
  13654. /**
  13655. * The angularVelocity of the device, values in array are [x,y,z].
  13656. */
  13657. readonly angularVelocity: Nullable<Float32Array>;
  13658. /**
  13659. * The angularAcceleration of the device, values in array are [x,y,z].
  13660. */
  13661. readonly angularAcceleration: Nullable<Float32Array>;
  13662. }
  13663. /**
  13664. * Interface representing a pose controlled object in Babylon.
  13665. * A pose controlled object has both regular pose values as well as pose values
  13666. * from an external device such as a VR head mounted display
  13667. */
  13668. export interface PoseControlled {
  13669. /**
  13670. * The position of the object in babylon space.
  13671. */
  13672. position: Vector3;
  13673. /**
  13674. * The rotation quaternion of the object in babylon space.
  13675. */
  13676. rotationQuaternion: Quaternion;
  13677. /**
  13678. * The position of the device in babylon space.
  13679. */
  13680. devicePosition?: Vector3;
  13681. /**
  13682. * The rotation quaternion of the device in babylon space.
  13683. */
  13684. deviceRotationQuaternion: Quaternion;
  13685. /**
  13686. * The raw pose coming from the device.
  13687. */
  13688. rawPose: Nullable<DevicePose>;
  13689. /**
  13690. * The scale of the device to be used when translating from device space to babylon space.
  13691. */
  13692. deviceScaleFactor: number;
  13693. /**
  13694. * Updates the poseControlled values based on the input device pose.
  13695. * @param poseData the pose data to update the object with
  13696. */
  13697. updateFromDevice(poseData: DevicePose): void;
  13698. }
  13699. /**
  13700. * Set of options to customize the webVRCamera
  13701. */
  13702. export interface WebVROptions {
  13703. /**
  13704. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13705. */
  13706. trackPosition?: boolean;
  13707. /**
  13708. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13709. */
  13710. positionScale?: number;
  13711. /**
  13712. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13713. */
  13714. displayName?: string;
  13715. /**
  13716. * Should the native controller meshes be initialized. (default: true)
  13717. */
  13718. controllerMeshes?: boolean;
  13719. /**
  13720. * Creating a default HemiLight only on controllers. (default: true)
  13721. */
  13722. defaultLightingOnControllers?: boolean;
  13723. /**
  13724. * If you don't want to use the default VR button of the helper. (default: false)
  13725. */
  13726. useCustomVRButton?: boolean;
  13727. /**
  13728. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13729. */
  13730. customVRButton?: HTMLButtonElement;
  13731. /**
  13732. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13733. */
  13734. rayLength?: number;
  13735. /**
  13736. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13737. */
  13738. defaultHeight?: number;
  13739. /**
  13740. * If multiview should be used if availible (default: false)
  13741. */
  13742. useMultiview?: boolean;
  13743. }
  13744. /**
  13745. * This represents a WebVR camera.
  13746. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13747. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13748. */
  13749. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13750. private webVROptions;
  13751. /**
  13752. * @hidden
  13753. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13754. */
  13755. _vrDevice: any;
  13756. /**
  13757. * The rawPose of the vrDevice.
  13758. */
  13759. rawPose: Nullable<DevicePose>;
  13760. private _onVREnabled;
  13761. private _specsVersion;
  13762. private _attached;
  13763. private _frameData;
  13764. protected _descendants: Array<Node>;
  13765. private _deviceRoomPosition;
  13766. /** @hidden */
  13767. _deviceRoomRotationQuaternion: Quaternion;
  13768. private _standingMatrix;
  13769. /**
  13770. * Represents device position in babylon space.
  13771. */
  13772. devicePosition: Vector3;
  13773. /**
  13774. * Represents device rotation in babylon space.
  13775. */
  13776. deviceRotationQuaternion: Quaternion;
  13777. /**
  13778. * The scale of the device to be used when translating from device space to babylon space.
  13779. */
  13780. deviceScaleFactor: number;
  13781. private _deviceToWorld;
  13782. private _worldToDevice;
  13783. /**
  13784. * References to the webVR controllers for the vrDevice.
  13785. */
  13786. controllers: Array<WebVRController>;
  13787. /**
  13788. * Emits an event when a controller is attached.
  13789. */
  13790. onControllersAttachedObservable: Observable<WebVRController[]>;
  13791. /**
  13792. * Emits an event when a controller's mesh has been loaded;
  13793. */
  13794. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13795. /**
  13796. * Emits an event when the HMD's pose has been updated.
  13797. */
  13798. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13799. private _poseSet;
  13800. /**
  13801. * If the rig cameras be used as parent instead of this camera.
  13802. */
  13803. rigParenting: boolean;
  13804. private _lightOnControllers;
  13805. private _defaultHeight?;
  13806. /**
  13807. * Instantiates a WebVRFreeCamera.
  13808. * @param name The name of the WebVRFreeCamera
  13809. * @param position The starting anchor position for the camera
  13810. * @param scene The scene the camera belongs to
  13811. * @param webVROptions a set of customizable options for the webVRCamera
  13812. */
  13813. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13814. /**
  13815. * Gets the device distance from the ground in meters.
  13816. * @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.
  13817. */
  13818. deviceDistanceToRoomGround(): number;
  13819. /**
  13820. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13821. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13822. */
  13823. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13824. /**
  13825. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13826. * @returns A promise with a boolean set to if the standing matrix is supported.
  13827. */
  13828. useStandingMatrixAsync(): Promise<boolean>;
  13829. /**
  13830. * Disposes the camera
  13831. */
  13832. dispose(): void;
  13833. /**
  13834. * Gets a vrController by name.
  13835. * @param name The name of the controller to retreive
  13836. * @returns the controller matching the name specified or null if not found
  13837. */
  13838. getControllerByName(name: string): Nullable<WebVRController>;
  13839. private _leftController;
  13840. /**
  13841. * The controller corrisponding to the users left hand.
  13842. */
  13843. readonly leftController: Nullable<WebVRController>;
  13844. private _rightController;
  13845. /**
  13846. * The controller corrisponding to the users right hand.
  13847. */
  13848. readonly rightController: Nullable<WebVRController>;
  13849. /**
  13850. * Casts a ray forward from the vrCamera's gaze.
  13851. * @param length Length of the ray (default: 100)
  13852. * @returns the ray corrisponding to the gaze
  13853. */
  13854. getForwardRay(length?: number): Ray;
  13855. /**
  13856. * @hidden
  13857. * Updates the camera based on device's frame data
  13858. */
  13859. _checkInputs(): void;
  13860. /**
  13861. * Updates the poseControlled values based on the input device pose.
  13862. * @param poseData Pose coming from the device
  13863. */
  13864. updateFromDevice(poseData: DevicePose): void;
  13865. private _htmlElementAttached;
  13866. private _detachIfAttached;
  13867. /**
  13868. * WebVR's attach control will start broadcasting frames to the device.
  13869. * Note that in certain browsers (chrome for example) this function must be called
  13870. * within a user-interaction callback. Example:
  13871. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13872. *
  13873. * @param element html element to attach the vrDevice to
  13874. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13875. */
  13876. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13877. /**
  13878. * Detaches the camera from the html element and disables VR
  13879. *
  13880. * @param element html element to detach from
  13881. */
  13882. detachControl(element: HTMLElement): void;
  13883. /**
  13884. * @returns the name of this class
  13885. */
  13886. getClassName(): string;
  13887. /**
  13888. * Calls resetPose on the vrDisplay
  13889. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13890. */
  13891. resetToCurrentRotation(): void;
  13892. /**
  13893. * @hidden
  13894. * Updates the rig cameras (left and right eye)
  13895. */
  13896. _updateRigCameras(): void;
  13897. private _workingVector;
  13898. private _oneVector;
  13899. private _workingMatrix;
  13900. private updateCacheCalled;
  13901. private _correctPositionIfNotTrackPosition;
  13902. /**
  13903. * @hidden
  13904. * Updates the cached values of the camera
  13905. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13906. */
  13907. _updateCache(ignoreParentClass?: boolean): void;
  13908. /**
  13909. * @hidden
  13910. * Get current device position in babylon world
  13911. */
  13912. _computeDevicePosition(): void;
  13913. /**
  13914. * Updates the current device position and rotation in the babylon world
  13915. */
  13916. update(): void;
  13917. /**
  13918. * @hidden
  13919. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13920. * @returns an identity matrix
  13921. */
  13922. _getViewMatrix(): Matrix;
  13923. private _tmpMatrix;
  13924. /**
  13925. * This function is called by the two RIG cameras.
  13926. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13927. * @hidden
  13928. */
  13929. _getWebVRViewMatrix(): Matrix;
  13930. /** @hidden */
  13931. _getWebVRProjectionMatrix(): Matrix;
  13932. private _onGamepadConnectedObserver;
  13933. private _onGamepadDisconnectedObserver;
  13934. private _updateCacheWhenTrackingDisabledObserver;
  13935. /**
  13936. * Initializes the controllers and their meshes
  13937. */
  13938. initControllers(): void;
  13939. }
  13940. }
  13941. declare module "babylonjs/PostProcesses/postProcess" {
  13942. import { Nullable } from "babylonjs/types";
  13943. import { SmartArray } from "babylonjs/Misc/smartArray";
  13944. import { Observable } from "babylonjs/Misc/observable";
  13945. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13946. import { Camera } from "babylonjs/Cameras/camera";
  13947. import { Effect } from "babylonjs/Materials/effect";
  13948. import "babylonjs/Shaders/postprocess.vertex";
  13949. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13950. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13951. import { Engine } from "babylonjs/Engines/engine";
  13952. /**
  13953. * Size options for a post process
  13954. */
  13955. export type PostProcessOptions = {
  13956. width: number;
  13957. height: number;
  13958. };
  13959. /**
  13960. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13961. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13962. */
  13963. export class PostProcess {
  13964. /** Name of the PostProcess. */
  13965. name: string;
  13966. /**
  13967. * Gets or sets the unique id of the post process
  13968. */
  13969. uniqueId: number;
  13970. /**
  13971. * Width of the texture to apply the post process on
  13972. */
  13973. width: number;
  13974. /**
  13975. * Height of the texture to apply the post process on
  13976. */
  13977. height: number;
  13978. /**
  13979. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13980. * @hidden
  13981. */
  13982. _outputTexture: Nullable<InternalTexture>;
  13983. /**
  13984. * Sampling mode used by the shader
  13985. * See https://doc.babylonjs.com/classes/3.1/texture
  13986. */
  13987. renderTargetSamplingMode: number;
  13988. /**
  13989. * Clear color to use when screen clearing
  13990. */
  13991. clearColor: Color4;
  13992. /**
  13993. * If the buffer needs to be cleared before applying the post process. (default: true)
  13994. * Should be set to false if shader will overwrite all previous pixels.
  13995. */
  13996. autoClear: boolean;
  13997. /**
  13998. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13999. */
  14000. alphaMode: number;
  14001. /**
  14002. * Sets the setAlphaBlendConstants of the babylon engine
  14003. */
  14004. alphaConstants: Color4;
  14005. /**
  14006. * Animations to be used for the post processing
  14007. */
  14008. animations: import("babylonjs/Animations/animation").Animation[];
  14009. /**
  14010. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14011. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14012. */
  14013. enablePixelPerfectMode: boolean;
  14014. /**
  14015. * Force the postprocess to be applied without taking in account viewport
  14016. */
  14017. forceFullscreenViewport: boolean;
  14018. /**
  14019. * List of inspectable custom properties (used by the Inspector)
  14020. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14021. */
  14022. inspectableCustomProperties: IInspectable[];
  14023. /**
  14024. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14025. *
  14026. * | Value | Type | Description |
  14027. * | ----- | ----------------------------------- | ----------- |
  14028. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14029. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14030. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14031. *
  14032. */
  14033. scaleMode: number;
  14034. /**
  14035. * Force textures to be a power of two (default: false)
  14036. */
  14037. alwaysForcePOT: boolean;
  14038. private _samples;
  14039. /**
  14040. * Number of sample textures (default: 1)
  14041. */
  14042. samples: number;
  14043. /**
  14044. * Modify the scale of the post process to be the same as the viewport (default: false)
  14045. */
  14046. adaptScaleToCurrentViewport: boolean;
  14047. private _camera;
  14048. private _scene;
  14049. private _engine;
  14050. private _options;
  14051. private _reusable;
  14052. private _textureType;
  14053. /**
  14054. * Smart array of input and output textures for the post process.
  14055. * @hidden
  14056. */
  14057. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  14058. /**
  14059. * The index in _textures that corresponds to the output texture.
  14060. * @hidden
  14061. */
  14062. _currentRenderTextureInd: number;
  14063. private _effect;
  14064. private _samplers;
  14065. private _fragmentUrl;
  14066. private _vertexUrl;
  14067. private _parameters;
  14068. private _scaleRatio;
  14069. protected _indexParameters: any;
  14070. private _shareOutputWithPostProcess;
  14071. private _texelSize;
  14072. private _forcedOutputTexture;
  14073. /**
  14074. * Returns the fragment url or shader name used in the post process.
  14075. * @returns the fragment url or name in the shader store.
  14076. */
  14077. getEffectName(): string;
  14078. /**
  14079. * An event triggered when the postprocess is activated.
  14080. */
  14081. onActivateObservable: Observable<Camera>;
  14082. private _onActivateObserver;
  14083. /**
  14084. * A function that is added to the onActivateObservable
  14085. */
  14086. onActivate: Nullable<(camera: Camera) => void>;
  14087. /**
  14088. * An event triggered when the postprocess changes its size.
  14089. */
  14090. onSizeChangedObservable: Observable<PostProcess>;
  14091. private _onSizeChangedObserver;
  14092. /**
  14093. * A function that is added to the onSizeChangedObservable
  14094. */
  14095. onSizeChanged: (postProcess: PostProcess) => void;
  14096. /**
  14097. * An event triggered when the postprocess applies its effect.
  14098. */
  14099. onApplyObservable: Observable<Effect>;
  14100. private _onApplyObserver;
  14101. /**
  14102. * A function that is added to the onApplyObservable
  14103. */
  14104. onApply: (effect: Effect) => void;
  14105. /**
  14106. * An event triggered before rendering the postprocess
  14107. */
  14108. onBeforeRenderObservable: Observable<Effect>;
  14109. private _onBeforeRenderObserver;
  14110. /**
  14111. * A function that is added to the onBeforeRenderObservable
  14112. */
  14113. onBeforeRender: (effect: Effect) => void;
  14114. /**
  14115. * An event triggered after rendering the postprocess
  14116. */
  14117. onAfterRenderObservable: Observable<Effect>;
  14118. private _onAfterRenderObserver;
  14119. /**
  14120. * A function that is added to the onAfterRenderObservable
  14121. */
  14122. onAfterRender: (efect: Effect) => void;
  14123. /**
  14124. * 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
  14125. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14126. */
  14127. inputTexture: InternalTexture;
  14128. /**
  14129. * Gets the camera which post process is applied to.
  14130. * @returns The camera the post process is applied to.
  14131. */
  14132. getCamera(): Camera;
  14133. /**
  14134. * Gets the texel size of the postprocess.
  14135. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14136. */
  14137. readonly texelSize: Vector2;
  14138. /**
  14139. * Creates a new instance PostProcess
  14140. * @param name The name of the PostProcess.
  14141. * @param fragmentUrl The url of the fragment shader to be used.
  14142. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14143. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14144. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14145. * @param camera The camera to apply the render pass to.
  14146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14147. * @param engine The engine which the post process will be applied. (default: current engine)
  14148. * @param reusable If the post process can be reused on the same frame. (default: false)
  14149. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14150. * @param textureType Type of textures used when performing the post process. (default: 0)
  14151. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  14152. * @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
  14153. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  14154. */
  14155. constructor(
  14156. /** Name of the PostProcess. */
  14157. 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);
  14158. /**
  14159. * Gets a string idenfifying the name of the class
  14160. * @returns "PostProcess" string
  14161. */
  14162. getClassName(): string;
  14163. /**
  14164. * Gets the engine which this post process belongs to.
  14165. * @returns The engine the post process was enabled with.
  14166. */
  14167. getEngine(): Engine;
  14168. /**
  14169. * The effect that is created when initializing the post process.
  14170. * @returns The created effect corrisponding the the postprocess.
  14171. */
  14172. getEffect(): Effect;
  14173. /**
  14174. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  14175. * @param postProcess The post process to share the output with.
  14176. * @returns This post process.
  14177. */
  14178. shareOutputWith(postProcess: PostProcess): PostProcess;
  14179. /**
  14180. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  14181. * This should be called if the post process that shares output with this post process is disabled/disposed.
  14182. */
  14183. useOwnOutput(): void;
  14184. /**
  14185. * Updates the effect with the current post process compile time values and recompiles the shader.
  14186. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  14187. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  14188. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  14189. * @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
  14190. * @param onCompiled Called when the shader has been compiled.
  14191. * @param onError Called if there is an error when compiling a shader.
  14192. */
  14193. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  14194. /**
  14195. * The post process is reusable if it can be used multiple times within one frame.
  14196. * @returns If the post process is reusable
  14197. */
  14198. isReusable(): boolean;
  14199. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  14200. markTextureDirty(): void;
  14201. /**
  14202. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  14203. * 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.
  14204. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  14205. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  14206. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  14207. * @returns The target texture that was bound to be written to.
  14208. */
  14209. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  14210. /**
  14211. * If the post process is supported.
  14212. */
  14213. readonly isSupported: boolean;
  14214. /**
  14215. * The aspect ratio of the output texture.
  14216. */
  14217. readonly aspectRatio: number;
  14218. /**
  14219. * Get a value indicating if the post-process is ready to be used
  14220. * @returns true if the post-process is ready (shader is compiled)
  14221. */
  14222. isReady(): boolean;
  14223. /**
  14224. * Binds all textures and uniforms to the shader, this will be run on every pass.
  14225. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  14226. */
  14227. apply(): Nullable<Effect>;
  14228. private _disposeTextures;
  14229. /**
  14230. * Disposes the post process.
  14231. * @param camera The camera to dispose the post process on.
  14232. */
  14233. dispose(camera?: Camera): void;
  14234. }
  14235. }
  14236. declare module "babylonjs/PostProcesses/postProcessManager" {
  14237. import { Nullable } from "babylonjs/types";
  14238. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14239. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  14240. import { Scene } from "babylonjs/scene";
  14241. /**
  14242. * PostProcessManager is used to manage one or more post processes or post process pipelines
  14243. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14244. */
  14245. export class PostProcessManager {
  14246. private _scene;
  14247. private _indexBuffer;
  14248. private _vertexBuffers;
  14249. /**
  14250. * Creates a new instance PostProcess
  14251. * @param scene The scene that the post process is associated with.
  14252. */
  14253. constructor(scene: Scene);
  14254. private _prepareBuffers;
  14255. private _buildIndexBuffer;
  14256. /**
  14257. * Rebuilds the vertex buffers of the manager.
  14258. * @hidden
  14259. */
  14260. _rebuild(): void;
  14261. /**
  14262. * Prepares a frame to be run through a post process.
  14263. * @param sourceTexture The input texture to the post procesess. (default: null)
  14264. * @param postProcesses An array of post processes to be run. (default: null)
  14265. * @returns True if the post processes were able to be run.
  14266. * @hidden
  14267. */
  14268. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  14269. /**
  14270. * Manually render a set of post processes to a texture.
  14271. * @param postProcesses An array of post processes to be run.
  14272. * @param targetTexture The target texture to render to.
  14273. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  14274. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  14275. * @param lodLevel defines which lod of the texture to render to
  14276. */
  14277. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  14278. /**
  14279. * Finalize the result of the output of the postprocesses.
  14280. * @param doNotPresent If true the result will not be displayed to the screen.
  14281. * @param targetTexture The target texture to render to.
  14282. * @param faceIndex The index of the face to bind the target texture to.
  14283. * @param postProcesses The array of post processes to render.
  14284. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  14285. * @hidden
  14286. */
  14287. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  14288. /**
  14289. * Disposes of the post process manager.
  14290. */
  14291. dispose(): void;
  14292. }
  14293. }
  14294. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14295. import { Scene } from "babylonjs/scene";
  14296. import { ISceneComponent } from "babylonjs/sceneComponent";
  14297. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14298. module "babylonjs/abstractScene" {
  14299. interface AbstractScene {
  14300. /**
  14301. * The list of procedural textures added to the scene
  14302. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14303. */
  14304. proceduralTextures: Array<ProceduralTexture>;
  14305. }
  14306. }
  14307. /**
  14308. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14309. * in a given scene.
  14310. */
  14311. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14312. /**
  14313. * The component name helpfull to identify the component in the list of scene components.
  14314. */
  14315. readonly name: string;
  14316. /**
  14317. * The scene the component belongs to.
  14318. */
  14319. scene: Scene;
  14320. /**
  14321. * Creates a new instance of the component for the given scene
  14322. * @param scene Defines the scene to register the component in
  14323. */
  14324. constructor(scene: Scene);
  14325. /**
  14326. * Registers the component in a given scene
  14327. */
  14328. register(): void;
  14329. /**
  14330. * Rebuilds the elements related to this component in case of
  14331. * context lost for instance.
  14332. */
  14333. rebuild(): void;
  14334. /**
  14335. * Disposes the component and the associated ressources.
  14336. */
  14337. dispose(): void;
  14338. private _beforeClear;
  14339. }
  14340. }
  14341. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  14342. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  14343. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  14344. module "babylonjs/Engines/engine" {
  14345. interface Engine {
  14346. /**
  14347. * Creates a new render target cube texture
  14348. * @param size defines the size of the texture
  14349. * @param options defines the options used to create the texture
  14350. * @returns a new render target cube texture stored in an InternalTexture
  14351. */
  14352. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  14353. }
  14354. }
  14355. }
  14356. declare module "babylonjs/Shaders/procedural.vertex" {
  14357. /** @hidden */
  14358. export var proceduralVertexShader: {
  14359. name: string;
  14360. shader: string;
  14361. };
  14362. }
  14363. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14364. import { Observable } from "babylonjs/Misc/observable";
  14365. import { Nullable } from "babylonjs/types";
  14366. import { Scene } from "babylonjs/scene";
  14367. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14368. import { Effect } from "babylonjs/Materials/effect";
  14369. import { Texture } from "babylonjs/Materials/Textures/texture";
  14370. import "babylonjs/Engines/Extensions/engine.renderTarget";
  14371. import "babylonjs/Shaders/procedural.vertex";
  14372. /**
  14373. * 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.
  14374. * This is the base class of any Procedural texture and contains most of the shareable code.
  14375. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14376. */
  14377. export class ProceduralTexture extends Texture {
  14378. isCube: boolean;
  14379. /**
  14380. * Define if the texture is enabled or not (disabled texture will not render)
  14381. */
  14382. isEnabled: boolean;
  14383. /**
  14384. * Define if the texture must be cleared before rendering (default is true)
  14385. */
  14386. autoClear: boolean;
  14387. /**
  14388. * Callback called when the texture is generated
  14389. */
  14390. onGenerated: () => void;
  14391. /**
  14392. * Event raised when the texture is generated
  14393. */
  14394. onGeneratedObservable: Observable<ProceduralTexture>;
  14395. /** @hidden */
  14396. _generateMipMaps: boolean;
  14397. /** @hidden **/
  14398. _effect: Effect;
  14399. /** @hidden */
  14400. _textures: {
  14401. [key: string]: Texture;
  14402. };
  14403. private _size;
  14404. private _currentRefreshId;
  14405. private _refreshRate;
  14406. private _vertexBuffers;
  14407. private _indexBuffer;
  14408. private _uniforms;
  14409. private _samplers;
  14410. private _fragment;
  14411. private _floats;
  14412. private _ints;
  14413. private _floatsArrays;
  14414. private _colors3;
  14415. private _colors4;
  14416. private _vectors2;
  14417. private _vectors3;
  14418. private _matrices;
  14419. private _fallbackTexture;
  14420. private _fallbackTextureUsed;
  14421. private _engine;
  14422. private _cachedDefines;
  14423. private _contentUpdateId;
  14424. private _contentData;
  14425. /**
  14426. * Instantiates a new procedural texture.
  14427. * 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.
  14428. * This is the base class of any Procedural texture and contains most of the shareable code.
  14429. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14430. * @param name Define the name of the texture
  14431. * @param size Define the size of the texture to create
  14432. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14433. * @param scene Define the scene the texture belongs to
  14434. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14435. * @param generateMipMaps Define if the texture should creates mip maps or not
  14436. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14437. */
  14438. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14439. /**
  14440. * The effect that is created when initializing the post process.
  14441. * @returns The created effect corrisponding the the postprocess.
  14442. */
  14443. getEffect(): Effect;
  14444. /**
  14445. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14446. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14447. */
  14448. getContent(): Nullable<ArrayBufferView>;
  14449. private _createIndexBuffer;
  14450. /** @hidden */
  14451. _rebuild(): void;
  14452. /**
  14453. * Resets the texture in order to recreate its associated resources.
  14454. * This can be called in case of context loss
  14455. */
  14456. reset(): void;
  14457. protected _getDefines(): string;
  14458. /**
  14459. * Is the texture ready to be used ? (rendered at least once)
  14460. * @returns true if ready, otherwise, false.
  14461. */
  14462. isReady(): boolean;
  14463. /**
  14464. * Resets the refresh counter of the texture and start bak from scratch.
  14465. * Could be useful to regenerate the texture if it is setup to render only once.
  14466. */
  14467. resetRefreshCounter(): void;
  14468. /**
  14469. * Set the fragment shader to use in order to render the texture.
  14470. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14471. */
  14472. setFragment(fragment: any): void;
  14473. /**
  14474. * Define the refresh rate of the texture or the rendering frequency.
  14475. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14476. */
  14477. refreshRate: number;
  14478. /** @hidden */
  14479. _shouldRender(): boolean;
  14480. /**
  14481. * Get the size the texture is rendering at.
  14482. * @returns the size (texture is always squared)
  14483. */
  14484. getRenderSize(): number;
  14485. /**
  14486. * Resize the texture to new value.
  14487. * @param size Define the new size the texture should have
  14488. * @param generateMipMaps Define whether the new texture should create mip maps
  14489. */
  14490. resize(size: number, generateMipMaps: boolean): void;
  14491. private _checkUniform;
  14492. /**
  14493. * Set a texture in the shader program used to render.
  14494. * @param name Define the name of the uniform samplers as defined in the shader
  14495. * @param texture Define the texture to bind to this sampler
  14496. * @return the texture itself allowing "fluent" like uniform updates
  14497. */
  14498. setTexture(name: string, texture: Texture): ProceduralTexture;
  14499. /**
  14500. * Set a float in the shader.
  14501. * @param name Define the name of the uniform as defined in the shader
  14502. * @param value Define the value to give to the uniform
  14503. * @return the texture itself allowing "fluent" like uniform updates
  14504. */
  14505. setFloat(name: string, value: number): ProceduralTexture;
  14506. /**
  14507. * Set a int in the shader.
  14508. * @param name Define the name of the uniform as defined in the shader
  14509. * @param value Define the value to give to the uniform
  14510. * @return the texture itself allowing "fluent" like uniform updates
  14511. */
  14512. setInt(name: string, value: number): ProceduralTexture;
  14513. /**
  14514. * Set an array of floats in the shader.
  14515. * @param name Define the name of the uniform as defined in the shader
  14516. * @param value Define the value to give to the uniform
  14517. * @return the texture itself allowing "fluent" like uniform updates
  14518. */
  14519. setFloats(name: string, value: number[]): ProceduralTexture;
  14520. /**
  14521. * Set a vec3 in the shader from a Color3.
  14522. * @param name Define the name of the uniform as defined in the shader
  14523. * @param value Define the value to give to the uniform
  14524. * @return the texture itself allowing "fluent" like uniform updates
  14525. */
  14526. setColor3(name: string, value: Color3): ProceduralTexture;
  14527. /**
  14528. * Set a vec4 in the shader from a Color4.
  14529. * @param name Define the name of the uniform as defined in the shader
  14530. * @param value Define the value to give to the uniform
  14531. * @return the texture itself allowing "fluent" like uniform updates
  14532. */
  14533. setColor4(name: string, value: Color4): ProceduralTexture;
  14534. /**
  14535. * Set a vec2 in the shader from a Vector2.
  14536. * @param name Define the name of the uniform as defined in the shader
  14537. * @param value Define the value to give to the uniform
  14538. * @return the texture itself allowing "fluent" like uniform updates
  14539. */
  14540. setVector2(name: string, value: Vector2): ProceduralTexture;
  14541. /**
  14542. * Set a vec3 in the shader from a Vector3.
  14543. * @param name Define the name of the uniform as defined in the shader
  14544. * @param value Define the value to give to the uniform
  14545. * @return the texture itself allowing "fluent" like uniform updates
  14546. */
  14547. setVector3(name: string, value: Vector3): ProceduralTexture;
  14548. /**
  14549. * Set a mat4 in the shader from a MAtrix.
  14550. * @param name Define the name of the uniform as defined in the shader
  14551. * @param value Define the value to give to the uniform
  14552. * @return the texture itself allowing "fluent" like uniform updates
  14553. */
  14554. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14555. /**
  14556. * Render the texture to its associated render target.
  14557. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14558. */
  14559. render(useCameraPostProcess?: boolean): void;
  14560. /**
  14561. * Clone the texture.
  14562. * @returns the cloned texture
  14563. */
  14564. clone(): ProceduralTexture;
  14565. /**
  14566. * Dispose the texture and release its asoociated resources.
  14567. */
  14568. dispose(): void;
  14569. }
  14570. }
  14571. declare module "babylonjs/Particles/baseParticleSystem" {
  14572. import { Nullable } from "babylonjs/types";
  14573. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14575. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14576. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14577. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14578. import { Scene } from "babylonjs/scene";
  14579. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14580. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14581. import { Texture } from "babylonjs/Materials/Textures/texture";
  14582. import { Animation } from "babylonjs/Animations/animation";
  14583. /**
  14584. * This represents the base class for particle system in Babylon.
  14585. * 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.
  14586. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14587. * @example https://doc.babylonjs.com/babylon101/particles
  14588. */
  14589. export class BaseParticleSystem {
  14590. /**
  14591. * Source color is added to the destination color without alpha affecting the result
  14592. */
  14593. static BLENDMODE_ONEONE: number;
  14594. /**
  14595. * Blend current color and particle color using particle’s alpha
  14596. */
  14597. static BLENDMODE_STANDARD: number;
  14598. /**
  14599. * Add current color and particle color multiplied by particle’s alpha
  14600. */
  14601. static BLENDMODE_ADD: number;
  14602. /**
  14603. * Multiply current color with particle color
  14604. */
  14605. static BLENDMODE_MULTIPLY: number;
  14606. /**
  14607. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14608. */
  14609. static BLENDMODE_MULTIPLYADD: number;
  14610. /**
  14611. * List of animations used by the particle system.
  14612. */
  14613. animations: Animation[];
  14614. /**
  14615. * The id of the Particle system.
  14616. */
  14617. id: string;
  14618. /**
  14619. * The friendly name of the Particle system.
  14620. */
  14621. name: string;
  14622. /**
  14623. * The rendering group used by the Particle system to chose when to render.
  14624. */
  14625. renderingGroupId: number;
  14626. /**
  14627. * The emitter represents the Mesh or position we are attaching the particle system to.
  14628. */
  14629. emitter: Nullable<AbstractMesh | Vector3>;
  14630. /**
  14631. * The maximum number of particles to emit per frame
  14632. */
  14633. emitRate: number;
  14634. /**
  14635. * If you want to launch only a few particles at once, that can be done, as well.
  14636. */
  14637. manualEmitCount: number;
  14638. /**
  14639. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14640. */
  14641. updateSpeed: number;
  14642. /**
  14643. * The amount of time the particle system is running (depends of the overall update speed).
  14644. */
  14645. targetStopDuration: number;
  14646. /**
  14647. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14648. */
  14649. disposeOnStop: boolean;
  14650. /**
  14651. * Minimum power of emitting particles.
  14652. */
  14653. minEmitPower: number;
  14654. /**
  14655. * Maximum power of emitting particles.
  14656. */
  14657. maxEmitPower: number;
  14658. /**
  14659. * Minimum life time of emitting particles.
  14660. */
  14661. minLifeTime: number;
  14662. /**
  14663. * Maximum life time of emitting particles.
  14664. */
  14665. maxLifeTime: number;
  14666. /**
  14667. * Minimum Size of emitting particles.
  14668. */
  14669. minSize: number;
  14670. /**
  14671. * Maximum Size of emitting particles.
  14672. */
  14673. maxSize: number;
  14674. /**
  14675. * Minimum scale of emitting particles on X axis.
  14676. */
  14677. minScaleX: number;
  14678. /**
  14679. * Maximum scale of emitting particles on X axis.
  14680. */
  14681. maxScaleX: number;
  14682. /**
  14683. * Minimum scale of emitting particles on Y axis.
  14684. */
  14685. minScaleY: number;
  14686. /**
  14687. * Maximum scale of emitting particles on Y axis.
  14688. */
  14689. maxScaleY: number;
  14690. /**
  14691. * Gets or sets the minimal initial rotation in radians.
  14692. */
  14693. minInitialRotation: number;
  14694. /**
  14695. * Gets or sets the maximal initial rotation in radians.
  14696. */
  14697. maxInitialRotation: number;
  14698. /**
  14699. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14700. */
  14701. minAngularSpeed: number;
  14702. /**
  14703. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14704. */
  14705. maxAngularSpeed: number;
  14706. /**
  14707. * The texture used to render each particle. (this can be a spritesheet)
  14708. */
  14709. particleTexture: Nullable<Texture>;
  14710. /**
  14711. * The layer mask we are rendering the particles through.
  14712. */
  14713. layerMask: number;
  14714. /**
  14715. * This can help using your own shader to render the particle system.
  14716. * The according effect will be created
  14717. */
  14718. customShader: any;
  14719. /**
  14720. * By default particle system starts as soon as they are created. This prevents the
  14721. * automatic start to happen and let you decide when to start emitting particles.
  14722. */
  14723. preventAutoStart: boolean;
  14724. private _noiseTexture;
  14725. /**
  14726. * Gets or sets a texture used to add random noise to particle positions
  14727. */
  14728. noiseTexture: Nullable<ProceduralTexture>;
  14729. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14730. noiseStrength: Vector3;
  14731. /**
  14732. * Callback triggered when the particle animation is ending.
  14733. */
  14734. onAnimationEnd: Nullable<() => void>;
  14735. /**
  14736. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14737. */
  14738. blendMode: number;
  14739. /**
  14740. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14741. * to override the particles.
  14742. */
  14743. forceDepthWrite: boolean;
  14744. /** 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 */
  14745. preWarmCycles: number;
  14746. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14747. preWarmStepOffset: number;
  14748. /**
  14749. * 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)
  14750. */
  14751. spriteCellChangeSpeed: number;
  14752. /**
  14753. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14754. */
  14755. startSpriteCellID: number;
  14756. /**
  14757. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14758. */
  14759. endSpriteCellID: number;
  14760. /**
  14761. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14762. */
  14763. spriteCellWidth: number;
  14764. /**
  14765. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14766. */
  14767. spriteCellHeight: number;
  14768. /**
  14769. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14770. */
  14771. spriteRandomStartCell: boolean;
  14772. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14773. translationPivot: Vector2;
  14774. /** @hidden */
  14775. protected _isAnimationSheetEnabled: boolean;
  14776. /**
  14777. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14778. */
  14779. beginAnimationOnStart: boolean;
  14780. /**
  14781. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14782. */
  14783. beginAnimationFrom: number;
  14784. /**
  14785. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14786. */
  14787. beginAnimationTo: number;
  14788. /**
  14789. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14790. */
  14791. beginAnimationLoop: boolean;
  14792. /**
  14793. * Gets or sets a world offset applied to all particles
  14794. */
  14795. worldOffset: Vector3;
  14796. /**
  14797. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14798. */
  14799. isAnimationSheetEnabled: boolean;
  14800. /**
  14801. * Get hosting scene
  14802. * @returns the scene
  14803. */
  14804. getScene(): Scene;
  14805. /**
  14806. * You can use gravity if you want to give an orientation to your particles.
  14807. */
  14808. gravity: Vector3;
  14809. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14810. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14811. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14812. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14813. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14814. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14815. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14816. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14817. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14818. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14819. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14820. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14821. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14822. /**
  14823. * Defines the delay in milliseconds before starting the system (0 by default)
  14824. */
  14825. startDelay: number;
  14826. /**
  14827. * Gets the current list of drag gradients.
  14828. * You must use addDragGradient and removeDragGradient to udpate this list
  14829. * @returns the list of drag gradients
  14830. */
  14831. getDragGradients(): Nullable<Array<FactorGradient>>;
  14832. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14833. limitVelocityDamping: number;
  14834. /**
  14835. * Gets the current list of limit velocity gradients.
  14836. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14837. * @returns the list of limit velocity gradients
  14838. */
  14839. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14840. /**
  14841. * Gets the current list of color gradients.
  14842. * You must use addColorGradient and removeColorGradient to udpate this list
  14843. * @returns the list of color gradients
  14844. */
  14845. getColorGradients(): Nullable<Array<ColorGradient>>;
  14846. /**
  14847. * Gets the current list of size gradients.
  14848. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14849. * @returns the list of size gradients
  14850. */
  14851. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14852. /**
  14853. * Gets the current list of color remap gradients.
  14854. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14855. * @returns the list of color remap gradients
  14856. */
  14857. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14858. /**
  14859. * Gets the current list of alpha remap gradients.
  14860. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14861. * @returns the list of alpha remap gradients
  14862. */
  14863. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14864. /**
  14865. * Gets the current list of life time gradients.
  14866. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14867. * @returns the list of life time gradients
  14868. */
  14869. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14870. /**
  14871. * Gets the current list of angular speed gradients.
  14872. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14873. * @returns the list of angular speed gradients
  14874. */
  14875. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14876. /**
  14877. * Gets the current list of velocity gradients.
  14878. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14879. * @returns the list of velocity gradients
  14880. */
  14881. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14882. /**
  14883. * Gets the current list of start size gradients.
  14884. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14885. * @returns the list of start size gradients
  14886. */
  14887. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14888. /**
  14889. * Gets the current list of emit rate gradients.
  14890. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14891. * @returns the list of emit rate gradients
  14892. */
  14893. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14894. /**
  14895. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14896. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14897. */
  14898. direction1: Vector3;
  14899. /**
  14900. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14901. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14902. */
  14903. direction2: Vector3;
  14904. /**
  14905. * 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.
  14906. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14907. */
  14908. minEmitBox: Vector3;
  14909. /**
  14910. * 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.
  14911. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14912. */
  14913. maxEmitBox: Vector3;
  14914. /**
  14915. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14916. */
  14917. color1: Color4;
  14918. /**
  14919. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14920. */
  14921. color2: Color4;
  14922. /**
  14923. * Color the particle will have at the end of its lifetime
  14924. */
  14925. colorDead: Color4;
  14926. /**
  14927. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14928. */
  14929. textureMask: Color4;
  14930. /**
  14931. * The particle emitter type defines the emitter used by the particle system.
  14932. * It can be for example box, sphere, or cone...
  14933. */
  14934. particleEmitterType: IParticleEmitterType;
  14935. /** @hidden */
  14936. _isSubEmitter: boolean;
  14937. /**
  14938. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14939. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14940. */
  14941. billboardMode: number;
  14942. protected _isBillboardBased: boolean;
  14943. /**
  14944. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14945. */
  14946. isBillboardBased: boolean;
  14947. /**
  14948. * The scene the particle system belongs to.
  14949. */
  14950. protected _scene: Scene;
  14951. /**
  14952. * Local cache of defines for image processing.
  14953. */
  14954. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14955. /**
  14956. * Default configuration related to image processing available in the standard Material.
  14957. */
  14958. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14959. /**
  14960. * Gets the image processing configuration used either in this material.
  14961. */
  14962. /**
  14963. * Sets the Default image processing configuration used either in the this material.
  14964. *
  14965. * If sets to null, the scene one is in use.
  14966. */
  14967. imageProcessingConfiguration: ImageProcessingConfiguration;
  14968. /**
  14969. * Attaches a new image processing configuration to the Standard Material.
  14970. * @param configuration
  14971. */
  14972. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14973. /** @hidden */
  14974. protected _reset(): void;
  14975. /** @hidden */
  14976. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14977. /**
  14978. * Instantiates a particle system.
  14979. * 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.
  14980. * @param name The name of the particle system
  14981. */
  14982. constructor(name: string);
  14983. /**
  14984. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14985. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14986. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14987. * @returns the emitter
  14988. */
  14989. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14990. /**
  14991. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14992. * @param radius The radius of the hemisphere to emit from
  14993. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14994. * @returns the emitter
  14995. */
  14996. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14997. /**
  14998. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14999. * @param radius The radius of the sphere to emit from
  15000. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15001. * @returns the emitter
  15002. */
  15003. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  15004. /**
  15005. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15006. * @param radius The radius of the sphere to emit from
  15007. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15008. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15009. * @returns the emitter
  15010. */
  15011. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  15012. /**
  15013. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15014. * @param radius The radius of the emission cylinder
  15015. * @param height The height of the emission cylinder
  15016. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15017. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15018. * @returns the emitter
  15019. */
  15020. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  15021. /**
  15022. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15023. * @param radius The radius of the cylinder to emit from
  15024. * @param height The height of the emission cylinder
  15025. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15026. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15027. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15028. * @returns the emitter
  15029. */
  15030. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  15031. /**
  15032. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15033. * @param radius The radius of the cone to emit from
  15034. * @param angle The base angle of the cone
  15035. * @returns the emitter
  15036. */
  15037. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  15038. /**
  15039. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15040. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15041. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15042. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15043. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15044. * @returns the emitter
  15045. */
  15046. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15047. }
  15048. }
  15049. declare module "babylonjs/Particles/subEmitter" {
  15050. import { Scene } from "babylonjs/scene";
  15051. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15052. /**
  15053. * Type of sub emitter
  15054. */
  15055. export enum SubEmitterType {
  15056. /**
  15057. * Attached to the particle over it's lifetime
  15058. */
  15059. ATTACHED = 0,
  15060. /**
  15061. * Created when the particle dies
  15062. */
  15063. END = 1
  15064. }
  15065. /**
  15066. * Sub emitter class used to emit particles from an existing particle
  15067. */
  15068. export class SubEmitter {
  15069. /**
  15070. * the particle system to be used by the sub emitter
  15071. */
  15072. particleSystem: ParticleSystem;
  15073. /**
  15074. * Type of the submitter (Default: END)
  15075. */
  15076. type: SubEmitterType;
  15077. /**
  15078. * 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)
  15079. * Note: This only is supported when using an emitter of type Mesh
  15080. */
  15081. inheritDirection: boolean;
  15082. /**
  15083. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  15084. */
  15085. inheritedVelocityAmount: number;
  15086. /**
  15087. * Creates a sub emitter
  15088. * @param particleSystem the particle system to be used by the sub emitter
  15089. */
  15090. constructor(
  15091. /**
  15092. * the particle system to be used by the sub emitter
  15093. */
  15094. particleSystem: ParticleSystem);
  15095. /**
  15096. * Clones the sub emitter
  15097. * @returns the cloned sub emitter
  15098. */
  15099. clone(): SubEmitter;
  15100. /**
  15101. * Serialize current object to a JSON object
  15102. * @returns the serialized object
  15103. */
  15104. serialize(): any;
  15105. /** @hidden */
  15106. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  15107. /**
  15108. * Creates a new SubEmitter from a serialized JSON version
  15109. * @param serializationObject defines the JSON object to read from
  15110. * @param scene defines the hosting scene
  15111. * @param rootUrl defines the rootUrl for data loading
  15112. * @returns a new SubEmitter
  15113. */
  15114. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  15115. /** Release associated resources */
  15116. dispose(): void;
  15117. }
  15118. }
  15119. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  15120. /** @hidden */
  15121. export var clipPlaneFragmentDeclaration: {
  15122. name: string;
  15123. shader: string;
  15124. };
  15125. }
  15126. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  15127. /** @hidden */
  15128. export var imageProcessingDeclaration: {
  15129. name: string;
  15130. shader: string;
  15131. };
  15132. }
  15133. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  15134. /** @hidden */
  15135. export var imageProcessingFunctions: {
  15136. name: string;
  15137. shader: string;
  15138. };
  15139. }
  15140. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  15141. /** @hidden */
  15142. export var clipPlaneFragment: {
  15143. name: string;
  15144. shader: string;
  15145. };
  15146. }
  15147. declare module "babylonjs/Shaders/particles.fragment" {
  15148. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  15149. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  15150. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  15151. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  15152. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  15153. /** @hidden */
  15154. export var particlesPixelShader: {
  15155. name: string;
  15156. shader: string;
  15157. };
  15158. }
  15159. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  15160. /** @hidden */
  15161. export var clipPlaneVertexDeclaration: {
  15162. name: string;
  15163. shader: string;
  15164. };
  15165. }
  15166. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  15167. /** @hidden */
  15168. export var clipPlaneVertex: {
  15169. name: string;
  15170. shader: string;
  15171. };
  15172. }
  15173. declare module "babylonjs/Shaders/particles.vertex" {
  15174. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15175. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15176. /** @hidden */
  15177. export var particlesVertexShader: {
  15178. name: string;
  15179. shader: string;
  15180. };
  15181. }
  15182. declare module "babylonjs/Particles/particleSystem" {
  15183. import { Nullable } from "babylonjs/types";
  15184. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15185. import { Observable } from "babylonjs/Misc/observable";
  15186. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15187. import { Effect } from "babylonjs/Materials/effect";
  15188. import { Scene, IDisposable } from "babylonjs/scene";
  15189. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15190. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15191. import { Particle } from "babylonjs/Particles/particle";
  15192. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15193. import "babylonjs/Shaders/particles.fragment";
  15194. import "babylonjs/Shaders/particles.vertex";
  15195. /**
  15196. * This represents a particle system in Babylon.
  15197. * 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.
  15198. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15199. * @example https://doc.babylonjs.com/babylon101/particles
  15200. */
  15201. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15202. /**
  15203. * Billboard mode will only apply to Y axis
  15204. */
  15205. static readonly BILLBOARDMODE_Y: number;
  15206. /**
  15207. * Billboard mode will apply to all axes
  15208. */
  15209. static readonly BILLBOARDMODE_ALL: number;
  15210. /**
  15211. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15212. */
  15213. static readonly BILLBOARDMODE_STRETCHED: number;
  15214. /**
  15215. * This function can be defined to provide custom update for active particles.
  15216. * This function will be called instead of regular update (age, position, color, etc.).
  15217. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15218. */
  15219. updateFunction: (particles: Particle[]) => void;
  15220. private _emitterWorldMatrix;
  15221. /**
  15222. * This function can be defined to specify initial direction for every new particle.
  15223. * It by default use the emitterType defined function
  15224. */
  15225. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15226. /**
  15227. * This function can be defined to specify initial position for every new particle.
  15228. * It by default use the emitterType defined function
  15229. */
  15230. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15231. /**
  15232. * @hidden
  15233. */
  15234. _inheritedVelocityOffset: Vector3;
  15235. /**
  15236. * An event triggered when the system is disposed
  15237. */
  15238. onDisposeObservable: Observable<ParticleSystem>;
  15239. private _onDisposeObserver;
  15240. /**
  15241. * Sets a callback that will be triggered when the system is disposed
  15242. */
  15243. onDispose: () => void;
  15244. private _particles;
  15245. private _epsilon;
  15246. private _capacity;
  15247. private _stockParticles;
  15248. private _newPartsExcess;
  15249. private _vertexData;
  15250. private _vertexBuffer;
  15251. private _vertexBuffers;
  15252. private _spriteBuffer;
  15253. private _indexBuffer;
  15254. private _effect;
  15255. private _customEffect;
  15256. private _cachedDefines;
  15257. private _scaledColorStep;
  15258. private _colorDiff;
  15259. private _scaledDirection;
  15260. private _scaledGravity;
  15261. private _currentRenderId;
  15262. private _alive;
  15263. private _useInstancing;
  15264. private _started;
  15265. private _stopped;
  15266. private _actualFrame;
  15267. private _scaledUpdateSpeed;
  15268. private _vertexBufferSize;
  15269. /** @hidden */
  15270. _currentEmitRateGradient: Nullable<FactorGradient>;
  15271. /** @hidden */
  15272. _currentEmitRate1: number;
  15273. /** @hidden */
  15274. _currentEmitRate2: number;
  15275. /** @hidden */
  15276. _currentStartSizeGradient: Nullable<FactorGradient>;
  15277. /** @hidden */
  15278. _currentStartSize1: number;
  15279. /** @hidden */
  15280. _currentStartSize2: number;
  15281. private readonly _rawTextureWidth;
  15282. private _rampGradientsTexture;
  15283. private _useRampGradients;
  15284. /** Gets or sets a boolean indicating that ramp gradients must be used
  15285. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15286. */
  15287. useRampGradients: boolean;
  15288. /**
  15289. * 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.
  15290. * 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: [])
  15291. */
  15292. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15293. private _subEmitters;
  15294. /**
  15295. * @hidden
  15296. * If the particle systems emitter should be disposed when the particle system is disposed
  15297. */
  15298. _disposeEmitterOnDispose: boolean;
  15299. /**
  15300. * The current active Sub-systems, this property is used by the root particle system only.
  15301. */
  15302. activeSubSystems: Array<ParticleSystem>;
  15303. private _rootParticleSystem;
  15304. /**
  15305. * Gets the current list of active particles
  15306. */
  15307. readonly particles: Particle[];
  15308. /**
  15309. * Returns the string "ParticleSystem"
  15310. * @returns a string containing the class name
  15311. */
  15312. getClassName(): string;
  15313. /**
  15314. * Instantiates a particle system.
  15315. * 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.
  15316. * @param name The name of the particle system
  15317. * @param capacity The max number of particles alive at the same time
  15318. * @param scene The scene the particle system belongs to
  15319. * @param customEffect a custom effect used to change the way particles are rendered by default
  15320. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15321. * @param epsilon Offset used to render the particles
  15322. */
  15323. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15324. private _addFactorGradient;
  15325. private _removeFactorGradient;
  15326. /**
  15327. * Adds a new life time gradient
  15328. * @param gradient defines the gradient to use (between 0 and 1)
  15329. * @param factor defines the life time factor to affect to the specified gradient
  15330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15331. * @returns the current particle system
  15332. */
  15333. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15334. /**
  15335. * Remove a specific life time gradient
  15336. * @param gradient defines the gradient to remove
  15337. * @returns the current particle system
  15338. */
  15339. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15340. /**
  15341. * Adds a new size gradient
  15342. * @param gradient defines the gradient to use (between 0 and 1)
  15343. * @param factor defines the size factor to affect to the specified gradient
  15344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15345. * @returns the current particle system
  15346. */
  15347. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15348. /**
  15349. * Remove a specific size gradient
  15350. * @param gradient defines the gradient to remove
  15351. * @returns the current particle system
  15352. */
  15353. removeSizeGradient(gradient: number): IParticleSystem;
  15354. /**
  15355. * Adds a new color remap gradient
  15356. * @param gradient defines the gradient to use (between 0 and 1)
  15357. * @param min defines the color remap minimal range
  15358. * @param max defines the color remap maximal range
  15359. * @returns the current particle system
  15360. */
  15361. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15362. /**
  15363. * Remove a specific color remap gradient
  15364. * @param gradient defines the gradient to remove
  15365. * @returns the current particle system
  15366. */
  15367. removeColorRemapGradient(gradient: number): IParticleSystem;
  15368. /**
  15369. * Adds a new alpha remap gradient
  15370. * @param gradient defines the gradient to use (between 0 and 1)
  15371. * @param min defines the alpha remap minimal range
  15372. * @param max defines the alpha remap maximal range
  15373. * @returns the current particle system
  15374. */
  15375. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15376. /**
  15377. * Remove a specific alpha remap gradient
  15378. * @param gradient defines the gradient to remove
  15379. * @returns the current particle system
  15380. */
  15381. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15382. /**
  15383. * Adds a new angular speed gradient
  15384. * @param gradient defines the gradient to use (between 0 and 1)
  15385. * @param factor defines the angular speed to affect to the specified gradient
  15386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15387. * @returns the current particle system
  15388. */
  15389. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15390. /**
  15391. * Remove a specific angular speed gradient
  15392. * @param gradient defines the gradient to remove
  15393. * @returns the current particle system
  15394. */
  15395. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15396. /**
  15397. * Adds a new velocity gradient
  15398. * @param gradient defines the gradient to use (between 0 and 1)
  15399. * @param factor defines the velocity to affect to the specified gradient
  15400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15401. * @returns the current particle system
  15402. */
  15403. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15404. /**
  15405. * Remove a specific velocity gradient
  15406. * @param gradient defines the gradient to remove
  15407. * @returns the current particle system
  15408. */
  15409. removeVelocityGradient(gradient: number): IParticleSystem;
  15410. /**
  15411. * Adds a new limit velocity gradient
  15412. * @param gradient defines the gradient to use (between 0 and 1)
  15413. * @param factor defines the limit velocity value to affect to the specified gradient
  15414. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15415. * @returns the current particle system
  15416. */
  15417. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15418. /**
  15419. * Remove a specific limit velocity gradient
  15420. * @param gradient defines the gradient to remove
  15421. * @returns the current particle system
  15422. */
  15423. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15424. /**
  15425. * Adds a new drag gradient
  15426. * @param gradient defines the gradient to use (between 0 and 1)
  15427. * @param factor defines the drag value to affect to the specified gradient
  15428. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15429. * @returns the current particle system
  15430. */
  15431. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15432. /**
  15433. * Remove a specific drag gradient
  15434. * @param gradient defines the gradient to remove
  15435. * @returns the current particle system
  15436. */
  15437. removeDragGradient(gradient: number): IParticleSystem;
  15438. /**
  15439. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15440. * @param gradient defines the gradient to use (between 0 and 1)
  15441. * @param factor defines the emit rate value to affect to the specified gradient
  15442. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15443. * @returns the current particle system
  15444. */
  15445. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15446. /**
  15447. * Remove a specific emit rate gradient
  15448. * @param gradient defines the gradient to remove
  15449. * @returns the current particle system
  15450. */
  15451. removeEmitRateGradient(gradient: number): IParticleSystem;
  15452. /**
  15453. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15454. * @param gradient defines the gradient to use (between 0 and 1)
  15455. * @param factor defines the start size value to affect to the specified gradient
  15456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15457. * @returns the current particle system
  15458. */
  15459. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15460. /**
  15461. * Remove a specific start size gradient
  15462. * @param gradient defines the gradient to remove
  15463. * @returns the current particle system
  15464. */
  15465. removeStartSizeGradient(gradient: number): IParticleSystem;
  15466. private _createRampGradientTexture;
  15467. /**
  15468. * Gets the current list of ramp gradients.
  15469. * You must use addRampGradient and removeRampGradient to udpate this list
  15470. * @returns the list of ramp gradients
  15471. */
  15472. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15473. /**
  15474. * Adds a new ramp gradient used to remap particle colors
  15475. * @param gradient defines the gradient to use (between 0 and 1)
  15476. * @param color defines the color to affect to the specified gradient
  15477. * @returns the current particle system
  15478. */
  15479. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15480. /**
  15481. * Remove a specific ramp gradient
  15482. * @param gradient defines the gradient to remove
  15483. * @returns the current particle system
  15484. */
  15485. removeRampGradient(gradient: number): ParticleSystem;
  15486. /**
  15487. * Adds a new color gradient
  15488. * @param gradient defines the gradient to use (between 0 and 1)
  15489. * @param color1 defines the color to affect to the specified gradient
  15490. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15491. * @returns this particle system
  15492. */
  15493. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15494. /**
  15495. * Remove a specific color gradient
  15496. * @param gradient defines the gradient to remove
  15497. * @returns this particle system
  15498. */
  15499. removeColorGradient(gradient: number): IParticleSystem;
  15500. private _fetchR;
  15501. protected _reset(): void;
  15502. private _resetEffect;
  15503. private _createVertexBuffers;
  15504. private _createIndexBuffer;
  15505. /**
  15506. * Gets the maximum number of particles active at the same time.
  15507. * @returns The max number of active particles.
  15508. */
  15509. getCapacity(): number;
  15510. /**
  15511. * Gets whether there are still active particles in the system.
  15512. * @returns True if it is alive, otherwise false.
  15513. */
  15514. isAlive(): boolean;
  15515. /**
  15516. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15517. * @returns True if it has been started, otherwise false.
  15518. */
  15519. isStarted(): boolean;
  15520. private _prepareSubEmitterInternalArray;
  15521. /**
  15522. * Starts the particle system and begins to emit
  15523. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15524. */
  15525. start(delay?: number): void;
  15526. /**
  15527. * Stops the particle system.
  15528. * @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.
  15529. */
  15530. stop(stopSubEmitters?: boolean): void;
  15531. /**
  15532. * Remove all active particles
  15533. */
  15534. reset(): void;
  15535. /**
  15536. * @hidden (for internal use only)
  15537. */
  15538. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15539. /**
  15540. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15541. * Its lifetime will start back at 0.
  15542. */
  15543. recycleParticle: (particle: Particle) => void;
  15544. private _stopSubEmitters;
  15545. private _createParticle;
  15546. private _removeFromRoot;
  15547. private _emitFromParticle;
  15548. private _update;
  15549. /** @hidden */
  15550. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15551. /** @hidden */
  15552. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15553. /** @hidden */
  15554. private _getEffect;
  15555. /**
  15556. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15557. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15558. */
  15559. animate(preWarmOnly?: boolean): void;
  15560. private _appendParticleVertices;
  15561. /**
  15562. * Rebuilds the particle system.
  15563. */
  15564. rebuild(): void;
  15565. /**
  15566. * Is this system ready to be used/rendered
  15567. * @return true if the system is ready
  15568. */
  15569. isReady(): boolean;
  15570. private _render;
  15571. /**
  15572. * Renders the particle system in its current state.
  15573. * @returns the current number of particles
  15574. */
  15575. render(): number;
  15576. /**
  15577. * Disposes the particle system and free the associated resources
  15578. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15579. */
  15580. dispose(disposeTexture?: boolean): void;
  15581. /**
  15582. * Clones the particle system.
  15583. * @param name The name of the cloned object
  15584. * @param newEmitter The new emitter to use
  15585. * @returns the cloned particle system
  15586. */
  15587. clone(name: string, newEmitter: any): ParticleSystem;
  15588. /**
  15589. * Serializes the particle system to a JSON object.
  15590. * @returns the JSON object
  15591. */
  15592. serialize(): any;
  15593. /** @hidden */
  15594. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15595. /** @hidden */
  15596. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15597. /**
  15598. * Parses a JSON object to create a particle system.
  15599. * @param parsedParticleSystem The JSON object to parse
  15600. * @param scene The scene to create the particle system in
  15601. * @param rootUrl The root url to use to load external dependencies like texture
  15602. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15603. * @returns the Parsed particle system
  15604. */
  15605. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15606. }
  15607. }
  15608. declare module "babylonjs/Particles/particle" {
  15609. import { Nullable } from "babylonjs/types";
  15610. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15611. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15612. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15613. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15614. /**
  15615. * A particle represents one of the element emitted by a particle system.
  15616. * This is mainly define by its coordinates, direction, velocity and age.
  15617. */
  15618. export class Particle {
  15619. /**
  15620. * The particle system the particle belongs to.
  15621. */
  15622. particleSystem: ParticleSystem;
  15623. private static _Count;
  15624. /**
  15625. * Unique ID of the particle
  15626. */
  15627. id: number;
  15628. /**
  15629. * The world position of the particle in the scene.
  15630. */
  15631. position: Vector3;
  15632. /**
  15633. * The world direction of the particle in the scene.
  15634. */
  15635. direction: Vector3;
  15636. /**
  15637. * The color of the particle.
  15638. */
  15639. color: Color4;
  15640. /**
  15641. * The color change of the particle per step.
  15642. */
  15643. colorStep: Color4;
  15644. /**
  15645. * Defines how long will the life of the particle be.
  15646. */
  15647. lifeTime: number;
  15648. /**
  15649. * The current age of the particle.
  15650. */
  15651. age: number;
  15652. /**
  15653. * The current size of the particle.
  15654. */
  15655. size: number;
  15656. /**
  15657. * The current scale of the particle.
  15658. */
  15659. scale: Vector2;
  15660. /**
  15661. * The current angle of the particle.
  15662. */
  15663. angle: number;
  15664. /**
  15665. * Defines how fast is the angle changing.
  15666. */
  15667. angularSpeed: number;
  15668. /**
  15669. * Defines the cell index used by the particle to be rendered from a sprite.
  15670. */
  15671. cellIndex: number;
  15672. /**
  15673. * The information required to support color remapping
  15674. */
  15675. remapData: Vector4;
  15676. /** @hidden */
  15677. _randomCellOffset?: number;
  15678. /** @hidden */
  15679. _initialDirection: Nullable<Vector3>;
  15680. /** @hidden */
  15681. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15682. /** @hidden */
  15683. _initialStartSpriteCellID: number;
  15684. /** @hidden */
  15685. _initialEndSpriteCellID: number;
  15686. /** @hidden */
  15687. _currentColorGradient: Nullable<ColorGradient>;
  15688. /** @hidden */
  15689. _currentColor1: Color4;
  15690. /** @hidden */
  15691. _currentColor2: Color4;
  15692. /** @hidden */
  15693. _currentSizeGradient: Nullable<FactorGradient>;
  15694. /** @hidden */
  15695. _currentSize1: number;
  15696. /** @hidden */
  15697. _currentSize2: number;
  15698. /** @hidden */
  15699. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15700. /** @hidden */
  15701. _currentAngularSpeed1: number;
  15702. /** @hidden */
  15703. _currentAngularSpeed2: number;
  15704. /** @hidden */
  15705. _currentVelocityGradient: Nullable<FactorGradient>;
  15706. /** @hidden */
  15707. _currentVelocity1: number;
  15708. /** @hidden */
  15709. _currentVelocity2: number;
  15710. /** @hidden */
  15711. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15712. /** @hidden */
  15713. _currentLimitVelocity1: number;
  15714. /** @hidden */
  15715. _currentLimitVelocity2: number;
  15716. /** @hidden */
  15717. _currentDragGradient: Nullable<FactorGradient>;
  15718. /** @hidden */
  15719. _currentDrag1: number;
  15720. /** @hidden */
  15721. _currentDrag2: number;
  15722. /** @hidden */
  15723. _randomNoiseCoordinates1: Vector3;
  15724. /** @hidden */
  15725. _randomNoiseCoordinates2: Vector3;
  15726. /**
  15727. * Creates a new instance Particle
  15728. * @param particleSystem the particle system the particle belongs to
  15729. */
  15730. constructor(
  15731. /**
  15732. * The particle system the particle belongs to.
  15733. */
  15734. particleSystem: ParticleSystem);
  15735. private updateCellInfoFromSystem;
  15736. /**
  15737. * Defines how the sprite cell index is updated for the particle
  15738. */
  15739. updateCellIndex(): void;
  15740. /** @hidden */
  15741. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15742. /** @hidden */
  15743. _inheritParticleInfoToSubEmitters(): void;
  15744. /** @hidden */
  15745. _reset(): void;
  15746. /**
  15747. * Copy the properties of particle to another one.
  15748. * @param other the particle to copy the information to.
  15749. */
  15750. copyTo(other: Particle): void;
  15751. }
  15752. }
  15753. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15754. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15755. import { Effect } from "babylonjs/Materials/effect";
  15756. import { Particle } from "babylonjs/Particles/particle";
  15757. /**
  15758. * Particle emitter represents a volume emitting particles.
  15759. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15760. */
  15761. export interface IParticleEmitterType {
  15762. /**
  15763. * Called by the particle System when the direction is computed for the created particle.
  15764. * @param worldMatrix is the world matrix of the particle system
  15765. * @param directionToUpdate is the direction vector to update with the result
  15766. * @param particle is the particle we are computed the direction for
  15767. */
  15768. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15769. /**
  15770. * Called by the particle System when the position is computed for the created particle.
  15771. * @param worldMatrix is the world matrix of the particle system
  15772. * @param positionToUpdate is the position vector to update with the result
  15773. * @param particle is the particle we are computed the position for
  15774. */
  15775. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15776. /**
  15777. * Clones the current emitter and returns a copy of it
  15778. * @returns the new emitter
  15779. */
  15780. clone(): IParticleEmitterType;
  15781. /**
  15782. * Called by the GPUParticleSystem to setup the update shader
  15783. * @param effect defines the update shader
  15784. */
  15785. applyToShader(effect: Effect): void;
  15786. /**
  15787. * Returns a string to use to update the GPU particles update shader
  15788. * @returns the effect defines string
  15789. */
  15790. getEffectDefines(): string;
  15791. /**
  15792. * Returns a string representing the class name
  15793. * @returns a string containing the class name
  15794. */
  15795. getClassName(): string;
  15796. /**
  15797. * Serializes the particle system to a JSON object.
  15798. * @returns the JSON object
  15799. */
  15800. serialize(): any;
  15801. /**
  15802. * Parse properties from a JSON object
  15803. * @param serializationObject defines the JSON object
  15804. */
  15805. parse(serializationObject: any): void;
  15806. }
  15807. }
  15808. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15809. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15810. import { Effect } from "babylonjs/Materials/effect";
  15811. import { Particle } from "babylonjs/Particles/particle";
  15812. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15813. /**
  15814. * Particle emitter emitting particles from the inside of a box.
  15815. * It emits the particles randomly between 2 given directions.
  15816. */
  15817. export class BoxParticleEmitter implements IParticleEmitterType {
  15818. /**
  15819. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15820. */
  15821. direction1: Vector3;
  15822. /**
  15823. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15824. */
  15825. direction2: Vector3;
  15826. /**
  15827. * 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.
  15828. */
  15829. minEmitBox: Vector3;
  15830. /**
  15831. * 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.
  15832. */
  15833. maxEmitBox: Vector3;
  15834. /**
  15835. * Creates a new instance BoxParticleEmitter
  15836. */
  15837. constructor();
  15838. /**
  15839. * Called by the particle System when the direction is computed for the created particle.
  15840. * @param worldMatrix is the world matrix of the particle system
  15841. * @param directionToUpdate is the direction vector to update with the result
  15842. * @param particle is the particle we are computed the direction for
  15843. */
  15844. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15845. /**
  15846. * Called by the particle System when the position is computed for the created particle.
  15847. * @param worldMatrix is the world matrix of the particle system
  15848. * @param positionToUpdate is the position vector to update with the result
  15849. * @param particle is the particle we are computed the position for
  15850. */
  15851. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15852. /**
  15853. * Clones the current emitter and returns a copy of it
  15854. * @returns the new emitter
  15855. */
  15856. clone(): BoxParticleEmitter;
  15857. /**
  15858. * Called by the GPUParticleSystem to setup the update shader
  15859. * @param effect defines the update shader
  15860. */
  15861. applyToShader(effect: Effect): void;
  15862. /**
  15863. * Returns a string to use to update the GPU particles update shader
  15864. * @returns a string containng the defines string
  15865. */
  15866. getEffectDefines(): string;
  15867. /**
  15868. * Returns the string "BoxParticleEmitter"
  15869. * @returns a string containing the class name
  15870. */
  15871. getClassName(): string;
  15872. /**
  15873. * Serializes the particle system to a JSON object.
  15874. * @returns the JSON object
  15875. */
  15876. serialize(): any;
  15877. /**
  15878. * Parse properties from a JSON object
  15879. * @param serializationObject defines the JSON object
  15880. */
  15881. parse(serializationObject: any): void;
  15882. }
  15883. }
  15884. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15885. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15886. import { Effect } from "babylonjs/Materials/effect";
  15887. import { Particle } from "babylonjs/Particles/particle";
  15888. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15889. /**
  15890. * Particle emitter emitting particles from the inside of a cone.
  15891. * It emits the particles alongside the cone volume from the base to the particle.
  15892. * The emission direction might be randomized.
  15893. */
  15894. export class ConeParticleEmitter implements IParticleEmitterType {
  15895. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15896. directionRandomizer: number;
  15897. private _radius;
  15898. private _angle;
  15899. private _height;
  15900. /**
  15901. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15902. */
  15903. radiusRange: number;
  15904. /**
  15905. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15906. */
  15907. heightRange: number;
  15908. /**
  15909. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15910. */
  15911. emitFromSpawnPointOnly: boolean;
  15912. /**
  15913. * Gets or sets the radius of the emission cone
  15914. */
  15915. radius: number;
  15916. /**
  15917. * Gets or sets the angle of the emission cone
  15918. */
  15919. angle: number;
  15920. private _buildHeight;
  15921. /**
  15922. * Creates a new instance ConeParticleEmitter
  15923. * @param radius the radius of the emission cone (1 by default)
  15924. * @param angle the cone base angle (PI by default)
  15925. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15926. */
  15927. constructor(radius?: number, angle?: number,
  15928. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15929. directionRandomizer?: number);
  15930. /**
  15931. * Called by the particle System when the direction is computed for the created particle.
  15932. * @param worldMatrix is the world matrix of the particle system
  15933. * @param directionToUpdate is the direction vector to update with the result
  15934. * @param particle is the particle we are computed the direction for
  15935. */
  15936. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15937. /**
  15938. * Called by the particle System when the position is computed for the created particle.
  15939. * @param worldMatrix is the world matrix of the particle system
  15940. * @param positionToUpdate is the position vector to update with the result
  15941. * @param particle is the particle we are computed the position for
  15942. */
  15943. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15944. /**
  15945. * Clones the current emitter and returns a copy of it
  15946. * @returns the new emitter
  15947. */
  15948. clone(): ConeParticleEmitter;
  15949. /**
  15950. * Called by the GPUParticleSystem to setup the update shader
  15951. * @param effect defines the update shader
  15952. */
  15953. applyToShader(effect: Effect): void;
  15954. /**
  15955. * Returns a string to use to update the GPU particles update shader
  15956. * @returns a string containng the defines string
  15957. */
  15958. getEffectDefines(): string;
  15959. /**
  15960. * Returns the string "ConeParticleEmitter"
  15961. * @returns a string containing the class name
  15962. */
  15963. getClassName(): string;
  15964. /**
  15965. * Serializes the particle system to a JSON object.
  15966. * @returns the JSON object
  15967. */
  15968. serialize(): any;
  15969. /**
  15970. * Parse properties from a JSON object
  15971. * @param serializationObject defines the JSON object
  15972. */
  15973. parse(serializationObject: any): void;
  15974. }
  15975. }
  15976. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15977. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15978. import { Effect } from "babylonjs/Materials/effect";
  15979. import { Particle } from "babylonjs/Particles/particle";
  15980. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15981. /**
  15982. * Particle emitter emitting particles from the inside of a cylinder.
  15983. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15984. */
  15985. export class CylinderParticleEmitter implements IParticleEmitterType {
  15986. /**
  15987. * The radius of the emission cylinder.
  15988. */
  15989. radius: number;
  15990. /**
  15991. * The height of the emission cylinder.
  15992. */
  15993. height: number;
  15994. /**
  15995. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15996. */
  15997. radiusRange: number;
  15998. /**
  15999. * How much to randomize the particle direction [0-1].
  16000. */
  16001. directionRandomizer: number;
  16002. /**
  16003. * Creates a new instance CylinderParticleEmitter
  16004. * @param radius the radius of the emission cylinder (1 by default)
  16005. * @param height the height of the emission cylinder (1 by default)
  16006. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16007. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16008. */
  16009. constructor(
  16010. /**
  16011. * The radius of the emission cylinder.
  16012. */
  16013. radius?: number,
  16014. /**
  16015. * The height of the emission cylinder.
  16016. */
  16017. height?: number,
  16018. /**
  16019. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16020. */
  16021. radiusRange?: number,
  16022. /**
  16023. * How much to randomize the particle direction [0-1].
  16024. */
  16025. directionRandomizer?: number);
  16026. /**
  16027. * Called by the particle System when the direction is computed for the created particle.
  16028. * @param worldMatrix is the world matrix of the particle system
  16029. * @param directionToUpdate is the direction vector to update with the result
  16030. * @param particle is the particle we are computed the direction for
  16031. */
  16032. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16033. /**
  16034. * Called by the particle System when the position is computed for the created particle.
  16035. * @param worldMatrix is the world matrix of the particle system
  16036. * @param positionToUpdate is the position vector to update with the result
  16037. * @param particle is the particle we are computed the position for
  16038. */
  16039. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16040. /**
  16041. * Clones the current emitter and returns a copy of it
  16042. * @returns the new emitter
  16043. */
  16044. clone(): CylinderParticleEmitter;
  16045. /**
  16046. * Called by the GPUParticleSystem to setup the update shader
  16047. * @param effect defines the update shader
  16048. */
  16049. applyToShader(effect: Effect): void;
  16050. /**
  16051. * Returns a string to use to update the GPU particles update shader
  16052. * @returns a string containng the defines string
  16053. */
  16054. getEffectDefines(): string;
  16055. /**
  16056. * Returns the string "CylinderParticleEmitter"
  16057. * @returns a string containing the class name
  16058. */
  16059. getClassName(): string;
  16060. /**
  16061. * Serializes the particle system to a JSON object.
  16062. * @returns the JSON object
  16063. */
  16064. serialize(): any;
  16065. /**
  16066. * Parse properties from a JSON object
  16067. * @param serializationObject defines the JSON object
  16068. */
  16069. parse(serializationObject: any): void;
  16070. }
  16071. /**
  16072. * Particle emitter emitting particles from the inside of a cylinder.
  16073. * It emits the particles randomly between two vectors.
  16074. */
  16075. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  16076. /**
  16077. * The min limit of the emission direction.
  16078. */
  16079. direction1: Vector3;
  16080. /**
  16081. * The max limit of the emission direction.
  16082. */
  16083. direction2: Vector3;
  16084. /**
  16085. * Creates a new instance CylinderDirectedParticleEmitter
  16086. * @param radius the radius of the emission cylinder (1 by default)
  16087. * @param height the height of the emission cylinder (1 by default)
  16088. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16089. * @param direction1 the min limit of the emission direction (up vector by default)
  16090. * @param direction2 the max limit of the emission direction (up vector by default)
  16091. */
  16092. constructor(radius?: number, height?: number, radiusRange?: number,
  16093. /**
  16094. * The min limit of the emission direction.
  16095. */
  16096. direction1?: Vector3,
  16097. /**
  16098. * The max limit of the emission direction.
  16099. */
  16100. direction2?: Vector3);
  16101. /**
  16102. * Called by the particle System when the direction is computed for the created particle.
  16103. * @param worldMatrix is the world matrix of the particle system
  16104. * @param directionToUpdate is the direction vector to update with the result
  16105. * @param particle is the particle we are computed the direction for
  16106. */
  16107. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16108. /**
  16109. * Clones the current emitter and returns a copy of it
  16110. * @returns the new emitter
  16111. */
  16112. clone(): CylinderDirectedParticleEmitter;
  16113. /**
  16114. * Called by the GPUParticleSystem to setup the update shader
  16115. * @param effect defines the update shader
  16116. */
  16117. applyToShader(effect: Effect): void;
  16118. /**
  16119. * Returns a string to use to update the GPU particles update shader
  16120. * @returns a string containng the defines string
  16121. */
  16122. getEffectDefines(): string;
  16123. /**
  16124. * Returns the string "CylinderDirectedParticleEmitter"
  16125. * @returns a string containing the class name
  16126. */
  16127. getClassName(): string;
  16128. /**
  16129. * Serializes the particle system to a JSON object.
  16130. * @returns the JSON object
  16131. */
  16132. serialize(): any;
  16133. /**
  16134. * Parse properties from a JSON object
  16135. * @param serializationObject defines the JSON object
  16136. */
  16137. parse(serializationObject: any): void;
  16138. }
  16139. }
  16140. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  16141. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16142. import { Effect } from "babylonjs/Materials/effect";
  16143. import { Particle } from "babylonjs/Particles/particle";
  16144. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16145. /**
  16146. * Particle emitter emitting particles from the inside of a hemisphere.
  16147. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  16148. */
  16149. export class HemisphericParticleEmitter implements IParticleEmitterType {
  16150. /**
  16151. * The radius of the emission hemisphere.
  16152. */
  16153. radius: number;
  16154. /**
  16155. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16156. */
  16157. radiusRange: number;
  16158. /**
  16159. * How much to randomize the particle direction [0-1].
  16160. */
  16161. directionRandomizer: number;
  16162. /**
  16163. * Creates a new instance HemisphericParticleEmitter
  16164. * @param radius the radius of the emission hemisphere (1 by default)
  16165. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16166. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16167. */
  16168. constructor(
  16169. /**
  16170. * The radius of the emission hemisphere.
  16171. */
  16172. radius?: number,
  16173. /**
  16174. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16175. */
  16176. radiusRange?: number,
  16177. /**
  16178. * How much to randomize the particle direction [0-1].
  16179. */
  16180. directionRandomizer?: number);
  16181. /**
  16182. * Called by the particle System when the direction is computed for the created particle.
  16183. * @param worldMatrix is the world matrix of the particle system
  16184. * @param directionToUpdate is the direction vector to update with the result
  16185. * @param particle is the particle we are computed the direction for
  16186. */
  16187. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16188. /**
  16189. * Called by the particle System when the position is computed for the created particle.
  16190. * @param worldMatrix is the world matrix of the particle system
  16191. * @param positionToUpdate is the position vector to update with the result
  16192. * @param particle is the particle we are computed the position for
  16193. */
  16194. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16195. /**
  16196. * Clones the current emitter and returns a copy of it
  16197. * @returns the new emitter
  16198. */
  16199. clone(): HemisphericParticleEmitter;
  16200. /**
  16201. * Called by the GPUParticleSystem to setup the update shader
  16202. * @param effect defines the update shader
  16203. */
  16204. applyToShader(effect: Effect): void;
  16205. /**
  16206. * Returns a string to use to update the GPU particles update shader
  16207. * @returns a string containng the defines string
  16208. */
  16209. getEffectDefines(): string;
  16210. /**
  16211. * Returns the string "HemisphericParticleEmitter"
  16212. * @returns a string containing the class name
  16213. */
  16214. getClassName(): string;
  16215. /**
  16216. * Serializes the particle system to a JSON object.
  16217. * @returns the JSON object
  16218. */
  16219. serialize(): any;
  16220. /**
  16221. * Parse properties from a JSON object
  16222. * @param serializationObject defines the JSON object
  16223. */
  16224. parse(serializationObject: any): void;
  16225. }
  16226. }
  16227. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16228. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16229. import { Effect } from "babylonjs/Materials/effect";
  16230. import { Particle } from "babylonjs/Particles/particle";
  16231. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16232. /**
  16233. * Particle emitter emitting particles from a point.
  16234. * It emits the particles randomly between 2 given directions.
  16235. */
  16236. export class PointParticleEmitter implements IParticleEmitterType {
  16237. /**
  16238. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16239. */
  16240. direction1: Vector3;
  16241. /**
  16242. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16243. */
  16244. direction2: Vector3;
  16245. /**
  16246. * Creates a new instance PointParticleEmitter
  16247. */
  16248. constructor();
  16249. /**
  16250. * Called by the particle System when the direction is computed for the created particle.
  16251. * @param worldMatrix is the world matrix of the particle system
  16252. * @param directionToUpdate is the direction vector to update with the result
  16253. * @param particle is the particle we are computed the direction for
  16254. */
  16255. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16256. /**
  16257. * Called by the particle System when the position is computed for the created particle.
  16258. * @param worldMatrix is the world matrix of the particle system
  16259. * @param positionToUpdate is the position vector to update with the result
  16260. * @param particle is the particle we are computed the position for
  16261. */
  16262. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16263. /**
  16264. * Clones the current emitter and returns a copy of it
  16265. * @returns the new emitter
  16266. */
  16267. clone(): PointParticleEmitter;
  16268. /**
  16269. * Called by the GPUParticleSystem to setup the update shader
  16270. * @param effect defines the update shader
  16271. */
  16272. applyToShader(effect: Effect): void;
  16273. /**
  16274. * Returns a string to use to update the GPU particles update shader
  16275. * @returns a string containng the defines string
  16276. */
  16277. getEffectDefines(): string;
  16278. /**
  16279. * Returns the string "PointParticleEmitter"
  16280. * @returns a string containing the class name
  16281. */
  16282. getClassName(): string;
  16283. /**
  16284. * Serializes the particle system to a JSON object.
  16285. * @returns the JSON object
  16286. */
  16287. serialize(): any;
  16288. /**
  16289. * Parse properties from a JSON object
  16290. * @param serializationObject defines the JSON object
  16291. */
  16292. parse(serializationObject: any): void;
  16293. }
  16294. }
  16295. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16296. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16297. import { Effect } from "babylonjs/Materials/effect";
  16298. import { Particle } from "babylonjs/Particles/particle";
  16299. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16300. /**
  16301. * Particle emitter emitting particles from the inside of a sphere.
  16302. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16303. */
  16304. export class SphereParticleEmitter implements IParticleEmitterType {
  16305. /**
  16306. * The radius of the emission sphere.
  16307. */
  16308. radius: number;
  16309. /**
  16310. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16311. */
  16312. radiusRange: number;
  16313. /**
  16314. * How much to randomize the particle direction [0-1].
  16315. */
  16316. directionRandomizer: number;
  16317. /**
  16318. * Creates a new instance SphereParticleEmitter
  16319. * @param radius the radius of the emission sphere (1 by default)
  16320. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16321. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16322. */
  16323. constructor(
  16324. /**
  16325. * The radius of the emission sphere.
  16326. */
  16327. radius?: number,
  16328. /**
  16329. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16330. */
  16331. radiusRange?: number,
  16332. /**
  16333. * How much to randomize the particle direction [0-1].
  16334. */
  16335. directionRandomizer?: number);
  16336. /**
  16337. * Called by the particle System when the direction is computed for the created particle.
  16338. * @param worldMatrix is the world matrix of the particle system
  16339. * @param directionToUpdate is the direction vector to update with the result
  16340. * @param particle is the particle we are computed the direction for
  16341. */
  16342. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16343. /**
  16344. * Called by the particle System when the position is computed for the created particle.
  16345. * @param worldMatrix is the world matrix of the particle system
  16346. * @param positionToUpdate is the position vector to update with the result
  16347. * @param particle is the particle we are computed the position for
  16348. */
  16349. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16350. /**
  16351. * Clones the current emitter and returns a copy of it
  16352. * @returns the new emitter
  16353. */
  16354. clone(): SphereParticleEmitter;
  16355. /**
  16356. * Called by the GPUParticleSystem to setup the update shader
  16357. * @param effect defines the update shader
  16358. */
  16359. applyToShader(effect: Effect): void;
  16360. /**
  16361. * Returns a string to use to update the GPU particles update shader
  16362. * @returns a string containng the defines string
  16363. */
  16364. getEffectDefines(): string;
  16365. /**
  16366. * Returns the string "SphereParticleEmitter"
  16367. * @returns a string containing the class name
  16368. */
  16369. getClassName(): string;
  16370. /**
  16371. * Serializes the particle system to a JSON object.
  16372. * @returns the JSON object
  16373. */
  16374. serialize(): any;
  16375. /**
  16376. * Parse properties from a JSON object
  16377. * @param serializationObject defines the JSON object
  16378. */
  16379. parse(serializationObject: any): void;
  16380. }
  16381. /**
  16382. * Particle emitter emitting particles from the inside of a sphere.
  16383. * It emits the particles randomly between two vectors.
  16384. */
  16385. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16386. /**
  16387. * The min limit of the emission direction.
  16388. */
  16389. direction1: Vector3;
  16390. /**
  16391. * The max limit of the emission direction.
  16392. */
  16393. direction2: Vector3;
  16394. /**
  16395. * Creates a new instance SphereDirectedParticleEmitter
  16396. * @param radius the radius of the emission sphere (1 by default)
  16397. * @param direction1 the min limit of the emission direction (up vector by default)
  16398. * @param direction2 the max limit of the emission direction (up vector by default)
  16399. */
  16400. constructor(radius?: number,
  16401. /**
  16402. * The min limit of the emission direction.
  16403. */
  16404. direction1?: Vector3,
  16405. /**
  16406. * The max limit of the emission direction.
  16407. */
  16408. direction2?: Vector3);
  16409. /**
  16410. * Called by the particle System when the direction is computed for the created particle.
  16411. * @param worldMatrix is the world matrix of the particle system
  16412. * @param directionToUpdate is the direction vector to update with the result
  16413. * @param particle is the particle we are computed the direction for
  16414. */
  16415. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16416. /**
  16417. * Clones the current emitter and returns a copy of it
  16418. * @returns the new emitter
  16419. */
  16420. clone(): SphereDirectedParticleEmitter;
  16421. /**
  16422. * Called by the GPUParticleSystem to setup the update shader
  16423. * @param effect defines the update shader
  16424. */
  16425. applyToShader(effect: Effect): void;
  16426. /**
  16427. * Returns a string to use to update the GPU particles update shader
  16428. * @returns a string containng the defines string
  16429. */
  16430. getEffectDefines(): string;
  16431. /**
  16432. * Returns the string "SphereDirectedParticleEmitter"
  16433. * @returns a string containing the class name
  16434. */
  16435. getClassName(): string;
  16436. /**
  16437. * Serializes the particle system to a JSON object.
  16438. * @returns the JSON object
  16439. */
  16440. serialize(): any;
  16441. /**
  16442. * Parse properties from a JSON object
  16443. * @param serializationObject defines the JSON object
  16444. */
  16445. parse(serializationObject: any): void;
  16446. }
  16447. }
  16448. declare module "babylonjs/Particles/EmitterTypes/index" {
  16449. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16450. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16451. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16452. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16453. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16454. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16455. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16456. }
  16457. declare module "babylonjs/Particles/IParticleSystem" {
  16458. import { Nullable } from "babylonjs/types";
  16459. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16460. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16461. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16462. import { Texture } from "babylonjs/Materials/Textures/texture";
  16463. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16464. import { Scene } from "babylonjs/scene";
  16465. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16466. import { Animation } from "babylonjs/Animations/animation";
  16467. /**
  16468. * Interface representing a particle system in Babylon.js.
  16469. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16470. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16471. */
  16472. export interface IParticleSystem {
  16473. /**
  16474. * List of animations used by the particle system.
  16475. */
  16476. animations: Animation[];
  16477. /**
  16478. * The id of the Particle system.
  16479. */
  16480. id: string;
  16481. /**
  16482. * The name of the Particle system.
  16483. */
  16484. name: string;
  16485. /**
  16486. * The emitter represents the Mesh or position we are attaching the particle system to.
  16487. */
  16488. emitter: Nullable<AbstractMesh | Vector3>;
  16489. /**
  16490. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16491. */
  16492. isBillboardBased: boolean;
  16493. /**
  16494. * The rendering group used by the Particle system to chose when to render.
  16495. */
  16496. renderingGroupId: number;
  16497. /**
  16498. * The layer mask we are rendering the particles through.
  16499. */
  16500. layerMask: number;
  16501. /**
  16502. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16503. */
  16504. updateSpeed: number;
  16505. /**
  16506. * The amount of time the particle system is running (depends of the overall update speed).
  16507. */
  16508. targetStopDuration: number;
  16509. /**
  16510. * The texture used to render each particle. (this can be a spritesheet)
  16511. */
  16512. particleTexture: Nullable<Texture>;
  16513. /**
  16514. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16515. */
  16516. blendMode: number;
  16517. /**
  16518. * Minimum life time of emitting particles.
  16519. */
  16520. minLifeTime: number;
  16521. /**
  16522. * Maximum life time of emitting particles.
  16523. */
  16524. maxLifeTime: number;
  16525. /**
  16526. * Minimum Size of emitting particles.
  16527. */
  16528. minSize: number;
  16529. /**
  16530. * Maximum Size of emitting particles.
  16531. */
  16532. maxSize: number;
  16533. /**
  16534. * Minimum scale of emitting particles on X axis.
  16535. */
  16536. minScaleX: number;
  16537. /**
  16538. * Maximum scale of emitting particles on X axis.
  16539. */
  16540. maxScaleX: number;
  16541. /**
  16542. * Minimum scale of emitting particles on Y axis.
  16543. */
  16544. minScaleY: number;
  16545. /**
  16546. * Maximum scale of emitting particles on Y axis.
  16547. */
  16548. maxScaleY: number;
  16549. /**
  16550. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16551. */
  16552. color1: Color4;
  16553. /**
  16554. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16555. */
  16556. color2: Color4;
  16557. /**
  16558. * Color the particle will have at the end of its lifetime.
  16559. */
  16560. colorDead: Color4;
  16561. /**
  16562. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16563. */
  16564. emitRate: number;
  16565. /**
  16566. * You can use gravity if you want to give an orientation to your particles.
  16567. */
  16568. gravity: Vector3;
  16569. /**
  16570. * Minimum power of emitting particles.
  16571. */
  16572. minEmitPower: number;
  16573. /**
  16574. * Maximum power of emitting particles.
  16575. */
  16576. maxEmitPower: number;
  16577. /**
  16578. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16579. */
  16580. minAngularSpeed: number;
  16581. /**
  16582. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16583. */
  16584. maxAngularSpeed: number;
  16585. /**
  16586. * Gets or sets the minimal initial rotation in radians.
  16587. */
  16588. minInitialRotation: number;
  16589. /**
  16590. * Gets or sets the maximal initial rotation in radians.
  16591. */
  16592. maxInitialRotation: number;
  16593. /**
  16594. * The particle emitter type defines the emitter used by the particle system.
  16595. * It can be for example box, sphere, or cone...
  16596. */
  16597. particleEmitterType: Nullable<IParticleEmitterType>;
  16598. /**
  16599. * Defines the delay in milliseconds before starting the system (0 by default)
  16600. */
  16601. startDelay: number;
  16602. /**
  16603. * 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
  16604. */
  16605. preWarmCycles: number;
  16606. /**
  16607. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16608. */
  16609. preWarmStepOffset: number;
  16610. /**
  16611. * 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)
  16612. */
  16613. spriteCellChangeSpeed: number;
  16614. /**
  16615. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16616. */
  16617. startSpriteCellID: number;
  16618. /**
  16619. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16620. */
  16621. endSpriteCellID: number;
  16622. /**
  16623. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16624. */
  16625. spriteCellWidth: number;
  16626. /**
  16627. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16628. */
  16629. spriteCellHeight: number;
  16630. /**
  16631. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16632. */
  16633. spriteRandomStartCell: boolean;
  16634. /**
  16635. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16636. */
  16637. isAnimationSheetEnabled: boolean;
  16638. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16639. translationPivot: Vector2;
  16640. /**
  16641. * Gets or sets a texture used to add random noise to particle positions
  16642. */
  16643. noiseTexture: Nullable<BaseTexture>;
  16644. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16645. noiseStrength: Vector3;
  16646. /**
  16647. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16648. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16649. */
  16650. billboardMode: number;
  16651. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16652. limitVelocityDamping: number;
  16653. /**
  16654. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16655. */
  16656. beginAnimationOnStart: boolean;
  16657. /**
  16658. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16659. */
  16660. beginAnimationFrom: number;
  16661. /**
  16662. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16663. */
  16664. beginAnimationTo: number;
  16665. /**
  16666. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16667. */
  16668. beginAnimationLoop: boolean;
  16669. /**
  16670. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16671. */
  16672. disposeOnStop: boolean;
  16673. /**
  16674. * Gets the maximum number of particles active at the same time.
  16675. * @returns The max number of active particles.
  16676. */
  16677. getCapacity(): number;
  16678. /**
  16679. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16680. * @returns True if it has been started, otherwise false.
  16681. */
  16682. isStarted(): boolean;
  16683. /**
  16684. * Animates the particle system for this frame.
  16685. */
  16686. animate(): void;
  16687. /**
  16688. * Renders the particle system in its current state.
  16689. * @returns the current number of particles
  16690. */
  16691. render(): number;
  16692. /**
  16693. * Dispose the particle system and frees its associated resources.
  16694. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16695. */
  16696. dispose(disposeTexture?: boolean): void;
  16697. /**
  16698. * Clones the particle system.
  16699. * @param name The name of the cloned object
  16700. * @param newEmitter The new emitter to use
  16701. * @returns the cloned particle system
  16702. */
  16703. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16704. /**
  16705. * Serializes the particle system to a JSON object.
  16706. * @returns the JSON object
  16707. */
  16708. serialize(): any;
  16709. /**
  16710. * Rebuild the particle system
  16711. */
  16712. rebuild(): void;
  16713. /**
  16714. * Starts the particle system and begins to emit
  16715. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16716. */
  16717. start(delay?: number): void;
  16718. /**
  16719. * Stops the particle system.
  16720. */
  16721. stop(): void;
  16722. /**
  16723. * Remove all active particles
  16724. */
  16725. reset(): void;
  16726. /**
  16727. * Is this system ready to be used/rendered
  16728. * @return true if the system is ready
  16729. */
  16730. isReady(): boolean;
  16731. /**
  16732. * Adds a new color gradient
  16733. * @param gradient defines the gradient to use (between 0 and 1)
  16734. * @param color1 defines the color to affect to the specified gradient
  16735. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16736. * @returns the current particle system
  16737. */
  16738. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16739. /**
  16740. * Remove a specific color gradient
  16741. * @param gradient defines the gradient to remove
  16742. * @returns the current particle system
  16743. */
  16744. removeColorGradient(gradient: number): IParticleSystem;
  16745. /**
  16746. * Adds a new size gradient
  16747. * @param gradient defines the gradient to use (between 0 and 1)
  16748. * @param factor defines the size factor to affect to the specified gradient
  16749. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16750. * @returns the current particle system
  16751. */
  16752. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16753. /**
  16754. * Remove a specific size gradient
  16755. * @param gradient defines the gradient to remove
  16756. * @returns the current particle system
  16757. */
  16758. removeSizeGradient(gradient: number): IParticleSystem;
  16759. /**
  16760. * Gets the current list of color gradients.
  16761. * You must use addColorGradient and removeColorGradient to udpate this list
  16762. * @returns the list of color gradients
  16763. */
  16764. getColorGradients(): Nullable<Array<ColorGradient>>;
  16765. /**
  16766. * Gets the current list of size gradients.
  16767. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16768. * @returns the list of size gradients
  16769. */
  16770. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16771. /**
  16772. * Gets the current list of angular speed gradients.
  16773. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16774. * @returns the list of angular speed gradients
  16775. */
  16776. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16777. /**
  16778. * Adds a new angular speed gradient
  16779. * @param gradient defines the gradient to use (between 0 and 1)
  16780. * @param factor defines the angular speed to affect to the specified gradient
  16781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16782. * @returns the current particle system
  16783. */
  16784. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16785. /**
  16786. * Remove a specific angular speed gradient
  16787. * @param gradient defines the gradient to remove
  16788. * @returns the current particle system
  16789. */
  16790. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16791. /**
  16792. * Gets the current list of velocity gradients.
  16793. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16794. * @returns the list of velocity gradients
  16795. */
  16796. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16797. /**
  16798. * Adds a new velocity gradient
  16799. * @param gradient defines the gradient to use (between 0 and 1)
  16800. * @param factor defines the velocity to affect to the specified gradient
  16801. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16802. * @returns the current particle system
  16803. */
  16804. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16805. /**
  16806. * Remove a specific velocity gradient
  16807. * @param gradient defines the gradient to remove
  16808. * @returns the current particle system
  16809. */
  16810. removeVelocityGradient(gradient: number): IParticleSystem;
  16811. /**
  16812. * Gets the current list of limit velocity gradients.
  16813. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16814. * @returns the list of limit velocity gradients
  16815. */
  16816. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16817. /**
  16818. * Adds a new limit velocity gradient
  16819. * @param gradient defines the gradient to use (between 0 and 1)
  16820. * @param factor defines the limit velocity to affect to the specified gradient
  16821. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16822. * @returns the current particle system
  16823. */
  16824. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16825. /**
  16826. * Remove a specific limit velocity gradient
  16827. * @param gradient defines the gradient to remove
  16828. * @returns the current particle system
  16829. */
  16830. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16831. /**
  16832. * Adds a new drag gradient
  16833. * @param gradient defines the gradient to use (between 0 and 1)
  16834. * @param factor defines the drag to affect to the specified gradient
  16835. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16836. * @returns the current particle system
  16837. */
  16838. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16839. /**
  16840. * Remove a specific drag gradient
  16841. * @param gradient defines the gradient to remove
  16842. * @returns the current particle system
  16843. */
  16844. removeDragGradient(gradient: number): IParticleSystem;
  16845. /**
  16846. * Gets the current list of drag gradients.
  16847. * You must use addDragGradient and removeDragGradient to udpate this list
  16848. * @returns the list of drag gradients
  16849. */
  16850. getDragGradients(): Nullable<Array<FactorGradient>>;
  16851. /**
  16852. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16853. * @param gradient defines the gradient to use (between 0 and 1)
  16854. * @param factor defines the emit rate to affect to the specified gradient
  16855. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16856. * @returns the current particle system
  16857. */
  16858. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16859. /**
  16860. * Remove a specific emit rate gradient
  16861. * @param gradient defines the gradient to remove
  16862. * @returns the current particle system
  16863. */
  16864. removeEmitRateGradient(gradient: number): IParticleSystem;
  16865. /**
  16866. * Gets the current list of emit rate gradients.
  16867. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16868. * @returns the list of emit rate gradients
  16869. */
  16870. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16871. /**
  16872. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16873. * @param gradient defines the gradient to use (between 0 and 1)
  16874. * @param factor defines the start size to affect to the specified gradient
  16875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16876. * @returns the current particle system
  16877. */
  16878. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16879. /**
  16880. * Remove a specific start size gradient
  16881. * @param gradient defines the gradient to remove
  16882. * @returns the current particle system
  16883. */
  16884. removeStartSizeGradient(gradient: number): IParticleSystem;
  16885. /**
  16886. * Gets the current list of start size gradients.
  16887. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16888. * @returns the list of start size gradients
  16889. */
  16890. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16891. /**
  16892. * Adds a new life time gradient
  16893. * @param gradient defines the gradient to use (between 0 and 1)
  16894. * @param factor defines the life time factor to affect to the specified gradient
  16895. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16896. * @returns the current particle system
  16897. */
  16898. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16899. /**
  16900. * Remove a specific life time gradient
  16901. * @param gradient defines the gradient to remove
  16902. * @returns the current particle system
  16903. */
  16904. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16905. /**
  16906. * Gets the current list of life time gradients.
  16907. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16908. * @returns the list of life time gradients
  16909. */
  16910. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16911. /**
  16912. * Gets the current list of color gradients.
  16913. * You must use addColorGradient and removeColorGradient to udpate this list
  16914. * @returns the list of color gradients
  16915. */
  16916. getColorGradients(): Nullable<Array<ColorGradient>>;
  16917. /**
  16918. * Adds a new ramp gradient used to remap particle colors
  16919. * @param gradient defines the gradient to use (between 0 and 1)
  16920. * @param color defines the color to affect to the specified gradient
  16921. * @returns the current particle system
  16922. */
  16923. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16924. /**
  16925. * Gets the current list of ramp gradients.
  16926. * You must use addRampGradient and removeRampGradient to udpate this list
  16927. * @returns the list of ramp gradients
  16928. */
  16929. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16930. /** Gets or sets a boolean indicating that ramp gradients must be used
  16931. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16932. */
  16933. useRampGradients: boolean;
  16934. /**
  16935. * Adds a new color remap gradient
  16936. * @param gradient defines the gradient to use (between 0 and 1)
  16937. * @param min defines the color remap minimal range
  16938. * @param max defines the color remap maximal range
  16939. * @returns the current particle system
  16940. */
  16941. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16942. /**
  16943. * Gets the current list of color remap gradients.
  16944. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16945. * @returns the list of color remap gradients
  16946. */
  16947. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16948. /**
  16949. * Adds a new alpha remap gradient
  16950. * @param gradient defines the gradient to use (between 0 and 1)
  16951. * @param min defines the alpha remap minimal range
  16952. * @param max defines the alpha remap maximal range
  16953. * @returns the current particle system
  16954. */
  16955. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16956. /**
  16957. * Gets the current list of alpha remap gradients.
  16958. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16959. * @returns the list of alpha remap gradients
  16960. */
  16961. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16962. /**
  16963. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16964. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16965. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16966. * @returns the emitter
  16967. */
  16968. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16969. /**
  16970. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16971. * @param radius The radius of the hemisphere to emit from
  16972. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16973. * @returns the emitter
  16974. */
  16975. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16976. /**
  16977. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16978. * @param radius The radius of the sphere to emit from
  16979. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16980. * @returns the emitter
  16981. */
  16982. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16983. /**
  16984. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16985. * @param radius The radius of the sphere to emit from
  16986. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16987. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16988. * @returns the emitter
  16989. */
  16990. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16991. /**
  16992. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16993. * @param radius The radius of the emission cylinder
  16994. * @param height The height of the emission cylinder
  16995. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16996. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16997. * @returns the emitter
  16998. */
  16999. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  17000. /**
  17001. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17002. * @param radius The radius of the cylinder to emit from
  17003. * @param height The height of the emission cylinder
  17004. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17005. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17006. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17007. * @returns the emitter
  17008. */
  17009. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  17010. /**
  17011. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17012. * @param radius The radius of the cone to emit from
  17013. * @param angle The base angle of the cone
  17014. * @returns the emitter
  17015. */
  17016. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  17017. /**
  17018. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17019. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17020. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17021. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17022. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17023. * @returns the emitter
  17024. */
  17025. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17026. /**
  17027. * Get hosting scene
  17028. * @returns the scene
  17029. */
  17030. getScene(): Scene;
  17031. }
  17032. }
  17033. declare module "babylonjs/Meshes/instancedMesh" {
  17034. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  17035. import { Vector3, Matrix } from "babylonjs/Maths/math";
  17036. import { Camera } from "babylonjs/Cameras/camera";
  17037. import { Node } from "babylonjs/node";
  17038. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17039. import { Mesh } from "babylonjs/Meshes/mesh";
  17040. import { Material } from "babylonjs/Materials/material";
  17041. import { Skeleton } from "babylonjs/Bones/skeleton";
  17042. import { Light } from "babylonjs/Lights/light";
  17043. /**
  17044. * Creates an instance based on a source mesh.
  17045. */
  17046. export class InstancedMesh extends AbstractMesh {
  17047. private _sourceMesh;
  17048. private _currentLOD;
  17049. /** @hidden */
  17050. _indexInSourceMeshInstanceArray: number;
  17051. constructor(name: string, source: Mesh);
  17052. /**
  17053. * Returns the string "InstancedMesh".
  17054. */
  17055. getClassName(): string;
  17056. /** Gets the list of lights affecting that mesh */
  17057. readonly lightSources: Light[];
  17058. _resyncLightSources(): void;
  17059. _resyncLighSource(light: Light): void;
  17060. _removeLightSource(light: Light): void;
  17061. /**
  17062. * If the source mesh receives shadows
  17063. */
  17064. readonly receiveShadows: boolean;
  17065. /**
  17066. * The material of the source mesh
  17067. */
  17068. readonly material: Nullable<Material>;
  17069. /**
  17070. * Visibility of the source mesh
  17071. */
  17072. readonly visibility: number;
  17073. /**
  17074. * Skeleton of the source mesh
  17075. */
  17076. readonly skeleton: Nullable<Skeleton>;
  17077. /**
  17078. * Rendering ground id of the source mesh
  17079. */
  17080. renderingGroupId: number;
  17081. /**
  17082. * Returns the total number of vertices (integer).
  17083. */
  17084. getTotalVertices(): number;
  17085. /**
  17086. * Returns a positive integer : the total number of indices in this mesh geometry.
  17087. * @returns the numner of indices or zero if the mesh has no geometry.
  17088. */
  17089. getTotalIndices(): number;
  17090. /**
  17091. * The source mesh of the instance
  17092. */
  17093. readonly sourceMesh: Mesh;
  17094. /**
  17095. * Is this node ready to be used/rendered
  17096. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  17097. * @return {boolean} is it ready
  17098. */
  17099. isReady(completeCheck?: boolean): boolean;
  17100. /**
  17101. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  17102. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  17103. * @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.
  17104. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  17105. */
  17106. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  17107. /**
  17108. * Sets the vertex data of the mesh geometry for the requested `kind`.
  17109. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  17110. * The `data` are either a numeric array either a Float32Array.
  17111. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  17112. * 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).
  17113. * Note that a new underlying VertexBuffer object is created each call.
  17114. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  17115. *
  17116. * Possible `kind` values :
  17117. * - VertexBuffer.PositionKind
  17118. * - VertexBuffer.UVKind
  17119. * - VertexBuffer.UV2Kind
  17120. * - VertexBuffer.UV3Kind
  17121. * - VertexBuffer.UV4Kind
  17122. * - VertexBuffer.UV5Kind
  17123. * - VertexBuffer.UV6Kind
  17124. * - VertexBuffer.ColorKind
  17125. * - VertexBuffer.MatricesIndicesKind
  17126. * - VertexBuffer.MatricesIndicesExtraKind
  17127. * - VertexBuffer.MatricesWeightsKind
  17128. * - VertexBuffer.MatricesWeightsExtraKind
  17129. *
  17130. * Returns the Mesh.
  17131. */
  17132. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  17133. /**
  17134. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  17135. * If the mesh has no geometry, it is simply returned as it is.
  17136. * The `data` are either a numeric array either a Float32Array.
  17137. * No new underlying VertexBuffer object is created.
  17138. * 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.
  17139. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  17140. *
  17141. * Possible `kind` values :
  17142. * - VertexBuffer.PositionKind
  17143. * - VertexBuffer.UVKind
  17144. * - VertexBuffer.UV2Kind
  17145. * - VertexBuffer.UV3Kind
  17146. * - VertexBuffer.UV4Kind
  17147. * - VertexBuffer.UV5Kind
  17148. * - VertexBuffer.UV6Kind
  17149. * - VertexBuffer.ColorKind
  17150. * - VertexBuffer.MatricesIndicesKind
  17151. * - VertexBuffer.MatricesIndicesExtraKind
  17152. * - VertexBuffer.MatricesWeightsKind
  17153. * - VertexBuffer.MatricesWeightsExtraKind
  17154. *
  17155. * Returns the Mesh.
  17156. */
  17157. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  17158. /**
  17159. * Sets the mesh indices.
  17160. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  17161. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  17162. * This method creates a new index buffer each call.
  17163. * Returns the Mesh.
  17164. */
  17165. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  17166. /**
  17167. * Boolean : True if the mesh owns the requested kind of data.
  17168. */
  17169. isVerticesDataPresent(kind: string): boolean;
  17170. /**
  17171. * Returns an array of indices (IndicesArray).
  17172. */
  17173. getIndices(): Nullable<IndicesArray>;
  17174. readonly _positions: Nullable<Vector3[]>;
  17175. /**
  17176. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  17177. * This means the mesh underlying bounding box and sphere are recomputed.
  17178. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17179. * @returns the current mesh
  17180. */
  17181. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17182. /** @hidden */
  17183. _preActivate(): InstancedMesh;
  17184. /** @hidden */
  17185. _activate(renderId: number, intermediateRendering: boolean): boolean;
  17186. /** @hidden */
  17187. _postActivate(): void;
  17188. getWorldMatrix(): Matrix;
  17189. readonly isAnInstance: boolean;
  17190. /**
  17191. * Returns the current associated LOD AbstractMesh.
  17192. */
  17193. getLOD(camera: Camera): AbstractMesh;
  17194. /** @hidden */
  17195. _syncSubMeshes(): InstancedMesh;
  17196. /** @hidden */
  17197. _generatePointsArray(): boolean;
  17198. /**
  17199. * Creates a new InstancedMesh from the current mesh.
  17200. * - name (string) : the cloned mesh name
  17201. * - newParent (optional Node) : the optional Node to parent the clone to.
  17202. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17203. *
  17204. * Returns the clone.
  17205. */
  17206. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17207. /**
  17208. * Disposes the InstancedMesh.
  17209. * Returns nothing.
  17210. */
  17211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17212. }
  17213. }
  17214. declare module "babylonjs/Materials/shaderMaterial" {
  17215. import { Scene } from "babylonjs/scene";
  17216. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17217. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17218. import { Mesh } from "babylonjs/Meshes/mesh";
  17219. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17220. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17221. import { Texture } from "babylonjs/Materials/Textures/texture";
  17222. import { Material } from "babylonjs/Materials/material";
  17223. /**
  17224. * Defines the options associated with the creation of a shader material.
  17225. */
  17226. export interface IShaderMaterialOptions {
  17227. /**
  17228. * Does the material work in alpha blend mode
  17229. */
  17230. needAlphaBlending: boolean;
  17231. /**
  17232. * Does the material work in alpha test mode
  17233. */
  17234. needAlphaTesting: boolean;
  17235. /**
  17236. * The list of attribute names used in the shader
  17237. */
  17238. attributes: string[];
  17239. /**
  17240. * The list of unifrom names used in the shader
  17241. */
  17242. uniforms: string[];
  17243. /**
  17244. * The list of UBO names used in the shader
  17245. */
  17246. uniformBuffers: string[];
  17247. /**
  17248. * The list of sampler names used in the shader
  17249. */
  17250. samplers: string[];
  17251. /**
  17252. * The list of defines used in the shader
  17253. */
  17254. defines: string[];
  17255. }
  17256. /**
  17257. * 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.
  17258. *
  17259. * This returned material effects how the mesh will look based on the code in the shaders.
  17260. *
  17261. * @see http://doc.babylonjs.com/how_to/shader_material
  17262. */
  17263. export class ShaderMaterial extends Material {
  17264. private _shaderPath;
  17265. private _options;
  17266. private _textures;
  17267. private _textureArrays;
  17268. private _floats;
  17269. private _ints;
  17270. private _floatsArrays;
  17271. private _colors3;
  17272. private _colors3Arrays;
  17273. private _colors4;
  17274. private _vectors2;
  17275. private _vectors3;
  17276. private _vectors4;
  17277. private _matrices;
  17278. private _matrices3x3;
  17279. private _matrices2x2;
  17280. private _vectors2Arrays;
  17281. private _vectors3Arrays;
  17282. private _cachedWorldViewMatrix;
  17283. private _cachedWorldViewProjectionMatrix;
  17284. private _renderId;
  17285. /**
  17286. * Instantiate a new shader material.
  17287. * 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.
  17288. * This returned material effects how the mesh will look based on the code in the shaders.
  17289. * @see http://doc.babylonjs.com/how_to/shader_material
  17290. * @param name Define the name of the material in the scene
  17291. * @param scene Define the scene the material belongs to
  17292. * @param shaderPath Defines the route to the shader code in one of three ways:
  17293. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17294. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17295. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17296. * @param options Define the options used to create the shader
  17297. */
  17298. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17299. /**
  17300. * Gets the options used to compile the shader.
  17301. * They can be modified to trigger a new compilation
  17302. */
  17303. readonly options: IShaderMaterialOptions;
  17304. /**
  17305. * Gets the current class name of the material e.g. "ShaderMaterial"
  17306. * Mainly use in serialization.
  17307. * @returns the class name
  17308. */
  17309. getClassName(): string;
  17310. /**
  17311. * Specifies if the material will require alpha blending
  17312. * @returns a boolean specifying if alpha blending is needed
  17313. */
  17314. needAlphaBlending(): boolean;
  17315. /**
  17316. * Specifies if this material should be rendered in alpha test mode
  17317. * @returns a boolean specifying if an alpha test is needed.
  17318. */
  17319. needAlphaTesting(): boolean;
  17320. private _checkUniform;
  17321. /**
  17322. * Set a texture in the shader.
  17323. * @param name Define the name of the uniform samplers as defined in the shader
  17324. * @param texture Define the texture to bind to this sampler
  17325. * @return the material itself allowing "fluent" like uniform updates
  17326. */
  17327. setTexture(name: string, texture: Texture): ShaderMaterial;
  17328. /**
  17329. * Set a texture array in the shader.
  17330. * @param name Define the name of the uniform sampler array as defined in the shader
  17331. * @param textures Define the list of textures to bind to this sampler
  17332. * @return the material itself allowing "fluent" like uniform updates
  17333. */
  17334. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17335. /**
  17336. * Set a float in the shader.
  17337. * @param name Define the name of the uniform as defined in the shader
  17338. * @param value Define the value to give to the uniform
  17339. * @return the material itself allowing "fluent" like uniform updates
  17340. */
  17341. setFloat(name: string, value: number): ShaderMaterial;
  17342. /**
  17343. * Set a int in the shader.
  17344. * @param name Define the name of the uniform as defined in the shader
  17345. * @param value Define the value to give to the uniform
  17346. * @return the material itself allowing "fluent" like uniform updates
  17347. */
  17348. setInt(name: string, value: number): ShaderMaterial;
  17349. /**
  17350. * Set an array of floats in the shader.
  17351. * @param name Define the name of the uniform as defined in the shader
  17352. * @param value Define the value to give to the uniform
  17353. * @return the material itself allowing "fluent" like uniform updates
  17354. */
  17355. setFloats(name: string, value: number[]): ShaderMaterial;
  17356. /**
  17357. * Set a vec3 in the shader from a Color3.
  17358. * @param name Define the name of the uniform as defined in the shader
  17359. * @param value Define the value to give to the uniform
  17360. * @return the material itself allowing "fluent" like uniform updates
  17361. */
  17362. setColor3(name: string, value: Color3): ShaderMaterial;
  17363. /**
  17364. * Set a vec3 array in the shader from a Color3 array.
  17365. * @param name Define the name of the uniform as defined in the shader
  17366. * @param value Define the value to give to the uniform
  17367. * @return the material itself allowing "fluent" like uniform updates
  17368. */
  17369. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17370. /**
  17371. * Set a vec4 in the shader from a Color4.
  17372. * @param name Define the name of the uniform as defined in the shader
  17373. * @param value Define the value to give to the uniform
  17374. * @return the material itself allowing "fluent" like uniform updates
  17375. */
  17376. setColor4(name: string, value: Color4): ShaderMaterial;
  17377. /**
  17378. * Set a vec2 in the shader from a Vector2.
  17379. * @param name Define the name of the uniform as defined in the shader
  17380. * @param value Define the value to give to the uniform
  17381. * @return the material itself allowing "fluent" like uniform updates
  17382. */
  17383. setVector2(name: string, value: Vector2): ShaderMaterial;
  17384. /**
  17385. * Set a vec3 in the shader from a Vector3.
  17386. * @param name Define the name of the uniform as defined in the shader
  17387. * @param value Define the value to give to the uniform
  17388. * @return the material itself allowing "fluent" like uniform updates
  17389. */
  17390. setVector3(name: string, value: Vector3): ShaderMaterial;
  17391. /**
  17392. * Set a vec4 in the shader from a Vector4.
  17393. * @param name Define the name of the uniform as defined in the shader
  17394. * @param value Define the value to give to the uniform
  17395. * @return the material itself allowing "fluent" like uniform updates
  17396. */
  17397. setVector4(name: string, value: Vector4): ShaderMaterial;
  17398. /**
  17399. * Set a mat4 in the shader from a Matrix.
  17400. * @param name Define the name of the uniform as defined in the shader
  17401. * @param value Define the value to give to the uniform
  17402. * @return the material itself allowing "fluent" like uniform updates
  17403. */
  17404. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17405. /**
  17406. * Set a mat3 in the shader from a Float32Array.
  17407. * @param name Define the name of the uniform as defined in the shader
  17408. * @param value Define the value to give to the uniform
  17409. * @return the material itself allowing "fluent" like uniform updates
  17410. */
  17411. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17412. /**
  17413. * Set a mat2 in the shader from a Float32Array.
  17414. * @param name Define the name of the uniform as defined in the shader
  17415. * @param value Define the value to give to the uniform
  17416. * @return the material itself allowing "fluent" like uniform updates
  17417. */
  17418. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17419. /**
  17420. * Set a vec2 array in the shader from a number array.
  17421. * @param name Define the name of the uniform as defined in the shader
  17422. * @param value Define the value to give to the uniform
  17423. * @return the material itself allowing "fluent" like uniform updates
  17424. */
  17425. setArray2(name: string, value: number[]): ShaderMaterial;
  17426. /**
  17427. * Set a vec3 array in the shader from a number array.
  17428. * @param name Define the name of the uniform as defined in the shader
  17429. * @param value Define the value to give to the uniform
  17430. * @return the material itself allowing "fluent" like uniform updates
  17431. */
  17432. setArray3(name: string, value: number[]): ShaderMaterial;
  17433. private _checkCache;
  17434. /**
  17435. * Specifies that the submesh is ready to be used
  17436. * @param mesh defines the mesh to check
  17437. * @param subMesh defines which submesh to check
  17438. * @param useInstances specifies that instances should be used
  17439. * @returns a boolean indicating that the submesh is ready or not
  17440. */
  17441. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17442. /**
  17443. * Checks if the material is ready to render the requested mesh
  17444. * @param mesh Define the mesh to render
  17445. * @param useInstances Define whether or not the material is used with instances
  17446. * @returns true if ready, otherwise false
  17447. */
  17448. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17449. /**
  17450. * Binds the world matrix to the material
  17451. * @param world defines the world transformation matrix
  17452. */
  17453. bindOnlyWorldMatrix(world: Matrix): void;
  17454. /**
  17455. * Binds the material to the mesh
  17456. * @param world defines the world transformation matrix
  17457. * @param mesh defines the mesh to bind the material to
  17458. */
  17459. bind(world: Matrix, mesh?: Mesh): void;
  17460. /**
  17461. * Gets the active textures from the material
  17462. * @returns an array of textures
  17463. */
  17464. getActiveTextures(): BaseTexture[];
  17465. /**
  17466. * Specifies if the material uses a texture
  17467. * @param texture defines the texture to check against the material
  17468. * @returns a boolean specifying if the material uses the texture
  17469. */
  17470. hasTexture(texture: BaseTexture): boolean;
  17471. /**
  17472. * Makes a duplicate of the material, and gives it a new name
  17473. * @param name defines the new name for the duplicated material
  17474. * @returns the cloned material
  17475. */
  17476. clone(name: string): ShaderMaterial;
  17477. /**
  17478. * Disposes the material
  17479. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17480. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17481. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17482. */
  17483. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17484. /**
  17485. * Serializes this material in a JSON representation
  17486. * @returns the serialized material object
  17487. */
  17488. serialize(): any;
  17489. /**
  17490. * Creates a shader material from parsed shader material data
  17491. * @param source defines the JSON represnetation of the material
  17492. * @param scene defines the hosting scene
  17493. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17494. * @returns a new material
  17495. */
  17496. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17497. }
  17498. }
  17499. declare module "babylonjs/Shaders/color.fragment" {
  17500. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17501. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17502. /** @hidden */
  17503. export var colorPixelShader: {
  17504. name: string;
  17505. shader: string;
  17506. };
  17507. }
  17508. declare module "babylonjs/Shaders/color.vertex" {
  17509. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17510. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17511. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17512. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17513. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17514. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17515. /** @hidden */
  17516. export var colorVertexShader: {
  17517. name: string;
  17518. shader: string;
  17519. };
  17520. }
  17521. declare module "babylonjs/Meshes/linesMesh" {
  17522. import { Nullable } from "babylonjs/types";
  17523. import { Scene } from "babylonjs/scene";
  17524. import { Color3 } from "babylonjs/Maths/math";
  17525. import { Node } from "babylonjs/node";
  17526. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17527. import { Mesh } from "babylonjs/Meshes/mesh";
  17528. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17529. import { Effect } from "babylonjs/Materials/effect";
  17530. import { Material } from "babylonjs/Materials/material";
  17531. import "babylonjs/Shaders/color.fragment";
  17532. import "babylonjs/Shaders/color.vertex";
  17533. /**
  17534. * Line mesh
  17535. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17536. */
  17537. export class LinesMesh extends Mesh {
  17538. /**
  17539. * If vertex color should be applied to the mesh
  17540. */
  17541. readonly useVertexColor?: boolean | undefined;
  17542. /**
  17543. * If vertex alpha should be applied to the mesh
  17544. */
  17545. readonly useVertexAlpha?: boolean | undefined;
  17546. /**
  17547. * Color of the line (Default: White)
  17548. */
  17549. color: Color3;
  17550. /**
  17551. * Alpha of the line (Default: 1)
  17552. */
  17553. alpha: number;
  17554. /**
  17555. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17556. * This margin is expressed in world space coordinates, so its value may vary.
  17557. * Default value is 0.1
  17558. */
  17559. intersectionThreshold: number;
  17560. private _colorShader;
  17561. private color4;
  17562. /**
  17563. * Creates a new LinesMesh
  17564. * @param name defines the name
  17565. * @param scene defines the hosting scene
  17566. * @param parent defines the parent mesh if any
  17567. * @param source defines the optional source LinesMesh used to clone data from
  17568. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17569. * When false, achieved by calling a clone(), also passing False.
  17570. * This will make creation of children, recursive.
  17571. * @param useVertexColor defines if this LinesMesh supports vertex color
  17572. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17573. */
  17574. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17575. /**
  17576. * If vertex color should be applied to the mesh
  17577. */
  17578. useVertexColor?: boolean | undefined,
  17579. /**
  17580. * If vertex alpha should be applied to the mesh
  17581. */
  17582. useVertexAlpha?: boolean | undefined);
  17583. private _addClipPlaneDefine;
  17584. private _removeClipPlaneDefine;
  17585. isReady(): boolean;
  17586. /**
  17587. * Returns the string "LineMesh"
  17588. */
  17589. getClassName(): string;
  17590. /**
  17591. * @hidden
  17592. */
  17593. /**
  17594. * @hidden
  17595. */
  17596. material: Material;
  17597. /**
  17598. * @hidden
  17599. */
  17600. readonly checkCollisions: boolean;
  17601. /** @hidden */
  17602. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17603. /** @hidden */
  17604. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17605. /**
  17606. * Disposes of the line mesh
  17607. * @param doNotRecurse If children should be disposed
  17608. */
  17609. dispose(doNotRecurse?: boolean): void;
  17610. /**
  17611. * Returns a new LineMesh object cloned from the current one.
  17612. */
  17613. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17614. /**
  17615. * Creates a new InstancedLinesMesh object from the mesh model.
  17616. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17617. * @param name defines the name of the new instance
  17618. * @returns a new InstancedLinesMesh
  17619. */
  17620. createInstance(name: string): InstancedLinesMesh;
  17621. }
  17622. /**
  17623. * Creates an instance based on a source LinesMesh
  17624. */
  17625. export class InstancedLinesMesh extends InstancedMesh {
  17626. /**
  17627. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17628. * This margin is expressed in world space coordinates, so its value may vary.
  17629. * Initilized with the intersectionThreshold value of the source LinesMesh
  17630. */
  17631. intersectionThreshold: number;
  17632. constructor(name: string, source: LinesMesh);
  17633. /**
  17634. * Returns the string "InstancedLinesMesh".
  17635. */
  17636. getClassName(): string;
  17637. }
  17638. }
  17639. declare module "babylonjs/Shaders/line.fragment" {
  17640. /** @hidden */
  17641. export var linePixelShader: {
  17642. name: string;
  17643. shader: string;
  17644. };
  17645. }
  17646. declare module "babylonjs/Shaders/line.vertex" {
  17647. /** @hidden */
  17648. export var lineVertexShader: {
  17649. name: string;
  17650. shader: string;
  17651. };
  17652. }
  17653. declare module "babylonjs/Rendering/edgesRenderer" {
  17654. import { Nullable } from "babylonjs/types";
  17655. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17656. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17657. import { Vector3 } from "babylonjs/Maths/math";
  17658. import { IDisposable } from "babylonjs/scene";
  17659. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17660. import "babylonjs/Shaders/line.fragment";
  17661. import "babylonjs/Shaders/line.vertex";
  17662. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17663. module "babylonjs/Meshes/abstractMesh" {
  17664. interface AbstractMesh {
  17665. /**
  17666. * Gets the edgesRenderer associated with the mesh
  17667. */
  17668. edgesRenderer: Nullable<EdgesRenderer>;
  17669. }
  17670. }
  17671. module "babylonjs/Meshes/linesMesh" {
  17672. interface LinesMesh {
  17673. /**
  17674. * Enables the edge rendering mode on the mesh.
  17675. * This mode makes the mesh edges visible
  17676. * @param epsilon defines the maximal distance between two angles to detect a face
  17677. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17678. * @returns the currentAbstractMesh
  17679. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17680. */
  17681. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17682. }
  17683. }
  17684. module "babylonjs/Meshes/linesMesh" {
  17685. interface InstancedLinesMesh {
  17686. /**
  17687. * Enables the edge rendering mode on the mesh.
  17688. * This mode makes the mesh edges visible
  17689. * @param epsilon defines the maximal distance between two angles to detect a face
  17690. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17691. * @returns the current InstancedLinesMesh
  17692. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17693. */
  17694. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17695. }
  17696. }
  17697. /**
  17698. * Defines the minimum contract an Edges renderer should follow.
  17699. */
  17700. export interface IEdgesRenderer extends IDisposable {
  17701. /**
  17702. * Gets or sets a boolean indicating if the edgesRenderer is active
  17703. */
  17704. isEnabled: boolean;
  17705. /**
  17706. * Renders the edges of the attached mesh,
  17707. */
  17708. render(): void;
  17709. /**
  17710. * Checks wether or not the edges renderer is ready to render.
  17711. * @return true if ready, otherwise false.
  17712. */
  17713. isReady(): boolean;
  17714. }
  17715. /**
  17716. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17717. */
  17718. export class EdgesRenderer implements IEdgesRenderer {
  17719. /**
  17720. * Define the size of the edges with an orthographic camera
  17721. */
  17722. edgesWidthScalerForOrthographic: number;
  17723. /**
  17724. * Define the size of the edges with a perspective camera
  17725. */
  17726. edgesWidthScalerForPerspective: number;
  17727. protected _source: AbstractMesh;
  17728. protected _linesPositions: number[];
  17729. protected _linesNormals: number[];
  17730. protected _linesIndices: number[];
  17731. protected _epsilon: number;
  17732. protected _indicesCount: number;
  17733. protected _lineShader: ShaderMaterial;
  17734. protected _ib: DataBuffer;
  17735. protected _buffers: {
  17736. [key: string]: Nullable<VertexBuffer>;
  17737. };
  17738. protected _checkVerticesInsteadOfIndices: boolean;
  17739. private _meshRebuildObserver;
  17740. private _meshDisposeObserver;
  17741. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17742. isEnabled: boolean;
  17743. /**
  17744. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17745. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17746. * @param source Mesh used to create edges
  17747. * @param epsilon sum of angles in adjacency to check for edge
  17748. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17749. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17750. */
  17751. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17752. protected _prepareRessources(): void;
  17753. /** @hidden */
  17754. _rebuild(): void;
  17755. /**
  17756. * Releases the required resources for the edges renderer
  17757. */
  17758. dispose(): void;
  17759. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17760. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17761. /**
  17762. * Checks if the pair of p0 and p1 is en edge
  17763. * @param faceIndex
  17764. * @param edge
  17765. * @param faceNormals
  17766. * @param p0
  17767. * @param p1
  17768. * @private
  17769. */
  17770. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17771. /**
  17772. * push line into the position, normal and index buffer
  17773. * @protected
  17774. */
  17775. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17776. /**
  17777. * Generates lines edges from adjacencjes
  17778. * @private
  17779. */
  17780. _generateEdgesLines(): void;
  17781. /**
  17782. * Checks wether or not the edges renderer is ready to render.
  17783. * @return true if ready, otherwise false.
  17784. */
  17785. isReady(): boolean;
  17786. /**
  17787. * Renders the edges of the attached mesh,
  17788. */
  17789. render(): void;
  17790. }
  17791. /**
  17792. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17793. */
  17794. export class LineEdgesRenderer extends EdgesRenderer {
  17795. /**
  17796. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17797. * @param source LineMesh used to generate edges
  17798. * @param epsilon not important (specified angle for edge detection)
  17799. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17800. */
  17801. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17802. /**
  17803. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17804. */
  17805. _generateEdgesLines(): void;
  17806. }
  17807. }
  17808. declare module "babylonjs/Rendering/renderingGroup" {
  17809. import { SmartArray } from "babylonjs/Misc/smartArray";
  17810. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17812. import { Nullable } from "babylonjs/types";
  17813. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17814. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17815. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17816. import { Material } from "babylonjs/Materials/material";
  17817. import { Scene } from "babylonjs/scene";
  17818. /**
  17819. * This represents the object necessary to create a rendering group.
  17820. * This is exclusively used and created by the rendering manager.
  17821. * To modify the behavior, you use the available helpers in your scene or meshes.
  17822. * @hidden
  17823. */
  17824. export class RenderingGroup {
  17825. index: number;
  17826. private static _zeroVector;
  17827. private _scene;
  17828. private _opaqueSubMeshes;
  17829. private _transparentSubMeshes;
  17830. private _alphaTestSubMeshes;
  17831. private _depthOnlySubMeshes;
  17832. private _particleSystems;
  17833. private _spriteManagers;
  17834. private _opaqueSortCompareFn;
  17835. private _alphaTestSortCompareFn;
  17836. private _transparentSortCompareFn;
  17837. private _renderOpaque;
  17838. private _renderAlphaTest;
  17839. private _renderTransparent;
  17840. /** @hidden */
  17841. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17842. onBeforeTransparentRendering: () => void;
  17843. /**
  17844. * Set the opaque sort comparison function.
  17845. * If null the sub meshes will be render in the order they were created
  17846. */
  17847. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17848. /**
  17849. * Set the alpha test sort comparison function.
  17850. * If null the sub meshes will be render in the order they were created
  17851. */
  17852. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17853. /**
  17854. * Set the transparent sort comparison function.
  17855. * If null the sub meshes will be render in the order they were created
  17856. */
  17857. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17858. /**
  17859. * Creates a new rendering group.
  17860. * @param index The rendering group index
  17861. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17862. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17863. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17864. */
  17865. 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>);
  17866. /**
  17867. * Render all the sub meshes contained in the group.
  17868. * @param customRenderFunction Used to override the default render behaviour of the group.
  17869. * @returns true if rendered some submeshes.
  17870. */
  17871. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17872. /**
  17873. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17874. * @param subMeshes The submeshes to render
  17875. */
  17876. private renderOpaqueSorted;
  17877. /**
  17878. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17879. * @param subMeshes The submeshes to render
  17880. */
  17881. private renderAlphaTestSorted;
  17882. /**
  17883. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17884. * @param subMeshes The submeshes to render
  17885. */
  17886. private renderTransparentSorted;
  17887. /**
  17888. * Renders the submeshes in a specified order.
  17889. * @param subMeshes The submeshes to sort before render
  17890. * @param sortCompareFn The comparison function use to sort
  17891. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17892. * @param transparent Specifies to activate blending if true
  17893. */
  17894. private static renderSorted;
  17895. /**
  17896. * Renders the submeshes in the order they were dispatched (no sort applied).
  17897. * @param subMeshes The submeshes to render
  17898. */
  17899. private static renderUnsorted;
  17900. /**
  17901. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17902. * are rendered back to front if in the same alpha index.
  17903. *
  17904. * @param a The first submesh
  17905. * @param b The second submesh
  17906. * @returns The result of the comparison
  17907. */
  17908. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17909. /**
  17910. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17911. * are rendered back to front.
  17912. *
  17913. * @param a The first submesh
  17914. * @param b The second submesh
  17915. * @returns The result of the comparison
  17916. */
  17917. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17918. /**
  17919. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17920. * are rendered front to back (prevent overdraw).
  17921. *
  17922. * @param a The first submesh
  17923. * @param b The second submesh
  17924. * @returns The result of the comparison
  17925. */
  17926. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17927. /**
  17928. * Resets the different lists of submeshes to prepare a new frame.
  17929. */
  17930. prepare(): void;
  17931. dispose(): void;
  17932. /**
  17933. * Inserts the submesh in its correct queue depending on its material.
  17934. * @param subMesh The submesh to dispatch
  17935. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17936. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17937. */
  17938. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17939. dispatchSprites(spriteManager: ISpriteManager): void;
  17940. dispatchParticles(particleSystem: IParticleSystem): void;
  17941. private _renderParticles;
  17942. private _renderSprites;
  17943. }
  17944. }
  17945. declare module "babylonjs/Rendering/renderingManager" {
  17946. import { Nullable } from "babylonjs/types";
  17947. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17948. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17949. import { SmartArray } from "babylonjs/Misc/smartArray";
  17950. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17951. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17952. import { Material } from "babylonjs/Materials/material";
  17953. import { Scene } from "babylonjs/scene";
  17954. import { Camera } from "babylonjs/Cameras/camera";
  17955. /**
  17956. * Interface describing the different options available in the rendering manager
  17957. * regarding Auto Clear between groups.
  17958. */
  17959. export interface IRenderingManagerAutoClearSetup {
  17960. /**
  17961. * Defines whether or not autoclear is enable.
  17962. */
  17963. autoClear: boolean;
  17964. /**
  17965. * Defines whether or not to autoclear the depth buffer.
  17966. */
  17967. depth: boolean;
  17968. /**
  17969. * Defines whether or not to autoclear the stencil buffer.
  17970. */
  17971. stencil: boolean;
  17972. }
  17973. /**
  17974. * This class is used by the onRenderingGroupObservable
  17975. */
  17976. export class RenderingGroupInfo {
  17977. /**
  17978. * The Scene that being rendered
  17979. */
  17980. scene: Scene;
  17981. /**
  17982. * The camera currently used for the rendering pass
  17983. */
  17984. camera: Nullable<Camera>;
  17985. /**
  17986. * The ID of the renderingGroup being processed
  17987. */
  17988. renderingGroupId: number;
  17989. }
  17990. /**
  17991. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17992. * It is enable to manage the different groups as well as the different necessary sort functions.
  17993. * This should not be used directly aside of the few static configurations
  17994. */
  17995. export class RenderingManager {
  17996. /**
  17997. * The max id used for rendering groups (not included)
  17998. */
  17999. static MAX_RENDERINGGROUPS: number;
  18000. /**
  18001. * The min id used for rendering groups (included)
  18002. */
  18003. static MIN_RENDERINGGROUPS: number;
  18004. /**
  18005. * Used to globally prevent autoclearing scenes.
  18006. */
  18007. static AUTOCLEAR: boolean;
  18008. /**
  18009. * @hidden
  18010. */
  18011. _useSceneAutoClearSetup: boolean;
  18012. private _scene;
  18013. private _renderingGroups;
  18014. private _depthStencilBufferAlreadyCleaned;
  18015. private _autoClearDepthStencil;
  18016. private _customOpaqueSortCompareFn;
  18017. private _customAlphaTestSortCompareFn;
  18018. private _customTransparentSortCompareFn;
  18019. private _renderingGroupInfo;
  18020. /**
  18021. * Instantiates a new rendering group for a particular scene
  18022. * @param scene Defines the scene the groups belongs to
  18023. */
  18024. constructor(scene: Scene);
  18025. private _clearDepthStencilBuffer;
  18026. /**
  18027. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  18028. * @hidden
  18029. */
  18030. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  18031. /**
  18032. * Resets the different information of the group to prepare a new frame
  18033. * @hidden
  18034. */
  18035. reset(): void;
  18036. /**
  18037. * Dispose and release the group and its associated resources.
  18038. * @hidden
  18039. */
  18040. dispose(): void;
  18041. /**
  18042. * Clear the info related to rendering groups preventing retention points during dispose.
  18043. */
  18044. freeRenderingGroups(): void;
  18045. private _prepareRenderingGroup;
  18046. /**
  18047. * Add a sprite manager to the rendering manager in order to render it this frame.
  18048. * @param spriteManager Define the sprite manager to render
  18049. */
  18050. dispatchSprites(spriteManager: ISpriteManager): void;
  18051. /**
  18052. * Add a particle system to the rendering manager in order to render it this frame.
  18053. * @param particleSystem Define the particle system to render
  18054. */
  18055. dispatchParticles(particleSystem: IParticleSystem): void;
  18056. /**
  18057. * Add a submesh to the manager in order to render it this frame
  18058. * @param subMesh The submesh to dispatch
  18059. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  18060. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  18061. */
  18062. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  18063. /**
  18064. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18065. * This allowed control for front to back rendering or reversly depending of the special needs.
  18066. *
  18067. * @param renderingGroupId The rendering group id corresponding to its index
  18068. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18069. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18070. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18071. */
  18072. 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;
  18073. /**
  18074. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18075. *
  18076. * @param renderingGroupId The rendering group id corresponding to its index
  18077. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18078. * @param depth Automatically clears depth between groups if true and autoClear is true.
  18079. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  18080. */
  18081. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  18082. /**
  18083. * Gets the current auto clear configuration for one rendering group of the rendering
  18084. * manager.
  18085. * @param index the rendering group index to get the information for
  18086. * @returns The auto clear setup for the requested rendering group
  18087. */
  18088. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  18089. }
  18090. }
  18091. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  18092. import { Observable } from "babylonjs/Misc/observable";
  18093. import { SmartArray } from "babylonjs/Misc/smartArray";
  18094. import { Nullable } from "babylonjs/types";
  18095. import { Camera } from "babylonjs/Cameras/camera";
  18096. import { Scene } from "babylonjs/scene";
  18097. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  18098. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  18099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18100. import { SubMesh } from "babylonjs/Meshes/subMesh";
  18101. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18102. import { Texture } from "babylonjs/Materials/Textures/texture";
  18103. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  18104. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  18105. import "babylonjs/Engines/Extensions/engine.renderTarget";
  18106. import { Engine } from "babylonjs/Engines/engine";
  18107. /**
  18108. * This Helps creating a texture that will be created from a camera in your scene.
  18109. * It is basically a dynamic texture that could be used to create special effects for instance.
  18110. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  18111. */
  18112. export class RenderTargetTexture extends Texture {
  18113. isCube: boolean;
  18114. /**
  18115. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  18116. */
  18117. static readonly REFRESHRATE_RENDER_ONCE: number;
  18118. /**
  18119. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  18120. */
  18121. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  18122. /**
  18123. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  18124. * the central point of your effect and can save a lot of performances.
  18125. */
  18126. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  18127. /**
  18128. * Use this predicate to dynamically define the list of mesh you want to render.
  18129. * If set, the renderList property will be overwritten.
  18130. */
  18131. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  18132. private _renderList;
  18133. /**
  18134. * Use this list to define the list of mesh you want to render.
  18135. */
  18136. renderList: Nullable<Array<AbstractMesh>>;
  18137. private _hookArray;
  18138. /**
  18139. * Define if particles should be rendered in your texture.
  18140. */
  18141. renderParticles: boolean;
  18142. /**
  18143. * Define if sprites should be rendered in your texture.
  18144. */
  18145. renderSprites: boolean;
  18146. /**
  18147. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  18148. */
  18149. coordinatesMode: number;
  18150. /**
  18151. * Define the camera used to render the texture.
  18152. */
  18153. activeCamera: Nullable<Camera>;
  18154. /**
  18155. * Override the render function of the texture with your own one.
  18156. */
  18157. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  18158. /**
  18159. * Define if camera post processes should be use while rendering the texture.
  18160. */
  18161. useCameraPostProcesses: boolean;
  18162. /**
  18163. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  18164. */
  18165. ignoreCameraViewport: boolean;
  18166. private _postProcessManager;
  18167. private _postProcesses;
  18168. private _resizeObserver;
  18169. /**
  18170. * An event triggered when the texture is unbind.
  18171. */
  18172. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18173. /**
  18174. * An event triggered when the texture is unbind.
  18175. */
  18176. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18177. private _onAfterUnbindObserver;
  18178. /**
  18179. * Set a after unbind callback in the texture.
  18180. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18181. */
  18182. onAfterUnbind: () => void;
  18183. /**
  18184. * An event triggered before rendering the texture
  18185. */
  18186. onBeforeRenderObservable: Observable<number>;
  18187. private _onBeforeRenderObserver;
  18188. /**
  18189. * Set a before render callback in the texture.
  18190. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18191. */
  18192. onBeforeRender: (faceIndex: number) => void;
  18193. /**
  18194. * An event triggered after rendering the texture
  18195. */
  18196. onAfterRenderObservable: Observable<number>;
  18197. private _onAfterRenderObserver;
  18198. /**
  18199. * Set a after render callback in the texture.
  18200. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18201. */
  18202. onAfterRender: (faceIndex: number) => void;
  18203. /**
  18204. * An event triggered after the texture clear
  18205. */
  18206. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18207. private _onClearObserver;
  18208. /**
  18209. * Set a clear callback in the texture.
  18210. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18211. */
  18212. onClear: (Engine: Engine) => void;
  18213. /**
  18214. * Define the clear color of the Render Target if it should be different from the scene.
  18215. */
  18216. clearColor: Color4;
  18217. protected _size: number | {
  18218. width: number;
  18219. height: number;
  18220. };
  18221. protected _initialSizeParameter: number | {
  18222. width: number;
  18223. height: number;
  18224. } | {
  18225. ratio: number;
  18226. };
  18227. protected _sizeRatio: Nullable<number>;
  18228. /** @hidden */
  18229. _generateMipMaps: boolean;
  18230. protected _renderingManager: RenderingManager;
  18231. /** @hidden */
  18232. _waitingRenderList: string[];
  18233. protected _doNotChangeAspectRatio: boolean;
  18234. protected _currentRefreshId: number;
  18235. protected _refreshRate: number;
  18236. protected _textureMatrix: Matrix;
  18237. protected _samples: number;
  18238. protected _renderTargetOptions: RenderTargetCreationOptions;
  18239. /**
  18240. * Gets render target creation options that were used.
  18241. */
  18242. readonly renderTargetOptions: RenderTargetCreationOptions;
  18243. protected _engine: Engine;
  18244. protected _onRatioRescale(): void;
  18245. /**
  18246. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18247. * It must define where the camera used to render the texture is set
  18248. */
  18249. boundingBoxPosition: Vector3;
  18250. private _boundingBoxSize;
  18251. /**
  18252. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18253. * When defined, the cubemap will switch to local mode
  18254. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18255. * @example https://www.babylonjs-playground.com/#RNASML
  18256. */
  18257. boundingBoxSize: Vector3;
  18258. /**
  18259. * In case the RTT has been created with a depth texture, get the associated
  18260. * depth texture.
  18261. * Otherwise, return null.
  18262. */
  18263. depthStencilTexture: Nullable<InternalTexture>;
  18264. /**
  18265. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18266. * or used a shadow, depth texture...
  18267. * @param name The friendly name of the texture
  18268. * @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)
  18269. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18270. * @param generateMipMaps True if mip maps need to be generated after render.
  18271. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18272. * @param type The type of the buffer in the RTT (int, half float, float...)
  18273. * @param isCube True if a cube texture needs to be created
  18274. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18275. * @param generateDepthBuffer True to generate a depth buffer
  18276. * @param generateStencilBuffer True to generate a stencil buffer
  18277. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18278. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18279. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18280. */
  18281. constructor(name: string, size: number | {
  18282. width: number;
  18283. height: number;
  18284. } | {
  18285. ratio: number;
  18286. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18287. /**
  18288. * Creates a depth stencil texture.
  18289. * This is only available in WebGL 2 or with the depth texture extension available.
  18290. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18291. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18292. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18293. */
  18294. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18295. private _processSizeParameter;
  18296. /**
  18297. * Define the number of samples to use in case of MSAA.
  18298. * It defaults to one meaning no MSAA has been enabled.
  18299. */
  18300. samples: number;
  18301. /**
  18302. * Resets the refresh counter of the texture and start bak from scratch.
  18303. * Could be useful to regenerate the texture if it is setup to render only once.
  18304. */
  18305. resetRefreshCounter(): void;
  18306. /**
  18307. * Define the refresh rate of the texture or the rendering frequency.
  18308. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18309. */
  18310. refreshRate: number;
  18311. /**
  18312. * Adds a post process to the render target rendering passes.
  18313. * @param postProcess define the post process to add
  18314. */
  18315. addPostProcess(postProcess: PostProcess): void;
  18316. /**
  18317. * Clear all the post processes attached to the render target
  18318. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18319. */
  18320. clearPostProcesses(dispose?: boolean): void;
  18321. /**
  18322. * Remove one of the post process from the list of attached post processes to the texture
  18323. * @param postProcess define the post process to remove from the list
  18324. */
  18325. removePostProcess(postProcess: PostProcess): void;
  18326. /** @hidden */
  18327. _shouldRender(): boolean;
  18328. /**
  18329. * Gets the actual render size of the texture.
  18330. * @returns the width of the render size
  18331. */
  18332. getRenderSize(): number;
  18333. /**
  18334. * Gets the actual render width of the texture.
  18335. * @returns the width of the render size
  18336. */
  18337. getRenderWidth(): number;
  18338. /**
  18339. * Gets the actual render height of the texture.
  18340. * @returns the height of the render size
  18341. */
  18342. getRenderHeight(): number;
  18343. /**
  18344. * Get if the texture can be rescaled or not.
  18345. */
  18346. readonly canRescale: boolean;
  18347. /**
  18348. * Resize the texture using a ratio.
  18349. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18350. */
  18351. scale(ratio: number): void;
  18352. /**
  18353. * Get the texture reflection matrix used to rotate/transform the reflection.
  18354. * @returns the reflection matrix
  18355. */
  18356. getReflectionTextureMatrix(): Matrix;
  18357. /**
  18358. * Resize the texture to a new desired size.
  18359. * Be carrefull as it will recreate all the data in the new texture.
  18360. * @param size Define the new size. It can be:
  18361. * - a number for squared texture,
  18362. * - an object containing { width: number, height: number }
  18363. * - or an object containing a ratio { ratio: number }
  18364. */
  18365. resize(size: number | {
  18366. width: number;
  18367. height: number;
  18368. } | {
  18369. ratio: number;
  18370. }): void;
  18371. /**
  18372. * Renders all the objects from the render list into the texture.
  18373. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18374. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18375. */
  18376. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18377. private _bestReflectionRenderTargetDimension;
  18378. /**
  18379. * @hidden
  18380. * @param faceIndex face index to bind to if this is a cubetexture
  18381. */
  18382. _bindFrameBuffer(faceIndex?: number): void;
  18383. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18384. private renderToTarget;
  18385. /**
  18386. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18387. * This allowed control for front to back rendering or reversly depending of the special needs.
  18388. *
  18389. * @param renderingGroupId The rendering group id corresponding to its index
  18390. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18391. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18392. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18393. */
  18394. 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;
  18395. /**
  18396. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18397. *
  18398. * @param renderingGroupId The rendering group id corresponding to its index
  18399. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18400. */
  18401. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18402. /**
  18403. * Clones the texture.
  18404. * @returns the cloned texture
  18405. */
  18406. clone(): RenderTargetTexture;
  18407. /**
  18408. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18409. * @returns The JSON representation of the texture
  18410. */
  18411. serialize(): any;
  18412. /**
  18413. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18414. */
  18415. disposeFramebufferObjects(): void;
  18416. /**
  18417. * Dispose the texture and release its associated resources.
  18418. */
  18419. dispose(): void;
  18420. /** @hidden */
  18421. _rebuild(): void;
  18422. /**
  18423. * Clear the info related to rendering groups preventing retention point in material dispose.
  18424. */
  18425. freeRenderingGroups(): void;
  18426. /**
  18427. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18428. * @returns the view count
  18429. */
  18430. getViewCount(): number;
  18431. }
  18432. }
  18433. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18434. import { Scene } from "babylonjs/scene";
  18435. import { Plane } from "babylonjs/Maths/math";
  18436. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18437. /**
  18438. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18439. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18440. * You can then easily use it as a reflectionTexture on a flat surface.
  18441. * In case the surface is not a plane, please consider relying on reflection probes.
  18442. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18443. */
  18444. export class MirrorTexture extends RenderTargetTexture {
  18445. private scene;
  18446. /**
  18447. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18448. * 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.
  18449. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18450. */
  18451. mirrorPlane: Plane;
  18452. /**
  18453. * Define the blur ratio used to blur the reflection if needed.
  18454. */
  18455. blurRatio: number;
  18456. /**
  18457. * Define the adaptive blur kernel used to blur the reflection if needed.
  18458. * This will autocompute the closest best match for the `blurKernel`
  18459. */
  18460. adaptiveBlurKernel: number;
  18461. /**
  18462. * Define the blur kernel used to blur the reflection if needed.
  18463. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18464. */
  18465. blurKernel: number;
  18466. /**
  18467. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18468. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18469. */
  18470. blurKernelX: number;
  18471. /**
  18472. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18473. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18474. */
  18475. blurKernelY: number;
  18476. private _autoComputeBlurKernel;
  18477. protected _onRatioRescale(): void;
  18478. private _updateGammaSpace;
  18479. private _imageProcessingConfigChangeObserver;
  18480. private _transformMatrix;
  18481. private _mirrorMatrix;
  18482. private _savedViewMatrix;
  18483. private _blurX;
  18484. private _blurY;
  18485. private _adaptiveBlurKernel;
  18486. private _blurKernelX;
  18487. private _blurKernelY;
  18488. private _blurRatio;
  18489. /**
  18490. * Instantiates a Mirror Texture.
  18491. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18492. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18493. * You can then easily use it as a reflectionTexture on a flat surface.
  18494. * In case the surface is not a plane, please consider relying on reflection probes.
  18495. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18496. * @param name
  18497. * @param size
  18498. * @param scene
  18499. * @param generateMipMaps
  18500. * @param type
  18501. * @param samplingMode
  18502. * @param generateDepthBuffer
  18503. */
  18504. constructor(name: string, size: number | {
  18505. width: number;
  18506. height: number;
  18507. } | {
  18508. ratio: number;
  18509. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18510. private _preparePostProcesses;
  18511. /**
  18512. * Clone the mirror texture.
  18513. * @returns the cloned texture
  18514. */
  18515. clone(): MirrorTexture;
  18516. /**
  18517. * Serialize the texture to a JSON representation you could use in Parse later on
  18518. * @returns the serialized JSON representation
  18519. */
  18520. serialize(): any;
  18521. /**
  18522. * Dispose the texture and release its associated resources.
  18523. */
  18524. dispose(): void;
  18525. }
  18526. }
  18527. declare module "babylonjs/Materials/Textures/texture" {
  18528. import { Observable } from "babylonjs/Misc/observable";
  18529. import { Nullable } from "babylonjs/types";
  18530. import { Scene } from "babylonjs/scene";
  18531. import { Matrix } from "babylonjs/Maths/math";
  18532. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18533. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18534. /**
  18535. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18536. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18537. */
  18538. export class Texture extends BaseTexture {
  18539. /** @hidden */
  18540. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18541. /** @hidden */
  18542. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18543. /** @hidden */
  18544. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18545. /** nearest is mag = nearest and min = nearest and mip = linear */
  18546. static readonly NEAREST_SAMPLINGMODE: number;
  18547. /** nearest is mag = nearest and min = nearest and mip = linear */
  18548. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18549. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18550. static readonly BILINEAR_SAMPLINGMODE: number;
  18551. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18552. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18553. /** Trilinear is mag = linear and min = linear and mip = linear */
  18554. static readonly TRILINEAR_SAMPLINGMODE: number;
  18555. /** Trilinear is mag = linear and min = linear and mip = linear */
  18556. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18557. /** mag = nearest and min = nearest and mip = nearest */
  18558. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18559. /** mag = nearest and min = linear and mip = nearest */
  18560. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18561. /** mag = nearest and min = linear and mip = linear */
  18562. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18563. /** mag = nearest and min = linear and mip = none */
  18564. static readonly NEAREST_LINEAR: number;
  18565. /** mag = nearest and min = nearest and mip = none */
  18566. static readonly NEAREST_NEAREST: number;
  18567. /** mag = linear and min = nearest and mip = nearest */
  18568. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18569. /** mag = linear and min = nearest and mip = linear */
  18570. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18571. /** mag = linear and min = linear and mip = none */
  18572. static readonly LINEAR_LINEAR: number;
  18573. /** mag = linear and min = nearest and mip = none */
  18574. static readonly LINEAR_NEAREST: number;
  18575. /** Explicit coordinates mode */
  18576. static readonly EXPLICIT_MODE: number;
  18577. /** Spherical coordinates mode */
  18578. static readonly SPHERICAL_MODE: number;
  18579. /** Planar coordinates mode */
  18580. static readonly PLANAR_MODE: number;
  18581. /** Cubic coordinates mode */
  18582. static readonly CUBIC_MODE: number;
  18583. /** Projection coordinates mode */
  18584. static readonly PROJECTION_MODE: number;
  18585. /** Inverse Cubic coordinates mode */
  18586. static readonly SKYBOX_MODE: number;
  18587. /** Inverse Cubic coordinates mode */
  18588. static readonly INVCUBIC_MODE: number;
  18589. /** Equirectangular coordinates mode */
  18590. static readonly EQUIRECTANGULAR_MODE: number;
  18591. /** Equirectangular Fixed coordinates mode */
  18592. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18593. /** Equirectangular Fixed Mirrored coordinates mode */
  18594. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18595. /** Texture is not repeating outside of 0..1 UVs */
  18596. static readonly CLAMP_ADDRESSMODE: number;
  18597. /** Texture is repeating outside of 0..1 UVs */
  18598. static readonly WRAP_ADDRESSMODE: number;
  18599. /** Texture is repeating and mirrored */
  18600. static readonly MIRROR_ADDRESSMODE: number;
  18601. /**
  18602. * 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
  18603. */
  18604. static UseSerializedUrlIfAny: boolean;
  18605. /**
  18606. * Define the url of the texture.
  18607. */
  18608. url: Nullable<string>;
  18609. /**
  18610. * Define an offset on the texture to offset the u coordinates of the UVs
  18611. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18612. */
  18613. uOffset: number;
  18614. /**
  18615. * Define an offset on the texture to offset the v coordinates of the UVs
  18616. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18617. */
  18618. vOffset: number;
  18619. /**
  18620. * Define an offset on the texture to scale the u coordinates of the UVs
  18621. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18622. */
  18623. uScale: number;
  18624. /**
  18625. * Define an offset on the texture to scale the v coordinates of the UVs
  18626. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18627. */
  18628. vScale: number;
  18629. /**
  18630. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18631. * @see http://doc.babylonjs.com/how_to/more_materials
  18632. */
  18633. uAng: number;
  18634. /**
  18635. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18636. * @see http://doc.babylonjs.com/how_to/more_materials
  18637. */
  18638. vAng: number;
  18639. /**
  18640. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18641. * @see http://doc.babylonjs.com/how_to/more_materials
  18642. */
  18643. wAng: number;
  18644. /**
  18645. * Defines the center of rotation (U)
  18646. */
  18647. uRotationCenter: number;
  18648. /**
  18649. * Defines the center of rotation (V)
  18650. */
  18651. vRotationCenter: number;
  18652. /**
  18653. * Defines the center of rotation (W)
  18654. */
  18655. wRotationCenter: number;
  18656. /**
  18657. * Are mip maps generated for this texture or not.
  18658. */
  18659. readonly noMipmap: boolean;
  18660. /**
  18661. * List of inspectable custom properties (used by the Inspector)
  18662. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18663. */
  18664. inspectableCustomProperties: Nullable<IInspectable[]>;
  18665. private _noMipmap;
  18666. /** @hidden */
  18667. _invertY: boolean;
  18668. private _rowGenerationMatrix;
  18669. private _cachedTextureMatrix;
  18670. private _projectionModeMatrix;
  18671. private _t0;
  18672. private _t1;
  18673. private _t2;
  18674. private _cachedUOffset;
  18675. private _cachedVOffset;
  18676. private _cachedUScale;
  18677. private _cachedVScale;
  18678. private _cachedUAng;
  18679. private _cachedVAng;
  18680. private _cachedWAng;
  18681. private _cachedProjectionMatrixId;
  18682. private _cachedCoordinatesMode;
  18683. /** @hidden */
  18684. protected _initialSamplingMode: number;
  18685. /** @hidden */
  18686. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18687. private _deleteBuffer;
  18688. protected _format: Nullable<number>;
  18689. private _delayedOnLoad;
  18690. private _delayedOnError;
  18691. /**
  18692. * Observable triggered once the texture has been loaded.
  18693. */
  18694. onLoadObservable: Observable<Texture>;
  18695. protected _isBlocking: boolean;
  18696. /**
  18697. * Is the texture preventing material to render while loading.
  18698. * If false, a default texture will be used instead of the loading one during the preparation step.
  18699. */
  18700. isBlocking: boolean;
  18701. /**
  18702. * Get the current sampling mode associated with the texture.
  18703. */
  18704. readonly samplingMode: number;
  18705. /**
  18706. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18707. */
  18708. readonly invertY: boolean;
  18709. /**
  18710. * Instantiates a new texture.
  18711. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18712. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18713. * @param url define the url of the picture to load as a texture
  18714. * @param scene define the scene the texture will belong to
  18715. * @param noMipmap define if the texture will require mip maps or not
  18716. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18717. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18718. * @param onLoad define a callback triggered when the texture has been loaded
  18719. * @param onError define a callback triggered when an error occurred during the loading session
  18720. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18721. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18722. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18723. */
  18724. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  18725. /**
  18726. * Update the url (and optional buffer) of this texture if url was null during construction.
  18727. * @param url the url of the texture
  18728. * @param buffer the buffer of the texture (defaults to null)
  18729. * @param onLoad callback called when the texture is loaded (defaults to null)
  18730. */
  18731. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18732. /**
  18733. * Finish the loading sequence of a texture flagged as delayed load.
  18734. * @hidden
  18735. */
  18736. delayLoad(): void;
  18737. private _prepareRowForTextureGeneration;
  18738. /**
  18739. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18740. * @returns the transform matrix of the texture.
  18741. */
  18742. getTextureMatrix(): Matrix;
  18743. /**
  18744. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18745. * @returns The reflection texture transform
  18746. */
  18747. getReflectionTextureMatrix(): Matrix;
  18748. /**
  18749. * Clones the texture.
  18750. * @returns the cloned texture
  18751. */
  18752. clone(): Texture;
  18753. /**
  18754. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18755. * @returns The JSON representation of the texture
  18756. */
  18757. serialize(): any;
  18758. /**
  18759. * Get the current class name of the texture useful for serialization or dynamic coding.
  18760. * @returns "Texture"
  18761. */
  18762. getClassName(): string;
  18763. /**
  18764. * Dispose the texture and release its associated resources.
  18765. */
  18766. dispose(): void;
  18767. /**
  18768. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18769. * @param parsedTexture Define the JSON representation of the texture
  18770. * @param scene Define the scene the parsed texture should be instantiated in
  18771. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18772. * @returns The parsed texture if successful
  18773. */
  18774. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18775. /**
  18776. * Creates a texture from its base 64 representation.
  18777. * @param data Define the base64 payload without the data: prefix
  18778. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18779. * @param scene Define the scene the texture should belong to
  18780. * @param noMipmap Forces the texture to not create mip map information if true
  18781. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18782. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18783. * @param onLoad define a callback triggered when the texture has been loaded
  18784. * @param onError define a callback triggered when an error occurred during the loading session
  18785. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18786. * @returns the created texture
  18787. */
  18788. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18789. /**
  18790. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18791. * @param data Define the base64 payload without the data: prefix
  18792. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18793. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18794. * @param scene Define the scene the texture should belong to
  18795. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18796. * @param noMipmap Forces the texture to not create mip map information if true
  18797. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18798. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18799. * @param onLoad define a callback triggered when the texture has been loaded
  18800. * @param onError define a callback triggered when an error occurred during the loading session
  18801. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18802. * @returns the created texture
  18803. */
  18804. 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;
  18805. }
  18806. }
  18807. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18808. import { Nullable } from "babylonjs/types";
  18809. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18810. import { Scene } from "babylonjs/scene";
  18811. module "babylonjs/Engines/engine" {
  18812. interface Engine {
  18813. /**
  18814. * Creates a raw texture
  18815. * @param data defines the data to store in the texture
  18816. * @param width defines the width of the texture
  18817. * @param height defines the height of the texture
  18818. * @param format defines the format of the data
  18819. * @param generateMipMaps defines if the engine should generate the mip levels
  18820. * @param invertY defines if data must be stored with Y axis inverted
  18821. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18822. * @param compression defines the compression used (null by default)
  18823. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18824. * @returns the raw texture inside an InternalTexture
  18825. */
  18826. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18827. /**
  18828. * Update a raw texture
  18829. * @param texture defines the texture to update
  18830. * @param data defines the data to store in the texture
  18831. * @param format defines the format of the data
  18832. * @param invertY defines if data must be stored with Y axis inverted
  18833. */
  18834. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18835. /**
  18836. * Update a raw texture
  18837. * @param texture defines the texture to update
  18838. * @param data defines the data to store in the texture
  18839. * @param format defines the format of the data
  18840. * @param invertY defines if data must be stored with Y axis inverted
  18841. * @param compression defines the compression used (null by default)
  18842. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18843. */
  18844. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18845. /**
  18846. * Creates a new raw cube texture
  18847. * @param data defines the array of data to use to create each face
  18848. * @param size defines the size of the textures
  18849. * @param format defines the format of the data
  18850. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18851. * @param generateMipMaps defines if the engine should generate the mip levels
  18852. * @param invertY defines if data must be stored with Y axis inverted
  18853. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18854. * @param compression defines the compression used (null by default)
  18855. * @returns the cube texture as an InternalTexture
  18856. */
  18857. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18858. /**
  18859. * Update a raw cube texture
  18860. * @param texture defines the texture to udpdate
  18861. * @param data defines the data to store
  18862. * @param format defines the data format
  18863. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18864. * @param invertY defines if data must be stored with Y axis inverted
  18865. */
  18866. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18867. /**
  18868. * Update a raw cube texture
  18869. * @param texture defines the texture to udpdate
  18870. * @param data defines the data to store
  18871. * @param format defines the data format
  18872. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18873. * @param invertY defines if data must be stored with Y axis inverted
  18874. * @param compression defines the compression used (null by default)
  18875. */
  18876. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18877. /**
  18878. * Update a raw cube texture
  18879. * @param texture defines the texture to udpdate
  18880. * @param data defines the data to store
  18881. * @param format defines the data format
  18882. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18883. * @param invertY defines if data must be stored with Y axis inverted
  18884. * @param compression defines the compression used (null by default)
  18885. * @param level defines which level of the texture to update
  18886. */
  18887. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18888. /**
  18889. * Creates a new raw cube texture from a specified url
  18890. * @param url defines the url where the data is located
  18891. * @param scene defines the current scene
  18892. * @param size defines the size of the textures
  18893. * @param format defines the format of the data
  18894. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18895. * @param noMipmap defines if the engine should avoid generating the mip levels
  18896. * @param callback defines a callback used to extract texture data from loaded data
  18897. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18898. * @param onLoad defines a callback called when texture is loaded
  18899. * @param onError defines a callback called if there is an error
  18900. * @returns the cube texture as an InternalTexture
  18901. */
  18902. 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;
  18903. /**
  18904. * Creates a new raw cube texture from a specified url
  18905. * @param url defines the url where the data is located
  18906. * @param scene defines the current scene
  18907. * @param size defines the size of the textures
  18908. * @param format defines the format of the data
  18909. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18910. * @param noMipmap defines if the engine should avoid generating the mip levels
  18911. * @param callback defines a callback used to extract texture data from loaded data
  18912. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18913. * @param onLoad defines a callback called when texture is loaded
  18914. * @param onError defines a callback called if there is an error
  18915. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18916. * @param invertY defines if data must be stored with Y axis inverted
  18917. * @returns the cube texture as an InternalTexture
  18918. */
  18919. 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;
  18920. /**
  18921. * Creates a new raw 3D texture
  18922. * @param data defines the data used to create the texture
  18923. * @param width defines the width of the texture
  18924. * @param height defines the height of the texture
  18925. * @param depth defines the depth of the texture
  18926. * @param format defines the format of the texture
  18927. * @param generateMipMaps defines if the engine must generate mip levels
  18928. * @param invertY defines if data must be stored with Y axis inverted
  18929. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18930. * @param compression defines the compressed used (can be null)
  18931. * @param textureType defines the compressed used (can be null)
  18932. * @returns a new raw 3D texture (stored in an InternalTexture)
  18933. */
  18934. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18935. /**
  18936. * Update a raw 3D texture
  18937. * @param texture defines the texture to update
  18938. * @param data defines the data to store
  18939. * @param format defines the data format
  18940. * @param invertY defines if data must be stored with Y axis inverted
  18941. */
  18942. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18943. /**
  18944. * Update a raw 3D texture
  18945. * @param texture defines the texture to update
  18946. * @param data defines the data to store
  18947. * @param format defines the data format
  18948. * @param invertY defines if data must be stored with Y axis inverted
  18949. * @param compression defines the used compression (can be null)
  18950. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18951. */
  18952. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18953. }
  18954. }
  18955. }
  18956. declare module "babylonjs/Materials/Textures/rawTexture" {
  18957. import { Scene } from "babylonjs/scene";
  18958. import { Texture } from "babylonjs/Materials/Textures/texture";
  18959. import "babylonjs/Engines/Extensions/engine.rawTexture";
  18960. /**
  18961. * Raw texture can help creating a texture directly from an array of data.
  18962. * This can be super useful if you either get the data from an uncompressed source or
  18963. * if you wish to create your texture pixel by pixel.
  18964. */
  18965. export class RawTexture extends Texture {
  18966. /**
  18967. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18968. */
  18969. format: number;
  18970. private _engine;
  18971. /**
  18972. * Instantiates a new RawTexture.
  18973. * Raw texture can help creating a texture directly from an array of data.
  18974. * This can be super useful if you either get the data from an uncompressed source or
  18975. * if you wish to create your texture pixel by pixel.
  18976. * @param data define the array of data to use to create the texture
  18977. * @param width define the width of the texture
  18978. * @param height define the height of the texture
  18979. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18980. * @param scene define the scene the texture belongs to
  18981. * @param generateMipMaps define whether mip maps should be generated or not
  18982. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18983. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18984. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18985. */
  18986. constructor(data: ArrayBufferView, width: number, height: number,
  18987. /**
  18988. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18989. */
  18990. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18991. /**
  18992. * Updates the texture underlying data.
  18993. * @param data Define the new data of the texture
  18994. */
  18995. update(data: ArrayBufferView): void;
  18996. /**
  18997. * Creates a luminance texture from some data.
  18998. * @param data Define the texture data
  18999. * @param width Define the width of the texture
  19000. * @param height Define the height of the texture
  19001. * @param scene Define the scene the texture belongs to
  19002. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19003. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19004. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19005. * @returns the luminance texture
  19006. */
  19007. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19008. /**
  19009. * Creates a luminance alpha texture from some data.
  19010. * @param data Define the texture data
  19011. * @param width Define the width of the texture
  19012. * @param height Define the height of the texture
  19013. * @param scene Define the scene the texture belongs to
  19014. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19015. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19016. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19017. * @returns the luminance alpha texture
  19018. */
  19019. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19020. /**
  19021. * Creates an alpha texture from some data.
  19022. * @param data Define the texture data
  19023. * @param width Define the width of the texture
  19024. * @param height Define the height of the texture
  19025. * @param scene Define the scene the texture belongs to
  19026. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19027. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19028. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19029. * @returns the alpha texture
  19030. */
  19031. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  19032. /**
  19033. * Creates a RGB texture from some data.
  19034. * @param data Define the texture data
  19035. * @param width Define the width of the texture
  19036. * @param height Define the height of the texture
  19037. * @param scene Define the scene the texture belongs to
  19038. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19039. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19040. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19041. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19042. * @returns the RGB alpha texture
  19043. */
  19044. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19045. /**
  19046. * Creates a RGBA texture from some data.
  19047. * @param data Define the texture data
  19048. * @param width Define the width of the texture
  19049. * @param height Define the height of the texture
  19050. * @param scene Define the scene the texture belongs to
  19051. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19052. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19053. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19054. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19055. * @returns the RGBA texture
  19056. */
  19057. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19058. /**
  19059. * Creates a R texture from some data.
  19060. * @param data Define the texture data
  19061. * @param width Define the width of the texture
  19062. * @param height Define the height of the texture
  19063. * @param scene Define the scene the texture belongs to
  19064. * @param generateMipMaps Define whether or not to create mip maps for the texture
  19065. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  19066. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  19067. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  19068. * @returns the R texture
  19069. */
  19070. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  19071. }
  19072. }
  19073. declare module "babylonjs/Animations/runtimeAnimation" {
  19074. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  19075. import { Animatable } from "babylonjs/Animations/animatable";
  19076. import { Scene } from "babylonjs/scene";
  19077. /**
  19078. * Defines a runtime animation
  19079. */
  19080. export class RuntimeAnimation {
  19081. private _events;
  19082. /**
  19083. * The current frame of the runtime animation
  19084. */
  19085. private _currentFrame;
  19086. /**
  19087. * The animation used by the runtime animation
  19088. */
  19089. private _animation;
  19090. /**
  19091. * The target of the runtime animation
  19092. */
  19093. private _target;
  19094. /**
  19095. * The initiating animatable
  19096. */
  19097. private _host;
  19098. /**
  19099. * The original value of the runtime animation
  19100. */
  19101. private _originalValue;
  19102. /**
  19103. * The original blend value of the runtime animation
  19104. */
  19105. private _originalBlendValue;
  19106. /**
  19107. * The offsets cache of the runtime animation
  19108. */
  19109. private _offsetsCache;
  19110. /**
  19111. * The high limits cache of the runtime animation
  19112. */
  19113. private _highLimitsCache;
  19114. /**
  19115. * Specifies if the runtime animation has been stopped
  19116. */
  19117. private _stopped;
  19118. /**
  19119. * The blending factor of the runtime animation
  19120. */
  19121. private _blendingFactor;
  19122. /**
  19123. * The BabylonJS scene
  19124. */
  19125. private _scene;
  19126. /**
  19127. * The current value of the runtime animation
  19128. */
  19129. private _currentValue;
  19130. /** @hidden */
  19131. _animationState: _IAnimationState;
  19132. /**
  19133. * The active target of the runtime animation
  19134. */
  19135. private _activeTargets;
  19136. private _currentActiveTarget;
  19137. private _directTarget;
  19138. /**
  19139. * The target path of the runtime animation
  19140. */
  19141. private _targetPath;
  19142. /**
  19143. * The weight of the runtime animation
  19144. */
  19145. private _weight;
  19146. /**
  19147. * The ratio offset of the runtime animation
  19148. */
  19149. private _ratioOffset;
  19150. /**
  19151. * The previous delay of the runtime animation
  19152. */
  19153. private _previousDelay;
  19154. /**
  19155. * The previous ratio of the runtime animation
  19156. */
  19157. private _previousRatio;
  19158. private _enableBlending;
  19159. private _keys;
  19160. private _minFrame;
  19161. private _maxFrame;
  19162. private _minValue;
  19163. private _maxValue;
  19164. private _targetIsArray;
  19165. /**
  19166. * Gets the current frame of the runtime animation
  19167. */
  19168. readonly currentFrame: number;
  19169. /**
  19170. * Gets the weight of the runtime animation
  19171. */
  19172. readonly weight: number;
  19173. /**
  19174. * Gets the current value of the runtime animation
  19175. */
  19176. readonly currentValue: any;
  19177. /**
  19178. * Gets the target path of the runtime animation
  19179. */
  19180. readonly targetPath: string;
  19181. /**
  19182. * Gets the actual target of the runtime animation
  19183. */
  19184. readonly target: any;
  19185. /** @hidden */
  19186. _onLoop: () => void;
  19187. /**
  19188. * Create a new RuntimeAnimation object
  19189. * @param target defines the target of the animation
  19190. * @param animation defines the source animation object
  19191. * @param scene defines the hosting scene
  19192. * @param host defines the initiating Animatable
  19193. */
  19194. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19195. private _preparePath;
  19196. /**
  19197. * Gets the animation from the runtime animation
  19198. */
  19199. readonly animation: Animation;
  19200. /**
  19201. * Resets the runtime animation to the beginning
  19202. * @param restoreOriginal defines whether to restore the target property to the original value
  19203. */
  19204. reset(restoreOriginal?: boolean): void;
  19205. /**
  19206. * Specifies if the runtime animation is stopped
  19207. * @returns Boolean specifying if the runtime animation is stopped
  19208. */
  19209. isStopped(): boolean;
  19210. /**
  19211. * Disposes of the runtime animation
  19212. */
  19213. dispose(): void;
  19214. /**
  19215. * Apply the interpolated value to the target
  19216. * @param currentValue defines the value computed by the animation
  19217. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19218. */
  19219. setValue(currentValue: any, weight: number): void;
  19220. private _getOriginalValues;
  19221. private _setValue;
  19222. /**
  19223. * Gets the loop pmode of the runtime animation
  19224. * @returns Loop Mode
  19225. */
  19226. private _getCorrectLoopMode;
  19227. /**
  19228. * Move the current animation to a given frame
  19229. * @param frame defines the frame to move to
  19230. */
  19231. goToFrame(frame: number): void;
  19232. /**
  19233. * @hidden Internal use only
  19234. */
  19235. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19236. /**
  19237. * Execute the current animation
  19238. * @param delay defines the delay to add to the current frame
  19239. * @param from defines the lower bound of the animation range
  19240. * @param to defines the upper bound of the animation range
  19241. * @param loop defines if the current animation must loop
  19242. * @param speedRatio defines the current speed ratio
  19243. * @param weight defines the weight of the animation (default is -1 so no weight)
  19244. * @param onLoop optional callback called when animation loops
  19245. * @returns a boolean indicating if the animation is running
  19246. */
  19247. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19248. }
  19249. }
  19250. declare module "babylonjs/Animations/animatable" {
  19251. import { Animation } from "babylonjs/Animations/animation";
  19252. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19253. import { Nullable } from "babylonjs/types";
  19254. import { Observable } from "babylonjs/Misc/observable";
  19255. import { Scene } from "babylonjs/scene";
  19256. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19257. import { Node } from "babylonjs/node";
  19258. /**
  19259. * Class used to store an actual running animation
  19260. */
  19261. export class Animatable {
  19262. /** defines the target object */
  19263. target: any;
  19264. /** defines the starting frame number (default is 0) */
  19265. fromFrame: number;
  19266. /** defines the ending frame number (default is 100) */
  19267. toFrame: number;
  19268. /** defines if the animation must loop (default is false) */
  19269. loopAnimation: boolean;
  19270. /** defines a callback to call when animation ends if it is not looping */
  19271. onAnimationEnd?: (() => void) | null | undefined;
  19272. /** defines a callback to call when animation loops */
  19273. onAnimationLoop?: (() => void) | null | undefined;
  19274. private _localDelayOffset;
  19275. private _pausedDelay;
  19276. private _runtimeAnimations;
  19277. private _paused;
  19278. private _scene;
  19279. private _speedRatio;
  19280. private _weight;
  19281. private _syncRoot;
  19282. /**
  19283. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19284. * This will only apply for non looping animation (default is true)
  19285. */
  19286. disposeOnEnd: boolean;
  19287. /**
  19288. * Gets a boolean indicating if the animation has started
  19289. */
  19290. animationStarted: boolean;
  19291. /**
  19292. * Observer raised when the animation ends
  19293. */
  19294. onAnimationEndObservable: Observable<Animatable>;
  19295. /**
  19296. * Observer raised when the animation loops
  19297. */
  19298. onAnimationLoopObservable: Observable<Animatable>;
  19299. /**
  19300. * Gets the root Animatable used to synchronize and normalize animations
  19301. */
  19302. readonly syncRoot: Nullable<Animatable>;
  19303. /**
  19304. * Gets the current frame of the first RuntimeAnimation
  19305. * Used to synchronize Animatables
  19306. */
  19307. readonly masterFrame: number;
  19308. /**
  19309. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19310. */
  19311. weight: number;
  19312. /**
  19313. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19314. */
  19315. speedRatio: number;
  19316. /**
  19317. * Creates a new Animatable
  19318. * @param scene defines the hosting scene
  19319. * @param target defines the target object
  19320. * @param fromFrame defines the starting frame number (default is 0)
  19321. * @param toFrame defines the ending frame number (default is 100)
  19322. * @param loopAnimation defines if the animation must loop (default is false)
  19323. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19324. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19325. * @param animations defines a group of animation to add to the new Animatable
  19326. * @param onAnimationLoop defines a callback to call when animation loops
  19327. */
  19328. constructor(scene: Scene,
  19329. /** defines the target object */
  19330. target: any,
  19331. /** defines the starting frame number (default is 0) */
  19332. fromFrame?: number,
  19333. /** defines the ending frame number (default is 100) */
  19334. toFrame?: number,
  19335. /** defines if the animation must loop (default is false) */
  19336. loopAnimation?: boolean, speedRatio?: number,
  19337. /** defines a callback to call when animation ends if it is not looping */
  19338. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19339. /** defines a callback to call when animation loops */
  19340. onAnimationLoop?: (() => void) | null | undefined);
  19341. /**
  19342. * Synchronize and normalize current Animatable with a source Animatable
  19343. * This is useful when using animation weights and when animations are not of the same length
  19344. * @param root defines the root Animatable to synchronize with
  19345. * @returns the current Animatable
  19346. */
  19347. syncWith(root: Animatable): Animatable;
  19348. /**
  19349. * Gets the list of runtime animations
  19350. * @returns an array of RuntimeAnimation
  19351. */
  19352. getAnimations(): RuntimeAnimation[];
  19353. /**
  19354. * Adds more animations to the current animatable
  19355. * @param target defines the target of the animations
  19356. * @param animations defines the new animations to add
  19357. */
  19358. appendAnimations(target: any, animations: Animation[]): void;
  19359. /**
  19360. * Gets the source animation for a specific property
  19361. * @param property defines the propertyu to look for
  19362. * @returns null or the source animation for the given property
  19363. */
  19364. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19365. /**
  19366. * Gets the runtime animation for a specific property
  19367. * @param property defines the propertyu to look for
  19368. * @returns null or the runtime animation for the given property
  19369. */
  19370. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19371. /**
  19372. * Resets the animatable to its original state
  19373. */
  19374. reset(): void;
  19375. /**
  19376. * Allows the animatable to blend with current running animations
  19377. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19378. * @param blendingSpeed defines the blending speed to use
  19379. */
  19380. enableBlending(blendingSpeed: number): void;
  19381. /**
  19382. * Disable animation blending
  19383. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19384. */
  19385. disableBlending(): void;
  19386. /**
  19387. * Jump directly to a given frame
  19388. * @param frame defines the frame to jump to
  19389. */
  19390. goToFrame(frame: number): void;
  19391. /**
  19392. * Pause the animation
  19393. */
  19394. pause(): void;
  19395. /**
  19396. * Restart the animation
  19397. */
  19398. restart(): void;
  19399. private _raiseOnAnimationEnd;
  19400. /**
  19401. * Stop and delete the current animation
  19402. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19403. * @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)
  19404. */
  19405. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19406. /**
  19407. * Wait asynchronously for the animation to end
  19408. * @returns a promise which will be fullfilled when the animation ends
  19409. */
  19410. waitAsync(): Promise<Animatable>;
  19411. /** @hidden */
  19412. _animate(delay: number): boolean;
  19413. }
  19414. module "babylonjs/scene" {
  19415. interface Scene {
  19416. /** @hidden */
  19417. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19418. /** @hidden */
  19419. _processLateAnimationBindingsForMatrices(holder: {
  19420. totalWeight: number;
  19421. animations: RuntimeAnimation[];
  19422. originalValue: Matrix;
  19423. }): any;
  19424. /** @hidden */
  19425. _processLateAnimationBindingsForQuaternions(holder: {
  19426. totalWeight: number;
  19427. animations: RuntimeAnimation[];
  19428. originalValue: Quaternion;
  19429. }, refQuaternion: Quaternion): Quaternion;
  19430. /** @hidden */
  19431. _processLateAnimationBindings(): void;
  19432. /**
  19433. * Will start the animation sequence of a given target
  19434. * @param target defines the target
  19435. * @param from defines from which frame should animation start
  19436. * @param to defines until which frame should animation run.
  19437. * @param weight defines the weight to apply to the animation (1.0 by default)
  19438. * @param loop defines if the animation loops
  19439. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19440. * @param onAnimationEnd defines the function to be executed when the animation ends
  19441. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19442. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19443. * @param onAnimationLoop defines the callback to call when an animation loops
  19444. * @returns the animatable object created for this animation
  19445. */
  19446. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19447. /**
  19448. * Will start the animation sequence of a given target
  19449. * @param target defines the target
  19450. * @param from defines from which frame should animation start
  19451. * @param to defines until which frame should animation run.
  19452. * @param loop defines if the animation loops
  19453. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19454. * @param onAnimationEnd defines the function to be executed when the animation ends
  19455. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19456. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19457. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19458. * @param onAnimationLoop defines the callback to call when an animation loops
  19459. * @returns the animatable object created for this animation
  19460. */
  19461. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19462. /**
  19463. * Will start the animation sequence of a given target and its hierarchy
  19464. * @param target defines the target
  19465. * @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.
  19466. * @param from defines from which frame should animation start
  19467. * @param to defines until which frame should animation run.
  19468. * @param loop defines if the animation loops
  19469. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19470. * @param onAnimationEnd defines the function to be executed when the animation ends
  19471. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19472. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19473. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19474. * @param onAnimationLoop defines the callback to call when an animation loops
  19475. * @returns the list of created animatables
  19476. */
  19477. 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[];
  19478. /**
  19479. * Begin a new animation on a given node
  19480. * @param target defines the target where the animation will take place
  19481. * @param animations defines the list of animations to start
  19482. * @param from defines the initial value
  19483. * @param to defines the final value
  19484. * @param loop defines if you want animation to loop (off by default)
  19485. * @param speedRatio defines the speed ratio to apply to all animations
  19486. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19487. * @param onAnimationLoop defines the callback to call when an animation loops
  19488. * @returns the list of created animatables
  19489. */
  19490. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19491. /**
  19492. * Begin a new animation on a given node and its hierarchy
  19493. * @param target defines the root node where the animation will take place
  19494. * @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.
  19495. * @param animations defines the list of animations to start
  19496. * @param from defines the initial value
  19497. * @param to defines the final value
  19498. * @param loop defines if you want animation to loop (off by default)
  19499. * @param speedRatio defines the speed ratio to apply to all animations
  19500. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19501. * @param onAnimationLoop defines the callback to call when an animation loops
  19502. * @returns the list of animatables created for all nodes
  19503. */
  19504. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19505. /**
  19506. * Gets the animatable associated with a specific target
  19507. * @param target defines the target of the animatable
  19508. * @returns the required animatable if found
  19509. */
  19510. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19511. /**
  19512. * Gets all animatables associated with a given target
  19513. * @param target defines the target to look animatables for
  19514. * @returns an array of Animatables
  19515. */
  19516. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19517. /**
  19518. * Stops and removes all animations that have been applied to the scene
  19519. */
  19520. stopAllAnimations(): void;
  19521. }
  19522. }
  19523. module "babylonjs/Bones/bone" {
  19524. interface Bone {
  19525. /**
  19526. * Copy an animation range from another bone
  19527. * @param source defines the source bone
  19528. * @param rangeName defines the range name to copy
  19529. * @param frameOffset defines the frame offset
  19530. * @param rescaleAsRequired defines if rescaling must be applied if required
  19531. * @param skelDimensionsRatio defines the scaling ratio
  19532. * @returns true if operation was successful
  19533. */
  19534. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19535. }
  19536. }
  19537. }
  19538. declare module "babylonjs/Bones/skeleton" {
  19539. import { Bone } from "babylonjs/Bones/bone";
  19540. import { IAnimatable } from "babylonjs/Misc/tools";
  19541. import { Observable } from "babylonjs/Misc/observable";
  19542. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19543. import { Scene } from "babylonjs/scene";
  19544. import { Nullable } from "babylonjs/types";
  19545. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19546. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19547. import { Animatable } from "babylonjs/Animations/animatable";
  19548. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19549. import { Animation } from "babylonjs/Animations/animation";
  19550. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19551. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19552. /**
  19553. * Class used to handle skinning animations
  19554. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19555. */
  19556. export class Skeleton implements IAnimatable {
  19557. /** defines the skeleton name */
  19558. name: string;
  19559. /** defines the skeleton Id */
  19560. id: string;
  19561. /**
  19562. * Defines the list of child bones
  19563. */
  19564. bones: Bone[];
  19565. /**
  19566. * Defines an estimate of the dimension of the skeleton at rest
  19567. */
  19568. dimensionsAtRest: Vector3;
  19569. /**
  19570. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19571. */
  19572. needInitialSkinMatrix: boolean;
  19573. /**
  19574. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19575. */
  19576. overrideMesh: Nullable<AbstractMesh>;
  19577. /**
  19578. * Gets the list of animations attached to this skeleton
  19579. */
  19580. animations: Array<Animation>;
  19581. private _scene;
  19582. private _isDirty;
  19583. private _transformMatrices;
  19584. private _transformMatrixTexture;
  19585. private _meshesWithPoseMatrix;
  19586. private _animatables;
  19587. private _identity;
  19588. private _synchronizedWithMesh;
  19589. private _ranges;
  19590. private _lastAbsoluteTransformsUpdateId;
  19591. private _canUseTextureForBones;
  19592. private _uniqueId;
  19593. /** @hidden */
  19594. _numBonesWithLinkedTransformNode: number;
  19595. /** @hidden */
  19596. _hasWaitingData: Nullable<boolean>;
  19597. /**
  19598. * Specifies if the skeleton should be serialized
  19599. */
  19600. doNotSerialize: boolean;
  19601. private _useTextureToStoreBoneMatrices;
  19602. /**
  19603. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19604. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19605. */
  19606. useTextureToStoreBoneMatrices: boolean;
  19607. private _animationPropertiesOverride;
  19608. /**
  19609. * Gets or sets the animation properties override
  19610. */
  19611. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19612. /**
  19613. * List of inspectable custom properties (used by the Inspector)
  19614. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19615. */
  19616. inspectableCustomProperties: IInspectable[];
  19617. /**
  19618. * An observable triggered before computing the skeleton's matrices
  19619. */
  19620. onBeforeComputeObservable: Observable<Skeleton>;
  19621. /**
  19622. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19623. */
  19624. readonly isUsingTextureForMatrices: boolean;
  19625. /**
  19626. * Gets the unique ID of this skeleton
  19627. */
  19628. readonly uniqueId: number;
  19629. /**
  19630. * Creates a new skeleton
  19631. * @param name defines the skeleton name
  19632. * @param id defines the skeleton Id
  19633. * @param scene defines the hosting scene
  19634. */
  19635. constructor(
  19636. /** defines the skeleton name */
  19637. name: string,
  19638. /** defines the skeleton Id */
  19639. id: string, scene: Scene);
  19640. /**
  19641. * Gets the current object class name.
  19642. * @return the class name
  19643. */
  19644. getClassName(): string;
  19645. /**
  19646. * Returns an array containing the root bones
  19647. * @returns an array containing the root bones
  19648. */
  19649. getChildren(): Array<Bone>;
  19650. /**
  19651. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19652. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19653. * @returns a Float32Array containing matrices data
  19654. */
  19655. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19656. /**
  19657. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19658. * @returns a raw texture containing the data
  19659. */
  19660. getTransformMatrixTexture(): Nullable<RawTexture>;
  19661. /**
  19662. * Gets the current hosting scene
  19663. * @returns a scene object
  19664. */
  19665. getScene(): Scene;
  19666. /**
  19667. * Gets a string representing the current skeleton data
  19668. * @param fullDetails defines a boolean indicating if we want a verbose version
  19669. * @returns a string representing the current skeleton data
  19670. */
  19671. toString(fullDetails?: boolean): string;
  19672. /**
  19673. * Get bone's index searching by name
  19674. * @param name defines bone's name to search for
  19675. * @return the indice of the bone. Returns -1 if not found
  19676. */
  19677. getBoneIndexByName(name: string): number;
  19678. /**
  19679. * Creater a new animation range
  19680. * @param name defines the name of the range
  19681. * @param from defines the start key
  19682. * @param to defines the end key
  19683. */
  19684. createAnimationRange(name: string, from: number, to: number): void;
  19685. /**
  19686. * Delete a specific animation range
  19687. * @param name defines the name of the range
  19688. * @param deleteFrames defines if frames must be removed as well
  19689. */
  19690. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19691. /**
  19692. * Gets a specific animation range
  19693. * @param name defines the name of the range to look for
  19694. * @returns the requested animation range or null if not found
  19695. */
  19696. getAnimationRange(name: string): Nullable<AnimationRange>;
  19697. /**
  19698. * Gets the list of all animation ranges defined on this skeleton
  19699. * @returns an array
  19700. */
  19701. getAnimationRanges(): Nullable<AnimationRange>[];
  19702. /**
  19703. * Copy animation range from a source skeleton.
  19704. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19705. * @param source defines the source skeleton
  19706. * @param name defines the name of the range to copy
  19707. * @param rescaleAsRequired defines if rescaling must be applied if required
  19708. * @returns true if operation was successful
  19709. */
  19710. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19711. /**
  19712. * Forces the skeleton to go to rest pose
  19713. */
  19714. returnToRest(): void;
  19715. private _getHighestAnimationFrame;
  19716. /**
  19717. * Begin a specific animation range
  19718. * @param name defines the name of the range to start
  19719. * @param loop defines if looping must be turned on (false by default)
  19720. * @param speedRatio defines the speed ratio to apply (1 by default)
  19721. * @param onAnimationEnd defines a callback which will be called when animation will end
  19722. * @returns a new animatable
  19723. */
  19724. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19725. /** @hidden */
  19726. _markAsDirty(): void;
  19727. /** @hidden */
  19728. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19729. /** @hidden */
  19730. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19731. private _computeTransformMatrices;
  19732. /**
  19733. * Build all resources required to render a skeleton
  19734. */
  19735. prepare(): void;
  19736. /**
  19737. * Gets the list of animatables currently running for this skeleton
  19738. * @returns an array of animatables
  19739. */
  19740. getAnimatables(): IAnimatable[];
  19741. /**
  19742. * Clone the current skeleton
  19743. * @param name defines the name of the new skeleton
  19744. * @param id defines the id of the new skeleton
  19745. * @returns the new skeleton
  19746. */
  19747. clone(name: string, id: string): Skeleton;
  19748. /**
  19749. * Enable animation blending for this skeleton
  19750. * @param blendingSpeed defines the blending speed to apply
  19751. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19752. */
  19753. enableBlending(blendingSpeed?: number): void;
  19754. /**
  19755. * Releases all resources associated with the current skeleton
  19756. */
  19757. dispose(): void;
  19758. /**
  19759. * Serialize the skeleton in a JSON object
  19760. * @returns a JSON object
  19761. */
  19762. serialize(): any;
  19763. /**
  19764. * Creates a new skeleton from serialized data
  19765. * @param parsedSkeleton defines the serialized data
  19766. * @param scene defines the hosting scene
  19767. * @returns a new skeleton
  19768. */
  19769. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19770. /**
  19771. * Compute all node absolute transforms
  19772. * @param forceUpdate defines if computation must be done even if cache is up to date
  19773. */
  19774. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19775. /**
  19776. * Gets the root pose matrix
  19777. * @returns a matrix
  19778. */
  19779. getPoseMatrix(): Nullable<Matrix>;
  19780. /**
  19781. * Sorts bones per internal index
  19782. */
  19783. sortBones(): void;
  19784. private _sortBones;
  19785. }
  19786. }
  19787. declare module "babylonjs/Morph/morphTarget" {
  19788. import { IAnimatable } from "babylonjs/Misc/tools";
  19789. import { Observable } from "babylonjs/Misc/observable";
  19790. import { Nullable, FloatArray } from "babylonjs/types";
  19791. import { Scene } from "babylonjs/scene";
  19792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19793. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19794. /**
  19795. * Defines a target to use with MorphTargetManager
  19796. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19797. */
  19798. export class MorphTarget implements IAnimatable {
  19799. /** defines the name of the target */
  19800. name: string;
  19801. /**
  19802. * Gets or sets the list of animations
  19803. */
  19804. animations: import("babylonjs/Animations/animation").Animation[];
  19805. private _scene;
  19806. private _positions;
  19807. private _normals;
  19808. private _tangents;
  19809. private _influence;
  19810. /**
  19811. * Observable raised when the influence changes
  19812. */
  19813. onInfluenceChanged: Observable<boolean>;
  19814. /** @hidden */
  19815. _onDataLayoutChanged: Observable<void>;
  19816. /**
  19817. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19818. */
  19819. influence: number;
  19820. /**
  19821. * Gets or sets the id of the morph Target
  19822. */
  19823. id: string;
  19824. private _animationPropertiesOverride;
  19825. /**
  19826. * Gets or sets the animation properties override
  19827. */
  19828. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19829. /**
  19830. * Creates a new MorphTarget
  19831. * @param name defines the name of the target
  19832. * @param influence defines the influence to use
  19833. * @param scene defines the scene the morphtarget belongs to
  19834. */
  19835. constructor(
  19836. /** defines the name of the target */
  19837. name: string, influence?: number, scene?: Nullable<Scene>);
  19838. /**
  19839. * Gets a boolean defining if the target contains position data
  19840. */
  19841. readonly hasPositions: boolean;
  19842. /**
  19843. * Gets a boolean defining if the target contains normal data
  19844. */
  19845. readonly hasNormals: boolean;
  19846. /**
  19847. * Gets a boolean defining if the target contains tangent data
  19848. */
  19849. readonly hasTangents: boolean;
  19850. /**
  19851. * Affects position data to this target
  19852. * @param data defines the position data to use
  19853. */
  19854. setPositions(data: Nullable<FloatArray>): void;
  19855. /**
  19856. * Gets the position data stored in this target
  19857. * @returns a FloatArray containing the position data (or null if not present)
  19858. */
  19859. getPositions(): Nullable<FloatArray>;
  19860. /**
  19861. * Affects normal data to this target
  19862. * @param data defines the normal data to use
  19863. */
  19864. setNormals(data: Nullable<FloatArray>): void;
  19865. /**
  19866. * Gets the normal data stored in this target
  19867. * @returns a FloatArray containing the normal data (or null if not present)
  19868. */
  19869. getNormals(): Nullable<FloatArray>;
  19870. /**
  19871. * Affects tangent data to this target
  19872. * @param data defines the tangent data to use
  19873. */
  19874. setTangents(data: Nullable<FloatArray>): void;
  19875. /**
  19876. * Gets the tangent data stored in this target
  19877. * @returns a FloatArray containing the tangent data (or null if not present)
  19878. */
  19879. getTangents(): Nullable<FloatArray>;
  19880. /**
  19881. * Serializes the current target into a Serialization object
  19882. * @returns the serialized object
  19883. */
  19884. serialize(): any;
  19885. /**
  19886. * Returns the string "MorphTarget"
  19887. * @returns "MorphTarget"
  19888. */
  19889. getClassName(): string;
  19890. /**
  19891. * Creates a new target from serialized data
  19892. * @param serializationObject defines the serialized data to use
  19893. * @returns a new MorphTarget
  19894. */
  19895. static Parse(serializationObject: any): MorphTarget;
  19896. /**
  19897. * Creates a MorphTarget from mesh data
  19898. * @param mesh defines the source mesh
  19899. * @param name defines the name to use for the new target
  19900. * @param influence defines the influence to attach to the target
  19901. * @returns a new MorphTarget
  19902. */
  19903. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19904. }
  19905. }
  19906. declare module "babylonjs/Morph/morphTargetManager" {
  19907. import { Nullable } from "babylonjs/types";
  19908. import { Scene } from "babylonjs/scene";
  19909. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19910. /**
  19911. * This class is used to deform meshes using morphing between different targets
  19912. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19913. */
  19914. export class MorphTargetManager {
  19915. private _targets;
  19916. private _targetInfluenceChangedObservers;
  19917. private _targetDataLayoutChangedObservers;
  19918. private _activeTargets;
  19919. private _scene;
  19920. private _influences;
  19921. private _supportsNormals;
  19922. private _supportsTangents;
  19923. private _vertexCount;
  19924. private _uniqueId;
  19925. private _tempInfluences;
  19926. /**
  19927. * Creates a new MorphTargetManager
  19928. * @param scene defines the current scene
  19929. */
  19930. constructor(scene?: Nullable<Scene>);
  19931. /**
  19932. * Gets the unique ID of this manager
  19933. */
  19934. readonly uniqueId: number;
  19935. /**
  19936. * Gets the number of vertices handled by this manager
  19937. */
  19938. readonly vertexCount: number;
  19939. /**
  19940. * Gets a boolean indicating if this manager supports morphing of normals
  19941. */
  19942. readonly supportsNormals: boolean;
  19943. /**
  19944. * Gets a boolean indicating if this manager supports morphing of tangents
  19945. */
  19946. readonly supportsTangents: boolean;
  19947. /**
  19948. * Gets the number of targets stored in this manager
  19949. */
  19950. readonly numTargets: number;
  19951. /**
  19952. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19953. */
  19954. readonly numInfluencers: number;
  19955. /**
  19956. * Gets the list of influences (one per target)
  19957. */
  19958. readonly influences: Float32Array;
  19959. /**
  19960. * Gets the active target at specified index. An active target is a target with an influence > 0
  19961. * @param index defines the index to check
  19962. * @returns the requested target
  19963. */
  19964. getActiveTarget(index: number): MorphTarget;
  19965. /**
  19966. * Gets the target at specified index
  19967. * @param index defines the index to check
  19968. * @returns the requested target
  19969. */
  19970. getTarget(index: number): MorphTarget;
  19971. /**
  19972. * Add a new target to this manager
  19973. * @param target defines the target to add
  19974. */
  19975. addTarget(target: MorphTarget): void;
  19976. /**
  19977. * Removes a target from the manager
  19978. * @param target defines the target to remove
  19979. */
  19980. removeTarget(target: MorphTarget): void;
  19981. /**
  19982. * Serializes the current manager into a Serialization object
  19983. * @returns the serialized object
  19984. */
  19985. serialize(): any;
  19986. private _syncActiveTargets;
  19987. /**
  19988. * Syncrhonize the targets with all the meshes using this morph target manager
  19989. */
  19990. synchronize(): void;
  19991. /**
  19992. * Creates a new MorphTargetManager from serialized data
  19993. * @param serializationObject defines the serialized data
  19994. * @param scene defines the hosting scene
  19995. * @returns the new MorphTargetManager
  19996. */
  19997. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19998. }
  19999. }
  20000. declare module "babylonjs/Meshes/meshLODLevel" {
  20001. import { Mesh } from "babylonjs/Meshes/mesh";
  20002. import { Nullable } from "babylonjs/types";
  20003. /**
  20004. * Class used to represent a specific level of detail of a mesh
  20005. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  20006. */
  20007. export class MeshLODLevel {
  20008. /** Defines the distance where this level should star being displayed */
  20009. distance: number;
  20010. /** Defines the mesh to use to render this level */
  20011. mesh: Nullable<Mesh>;
  20012. /**
  20013. * Creates a new LOD level
  20014. * @param distance defines the distance where this level should star being displayed
  20015. * @param mesh defines the mesh to use to render this level
  20016. */
  20017. constructor(
  20018. /** Defines the distance where this level should star being displayed */
  20019. distance: number,
  20020. /** Defines the mesh to use to render this level */
  20021. mesh: Nullable<Mesh>);
  20022. }
  20023. }
  20024. declare module "babylonjs/Meshes/groundMesh" {
  20025. import { Scene } from "babylonjs/scene";
  20026. import { Vector3 } from "babylonjs/Maths/math";
  20027. import { Mesh } from "babylonjs/Meshes/mesh";
  20028. /**
  20029. * Mesh representing the gorund
  20030. */
  20031. export class GroundMesh extends Mesh {
  20032. /** If octree should be generated */
  20033. generateOctree: boolean;
  20034. private _heightQuads;
  20035. /** @hidden */
  20036. _subdivisionsX: number;
  20037. /** @hidden */
  20038. _subdivisionsY: number;
  20039. /** @hidden */
  20040. _width: number;
  20041. /** @hidden */
  20042. _height: number;
  20043. /** @hidden */
  20044. _minX: number;
  20045. /** @hidden */
  20046. _maxX: number;
  20047. /** @hidden */
  20048. _minZ: number;
  20049. /** @hidden */
  20050. _maxZ: number;
  20051. constructor(name: string, scene: Scene);
  20052. /**
  20053. * "GroundMesh"
  20054. * @returns "GroundMesh"
  20055. */
  20056. getClassName(): string;
  20057. /**
  20058. * The minimum of x and y subdivisions
  20059. */
  20060. readonly subdivisions: number;
  20061. /**
  20062. * X subdivisions
  20063. */
  20064. readonly subdivisionsX: number;
  20065. /**
  20066. * Y subdivisions
  20067. */
  20068. readonly subdivisionsY: number;
  20069. /**
  20070. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  20071. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  20072. * @param chunksCount the number of subdivisions for x and y
  20073. * @param octreeBlocksSize (Default: 32)
  20074. */
  20075. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  20076. /**
  20077. * Returns a height (y) value in the Worl system :
  20078. * the ground altitude at the coordinates (x, z) expressed in the World system.
  20079. * @param x x coordinate
  20080. * @param z z coordinate
  20081. * @returns the ground y position if (x, z) are outside the ground surface.
  20082. */
  20083. getHeightAtCoordinates(x: number, z: number): number;
  20084. /**
  20085. * Returns a normalized vector (Vector3) orthogonal to the ground
  20086. * at the ground coordinates (x, z) expressed in the World system.
  20087. * @param x x coordinate
  20088. * @param z z coordinate
  20089. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  20090. */
  20091. getNormalAtCoordinates(x: number, z: number): Vector3;
  20092. /**
  20093. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  20094. * at the ground coordinates (x, z) expressed in the World system.
  20095. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  20096. * @param x x coordinate
  20097. * @param z z coordinate
  20098. * @param ref vector to store the result
  20099. * @returns the GroundMesh.
  20100. */
  20101. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  20102. /**
  20103. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  20104. * if the ground has been updated.
  20105. * This can be used in the render loop.
  20106. * @returns the GroundMesh.
  20107. */
  20108. updateCoordinateHeights(): GroundMesh;
  20109. private _getFacetAt;
  20110. private _initHeightQuads;
  20111. private _computeHeightQuads;
  20112. /**
  20113. * Serializes this ground mesh
  20114. * @param serializationObject object to write serialization to
  20115. */
  20116. serialize(serializationObject: any): void;
  20117. /**
  20118. * Parses a serialized ground mesh
  20119. * @param parsedMesh the serialized mesh
  20120. * @param scene the scene to create the ground mesh in
  20121. * @returns the created ground mesh
  20122. */
  20123. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  20124. }
  20125. }
  20126. declare module "babylonjs/Physics/physicsJoint" {
  20127. import { Vector3 } from "babylonjs/Maths/math";
  20128. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  20129. /**
  20130. * Interface for Physics-Joint data
  20131. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20132. */
  20133. export interface PhysicsJointData {
  20134. /**
  20135. * The main pivot of the joint
  20136. */
  20137. mainPivot?: Vector3;
  20138. /**
  20139. * The connected pivot of the joint
  20140. */
  20141. connectedPivot?: Vector3;
  20142. /**
  20143. * The main axis of the joint
  20144. */
  20145. mainAxis?: Vector3;
  20146. /**
  20147. * The connected axis of the joint
  20148. */
  20149. connectedAxis?: Vector3;
  20150. /**
  20151. * The collision of the joint
  20152. */
  20153. collision?: boolean;
  20154. /**
  20155. * Native Oimo/Cannon/Energy data
  20156. */
  20157. nativeParams?: any;
  20158. }
  20159. /**
  20160. * This is a holder class for the physics joint created by the physics plugin
  20161. * It holds a set of functions to control the underlying joint
  20162. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20163. */
  20164. export class PhysicsJoint {
  20165. /**
  20166. * The type of the physics joint
  20167. */
  20168. type: number;
  20169. /**
  20170. * The data for the physics joint
  20171. */
  20172. jointData: PhysicsJointData;
  20173. private _physicsJoint;
  20174. protected _physicsPlugin: IPhysicsEnginePlugin;
  20175. /**
  20176. * Initializes the physics joint
  20177. * @param type The type of the physics joint
  20178. * @param jointData The data for the physics joint
  20179. */
  20180. constructor(
  20181. /**
  20182. * The type of the physics joint
  20183. */
  20184. type: number,
  20185. /**
  20186. * The data for the physics joint
  20187. */
  20188. jointData: PhysicsJointData);
  20189. /**
  20190. * Gets the physics joint
  20191. */
  20192. /**
  20193. * Sets the physics joint
  20194. */
  20195. physicsJoint: any;
  20196. /**
  20197. * Sets the physics plugin
  20198. */
  20199. physicsPlugin: IPhysicsEnginePlugin;
  20200. /**
  20201. * Execute a function that is physics-plugin specific.
  20202. * @param {Function} func the function that will be executed.
  20203. * It accepts two parameters: the physics world and the physics joint
  20204. */
  20205. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20206. /**
  20207. * Distance-Joint type
  20208. */
  20209. static DistanceJoint: number;
  20210. /**
  20211. * Hinge-Joint type
  20212. */
  20213. static HingeJoint: number;
  20214. /**
  20215. * Ball-and-Socket joint type
  20216. */
  20217. static BallAndSocketJoint: number;
  20218. /**
  20219. * Wheel-Joint type
  20220. */
  20221. static WheelJoint: number;
  20222. /**
  20223. * Slider-Joint type
  20224. */
  20225. static SliderJoint: number;
  20226. /**
  20227. * Prismatic-Joint type
  20228. */
  20229. static PrismaticJoint: number;
  20230. /**
  20231. * Universal-Joint type
  20232. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20233. */
  20234. static UniversalJoint: number;
  20235. /**
  20236. * Hinge-Joint 2 type
  20237. */
  20238. static Hinge2Joint: number;
  20239. /**
  20240. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20241. */
  20242. static PointToPointJoint: number;
  20243. /**
  20244. * Spring-Joint type
  20245. */
  20246. static SpringJoint: number;
  20247. /**
  20248. * Lock-Joint type
  20249. */
  20250. static LockJoint: number;
  20251. }
  20252. /**
  20253. * A class representing a physics distance joint
  20254. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20255. */
  20256. export class DistanceJoint extends PhysicsJoint {
  20257. /**
  20258. *
  20259. * @param jointData The data for the Distance-Joint
  20260. */
  20261. constructor(jointData: DistanceJointData);
  20262. /**
  20263. * Update the predefined distance.
  20264. * @param maxDistance The maximum preferred distance
  20265. * @param minDistance The minimum preferred distance
  20266. */
  20267. updateDistance(maxDistance: number, minDistance?: number): void;
  20268. }
  20269. /**
  20270. * Represents a Motor-Enabled Joint
  20271. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20272. */
  20273. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20274. /**
  20275. * Initializes the Motor-Enabled Joint
  20276. * @param type The type of the joint
  20277. * @param jointData The physica joint data for the joint
  20278. */
  20279. constructor(type: number, jointData: PhysicsJointData);
  20280. /**
  20281. * Set the motor values.
  20282. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20283. * @param force the force to apply
  20284. * @param maxForce max force for this motor.
  20285. */
  20286. setMotor(force?: number, maxForce?: number): void;
  20287. /**
  20288. * Set the motor's limits.
  20289. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20290. * @param upperLimit The upper limit of the motor
  20291. * @param lowerLimit The lower limit of the motor
  20292. */
  20293. setLimit(upperLimit: number, lowerLimit?: number): void;
  20294. }
  20295. /**
  20296. * This class represents a single physics Hinge-Joint
  20297. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20298. */
  20299. export class HingeJoint extends MotorEnabledJoint {
  20300. /**
  20301. * Initializes the Hinge-Joint
  20302. * @param jointData The joint data for the Hinge-Joint
  20303. */
  20304. constructor(jointData: PhysicsJointData);
  20305. /**
  20306. * Set the motor values.
  20307. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20308. * @param {number} force the force to apply
  20309. * @param {number} maxForce max force for this motor.
  20310. */
  20311. setMotor(force?: number, maxForce?: number): void;
  20312. /**
  20313. * Set the motor's limits.
  20314. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20315. * @param upperLimit The upper limit of the motor
  20316. * @param lowerLimit The lower limit of the motor
  20317. */
  20318. setLimit(upperLimit: number, lowerLimit?: number): void;
  20319. }
  20320. /**
  20321. * This class represents a dual hinge physics joint (same as wheel joint)
  20322. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20323. */
  20324. export class Hinge2Joint extends MotorEnabledJoint {
  20325. /**
  20326. * Initializes the Hinge2-Joint
  20327. * @param jointData The joint data for the Hinge2-Joint
  20328. */
  20329. constructor(jointData: PhysicsJointData);
  20330. /**
  20331. * Set the motor values.
  20332. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20333. * @param {number} targetSpeed the speed the motor is to reach
  20334. * @param {number} maxForce max force for this motor.
  20335. * @param {motorIndex} the motor's index, 0 or 1.
  20336. */
  20337. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20338. /**
  20339. * Set the motor limits.
  20340. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20341. * @param {number} upperLimit the upper limit
  20342. * @param {number} lowerLimit lower limit
  20343. * @param {motorIndex} the motor's index, 0 or 1.
  20344. */
  20345. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20346. }
  20347. /**
  20348. * Interface for a motor enabled joint
  20349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20350. */
  20351. export interface IMotorEnabledJoint {
  20352. /**
  20353. * Physics joint
  20354. */
  20355. physicsJoint: any;
  20356. /**
  20357. * Sets the motor of the motor-enabled joint
  20358. * @param force The force of the motor
  20359. * @param maxForce The maximum force of the motor
  20360. * @param motorIndex The index of the motor
  20361. */
  20362. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20363. /**
  20364. * Sets the limit of the motor
  20365. * @param upperLimit The upper limit of the motor
  20366. * @param lowerLimit The lower limit of the motor
  20367. * @param motorIndex The index of the motor
  20368. */
  20369. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20370. }
  20371. /**
  20372. * Joint data for a Distance-Joint
  20373. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20374. */
  20375. export interface DistanceJointData extends PhysicsJointData {
  20376. /**
  20377. * Max distance the 2 joint objects can be apart
  20378. */
  20379. maxDistance: number;
  20380. }
  20381. /**
  20382. * Joint data from a spring joint
  20383. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20384. */
  20385. export interface SpringJointData extends PhysicsJointData {
  20386. /**
  20387. * Length of the spring
  20388. */
  20389. length: number;
  20390. /**
  20391. * Stiffness of the spring
  20392. */
  20393. stiffness: number;
  20394. /**
  20395. * Damping of the spring
  20396. */
  20397. damping: number;
  20398. /** this callback will be called when applying the force to the impostors. */
  20399. forceApplicationCallback: () => void;
  20400. }
  20401. }
  20402. declare module "babylonjs/Physics/physicsRaycastResult" {
  20403. import { Vector3 } from "babylonjs/Maths/math";
  20404. /**
  20405. * Holds the data for the raycast result
  20406. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20407. */
  20408. export class PhysicsRaycastResult {
  20409. private _hasHit;
  20410. private _hitDistance;
  20411. private _hitNormalWorld;
  20412. private _hitPointWorld;
  20413. private _rayFromWorld;
  20414. private _rayToWorld;
  20415. /**
  20416. * Gets if there was a hit
  20417. */
  20418. readonly hasHit: boolean;
  20419. /**
  20420. * Gets the distance from the hit
  20421. */
  20422. readonly hitDistance: number;
  20423. /**
  20424. * Gets the hit normal/direction in the world
  20425. */
  20426. readonly hitNormalWorld: Vector3;
  20427. /**
  20428. * Gets the hit point in the world
  20429. */
  20430. readonly hitPointWorld: Vector3;
  20431. /**
  20432. * Gets the ray "start point" of the ray in the world
  20433. */
  20434. readonly rayFromWorld: Vector3;
  20435. /**
  20436. * Gets the ray "end point" of the ray in the world
  20437. */
  20438. readonly rayToWorld: Vector3;
  20439. /**
  20440. * Sets the hit data (normal & point in world space)
  20441. * @param hitNormalWorld defines the normal in world space
  20442. * @param hitPointWorld defines the point in world space
  20443. */
  20444. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20445. /**
  20446. * Sets the distance from the start point to the hit point
  20447. * @param distance
  20448. */
  20449. setHitDistance(distance: number): void;
  20450. /**
  20451. * Calculates the distance manually
  20452. */
  20453. calculateHitDistance(): void;
  20454. /**
  20455. * Resets all the values to default
  20456. * @param from The from point on world space
  20457. * @param to The to point on world space
  20458. */
  20459. reset(from?: Vector3, to?: Vector3): void;
  20460. }
  20461. /**
  20462. * Interface for the size containing width and height
  20463. */
  20464. interface IXYZ {
  20465. /**
  20466. * X
  20467. */
  20468. x: number;
  20469. /**
  20470. * Y
  20471. */
  20472. y: number;
  20473. /**
  20474. * Z
  20475. */
  20476. z: number;
  20477. }
  20478. }
  20479. declare module "babylonjs/Physics/IPhysicsEngine" {
  20480. import { Nullable } from "babylonjs/types";
  20481. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20482. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20483. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20484. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20485. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20486. /**
  20487. * Interface used to describe a physics joint
  20488. */
  20489. export interface PhysicsImpostorJoint {
  20490. /** Defines the main impostor to which the joint is linked */
  20491. mainImpostor: PhysicsImpostor;
  20492. /** Defines the impostor that is connected to the main impostor using this joint */
  20493. connectedImpostor: PhysicsImpostor;
  20494. /** Defines the joint itself */
  20495. joint: PhysicsJoint;
  20496. }
  20497. /** @hidden */
  20498. export interface IPhysicsEnginePlugin {
  20499. world: any;
  20500. name: string;
  20501. setGravity(gravity: Vector3): void;
  20502. setTimeStep(timeStep: number): void;
  20503. getTimeStep(): number;
  20504. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20505. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20506. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20507. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20508. removePhysicsBody(impostor: PhysicsImpostor): void;
  20509. generateJoint(joint: PhysicsImpostorJoint): void;
  20510. removeJoint(joint: PhysicsImpostorJoint): void;
  20511. isSupported(): boolean;
  20512. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20513. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20514. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20515. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20516. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20517. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20518. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20519. getBodyMass(impostor: PhysicsImpostor): number;
  20520. getBodyFriction(impostor: PhysicsImpostor): number;
  20521. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20522. getBodyRestitution(impostor: PhysicsImpostor): number;
  20523. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20524. getBodyPressure?(impostor: PhysicsImpostor): number;
  20525. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20526. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20527. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20528. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20529. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20530. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20531. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20532. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20533. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20534. sleepBody(impostor: PhysicsImpostor): void;
  20535. wakeUpBody(impostor: PhysicsImpostor): void;
  20536. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20537. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20538. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20539. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20540. getRadius(impostor: PhysicsImpostor): number;
  20541. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20542. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20543. dispose(): void;
  20544. }
  20545. /**
  20546. * Interface used to define a physics engine
  20547. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20548. */
  20549. export interface IPhysicsEngine {
  20550. /**
  20551. * Gets the gravity vector used by the simulation
  20552. */
  20553. gravity: Vector3;
  20554. /**
  20555. * Sets the gravity vector used by the simulation
  20556. * @param gravity defines the gravity vector to use
  20557. */
  20558. setGravity(gravity: Vector3): void;
  20559. /**
  20560. * Set the time step of the physics engine.
  20561. * Default is 1/60.
  20562. * To slow it down, enter 1/600 for example.
  20563. * To speed it up, 1/30
  20564. * @param newTimeStep the new timestep to apply to this world.
  20565. */
  20566. setTimeStep(newTimeStep: number): void;
  20567. /**
  20568. * Get the time step of the physics engine.
  20569. * @returns the current time step
  20570. */
  20571. getTimeStep(): number;
  20572. /**
  20573. * Release all resources
  20574. */
  20575. dispose(): void;
  20576. /**
  20577. * Gets the name of the current physics plugin
  20578. * @returns the name of the plugin
  20579. */
  20580. getPhysicsPluginName(): string;
  20581. /**
  20582. * Adding a new impostor for the impostor tracking.
  20583. * This will be done by the impostor itself.
  20584. * @param impostor the impostor to add
  20585. */
  20586. addImpostor(impostor: PhysicsImpostor): void;
  20587. /**
  20588. * Remove an impostor from the engine.
  20589. * This impostor and its mesh will not longer be updated by the physics engine.
  20590. * @param impostor the impostor to remove
  20591. */
  20592. removeImpostor(impostor: PhysicsImpostor): void;
  20593. /**
  20594. * Add a joint to the physics engine
  20595. * @param mainImpostor defines the main impostor to which the joint is added.
  20596. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20597. * @param joint defines the joint that will connect both impostors.
  20598. */
  20599. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20600. /**
  20601. * Removes a joint from the simulation
  20602. * @param mainImpostor defines the impostor used with the joint
  20603. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20604. * @param joint defines the joint to remove
  20605. */
  20606. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20607. /**
  20608. * Gets the current plugin used to run the simulation
  20609. * @returns current plugin
  20610. */
  20611. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20612. /**
  20613. * Gets the list of physic impostors
  20614. * @returns an array of PhysicsImpostor
  20615. */
  20616. getImpostors(): Array<PhysicsImpostor>;
  20617. /**
  20618. * Gets the impostor for a physics enabled object
  20619. * @param object defines the object impersonated by the impostor
  20620. * @returns the PhysicsImpostor or null if not found
  20621. */
  20622. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20623. /**
  20624. * Gets the impostor for a physics body object
  20625. * @param body defines physics body used by the impostor
  20626. * @returns the PhysicsImpostor or null if not found
  20627. */
  20628. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20629. /**
  20630. * Does a raycast in the physics world
  20631. * @param from when should the ray start?
  20632. * @param to when should the ray end?
  20633. * @returns PhysicsRaycastResult
  20634. */
  20635. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20636. /**
  20637. * Called by the scene. No need to call it.
  20638. * @param delta defines the timespam between frames
  20639. */
  20640. _step(delta: number): void;
  20641. }
  20642. }
  20643. declare module "babylonjs/Physics/physicsImpostor" {
  20644. import { Nullable, IndicesArray } from "babylonjs/types";
  20645. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20646. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20647. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20648. import { Scene } from "babylonjs/scene";
  20649. import { Bone } from "babylonjs/Bones/bone";
  20650. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20651. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20652. /**
  20653. * The interface for the physics imposter parameters
  20654. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20655. */
  20656. export interface PhysicsImpostorParameters {
  20657. /**
  20658. * The mass of the physics imposter
  20659. */
  20660. mass: number;
  20661. /**
  20662. * The friction of the physics imposter
  20663. */
  20664. friction?: number;
  20665. /**
  20666. * The coefficient of restitution of the physics imposter
  20667. */
  20668. restitution?: number;
  20669. /**
  20670. * The native options of the physics imposter
  20671. */
  20672. nativeOptions?: any;
  20673. /**
  20674. * Specifies if the parent should be ignored
  20675. */
  20676. ignoreParent?: boolean;
  20677. /**
  20678. * Specifies if bi-directional transformations should be disabled
  20679. */
  20680. disableBidirectionalTransformation?: boolean;
  20681. /**
  20682. * The pressure inside the physics imposter, soft object only
  20683. */
  20684. pressure?: number;
  20685. /**
  20686. * The stiffness the physics imposter, soft object only
  20687. */
  20688. stiffness?: number;
  20689. /**
  20690. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20691. */
  20692. velocityIterations?: number;
  20693. /**
  20694. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20695. */
  20696. positionIterations?: number;
  20697. /**
  20698. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20699. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20700. * Add to fix multiple points
  20701. */
  20702. fixedPoints?: number;
  20703. /**
  20704. * The collision margin around a soft object
  20705. */
  20706. margin?: number;
  20707. /**
  20708. * The collision margin around a soft object
  20709. */
  20710. damping?: number;
  20711. /**
  20712. * The path for a rope based on an extrusion
  20713. */
  20714. path?: any;
  20715. /**
  20716. * The shape of an extrusion used for a rope based on an extrusion
  20717. */
  20718. shape?: any;
  20719. }
  20720. /**
  20721. * Interface for a physics-enabled object
  20722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20723. */
  20724. export interface IPhysicsEnabledObject {
  20725. /**
  20726. * The position of the physics-enabled object
  20727. */
  20728. position: Vector3;
  20729. /**
  20730. * The rotation of the physics-enabled object
  20731. */
  20732. rotationQuaternion: Nullable<Quaternion>;
  20733. /**
  20734. * The scale of the physics-enabled object
  20735. */
  20736. scaling: Vector3;
  20737. /**
  20738. * The rotation of the physics-enabled object
  20739. */
  20740. rotation?: Vector3;
  20741. /**
  20742. * The parent of the physics-enabled object
  20743. */
  20744. parent?: any;
  20745. /**
  20746. * The bounding info of the physics-enabled object
  20747. * @returns The bounding info of the physics-enabled object
  20748. */
  20749. getBoundingInfo(): BoundingInfo;
  20750. /**
  20751. * Computes the world matrix
  20752. * @param force Specifies if the world matrix should be computed by force
  20753. * @returns A world matrix
  20754. */
  20755. computeWorldMatrix(force: boolean): Matrix;
  20756. /**
  20757. * Gets the world matrix
  20758. * @returns A world matrix
  20759. */
  20760. getWorldMatrix?(): Matrix;
  20761. /**
  20762. * Gets the child meshes
  20763. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20764. * @returns An array of abstract meshes
  20765. */
  20766. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20767. /**
  20768. * Gets the vertex data
  20769. * @param kind The type of vertex data
  20770. * @returns A nullable array of numbers, or a float32 array
  20771. */
  20772. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20773. /**
  20774. * Gets the indices from the mesh
  20775. * @returns A nullable array of index arrays
  20776. */
  20777. getIndices?(): Nullable<IndicesArray>;
  20778. /**
  20779. * Gets the scene from the mesh
  20780. * @returns the indices array or null
  20781. */
  20782. getScene?(): Scene;
  20783. /**
  20784. * Gets the absolute position from the mesh
  20785. * @returns the absolute position
  20786. */
  20787. getAbsolutePosition(): Vector3;
  20788. /**
  20789. * Gets the absolute pivot point from the mesh
  20790. * @returns the absolute pivot point
  20791. */
  20792. getAbsolutePivotPoint(): Vector3;
  20793. /**
  20794. * Rotates the mesh
  20795. * @param axis The axis of rotation
  20796. * @param amount The amount of rotation
  20797. * @param space The space of the rotation
  20798. * @returns The rotation transform node
  20799. */
  20800. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20801. /**
  20802. * Translates the mesh
  20803. * @param axis The axis of translation
  20804. * @param distance The distance of translation
  20805. * @param space The space of the translation
  20806. * @returns The transform node
  20807. */
  20808. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20809. /**
  20810. * Sets the absolute position of the mesh
  20811. * @param absolutePosition The absolute position of the mesh
  20812. * @returns The transform node
  20813. */
  20814. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20815. /**
  20816. * Gets the class name of the mesh
  20817. * @returns The class name
  20818. */
  20819. getClassName(): string;
  20820. }
  20821. /**
  20822. * Represents a physics imposter
  20823. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20824. */
  20825. export class PhysicsImpostor {
  20826. /**
  20827. * The physics-enabled object used as the physics imposter
  20828. */
  20829. object: IPhysicsEnabledObject;
  20830. /**
  20831. * The type of the physics imposter
  20832. */
  20833. type: number;
  20834. private _options;
  20835. private _scene?;
  20836. /**
  20837. * The default object size of the imposter
  20838. */
  20839. static DEFAULT_OBJECT_SIZE: Vector3;
  20840. /**
  20841. * The identity quaternion of the imposter
  20842. */
  20843. static IDENTITY_QUATERNION: Quaternion;
  20844. /** @hidden */
  20845. _pluginData: any;
  20846. private _physicsEngine;
  20847. private _physicsBody;
  20848. private _bodyUpdateRequired;
  20849. private _onBeforePhysicsStepCallbacks;
  20850. private _onAfterPhysicsStepCallbacks;
  20851. /** @hidden */
  20852. _onPhysicsCollideCallbacks: Array<{
  20853. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20854. otherImpostors: Array<PhysicsImpostor>;
  20855. }>;
  20856. private _deltaPosition;
  20857. private _deltaRotation;
  20858. private _deltaRotationConjugated;
  20859. /** hidden */
  20860. _isFromLine: boolean;
  20861. private _parent;
  20862. private _isDisposed;
  20863. private static _tmpVecs;
  20864. private static _tmpQuat;
  20865. /**
  20866. * Specifies if the physics imposter is disposed
  20867. */
  20868. readonly isDisposed: boolean;
  20869. /**
  20870. * Gets the mass of the physics imposter
  20871. */
  20872. mass: number;
  20873. /**
  20874. * Gets the coefficient of friction
  20875. */
  20876. /**
  20877. * Sets the coefficient of friction
  20878. */
  20879. friction: number;
  20880. /**
  20881. * Gets the coefficient of restitution
  20882. */
  20883. /**
  20884. * Sets the coefficient of restitution
  20885. */
  20886. restitution: number;
  20887. /**
  20888. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20889. */
  20890. /**
  20891. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20892. */
  20893. pressure: number;
  20894. /**
  20895. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20896. */
  20897. /**
  20898. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20899. */
  20900. stiffness: number;
  20901. /**
  20902. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20903. */
  20904. /**
  20905. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20906. */
  20907. velocityIterations: number;
  20908. /**
  20909. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20910. */
  20911. /**
  20912. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20913. */
  20914. positionIterations: number;
  20915. /**
  20916. * The unique id of the physics imposter
  20917. * set by the physics engine when adding this impostor to the array
  20918. */
  20919. uniqueId: number;
  20920. /**
  20921. * @hidden
  20922. */
  20923. soft: boolean;
  20924. /**
  20925. * @hidden
  20926. */
  20927. segments: number;
  20928. private _joints;
  20929. /**
  20930. * Initializes the physics imposter
  20931. * @param object The physics-enabled object used as the physics imposter
  20932. * @param type The type of the physics imposter
  20933. * @param _options The options for the physics imposter
  20934. * @param _scene The Babylon scene
  20935. */
  20936. constructor(
  20937. /**
  20938. * The physics-enabled object used as the physics imposter
  20939. */
  20940. object: IPhysicsEnabledObject,
  20941. /**
  20942. * The type of the physics imposter
  20943. */
  20944. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20945. /**
  20946. * This function will completly initialize this impostor.
  20947. * It will create a new body - but only if this mesh has no parent.
  20948. * If it has, this impostor will not be used other than to define the impostor
  20949. * of the child mesh.
  20950. * @hidden
  20951. */
  20952. _init(): void;
  20953. private _getPhysicsParent;
  20954. /**
  20955. * Should a new body be generated.
  20956. * @returns boolean specifying if body initialization is required
  20957. */
  20958. isBodyInitRequired(): boolean;
  20959. /**
  20960. * Sets the updated scaling
  20961. * @param updated Specifies if the scaling is updated
  20962. */
  20963. setScalingUpdated(): void;
  20964. /**
  20965. * Force a regeneration of this or the parent's impostor's body.
  20966. * Use under cautious - This will remove all joints already implemented.
  20967. */
  20968. forceUpdate(): void;
  20969. /**
  20970. * Gets the body that holds this impostor. Either its own, or its parent.
  20971. */
  20972. /**
  20973. * Set the physics body. Used mainly by the physics engine/plugin
  20974. */
  20975. physicsBody: any;
  20976. /**
  20977. * Get the parent of the physics imposter
  20978. * @returns Physics imposter or null
  20979. */
  20980. /**
  20981. * Sets the parent of the physics imposter
  20982. */
  20983. parent: Nullable<PhysicsImpostor>;
  20984. /**
  20985. * Resets the update flags
  20986. */
  20987. resetUpdateFlags(): void;
  20988. /**
  20989. * Gets the object extend size
  20990. * @returns the object extend size
  20991. */
  20992. getObjectExtendSize(): Vector3;
  20993. /**
  20994. * Gets the object center
  20995. * @returns The object center
  20996. */
  20997. getObjectCenter(): Vector3;
  20998. /**
  20999. * Get a specific parametes from the options parameter
  21000. * @param paramName The object parameter name
  21001. * @returns The object parameter
  21002. */
  21003. getParam(paramName: string): any;
  21004. /**
  21005. * Sets a specific parameter in the options given to the physics plugin
  21006. * @param paramName The parameter name
  21007. * @param value The value of the parameter
  21008. */
  21009. setParam(paramName: string, value: number): void;
  21010. /**
  21011. * Specifically change the body's mass option. Won't recreate the physics body object
  21012. * @param mass The mass of the physics imposter
  21013. */
  21014. setMass(mass: number): void;
  21015. /**
  21016. * Gets the linear velocity
  21017. * @returns linear velocity or null
  21018. */
  21019. getLinearVelocity(): Nullable<Vector3>;
  21020. /**
  21021. * Sets the linear velocity
  21022. * @param velocity linear velocity or null
  21023. */
  21024. setLinearVelocity(velocity: Nullable<Vector3>): void;
  21025. /**
  21026. * Gets the angular velocity
  21027. * @returns angular velocity or null
  21028. */
  21029. getAngularVelocity(): Nullable<Vector3>;
  21030. /**
  21031. * Sets the angular velocity
  21032. * @param velocity The velocity or null
  21033. */
  21034. setAngularVelocity(velocity: Nullable<Vector3>): void;
  21035. /**
  21036. * Execute a function with the physics plugin native code
  21037. * Provide a function the will have two variables - the world object and the physics body object
  21038. * @param func The function to execute with the physics plugin native code
  21039. */
  21040. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  21041. /**
  21042. * Register a function that will be executed before the physics world is stepping forward
  21043. * @param func The function to execute before the physics world is stepped forward
  21044. */
  21045. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21046. /**
  21047. * Unregister a function that will be executed before the physics world is stepping forward
  21048. * @param func The function to execute before the physics world is stepped forward
  21049. */
  21050. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21051. /**
  21052. * Register a function that will be executed after the physics step
  21053. * @param func The function to execute after physics step
  21054. */
  21055. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21056. /**
  21057. * Unregisters a function that will be executed after the physics step
  21058. * @param func The function to execute after physics step
  21059. */
  21060. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  21061. /**
  21062. * register a function that will be executed when this impostor collides against a different body
  21063. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  21064. * @param func Callback that is executed on collision
  21065. */
  21066. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  21067. /**
  21068. * Unregisters the physics imposter on contact
  21069. * @param collideAgainst The physics object to collide against
  21070. * @param func Callback to execute on collision
  21071. */
  21072. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  21073. private _tmpQuat;
  21074. private _tmpQuat2;
  21075. /**
  21076. * Get the parent rotation
  21077. * @returns The parent rotation
  21078. */
  21079. getParentsRotation(): Quaternion;
  21080. /**
  21081. * this function is executed by the physics engine.
  21082. */
  21083. beforeStep: () => void;
  21084. /**
  21085. * this function is executed by the physics engine
  21086. */
  21087. afterStep: () => void;
  21088. /**
  21089. * Legacy collision detection event support
  21090. */
  21091. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  21092. /**
  21093. * event and body object due to cannon's event-based architecture.
  21094. */
  21095. onCollide: (e: {
  21096. body: any;
  21097. }) => void;
  21098. /**
  21099. * Apply a force
  21100. * @param force The force to apply
  21101. * @param contactPoint The contact point for the force
  21102. * @returns The physics imposter
  21103. */
  21104. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21105. /**
  21106. * Apply an impulse
  21107. * @param force The impulse force
  21108. * @param contactPoint The contact point for the impulse force
  21109. * @returns The physics imposter
  21110. */
  21111. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  21112. /**
  21113. * A help function to create a joint
  21114. * @param otherImpostor A physics imposter used to create a joint
  21115. * @param jointType The type of joint
  21116. * @param jointData The data for the joint
  21117. * @returns The physics imposter
  21118. */
  21119. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  21120. /**
  21121. * Add a joint to this impostor with a different impostor
  21122. * @param otherImpostor A physics imposter used to add a joint
  21123. * @param joint The joint to add
  21124. * @returns The physics imposter
  21125. */
  21126. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  21127. /**
  21128. * Add an anchor to a cloth impostor
  21129. * @param otherImpostor rigid impostor to anchor to
  21130. * @param width ratio across width from 0 to 1
  21131. * @param height ratio up height from 0 to 1
  21132. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  21133. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  21134. * @returns impostor the soft imposter
  21135. */
  21136. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21137. /**
  21138. * Add a hook to a rope impostor
  21139. * @param otherImpostor rigid impostor to anchor to
  21140. * @param length ratio across rope from 0 to 1
  21141. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  21142. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  21143. * @returns impostor the rope imposter
  21144. */
  21145. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  21146. /**
  21147. * Will keep this body still, in a sleep mode.
  21148. * @returns the physics imposter
  21149. */
  21150. sleep(): PhysicsImpostor;
  21151. /**
  21152. * Wake the body up.
  21153. * @returns The physics imposter
  21154. */
  21155. wakeUp(): PhysicsImpostor;
  21156. /**
  21157. * Clones the physics imposter
  21158. * @param newObject The physics imposter clones to this physics-enabled object
  21159. * @returns A nullable physics imposter
  21160. */
  21161. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  21162. /**
  21163. * Disposes the physics imposter
  21164. */
  21165. dispose(): void;
  21166. /**
  21167. * Sets the delta position
  21168. * @param position The delta position amount
  21169. */
  21170. setDeltaPosition(position: Vector3): void;
  21171. /**
  21172. * Sets the delta rotation
  21173. * @param rotation The delta rotation amount
  21174. */
  21175. setDeltaRotation(rotation: Quaternion): void;
  21176. /**
  21177. * Gets the box size of the physics imposter and stores the result in the input parameter
  21178. * @param result Stores the box size
  21179. * @returns The physics imposter
  21180. */
  21181. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  21182. /**
  21183. * Gets the radius of the physics imposter
  21184. * @returns Radius of the physics imposter
  21185. */
  21186. getRadius(): number;
  21187. /**
  21188. * Sync a bone with this impostor
  21189. * @param bone The bone to sync to the impostor.
  21190. * @param boneMesh The mesh that the bone is influencing.
  21191. * @param jointPivot The pivot of the joint / bone in local space.
  21192. * @param distToJoint Optional distance from the impostor to the joint.
  21193. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21194. */
  21195. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21196. /**
  21197. * Sync impostor to a bone
  21198. * @param bone The bone that the impostor will be synced to.
  21199. * @param boneMesh The mesh that the bone is influencing.
  21200. * @param jointPivot The pivot of the joint / bone in local space.
  21201. * @param distToJoint Optional distance from the impostor to the joint.
  21202. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21203. * @param boneAxis Optional vector3 axis the bone is aligned with
  21204. */
  21205. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21206. /**
  21207. * No-Imposter type
  21208. */
  21209. static NoImpostor: number;
  21210. /**
  21211. * Sphere-Imposter type
  21212. */
  21213. static SphereImpostor: number;
  21214. /**
  21215. * Box-Imposter type
  21216. */
  21217. static BoxImpostor: number;
  21218. /**
  21219. * Plane-Imposter type
  21220. */
  21221. static PlaneImpostor: number;
  21222. /**
  21223. * Mesh-imposter type
  21224. */
  21225. static MeshImpostor: number;
  21226. /**
  21227. * Cylinder-Imposter type
  21228. */
  21229. static CylinderImpostor: number;
  21230. /**
  21231. * Particle-Imposter type
  21232. */
  21233. static ParticleImpostor: number;
  21234. /**
  21235. * Heightmap-Imposter type
  21236. */
  21237. static HeightmapImpostor: number;
  21238. /**
  21239. * ConvexHull-Impostor type (Ammo.js plugin only)
  21240. */
  21241. static ConvexHullImpostor: number;
  21242. /**
  21243. * Rope-Imposter type
  21244. */
  21245. static RopeImpostor: number;
  21246. /**
  21247. * Cloth-Imposter type
  21248. */
  21249. static ClothImpostor: number;
  21250. /**
  21251. * Softbody-Imposter type
  21252. */
  21253. static SoftbodyImpostor: number;
  21254. }
  21255. }
  21256. declare module "babylonjs/Meshes/mesh" {
  21257. import { Observable } from "babylonjs/Misc/observable";
  21258. import { IAnimatable } from "babylonjs/Misc/tools";
  21259. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21260. import { Camera } from "babylonjs/Cameras/camera";
  21261. import { Scene } from "babylonjs/scene";
  21262. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21263. import { Engine } from "babylonjs/Engines/engine";
  21264. import { Node } from "babylonjs/node";
  21265. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21266. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21267. import { Buffer } from "babylonjs/Meshes/buffer";
  21268. import { Geometry } from "babylonjs/Meshes/geometry";
  21269. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21270. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21271. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21272. import { Effect } from "babylonjs/Materials/effect";
  21273. import { Material } from "babylonjs/Materials/material";
  21274. import { Skeleton } from "babylonjs/Bones/skeleton";
  21275. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21276. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  21277. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21278. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21279. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21280. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21281. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21282. /**
  21283. * @hidden
  21284. **/
  21285. export class _CreationDataStorage {
  21286. closePath?: boolean;
  21287. closeArray?: boolean;
  21288. idx: number[];
  21289. dashSize: number;
  21290. gapSize: number;
  21291. path3D: Path3D;
  21292. pathArray: Vector3[][];
  21293. arc: number;
  21294. radius: number;
  21295. cap: number;
  21296. tessellation: number;
  21297. }
  21298. /**
  21299. * @hidden
  21300. **/
  21301. class _InstanceDataStorage {
  21302. visibleInstances: any;
  21303. batchCache: _InstancesBatch;
  21304. instancesBufferSize: number;
  21305. instancesBuffer: Nullable<Buffer>;
  21306. instancesData: Float32Array;
  21307. overridenInstanceCount: number;
  21308. isFrozen: boolean;
  21309. previousBatch: _InstancesBatch;
  21310. hardwareInstancedRendering: boolean;
  21311. sideOrientation: number;
  21312. }
  21313. /**
  21314. * @hidden
  21315. **/
  21316. export class _InstancesBatch {
  21317. mustReturn: boolean;
  21318. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21319. renderSelf: boolean[];
  21320. hardwareInstancedRendering: boolean[];
  21321. }
  21322. /**
  21323. * Class used to represent renderable models
  21324. */
  21325. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21326. /**
  21327. * Mesh side orientation : usually the external or front surface
  21328. */
  21329. static readonly FRONTSIDE: number;
  21330. /**
  21331. * Mesh side orientation : usually the internal or back surface
  21332. */
  21333. static readonly BACKSIDE: number;
  21334. /**
  21335. * Mesh side orientation : both internal and external or front and back surfaces
  21336. */
  21337. static readonly DOUBLESIDE: number;
  21338. /**
  21339. * Mesh side orientation : by default, `FRONTSIDE`
  21340. */
  21341. static readonly DEFAULTSIDE: number;
  21342. /**
  21343. * Mesh cap setting : no cap
  21344. */
  21345. static readonly NO_CAP: number;
  21346. /**
  21347. * Mesh cap setting : one cap at the beginning of the mesh
  21348. */
  21349. static readonly CAP_START: number;
  21350. /**
  21351. * Mesh cap setting : one cap at the end of the mesh
  21352. */
  21353. static readonly CAP_END: number;
  21354. /**
  21355. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21356. */
  21357. static readonly CAP_ALL: number;
  21358. /**
  21359. * Mesh pattern setting : no flip or rotate
  21360. */
  21361. static readonly NO_FLIP: number;
  21362. /**
  21363. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  21364. */
  21365. static readonly FLIP_TILE: number;
  21366. /**
  21367. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  21368. */
  21369. static readonly ROTATE_TILE: number;
  21370. /**
  21371. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  21372. */
  21373. static readonly FLIP_ROW: number;
  21374. /**
  21375. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  21376. */
  21377. static readonly ROTATE_ROW: number;
  21378. /**
  21379. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  21380. */
  21381. static readonly FLIP_N_ROTATE_TILE: number;
  21382. /**
  21383. * Mesh pattern setting : rotate pattern and rotate
  21384. */
  21385. static readonly FLIP_N_ROTATE_ROW: number;
  21386. /**
  21387. * Mesh tile positioning : part tiles same on left/right or top/bottom
  21388. */
  21389. static readonly CENTER: number;
  21390. /**
  21391. * Mesh tile positioning : part tiles on left
  21392. */
  21393. static readonly LEFT: number;
  21394. /**
  21395. * Mesh tile positioning : part tiles on right
  21396. */
  21397. static readonly RIGHT: number;
  21398. /**
  21399. * Mesh tile positioning : part tiles on top
  21400. */
  21401. static readonly TOP: number;
  21402. /**
  21403. * Mesh tile positioning : part tiles on bottom
  21404. */
  21405. static readonly BOTTOM: number;
  21406. /**
  21407. * Gets the default side orientation.
  21408. * @param orientation the orientation to value to attempt to get
  21409. * @returns the default orientation
  21410. * @hidden
  21411. */
  21412. static _GetDefaultSideOrientation(orientation?: number): number;
  21413. private _internalMeshDataInfo;
  21414. /**
  21415. * An event triggered before rendering the mesh
  21416. */
  21417. readonly onBeforeRenderObservable: Observable<Mesh>;
  21418. /**
  21419. * An event triggered before binding the mesh
  21420. */
  21421. readonly onBeforeBindObservable: Observable<Mesh>;
  21422. /**
  21423. * An event triggered after rendering the mesh
  21424. */
  21425. readonly onAfterRenderObservable: Observable<Mesh>;
  21426. /**
  21427. * An event triggered before drawing the mesh
  21428. */
  21429. readonly onBeforeDrawObservable: Observable<Mesh>;
  21430. private _onBeforeDrawObserver;
  21431. /**
  21432. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21433. */
  21434. onBeforeDraw: () => void;
  21435. /**
  21436. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21437. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21438. */
  21439. delayLoadState: number;
  21440. /**
  21441. * Gets the list of instances created from this mesh
  21442. * it is not supposed to be modified manually.
  21443. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21444. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21445. */
  21446. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21447. /**
  21448. * Gets the file containing delay loading data for this mesh
  21449. */
  21450. delayLoadingFile: string;
  21451. /** @hidden */
  21452. _binaryInfo: any;
  21453. /**
  21454. * User defined function used to change how LOD level selection is done
  21455. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21456. */
  21457. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21458. /**
  21459. * Gets or sets the morph target manager
  21460. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21461. */
  21462. morphTargetManager: Nullable<MorphTargetManager>;
  21463. /** @hidden */
  21464. _creationDataStorage: Nullable<_CreationDataStorage>;
  21465. /** @hidden */
  21466. _geometry: Nullable<Geometry>;
  21467. /** @hidden */
  21468. _delayInfo: Array<string>;
  21469. /** @hidden */
  21470. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21471. /** @hidden */
  21472. _instanceDataStorage: _InstanceDataStorage;
  21473. private _effectiveMaterial;
  21474. /** @hidden */
  21475. _shouldGenerateFlatShading: boolean;
  21476. /** @hidden */
  21477. _originalBuilderSideOrientation: number;
  21478. /**
  21479. * Use this property to change the original side orientation defined at construction time
  21480. */
  21481. overrideMaterialSideOrientation: Nullable<number>;
  21482. /**
  21483. * Gets the source mesh (the one used to clone this one from)
  21484. */
  21485. readonly source: Nullable<Mesh>;
  21486. /**
  21487. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21488. */
  21489. isUnIndexed: boolean;
  21490. /**
  21491. * @constructor
  21492. * @param name The value used by scene.getMeshByName() to do a lookup.
  21493. * @param scene The scene to add this mesh to.
  21494. * @param parent The parent of this mesh, if it has one
  21495. * @param source An optional Mesh from which geometry is shared, cloned.
  21496. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21497. * When false, achieved by calling a clone(), also passing False.
  21498. * This will make creation of children, recursive.
  21499. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21500. */
  21501. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21502. /**
  21503. * Gets the class name
  21504. * @returns the string "Mesh".
  21505. */
  21506. getClassName(): string;
  21507. /** @hidden */
  21508. readonly _isMesh: boolean;
  21509. /**
  21510. * Returns a description of this mesh
  21511. * @param fullDetails define if full details about this mesh must be used
  21512. * @returns a descriptive string representing this mesh
  21513. */
  21514. toString(fullDetails?: boolean): string;
  21515. /** @hidden */
  21516. _unBindEffect(): void;
  21517. /**
  21518. * Gets a boolean indicating if this mesh has LOD
  21519. */
  21520. readonly hasLODLevels: boolean;
  21521. /**
  21522. * Gets the list of MeshLODLevel associated with the current mesh
  21523. * @returns an array of MeshLODLevel
  21524. */
  21525. getLODLevels(): MeshLODLevel[];
  21526. private _sortLODLevels;
  21527. /**
  21528. * Add a mesh as LOD level triggered at the given distance.
  21529. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21530. * @param distance The distance from the center of the object to show this level
  21531. * @param mesh The mesh to be added as LOD level (can be null)
  21532. * @return This mesh (for chaining)
  21533. */
  21534. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21535. /**
  21536. * Returns the LOD level mesh at the passed distance or null if not found.
  21537. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21538. * @param distance The distance from the center of the object to show this level
  21539. * @returns a Mesh or `null`
  21540. */
  21541. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21542. /**
  21543. * Remove a mesh from the LOD array
  21544. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21545. * @param mesh defines the mesh to be removed
  21546. * @return This mesh (for chaining)
  21547. */
  21548. removeLODLevel(mesh: Mesh): Mesh;
  21549. /**
  21550. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21551. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21552. * @param camera defines the camera to use to compute distance
  21553. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21554. * @return This mesh (for chaining)
  21555. */
  21556. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21557. /**
  21558. * Gets the mesh internal Geometry object
  21559. */
  21560. readonly geometry: Nullable<Geometry>;
  21561. /**
  21562. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21563. * @returns the total number of vertices
  21564. */
  21565. getTotalVertices(): number;
  21566. /**
  21567. * Returns the content of an associated vertex buffer
  21568. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21569. * - VertexBuffer.PositionKind
  21570. * - VertexBuffer.UVKind
  21571. * - VertexBuffer.UV2Kind
  21572. * - VertexBuffer.UV3Kind
  21573. * - VertexBuffer.UV4Kind
  21574. * - VertexBuffer.UV5Kind
  21575. * - VertexBuffer.UV6Kind
  21576. * - VertexBuffer.ColorKind
  21577. * - VertexBuffer.MatricesIndicesKind
  21578. * - VertexBuffer.MatricesIndicesExtraKind
  21579. * - VertexBuffer.MatricesWeightsKind
  21580. * - VertexBuffer.MatricesWeightsExtraKind
  21581. * @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
  21582. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21583. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21584. */
  21585. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21586. /**
  21587. * Returns the mesh VertexBuffer object from the requested `kind`
  21588. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21589. * - VertexBuffer.PositionKind
  21590. * - VertexBuffer.NormalKind
  21591. * - VertexBuffer.UVKind
  21592. * - VertexBuffer.UV2Kind
  21593. * - VertexBuffer.UV3Kind
  21594. * - VertexBuffer.UV4Kind
  21595. * - VertexBuffer.UV5Kind
  21596. * - VertexBuffer.UV6Kind
  21597. * - VertexBuffer.ColorKind
  21598. * - VertexBuffer.MatricesIndicesKind
  21599. * - VertexBuffer.MatricesIndicesExtraKind
  21600. * - VertexBuffer.MatricesWeightsKind
  21601. * - VertexBuffer.MatricesWeightsExtraKind
  21602. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21603. */
  21604. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21605. /**
  21606. * Tests if a specific vertex buffer is associated with this mesh
  21607. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21608. * - VertexBuffer.PositionKind
  21609. * - VertexBuffer.NormalKind
  21610. * - VertexBuffer.UVKind
  21611. * - VertexBuffer.UV2Kind
  21612. * - VertexBuffer.UV3Kind
  21613. * - VertexBuffer.UV4Kind
  21614. * - VertexBuffer.UV5Kind
  21615. * - VertexBuffer.UV6Kind
  21616. * - VertexBuffer.ColorKind
  21617. * - VertexBuffer.MatricesIndicesKind
  21618. * - VertexBuffer.MatricesIndicesExtraKind
  21619. * - VertexBuffer.MatricesWeightsKind
  21620. * - VertexBuffer.MatricesWeightsExtraKind
  21621. * @returns a boolean
  21622. */
  21623. isVerticesDataPresent(kind: string): boolean;
  21624. /**
  21625. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21626. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21627. * - VertexBuffer.PositionKind
  21628. * - VertexBuffer.UVKind
  21629. * - VertexBuffer.UV2Kind
  21630. * - VertexBuffer.UV3Kind
  21631. * - VertexBuffer.UV4Kind
  21632. * - VertexBuffer.UV5Kind
  21633. * - VertexBuffer.UV6Kind
  21634. * - VertexBuffer.ColorKind
  21635. * - VertexBuffer.MatricesIndicesKind
  21636. * - VertexBuffer.MatricesIndicesExtraKind
  21637. * - VertexBuffer.MatricesWeightsKind
  21638. * - VertexBuffer.MatricesWeightsExtraKind
  21639. * @returns a boolean
  21640. */
  21641. isVertexBufferUpdatable(kind: string): boolean;
  21642. /**
  21643. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21644. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21645. * - VertexBuffer.PositionKind
  21646. * - VertexBuffer.NormalKind
  21647. * - VertexBuffer.UVKind
  21648. * - VertexBuffer.UV2Kind
  21649. * - VertexBuffer.UV3Kind
  21650. * - VertexBuffer.UV4Kind
  21651. * - VertexBuffer.UV5Kind
  21652. * - VertexBuffer.UV6Kind
  21653. * - VertexBuffer.ColorKind
  21654. * - VertexBuffer.MatricesIndicesKind
  21655. * - VertexBuffer.MatricesIndicesExtraKind
  21656. * - VertexBuffer.MatricesWeightsKind
  21657. * - VertexBuffer.MatricesWeightsExtraKind
  21658. * @returns an array of strings
  21659. */
  21660. getVerticesDataKinds(): string[];
  21661. /**
  21662. * Returns a positive integer : the total number of indices in this mesh geometry.
  21663. * @returns the numner of indices or zero if the mesh has no geometry.
  21664. */
  21665. getTotalIndices(): number;
  21666. /**
  21667. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21668. * @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.
  21669. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21670. * @returns the indices array or an empty array if the mesh has no geometry
  21671. */
  21672. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21673. readonly isBlocked: boolean;
  21674. /**
  21675. * Determine if the current mesh is ready to be rendered
  21676. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21677. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21678. * @returns true if all associated assets are ready (material, textures, shaders)
  21679. */
  21680. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21681. /**
  21682. * 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.
  21683. */
  21684. readonly areNormalsFrozen: boolean;
  21685. /**
  21686. * 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.
  21687. * @returns the current mesh
  21688. */
  21689. freezeNormals(): Mesh;
  21690. /**
  21691. * 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
  21692. * @returns the current mesh
  21693. */
  21694. unfreezeNormals(): Mesh;
  21695. /**
  21696. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21697. */
  21698. overridenInstanceCount: number;
  21699. /** @hidden */
  21700. _preActivate(): Mesh;
  21701. /** @hidden */
  21702. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21703. /** @hidden */
  21704. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21705. /**
  21706. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21707. * This means the mesh underlying bounding box and sphere are recomputed.
  21708. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21709. * @returns the current mesh
  21710. */
  21711. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21712. /** @hidden */
  21713. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21714. /**
  21715. * This function will subdivide the mesh into multiple submeshes
  21716. * @param count defines the expected number of submeshes
  21717. */
  21718. subdivide(count: number): void;
  21719. /**
  21720. * Copy a FloatArray into a specific associated vertex buffer
  21721. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21722. * - VertexBuffer.PositionKind
  21723. * - VertexBuffer.UVKind
  21724. * - VertexBuffer.UV2Kind
  21725. * - VertexBuffer.UV3Kind
  21726. * - VertexBuffer.UV4Kind
  21727. * - VertexBuffer.UV5Kind
  21728. * - VertexBuffer.UV6Kind
  21729. * - VertexBuffer.ColorKind
  21730. * - VertexBuffer.MatricesIndicesKind
  21731. * - VertexBuffer.MatricesIndicesExtraKind
  21732. * - VertexBuffer.MatricesWeightsKind
  21733. * - VertexBuffer.MatricesWeightsExtraKind
  21734. * @param data defines the data source
  21735. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21736. * @param stride defines the data stride size (can be null)
  21737. * @returns the current mesh
  21738. */
  21739. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21740. /**
  21741. * Flags an associated vertex buffer as updatable
  21742. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21743. * - VertexBuffer.PositionKind
  21744. * - VertexBuffer.UVKind
  21745. * - VertexBuffer.UV2Kind
  21746. * - VertexBuffer.UV3Kind
  21747. * - VertexBuffer.UV4Kind
  21748. * - VertexBuffer.UV5Kind
  21749. * - VertexBuffer.UV6Kind
  21750. * - VertexBuffer.ColorKind
  21751. * - VertexBuffer.MatricesIndicesKind
  21752. * - VertexBuffer.MatricesIndicesExtraKind
  21753. * - VertexBuffer.MatricesWeightsKind
  21754. * - VertexBuffer.MatricesWeightsExtraKind
  21755. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21756. */
  21757. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21758. /**
  21759. * Sets the mesh global Vertex Buffer
  21760. * @param buffer defines the buffer to use
  21761. * @returns the current mesh
  21762. */
  21763. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21764. /**
  21765. * Update a specific associated vertex buffer
  21766. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21767. * - VertexBuffer.PositionKind
  21768. * - VertexBuffer.UVKind
  21769. * - VertexBuffer.UV2Kind
  21770. * - VertexBuffer.UV3Kind
  21771. * - VertexBuffer.UV4Kind
  21772. * - VertexBuffer.UV5Kind
  21773. * - VertexBuffer.UV6Kind
  21774. * - VertexBuffer.ColorKind
  21775. * - VertexBuffer.MatricesIndicesKind
  21776. * - VertexBuffer.MatricesIndicesExtraKind
  21777. * - VertexBuffer.MatricesWeightsKind
  21778. * - VertexBuffer.MatricesWeightsExtraKind
  21779. * @param data defines the data source
  21780. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21781. * @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)
  21782. * @returns the current mesh
  21783. */
  21784. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21785. /**
  21786. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21787. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21788. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21789. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21790. * @returns the current mesh
  21791. */
  21792. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21793. /**
  21794. * Creates a un-shared specific occurence of the geometry for the mesh.
  21795. * @returns the current mesh
  21796. */
  21797. makeGeometryUnique(): Mesh;
  21798. /**
  21799. * Set the index buffer of this mesh
  21800. * @param indices defines the source data
  21801. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21802. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21803. * @returns the current mesh
  21804. */
  21805. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21806. /**
  21807. * Update the current index buffer
  21808. * @param indices defines the source data
  21809. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21810. * @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)
  21811. * @returns the current mesh
  21812. */
  21813. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21814. /**
  21815. * Invert the geometry to move from a right handed system to a left handed one.
  21816. * @returns the current mesh
  21817. */
  21818. toLeftHanded(): Mesh;
  21819. /** @hidden */
  21820. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21821. /** @hidden */
  21822. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21823. /**
  21824. * Registers for this mesh a javascript function called just before the rendering process
  21825. * @param func defines the function to call before rendering this mesh
  21826. * @returns the current mesh
  21827. */
  21828. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21829. /**
  21830. * Disposes a previously registered javascript function called before the rendering
  21831. * @param func defines the function to remove
  21832. * @returns the current mesh
  21833. */
  21834. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21835. /**
  21836. * Registers for this mesh a javascript function called just after the rendering is complete
  21837. * @param func defines the function to call after rendering this mesh
  21838. * @returns the current mesh
  21839. */
  21840. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21841. /**
  21842. * Disposes a previously registered javascript function called after the rendering.
  21843. * @param func defines the function to remove
  21844. * @returns the current mesh
  21845. */
  21846. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21847. /** @hidden */
  21848. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21849. /** @hidden */
  21850. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21851. /** @hidden */
  21852. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21853. /** @hidden */
  21854. _freeze(): void;
  21855. /** @hidden */
  21856. _unFreeze(): void;
  21857. /**
  21858. * 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
  21859. * @param subMesh defines the subMesh to render
  21860. * @param enableAlphaMode defines if alpha mode can be changed
  21861. * @returns the current mesh
  21862. */
  21863. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21864. private _onBeforeDraw;
  21865. /**
  21866. * Renormalize the mesh and patch it up if there are no weights
  21867. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21868. * However in the case of zero weights then we set just a single influence to 1.
  21869. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21870. */
  21871. cleanMatrixWeights(): void;
  21872. private normalizeSkinFourWeights;
  21873. private normalizeSkinWeightsAndExtra;
  21874. /**
  21875. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21876. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21877. * the user know there was an issue with importing the mesh
  21878. * @returns a validation object with skinned, valid and report string
  21879. */
  21880. validateSkinning(): {
  21881. skinned: boolean;
  21882. valid: boolean;
  21883. report: string;
  21884. };
  21885. /** @hidden */
  21886. _checkDelayState(): Mesh;
  21887. private _queueLoad;
  21888. /**
  21889. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21890. * A mesh is in the frustum if its bounding box intersects the frustum
  21891. * @param frustumPlanes defines the frustum to test
  21892. * @returns true if the mesh is in the frustum planes
  21893. */
  21894. isInFrustum(frustumPlanes: Plane[]): boolean;
  21895. /**
  21896. * Sets the mesh material by the material or multiMaterial `id` property
  21897. * @param id is a string identifying the material or the multiMaterial
  21898. * @returns the current mesh
  21899. */
  21900. setMaterialByID(id: string): Mesh;
  21901. /**
  21902. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21903. * @returns an array of IAnimatable
  21904. */
  21905. getAnimatables(): IAnimatable[];
  21906. /**
  21907. * Modifies the mesh geometry according to the passed transformation matrix.
  21908. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21909. * The mesh normals are modified using the same transformation.
  21910. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21911. * @param transform defines the transform matrix to use
  21912. * @see http://doc.babylonjs.com/resources/baking_transformations
  21913. * @returns the current mesh
  21914. */
  21915. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21916. /**
  21917. * Modifies the mesh geometry according to its own current World Matrix.
  21918. * The mesh World Matrix is then reset.
  21919. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21920. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21921. * @see http://doc.babylonjs.com/resources/baking_transformations
  21922. * @returns the current mesh
  21923. */
  21924. bakeCurrentTransformIntoVertices(): Mesh;
  21925. /** @hidden */
  21926. readonly _positions: Nullable<Vector3[]>;
  21927. /** @hidden */
  21928. _resetPointsArrayCache(): Mesh;
  21929. /** @hidden */
  21930. _generatePointsArray(): boolean;
  21931. /**
  21932. * Returns a new Mesh object generated from the current mesh properties.
  21933. * This method must not get confused with createInstance()
  21934. * @param name is a string, the name given to the new mesh
  21935. * @param newParent can be any Node object (default `null`)
  21936. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21937. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21938. * @returns a new mesh
  21939. */
  21940. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21941. /**
  21942. * Releases resources associated with this mesh.
  21943. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21944. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21945. */
  21946. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21947. /**
  21948. * Modifies the mesh geometry according to a displacement map.
  21949. * 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.
  21950. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21951. * @param url is a string, the URL from the image file is to be downloaded.
  21952. * @param minHeight is the lower limit of the displacement.
  21953. * @param maxHeight is the upper limit of the displacement.
  21954. * @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.
  21955. * @param uvOffset is an optional vector2 used to offset UV.
  21956. * @param uvScale is an optional vector2 used to scale UV.
  21957. * @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.
  21958. * @returns the Mesh.
  21959. */
  21960. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21961. /**
  21962. * Modifies the mesh geometry according to a displacementMap buffer.
  21963. * 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.
  21964. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21965. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21966. * @param heightMapWidth is the width of the buffer image.
  21967. * @param heightMapHeight is the height of the buffer image.
  21968. * @param minHeight is the lower limit of the displacement.
  21969. * @param maxHeight is the upper limit of the displacement.
  21970. * @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.
  21971. * @param uvOffset is an optional vector2 used to offset UV.
  21972. * @param uvScale is an optional vector2 used to scale UV.
  21973. * @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.
  21974. * @returns the Mesh.
  21975. */
  21976. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21977. /**
  21978. * Modify the mesh to get a flat shading rendering.
  21979. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21980. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21981. * @returns current mesh
  21982. */
  21983. convertToFlatShadedMesh(): Mesh;
  21984. /**
  21985. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21986. * In other words, more vertices, no more indices and a single bigger VBO.
  21987. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21988. * @returns current mesh
  21989. */
  21990. convertToUnIndexedMesh(): Mesh;
  21991. /**
  21992. * Inverses facet orientations.
  21993. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21994. * @param flipNormals will also inverts the normals
  21995. * @returns current mesh
  21996. */
  21997. flipFaces(flipNormals?: boolean): Mesh;
  21998. /**
  21999. * Increase the number of facets and hence vertices in a mesh
  22000. * Vertex normals are interpolated from existing vertex normals
  22001. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22002. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  22003. */
  22004. increaseVertices(numberPerEdge: number): void;
  22005. /**
  22006. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  22007. * This will undo any application of covertToFlatShadedMesh
  22008. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  22009. */
  22010. forceSharedVertices(): void;
  22011. /** @hidden */
  22012. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  22013. /** @hidden */
  22014. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  22015. /**
  22016. * Creates a new InstancedMesh object from the mesh model.
  22017. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  22018. * @param name defines the name of the new instance
  22019. * @returns a new InstancedMesh
  22020. */
  22021. createInstance(name: string): InstancedMesh;
  22022. /**
  22023. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  22024. * After this call, all the mesh instances have the same submeshes than the current mesh.
  22025. * @returns the current mesh
  22026. */
  22027. synchronizeInstances(): Mesh;
  22028. /**
  22029. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  22030. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  22031. * This should be used together with the simplification to avoid disappearing triangles.
  22032. * @param successCallback an optional success callback to be called after the optimization finished.
  22033. * @returns the current mesh
  22034. */
  22035. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  22036. /**
  22037. * Serialize current mesh
  22038. * @param serializationObject defines the object which will receive the serialization data
  22039. */
  22040. serialize(serializationObject: any): void;
  22041. /** @hidden */
  22042. _syncGeometryWithMorphTargetManager(): void;
  22043. /** @hidden */
  22044. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  22045. /**
  22046. * Returns a new Mesh object parsed from the source provided.
  22047. * @param parsedMesh is the source
  22048. * @param scene defines the hosting scene
  22049. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  22050. * @returns a new Mesh
  22051. */
  22052. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  22053. /**
  22054. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  22055. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22056. * @param name defines the name of the mesh to create
  22057. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  22058. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  22059. * @param closePath creates a seam between the first and the last points of each path of the path array
  22060. * @param offset is taken in account only if the `pathArray` is containing a single path
  22061. * @param scene defines the hosting scene
  22062. * @param updatable defines if the mesh must be flagged as updatable
  22063. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22064. * @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)
  22065. * @returns a new Mesh
  22066. */
  22067. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22068. /**
  22069. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  22070. * @param name defines the name of the mesh to create
  22071. * @param radius sets the radius size (float) of the polygon (default 0.5)
  22072. * @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
  22073. * @param scene defines the hosting scene
  22074. * @param updatable defines if the mesh must be flagged as updatable
  22075. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22076. * @returns a new Mesh
  22077. */
  22078. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22079. /**
  22080. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  22081. * @param name defines the name of the mesh to create
  22082. * @param size sets the size (float) of each box side (default 1)
  22083. * @param scene defines the hosting scene
  22084. * @param updatable defines if the mesh must be flagged as updatable
  22085. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22086. * @returns a new Mesh
  22087. */
  22088. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  22089. /**
  22090. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  22091. * @param name defines the name of the mesh to create
  22092. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22093. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22094. * @param scene defines the hosting scene
  22095. * @param updatable defines if the mesh must be flagged as updatable
  22096. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22097. * @returns a new Mesh
  22098. */
  22099. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22100. /**
  22101. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  22102. * @param name defines the name of the mesh to create
  22103. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  22104. * @param diameter sets the diameter size (float) of the sphere (default 1)
  22105. * @param scene defines the hosting scene
  22106. * @returns a new Mesh
  22107. */
  22108. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  22109. /**
  22110. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  22111. * @param name defines the name of the mesh to create
  22112. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  22113. * @param diameterTop set the top cap diameter (floats, default 1)
  22114. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  22115. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  22116. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  22117. * @param scene defines the hosting scene
  22118. * @param updatable defines if the mesh must be flagged as updatable
  22119. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22120. * @returns a new Mesh
  22121. */
  22122. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  22123. /**
  22124. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  22125. * @param name defines the name of the mesh to create
  22126. * @param diameter sets the diameter size (float) of the torus (default 1)
  22127. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  22128. * @param tessellation sets the number of torus sides (postive integer, default 16)
  22129. * @param scene defines the hosting scene
  22130. * @param updatable defines if the mesh must be flagged as updatable
  22131. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22132. * @returns a new Mesh
  22133. */
  22134. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22135. /**
  22136. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  22137. * @param name defines the name of the mesh to create
  22138. * @param radius sets the global radius size (float) of the torus knot (default 2)
  22139. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  22140. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  22141. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  22142. * @param p the number of windings on X axis (positive integers, default 2)
  22143. * @param q the number of windings on Y axis (positive integers, default 3)
  22144. * @param scene defines the hosting scene
  22145. * @param updatable defines if the mesh must be flagged as updatable
  22146. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22147. * @returns a new Mesh
  22148. */
  22149. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22150. /**
  22151. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  22152. * @param name defines the name of the mesh to create
  22153. * @param points is an array successive Vector3
  22154. * @param scene defines the hosting scene
  22155. * @param updatable defines if the mesh must be flagged as updatable
  22156. * @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).
  22157. * @returns a new Mesh
  22158. */
  22159. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  22160. /**
  22161. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  22162. * @param name defines the name of the mesh to create
  22163. * @param points is an array successive Vector3
  22164. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  22165. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  22166. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  22167. * @param scene defines the hosting scene
  22168. * @param updatable defines if the mesh must be flagged as updatable
  22169. * @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)
  22170. * @returns a new Mesh
  22171. */
  22172. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  22173. /**
  22174. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  22175. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  22176. * 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.
  22177. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22178. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  22179. * Remember you can only change the shape positions, not their number when updating a polygon.
  22180. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  22181. * @param name defines the name of the mesh to create
  22182. * @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
  22183. * @param scene defines the hosting scene
  22184. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22185. * @param updatable defines if the mesh must be flagged as updatable
  22186. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22187. * @param earcutInjection can be used to inject your own earcut reference
  22188. * @returns a new Mesh
  22189. */
  22190. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22191. /**
  22192. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  22193. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  22194. * @param name defines the name of the mesh to create
  22195. * @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
  22196. * @param depth defines the height of extrusion
  22197. * @param scene defines the hosting scene
  22198. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  22199. * @param updatable defines if the mesh must be flagged as updatable
  22200. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22201. * @param earcutInjection can be used to inject your own earcut reference
  22202. * @returns a new Mesh
  22203. */
  22204. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  22205. /**
  22206. * Creates an extruded shape mesh.
  22207. * 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
  22208. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22209. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22210. * @param name defines the name of the mesh to create
  22211. * @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
  22212. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22213. * @param scale is the value to scale the shape
  22214. * @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
  22215. * @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
  22216. * @param scene defines the hosting scene
  22217. * @param updatable defines if the mesh must be flagged as updatable
  22218. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22219. * @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)
  22220. * @returns a new Mesh
  22221. */
  22222. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22223. /**
  22224. * Creates an custom extruded shape mesh.
  22225. * The custom extrusion is a parametric shape.
  22226. * It has no predefined shape. Its final shape will depend on the input parameters.
  22227. * Please consider using the same method from the MeshBuilder class instead
  22228. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22229. * @param name defines the name of the mesh to create
  22230. * @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
  22231. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22232. * @param scaleFunction is a custom Javascript function called on each path point
  22233. * @param rotationFunction is a custom Javascript function called on each path point
  22234. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22235. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22236. * @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
  22237. * @param scene defines the hosting scene
  22238. * @param updatable defines if the mesh must be flagged as updatable
  22239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22240. * @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)
  22241. * @returns a new Mesh
  22242. */
  22243. 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;
  22244. /**
  22245. * Creates lathe mesh.
  22246. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22247. * Please consider using the same method from the MeshBuilder class instead
  22248. * @param name defines the name of the mesh to create
  22249. * @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
  22250. * @param radius is the radius value of the lathe
  22251. * @param tessellation is the side number of the lathe.
  22252. * @param scene defines the hosting scene
  22253. * @param updatable defines if the mesh must be flagged as updatable
  22254. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22255. * @returns a new Mesh
  22256. */
  22257. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22258. /**
  22259. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22260. * @param name defines the name of the mesh to create
  22261. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22262. * @param scene defines the hosting scene
  22263. * @param updatable defines if the mesh must be flagged as updatable
  22264. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22265. * @returns a new Mesh
  22266. */
  22267. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22268. /**
  22269. * Creates a ground mesh.
  22270. * Please consider using the same method from the MeshBuilder class instead
  22271. * @param name defines the name of the mesh to create
  22272. * @param width set the width of the ground
  22273. * @param height set the height of the ground
  22274. * @param subdivisions sets the number of subdivisions per side
  22275. * @param scene defines the hosting scene
  22276. * @param updatable defines if the mesh must be flagged as updatable
  22277. * @returns a new Mesh
  22278. */
  22279. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22280. /**
  22281. * Creates a tiled ground mesh.
  22282. * Please consider using the same method from the MeshBuilder class instead
  22283. * @param name defines the name of the mesh to create
  22284. * @param xmin set the ground minimum X coordinate
  22285. * @param zmin set the ground minimum Y coordinate
  22286. * @param xmax set the ground maximum X coordinate
  22287. * @param zmax set the ground maximum Z coordinate
  22288. * @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
  22289. * @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
  22290. * @param scene defines the hosting scene
  22291. * @param updatable defines if the mesh must be flagged as updatable
  22292. * @returns a new Mesh
  22293. */
  22294. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22295. w: number;
  22296. h: number;
  22297. }, precision: {
  22298. w: number;
  22299. h: number;
  22300. }, scene: Scene, updatable?: boolean): Mesh;
  22301. /**
  22302. * Creates a ground mesh from a height map.
  22303. * Please consider using the same method from the MeshBuilder class instead
  22304. * @see http://doc.babylonjs.com/babylon101/height_map
  22305. * @param name defines the name of the mesh to create
  22306. * @param url sets the URL of the height map image resource
  22307. * @param width set the ground width size
  22308. * @param height set the ground height size
  22309. * @param subdivisions sets the number of subdivision per side
  22310. * @param minHeight is the minimum altitude on the ground
  22311. * @param maxHeight is the maximum altitude on the ground
  22312. * @param scene defines the hosting scene
  22313. * @param updatable defines if the mesh must be flagged as updatable
  22314. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22315. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22316. * @returns a new Mesh
  22317. */
  22318. 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;
  22319. /**
  22320. * Creates a tube mesh.
  22321. * The tube is a parametric shape.
  22322. * It has no predefined shape. Its final shape will depend on the input parameters.
  22323. * Please consider using the same method from the MeshBuilder class instead
  22324. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22325. * @param name defines the name of the mesh to create
  22326. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22327. * @param radius sets the tube radius size
  22328. * @param tessellation is the number of sides on the tubular surface
  22329. * @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
  22330. * @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
  22331. * @param scene defines the hosting scene
  22332. * @param updatable defines if the mesh must be flagged as updatable
  22333. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22334. * @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)
  22335. * @returns a new Mesh
  22336. */
  22337. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22338. (i: number, distance: number): number;
  22339. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22340. /**
  22341. * Creates a polyhedron mesh.
  22342. * Please consider using the same method from the MeshBuilder class instead.
  22343. * * 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
  22344. * * The parameter `size` (positive float, default 1) sets the polygon size
  22345. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22346. * * 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`
  22347. * * 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
  22348. * * 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)`)
  22349. * * 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
  22350. * * 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
  22351. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22352. * * If you create a double-sided mesh, you can choose what parts of 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
  22353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22354. * @param name defines the name of the mesh to create
  22355. * @param options defines the options used to create the mesh
  22356. * @param scene defines the hosting scene
  22357. * @returns a new Mesh
  22358. */
  22359. static CreatePolyhedron(name: string, options: {
  22360. type?: number;
  22361. size?: number;
  22362. sizeX?: number;
  22363. sizeY?: number;
  22364. sizeZ?: number;
  22365. custom?: any;
  22366. faceUV?: Vector4[];
  22367. faceColors?: Color4[];
  22368. updatable?: boolean;
  22369. sideOrientation?: number;
  22370. }, scene: Scene): Mesh;
  22371. /**
  22372. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22373. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22374. * * 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`)
  22375. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22376. * * 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
  22377. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22378. * * If you create a double-sided mesh, you can choose what parts of 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
  22379. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22380. * @param name defines the name of the mesh
  22381. * @param options defines the options used to create the mesh
  22382. * @param scene defines the hosting scene
  22383. * @returns a new Mesh
  22384. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22385. */
  22386. static CreateIcoSphere(name: string, options: {
  22387. radius?: number;
  22388. flat?: boolean;
  22389. subdivisions?: number;
  22390. sideOrientation?: number;
  22391. updatable?: boolean;
  22392. }, scene: Scene): Mesh;
  22393. /**
  22394. * Creates a decal mesh.
  22395. * Please consider using the same method from the MeshBuilder class instead.
  22396. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22397. * @param name defines the name of the mesh
  22398. * @param sourceMesh defines the mesh receiving the decal
  22399. * @param position sets the position of the decal in world coordinates
  22400. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22401. * @param size sets the decal scaling
  22402. * @param angle sets the angle to rotate the decal
  22403. * @returns a new Mesh
  22404. */
  22405. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22406. /**
  22407. * Prepare internal position array for software CPU skinning
  22408. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22409. */
  22410. setPositionsForCPUSkinning(): Float32Array;
  22411. /**
  22412. * Prepare internal normal array for software CPU skinning
  22413. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22414. */
  22415. setNormalsForCPUSkinning(): Float32Array;
  22416. /**
  22417. * Updates the vertex buffer by applying transformation from the bones
  22418. * @param skeleton defines the skeleton to apply to current mesh
  22419. * @returns the current mesh
  22420. */
  22421. applySkeleton(skeleton: Skeleton): Mesh;
  22422. /**
  22423. * 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
  22424. * @param meshes defines the list of meshes to scan
  22425. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22426. */
  22427. static MinMax(meshes: AbstractMesh[]): {
  22428. min: Vector3;
  22429. max: Vector3;
  22430. };
  22431. /**
  22432. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22433. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22434. * @returns a vector3
  22435. */
  22436. static Center(meshesOrMinMaxVector: {
  22437. min: Vector3;
  22438. max: Vector3;
  22439. } | AbstractMesh[]): Vector3;
  22440. /**
  22441. * Merge the array of meshes into a single mesh for performance reasons.
  22442. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22443. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22444. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22445. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22446. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22447. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22448. * @returns a new mesh
  22449. */
  22450. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22451. /** @hidden */
  22452. addInstance(instance: InstancedMesh): void;
  22453. /** @hidden */
  22454. removeInstance(instance: InstancedMesh): void;
  22455. }
  22456. }
  22457. declare module "babylonjs/Materials/material" {
  22458. import { IAnimatable } from "babylonjs/Misc/tools";
  22459. import { SmartArray } from "babylonjs/Misc/smartArray";
  22460. import { Observable } from "babylonjs/Misc/observable";
  22461. import { Nullable } from "babylonjs/types";
  22462. import { Scene } from "babylonjs/scene";
  22463. import { Matrix } from "babylonjs/Maths/math";
  22464. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22465. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22466. import { Mesh } from "babylonjs/Meshes/mesh";
  22467. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22468. import { Effect } from "babylonjs/Materials/effect";
  22469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22471. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22472. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22473. import { Animation } from "babylonjs/Animations/animation";
  22474. /**
  22475. * Base class for the main features of a material in Babylon.js
  22476. */
  22477. export class Material implements IAnimatable {
  22478. /**
  22479. * Returns the triangle fill mode
  22480. */
  22481. static readonly TriangleFillMode: number;
  22482. /**
  22483. * Returns the wireframe mode
  22484. */
  22485. static readonly WireFrameFillMode: number;
  22486. /**
  22487. * Returns the point fill mode
  22488. */
  22489. static readonly PointFillMode: number;
  22490. /**
  22491. * Returns the point list draw mode
  22492. */
  22493. static readonly PointListDrawMode: number;
  22494. /**
  22495. * Returns the line list draw mode
  22496. */
  22497. static readonly LineListDrawMode: number;
  22498. /**
  22499. * Returns the line loop draw mode
  22500. */
  22501. static readonly LineLoopDrawMode: number;
  22502. /**
  22503. * Returns the line strip draw mode
  22504. */
  22505. static readonly LineStripDrawMode: number;
  22506. /**
  22507. * Returns the triangle strip draw mode
  22508. */
  22509. static readonly TriangleStripDrawMode: number;
  22510. /**
  22511. * Returns the triangle fan draw mode
  22512. */
  22513. static readonly TriangleFanDrawMode: number;
  22514. /**
  22515. * Stores the clock-wise side orientation
  22516. */
  22517. static readonly ClockWiseSideOrientation: number;
  22518. /**
  22519. * Stores the counter clock-wise side orientation
  22520. */
  22521. static readonly CounterClockWiseSideOrientation: number;
  22522. /**
  22523. * The dirty texture flag value
  22524. */
  22525. static readonly TextureDirtyFlag: number;
  22526. /**
  22527. * The dirty light flag value
  22528. */
  22529. static readonly LightDirtyFlag: number;
  22530. /**
  22531. * The dirty fresnel flag value
  22532. */
  22533. static readonly FresnelDirtyFlag: number;
  22534. /**
  22535. * The dirty attribute flag value
  22536. */
  22537. static readonly AttributesDirtyFlag: number;
  22538. /**
  22539. * The dirty misc flag value
  22540. */
  22541. static readonly MiscDirtyFlag: number;
  22542. /**
  22543. * The all dirty flag value
  22544. */
  22545. static readonly AllDirtyFlag: number;
  22546. /**
  22547. * The ID of the material
  22548. */
  22549. id: string;
  22550. /**
  22551. * Gets or sets the unique id of the material
  22552. */
  22553. uniqueId: number;
  22554. /**
  22555. * The name of the material
  22556. */
  22557. name: string;
  22558. /**
  22559. * Gets or sets user defined metadata
  22560. */
  22561. metadata: any;
  22562. /**
  22563. * For internal use only. Please do not use.
  22564. */
  22565. reservedDataStore: any;
  22566. /**
  22567. * Specifies if the ready state should be checked on each call
  22568. */
  22569. checkReadyOnEveryCall: boolean;
  22570. /**
  22571. * Specifies if the ready state should be checked once
  22572. */
  22573. checkReadyOnlyOnce: boolean;
  22574. /**
  22575. * The state of the material
  22576. */
  22577. state: string;
  22578. /**
  22579. * The alpha value of the material
  22580. */
  22581. protected _alpha: number;
  22582. /**
  22583. * List of inspectable custom properties (used by the Inspector)
  22584. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22585. */
  22586. inspectableCustomProperties: IInspectable[];
  22587. /**
  22588. * Sets the alpha value of the material
  22589. */
  22590. /**
  22591. * Gets the alpha value of the material
  22592. */
  22593. alpha: number;
  22594. /**
  22595. * Specifies if back face culling is enabled
  22596. */
  22597. protected _backFaceCulling: boolean;
  22598. /**
  22599. * Sets the back-face culling state
  22600. */
  22601. /**
  22602. * Gets the back-face culling state
  22603. */
  22604. backFaceCulling: boolean;
  22605. /**
  22606. * Stores the value for side orientation
  22607. */
  22608. sideOrientation: number;
  22609. /**
  22610. * Callback triggered when the material is compiled
  22611. */
  22612. onCompiled: Nullable<(effect: Effect) => void>;
  22613. /**
  22614. * Callback triggered when an error occurs
  22615. */
  22616. onError: Nullable<(effect: Effect, errors: string) => void>;
  22617. /**
  22618. * Callback triggered to get the render target textures
  22619. */
  22620. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22621. /**
  22622. * Gets a boolean indicating that current material needs to register RTT
  22623. */
  22624. readonly hasRenderTargetTextures: boolean;
  22625. /**
  22626. * Specifies if the material should be serialized
  22627. */
  22628. doNotSerialize: boolean;
  22629. /**
  22630. * @hidden
  22631. */
  22632. _storeEffectOnSubMeshes: boolean;
  22633. /**
  22634. * Stores the animations for the material
  22635. */
  22636. animations: Nullable<Array<Animation>>;
  22637. /**
  22638. * An event triggered when the material is disposed
  22639. */
  22640. onDisposeObservable: Observable<Material>;
  22641. /**
  22642. * An observer which watches for dispose events
  22643. */
  22644. private _onDisposeObserver;
  22645. private _onUnBindObservable;
  22646. /**
  22647. * Called during a dispose event
  22648. */
  22649. onDispose: () => void;
  22650. private _onBindObservable;
  22651. /**
  22652. * An event triggered when the material is bound
  22653. */
  22654. readonly onBindObservable: Observable<AbstractMesh>;
  22655. /**
  22656. * An observer which watches for bind events
  22657. */
  22658. private _onBindObserver;
  22659. /**
  22660. * Called during a bind event
  22661. */
  22662. onBind: (Mesh: AbstractMesh) => void;
  22663. /**
  22664. * An event triggered when the material is unbound
  22665. */
  22666. readonly onUnBindObservable: Observable<Material>;
  22667. /**
  22668. * Stores the value of the alpha mode
  22669. */
  22670. private _alphaMode;
  22671. /**
  22672. * Sets the value of the alpha mode.
  22673. *
  22674. * | Value | Type | Description |
  22675. * | --- | --- | --- |
  22676. * | 0 | ALPHA_DISABLE | |
  22677. * | 1 | ALPHA_ADD | |
  22678. * | 2 | ALPHA_COMBINE | |
  22679. * | 3 | ALPHA_SUBTRACT | |
  22680. * | 4 | ALPHA_MULTIPLY | |
  22681. * | 5 | ALPHA_MAXIMIZED | |
  22682. * | 6 | ALPHA_ONEONE | |
  22683. * | 7 | ALPHA_PREMULTIPLIED | |
  22684. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22685. * | 9 | ALPHA_INTERPOLATE | |
  22686. * | 10 | ALPHA_SCREENMODE | |
  22687. *
  22688. */
  22689. /**
  22690. * Gets the value of the alpha mode
  22691. */
  22692. alphaMode: number;
  22693. /**
  22694. * Stores the state of the need depth pre-pass value
  22695. */
  22696. private _needDepthPrePass;
  22697. /**
  22698. * Sets the need depth pre-pass value
  22699. */
  22700. /**
  22701. * Gets the depth pre-pass value
  22702. */
  22703. needDepthPrePass: boolean;
  22704. /**
  22705. * Specifies if depth writing should be disabled
  22706. */
  22707. disableDepthWrite: boolean;
  22708. /**
  22709. * Specifies if depth writing should be forced
  22710. */
  22711. forceDepthWrite: boolean;
  22712. /**
  22713. * Specifies if there should be a separate pass for culling
  22714. */
  22715. separateCullingPass: boolean;
  22716. /**
  22717. * Stores the state specifing if fog should be enabled
  22718. */
  22719. private _fogEnabled;
  22720. /**
  22721. * Sets the state for enabling fog
  22722. */
  22723. /**
  22724. * Gets the value of the fog enabled state
  22725. */
  22726. fogEnabled: boolean;
  22727. /**
  22728. * Stores the size of points
  22729. */
  22730. pointSize: number;
  22731. /**
  22732. * Stores the z offset value
  22733. */
  22734. zOffset: number;
  22735. /**
  22736. * Gets a value specifying if wireframe mode is enabled
  22737. */
  22738. /**
  22739. * Sets the state of wireframe mode
  22740. */
  22741. wireframe: boolean;
  22742. /**
  22743. * Gets the value specifying if point clouds are enabled
  22744. */
  22745. /**
  22746. * Sets the state of point cloud mode
  22747. */
  22748. pointsCloud: boolean;
  22749. /**
  22750. * Gets the material fill mode
  22751. */
  22752. /**
  22753. * Sets the material fill mode
  22754. */
  22755. fillMode: number;
  22756. /**
  22757. * @hidden
  22758. * Stores the effects for the material
  22759. */
  22760. _effect: Nullable<Effect>;
  22761. /**
  22762. * @hidden
  22763. * Specifies if the material was previously ready
  22764. */
  22765. _wasPreviouslyReady: boolean;
  22766. /**
  22767. * Specifies if uniform buffers should be used
  22768. */
  22769. private _useUBO;
  22770. /**
  22771. * Stores a reference to the scene
  22772. */
  22773. private _scene;
  22774. /**
  22775. * Stores the fill mode state
  22776. */
  22777. private _fillMode;
  22778. /**
  22779. * Specifies if the depth write state should be cached
  22780. */
  22781. private _cachedDepthWriteState;
  22782. /**
  22783. * Stores the uniform buffer
  22784. */
  22785. protected _uniformBuffer: UniformBuffer;
  22786. /** @hidden */
  22787. _indexInSceneMaterialArray: number;
  22788. /** @hidden */
  22789. meshMap: Nullable<{
  22790. [id: string]: AbstractMesh | undefined;
  22791. }>;
  22792. /**
  22793. * Creates a material instance
  22794. * @param name defines the name of the material
  22795. * @param scene defines the scene to reference
  22796. * @param doNotAdd specifies if the material should be added to the scene
  22797. */
  22798. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22799. /**
  22800. * Returns a string representation of the current material
  22801. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22802. * @returns a string with material information
  22803. */
  22804. toString(fullDetails?: boolean): string;
  22805. /**
  22806. * Gets the class name of the material
  22807. * @returns a string with the class name of the material
  22808. */
  22809. getClassName(): string;
  22810. /**
  22811. * Specifies if updates for the material been locked
  22812. */
  22813. readonly isFrozen: boolean;
  22814. /**
  22815. * Locks updates for the material
  22816. */
  22817. freeze(): void;
  22818. /**
  22819. * Unlocks updates for the material
  22820. */
  22821. unfreeze(): void;
  22822. /**
  22823. * Specifies if the material is ready to be used
  22824. * @param mesh defines the mesh to check
  22825. * @param useInstances specifies if instances should be used
  22826. * @returns a boolean indicating if the material is ready to be used
  22827. */
  22828. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22829. /**
  22830. * Specifies that the submesh is ready to be used
  22831. * @param mesh defines the mesh to check
  22832. * @param subMesh defines which submesh to check
  22833. * @param useInstances specifies that instances should be used
  22834. * @returns a boolean indicating that the submesh is ready or not
  22835. */
  22836. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22837. /**
  22838. * Returns the material effect
  22839. * @returns the effect associated with the material
  22840. */
  22841. getEffect(): Nullable<Effect>;
  22842. /**
  22843. * Returns the current scene
  22844. * @returns a Scene
  22845. */
  22846. getScene(): Scene;
  22847. /**
  22848. * Specifies if the material will require alpha blending
  22849. * @returns a boolean specifying if alpha blending is needed
  22850. */
  22851. needAlphaBlending(): boolean;
  22852. /**
  22853. * Specifies if the mesh will require alpha blending
  22854. * @param mesh defines the mesh to check
  22855. * @returns a boolean specifying if alpha blending is needed for the mesh
  22856. */
  22857. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22858. /**
  22859. * Specifies if this material should be rendered in alpha test mode
  22860. * @returns a boolean specifying if an alpha test is needed.
  22861. */
  22862. needAlphaTesting(): boolean;
  22863. /**
  22864. * Gets the texture used for the alpha test
  22865. * @returns the texture to use for alpha testing
  22866. */
  22867. getAlphaTestTexture(): Nullable<BaseTexture>;
  22868. /**
  22869. * Marks the material to indicate that it needs to be re-calculated
  22870. */
  22871. markDirty(): void;
  22872. /** @hidden */
  22873. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22874. /**
  22875. * Binds the material to the mesh
  22876. * @param world defines the world transformation matrix
  22877. * @param mesh defines the mesh to bind the material to
  22878. */
  22879. bind(world: Matrix, mesh?: Mesh): void;
  22880. /**
  22881. * Binds the submesh to the material
  22882. * @param world defines the world transformation matrix
  22883. * @param mesh defines the mesh containing the submesh
  22884. * @param subMesh defines the submesh to bind the material to
  22885. */
  22886. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22887. /**
  22888. * Binds the world matrix to the material
  22889. * @param world defines the world transformation matrix
  22890. */
  22891. bindOnlyWorldMatrix(world: Matrix): void;
  22892. /**
  22893. * Binds the scene's uniform buffer to the effect.
  22894. * @param effect defines the effect to bind to the scene uniform buffer
  22895. * @param sceneUbo defines the uniform buffer storing scene data
  22896. */
  22897. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22898. /**
  22899. * Binds the view matrix to the effect
  22900. * @param effect defines the effect to bind the view matrix to
  22901. */
  22902. bindView(effect: Effect): void;
  22903. /**
  22904. * Binds the view projection matrix to the effect
  22905. * @param effect defines the effect to bind the view projection matrix to
  22906. */
  22907. bindViewProjection(effect: Effect): void;
  22908. /**
  22909. * Specifies if material alpha testing should be turned on for the mesh
  22910. * @param mesh defines the mesh to check
  22911. */
  22912. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22913. /**
  22914. * Processes to execute after binding the material to a mesh
  22915. * @param mesh defines the rendered mesh
  22916. */
  22917. protected _afterBind(mesh?: Mesh): void;
  22918. /**
  22919. * Unbinds the material from the mesh
  22920. */
  22921. unbind(): void;
  22922. /**
  22923. * Gets the active textures from the material
  22924. * @returns an array of textures
  22925. */
  22926. getActiveTextures(): BaseTexture[];
  22927. /**
  22928. * Specifies if the material uses a texture
  22929. * @param texture defines the texture to check against the material
  22930. * @returns a boolean specifying if the material uses the texture
  22931. */
  22932. hasTexture(texture: BaseTexture): boolean;
  22933. /**
  22934. * Makes a duplicate of the material, and gives it a new name
  22935. * @param name defines the new name for the duplicated material
  22936. * @returns the cloned material
  22937. */
  22938. clone(name: string): Nullable<Material>;
  22939. /**
  22940. * Gets the meshes bound to the material
  22941. * @returns an array of meshes bound to the material
  22942. */
  22943. getBindedMeshes(): AbstractMesh[];
  22944. /**
  22945. * Force shader compilation
  22946. * @param mesh defines the mesh associated with this material
  22947. * @param onCompiled defines a function to execute once the material is compiled
  22948. * @param options defines the options to configure the compilation
  22949. */
  22950. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22951. clipPlane: boolean;
  22952. }>): void;
  22953. /**
  22954. * Force shader compilation
  22955. * @param mesh defines the mesh that will use this material
  22956. * @param options defines additional options for compiling the shaders
  22957. * @returns a promise that resolves when the compilation completes
  22958. */
  22959. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22960. clipPlane: boolean;
  22961. }>): Promise<void>;
  22962. private static readonly _AllDirtyCallBack;
  22963. private static readonly _ImageProcessingDirtyCallBack;
  22964. private static readonly _TextureDirtyCallBack;
  22965. private static readonly _FresnelDirtyCallBack;
  22966. private static readonly _MiscDirtyCallBack;
  22967. private static readonly _LightsDirtyCallBack;
  22968. private static readonly _AttributeDirtyCallBack;
  22969. private static _FresnelAndMiscDirtyCallBack;
  22970. private static _TextureAndMiscDirtyCallBack;
  22971. private static readonly _DirtyCallbackArray;
  22972. private static readonly _RunDirtyCallBacks;
  22973. /**
  22974. * Marks a define in the material to indicate that it needs to be re-computed
  22975. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22976. */
  22977. markAsDirty(flag: number): void;
  22978. /**
  22979. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22980. * @param func defines a function which checks material defines against the submeshes
  22981. */
  22982. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22983. /**
  22984. * Indicates that we need to re-calculated for all submeshes
  22985. */
  22986. protected _markAllSubMeshesAsAllDirty(): void;
  22987. /**
  22988. * Indicates that image processing needs to be re-calculated for all submeshes
  22989. */
  22990. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22991. /**
  22992. * Indicates that textures need to be re-calculated for all submeshes
  22993. */
  22994. protected _markAllSubMeshesAsTexturesDirty(): void;
  22995. /**
  22996. * Indicates that fresnel needs to be re-calculated for all submeshes
  22997. */
  22998. protected _markAllSubMeshesAsFresnelDirty(): void;
  22999. /**
  23000. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  23001. */
  23002. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  23003. /**
  23004. * Indicates that lights need to be re-calculated for all submeshes
  23005. */
  23006. protected _markAllSubMeshesAsLightsDirty(): void;
  23007. /**
  23008. * Indicates that attributes need to be re-calculated for all submeshes
  23009. */
  23010. protected _markAllSubMeshesAsAttributesDirty(): void;
  23011. /**
  23012. * Indicates that misc needs to be re-calculated for all submeshes
  23013. */
  23014. protected _markAllSubMeshesAsMiscDirty(): void;
  23015. /**
  23016. * Indicates that textures and misc need to be re-calculated for all submeshes
  23017. */
  23018. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  23019. /**
  23020. * Disposes the material
  23021. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23022. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23023. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23024. */
  23025. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23026. /** @hidden */
  23027. private releaseVertexArrayObject;
  23028. /**
  23029. * Serializes this material
  23030. * @returns the serialized material object
  23031. */
  23032. serialize(): any;
  23033. /**
  23034. * Creates a material from parsed material data
  23035. * @param parsedMaterial defines parsed material data
  23036. * @param scene defines the hosting scene
  23037. * @param rootUrl defines the root URL to use to load textures
  23038. * @returns a new material
  23039. */
  23040. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  23041. }
  23042. }
  23043. declare module "babylonjs/Meshes/subMesh" {
  23044. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  23045. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  23046. import { Engine } from "babylonjs/Engines/engine";
  23047. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  23048. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23049. import { Effect } from "babylonjs/Materials/effect";
  23050. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23051. import { Collider } from "babylonjs/Collisions/collider";
  23052. import { Material } from "babylonjs/Materials/material";
  23053. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23054. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23055. import { Mesh } from "babylonjs/Meshes/mesh";
  23056. import { Ray } from "babylonjs/Culling/ray";
  23057. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  23058. /**
  23059. * Base class for submeshes
  23060. */
  23061. export class BaseSubMesh {
  23062. /** @hidden */
  23063. _materialDefines: Nullable<MaterialDefines>;
  23064. /** @hidden */
  23065. _materialEffect: Nullable<Effect>;
  23066. /**
  23067. * Gets associated effect
  23068. */
  23069. readonly effect: Nullable<Effect>;
  23070. /**
  23071. * Sets associated effect (effect used to render this submesh)
  23072. * @param effect defines the effect to associate with
  23073. * @param defines defines the set of defines used to compile this effect
  23074. */
  23075. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  23076. }
  23077. /**
  23078. * Defines a subdivision inside a mesh
  23079. */
  23080. export class SubMesh extends BaseSubMesh implements ICullable {
  23081. /** the material index to use */
  23082. materialIndex: number;
  23083. /** vertex index start */
  23084. verticesStart: number;
  23085. /** vertices count */
  23086. verticesCount: number;
  23087. /** index start */
  23088. indexStart: number;
  23089. /** indices count */
  23090. indexCount: number;
  23091. /** @hidden */
  23092. _linesIndexCount: number;
  23093. private _mesh;
  23094. private _renderingMesh;
  23095. private _boundingInfo;
  23096. private _linesIndexBuffer;
  23097. /** @hidden */
  23098. _lastColliderWorldVertices: Nullable<Vector3[]>;
  23099. /** @hidden */
  23100. _trianglePlanes: Plane[];
  23101. /** @hidden */
  23102. _lastColliderTransformMatrix: Nullable<Matrix>;
  23103. /** @hidden */
  23104. _renderId: number;
  23105. /** @hidden */
  23106. _alphaIndex: number;
  23107. /** @hidden */
  23108. _distanceToCamera: number;
  23109. /** @hidden */
  23110. _id: number;
  23111. private _currentMaterial;
  23112. /**
  23113. * Add a new submesh to a mesh
  23114. * @param materialIndex defines the material index to use
  23115. * @param verticesStart defines vertex index start
  23116. * @param verticesCount defines vertices count
  23117. * @param indexStart defines index start
  23118. * @param indexCount defines indices count
  23119. * @param mesh defines the parent mesh
  23120. * @param renderingMesh defines an optional rendering mesh
  23121. * @param createBoundingBox defines if bounding box should be created for this submesh
  23122. * @returns the new submesh
  23123. */
  23124. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  23125. /**
  23126. * Creates a new submesh
  23127. * @param materialIndex defines the material index to use
  23128. * @param verticesStart defines vertex index start
  23129. * @param verticesCount defines vertices count
  23130. * @param indexStart defines index start
  23131. * @param indexCount defines indices count
  23132. * @param mesh defines the parent mesh
  23133. * @param renderingMesh defines an optional rendering mesh
  23134. * @param createBoundingBox defines if bounding box should be created for this submesh
  23135. */
  23136. constructor(
  23137. /** the material index to use */
  23138. materialIndex: number,
  23139. /** vertex index start */
  23140. verticesStart: number,
  23141. /** vertices count */
  23142. verticesCount: number,
  23143. /** index start */
  23144. indexStart: number,
  23145. /** indices count */
  23146. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  23147. /**
  23148. * Returns true if this submesh covers the entire parent mesh
  23149. * @ignorenaming
  23150. */
  23151. readonly IsGlobal: boolean;
  23152. /**
  23153. * Returns the submesh BoudingInfo object
  23154. * @returns current bounding info (or mesh's one if the submesh is global)
  23155. */
  23156. getBoundingInfo(): BoundingInfo;
  23157. /**
  23158. * Sets the submesh BoundingInfo
  23159. * @param boundingInfo defines the new bounding info to use
  23160. * @returns the SubMesh
  23161. */
  23162. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  23163. /**
  23164. * Returns the mesh of the current submesh
  23165. * @return the parent mesh
  23166. */
  23167. getMesh(): AbstractMesh;
  23168. /**
  23169. * Returns the rendering mesh of the submesh
  23170. * @returns the rendering mesh (could be different from parent mesh)
  23171. */
  23172. getRenderingMesh(): Mesh;
  23173. /**
  23174. * Returns the submesh material
  23175. * @returns null or the current material
  23176. */
  23177. getMaterial(): Nullable<Material>;
  23178. /**
  23179. * Sets a new updated BoundingInfo object to the submesh
  23180. * @param data defines an optional position array to use to determine the bounding info
  23181. * @returns the SubMesh
  23182. */
  23183. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  23184. /** @hidden */
  23185. _checkCollision(collider: Collider): boolean;
  23186. /**
  23187. * Updates the submesh BoundingInfo
  23188. * @param world defines the world matrix to use to update the bounding info
  23189. * @returns the submesh
  23190. */
  23191. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  23192. /**
  23193. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  23194. * @param frustumPlanes defines the frustum planes
  23195. * @returns true if the submesh is intersecting with the frustum
  23196. */
  23197. isInFrustum(frustumPlanes: Plane[]): boolean;
  23198. /**
  23199. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  23200. * @param frustumPlanes defines the frustum planes
  23201. * @returns true if the submesh is inside the frustum
  23202. */
  23203. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  23204. /**
  23205. * Renders the submesh
  23206. * @param enableAlphaMode defines if alpha needs to be used
  23207. * @returns the submesh
  23208. */
  23209. render(enableAlphaMode: boolean): SubMesh;
  23210. /**
  23211. * @hidden
  23212. */
  23213. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  23214. /**
  23215. * Checks if the submesh intersects with a ray
  23216. * @param ray defines the ray to test
  23217. * @returns true is the passed ray intersects the submesh bounding box
  23218. */
  23219. canIntersects(ray: Ray): boolean;
  23220. /**
  23221. * Intersects current submesh with a ray
  23222. * @param ray defines the ray to test
  23223. * @param positions defines mesh's positions array
  23224. * @param indices defines mesh's indices array
  23225. * @param fastCheck defines if only bounding info should be used
  23226. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23227. * @returns intersection info or null if no intersection
  23228. */
  23229. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23230. /** @hidden */
  23231. private _intersectLines;
  23232. /** @hidden */
  23233. private _intersectUnIndexedLines;
  23234. /** @hidden */
  23235. private _intersectTriangles;
  23236. /** @hidden */
  23237. private _intersectUnIndexedTriangles;
  23238. /** @hidden */
  23239. _rebuild(): void;
  23240. /**
  23241. * Creates a new submesh from the passed mesh
  23242. * @param newMesh defines the new hosting mesh
  23243. * @param newRenderingMesh defines an optional rendering mesh
  23244. * @returns the new submesh
  23245. */
  23246. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23247. /**
  23248. * Release associated resources
  23249. */
  23250. dispose(): void;
  23251. /**
  23252. * Gets the class name
  23253. * @returns the string "SubMesh".
  23254. */
  23255. getClassName(): string;
  23256. /**
  23257. * Creates a new submesh from indices data
  23258. * @param materialIndex the index of the main mesh material
  23259. * @param startIndex the index where to start the copy in the mesh indices array
  23260. * @param indexCount the number of indices to copy then from the startIndex
  23261. * @param mesh the main mesh to create the submesh from
  23262. * @param renderingMesh the optional rendering mesh
  23263. * @returns a new submesh
  23264. */
  23265. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23266. }
  23267. }
  23268. declare module "babylonjs/Meshes/geometry" {
  23269. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23270. import { Scene } from "babylonjs/scene";
  23271. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23272. import { Engine } from "babylonjs/Engines/engine";
  23273. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23274. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23275. import { Effect } from "babylonjs/Materials/effect";
  23276. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23277. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  23278. import { Mesh } from "babylonjs/Meshes/mesh";
  23279. /**
  23280. * Class used to store geometry data (vertex buffers + index buffer)
  23281. */
  23282. export class Geometry implements IGetSetVerticesData {
  23283. /**
  23284. * Gets or sets the ID of the geometry
  23285. */
  23286. id: string;
  23287. /**
  23288. * Gets or sets the unique ID of the geometry
  23289. */
  23290. uniqueId: number;
  23291. /**
  23292. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23293. */
  23294. delayLoadState: number;
  23295. /**
  23296. * Gets the file containing the data to load when running in delay load state
  23297. */
  23298. delayLoadingFile: Nullable<string>;
  23299. /**
  23300. * Callback called when the geometry is updated
  23301. */
  23302. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23303. private _scene;
  23304. private _engine;
  23305. private _meshes;
  23306. private _totalVertices;
  23307. /** @hidden */
  23308. _indices: IndicesArray;
  23309. /** @hidden */
  23310. _vertexBuffers: {
  23311. [key: string]: VertexBuffer;
  23312. };
  23313. private _isDisposed;
  23314. private _extend;
  23315. private _boundingBias;
  23316. /** @hidden */
  23317. _delayInfo: Array<string>;
  23318. private _indexBuffer;
  23319. private _indexBufferIsUpdatable;
  23320. /** @hidden */
  23321. _boundingInfo: Nullable<BoundingInfo>;
  23322. /** @hidden */
  23323. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23324. /** @hidden */
  23325. _softwareSkinningFrameId: number;
  23326. private _vertexArrayObjects;
  23327. private _updatable;
  23328. /** @hidden */
  23329. _positions: Nullable<Vector3[]>;
  23330. /**
  23331. * 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
  23332. */
  23333. /**
  23334. * 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
  23335. */
  23336. boundingBias: Vector2;
  23337. /**
  23338. * Static function used to attach a new empty geometry to a mesh
  23339. * @param mesh defines the mesh to attach the geometry to
  23340. * @returns the new Geometry
  23341. */
  23342. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23343. /**
  23344. * Creates a new geometry
  23345. * @param id defines the unique ID
  23346. * @param scene defines the hosting scene
  23347. * @param vertexData defines the VertexData used to get geometry data
  23348. * @param updatable defines if geometry must be updatable (false by default)
  23349. * @param mesh defines the mesh that will be associated with the geometry
  23350. */
  23351. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23352. /**
  23353. * Gets the current extend of the geometry
  23354. */
  23355. readonly extend: {
  23356. minimum: Vector3;
  23357. maximum: Vector3;
  23358. };
  23359. /**
  23360. * Gets the hosting scene
  23361. * @returns the hosting Scene
  23362. */
  23363. getScene(): Scene;
  23364. /**
  23365. * Gets the hosting engine
  23366. * @returns the hosting Engine
  23367. */
  23368. getEngine(): Engine;
  23369. /**
  23370. * Defines if the geometry is ready to use
  23371. * @returns true if the geometry is ready to be used
  23372. */
  23373. isReady(): boolean;
  23374. /**
  23375. * Gets a value indicating that the geometry should not be serialized
  23376. */
  23377. readonly doNotSerialize: boolean;
  23378. /** @hidden */
  23379. _rebuild(): void;
  23380. /**
  23381. * Affects all geometry data in one call
  23382. * @param vertexData defines the geometry data
  23383. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23384. */
  23385. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23386. /**
  23387. * Set specific vertex data
  23388. * @param kind defines the data kind (Position, normal, etc...)
  23389. * @param data defines the vertex data to use
  23390. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23391. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23392. */
  23393. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23394. /**
  23395. * Removes a specific vertex data
  23396. * @param kind defines the data kind (Position, normal, etc...)
  23397. */
  23398. removeVerticesData(kind: string): void;
  23399. /**
  23400. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23401. * @param buffer defines the vertex buffer to use
  23402. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23403. */
  23404. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23405. /**
  23406. * Update a specific vertex buffer
  23407. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  23408. * It will do nothing if the buffer is not updatable
  23409. * @param kind defines the data kind (Position, normal, etc...)
  23410. * @param data defines the data to use
  23411. * @param offset defines the offset in the target buffer where to store the data
  23412. * @param useBytes set to true if the offset is in bytes
  23413. */
  23414. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23415. /**
  23416. * Update a specific vertex buffer
  23417. * This function will create a new buffer if the current one is not updatable
  23418. * @param kind defines the data kind (Position, normal, etc...)
  23419. * @param data defines the data to use
  23420. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23421. */
  23422. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23423. private _updateBoundingInfo;
  23424. /** @hidden */
  23425. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  23426. /**
  23427. * Gets total number of vertices
  23428. * @returns the total number of vertices
  23429. */
  23430. getTotalVertices(): number;
  23431. /**
  23432. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23433. * @param kind defines the data kind (Position, normal, etc...)
  23434. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23435. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23436. * @returns a float array containing vertex data
  23437. */
  23438. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23439. /**
  23440. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23441. * @param kind defines the data kind (Position, normal, etc...)
  23442. * @returns true if the vertex buffer with the specified kind is updatable
  23443. */
  23444. isVertexBufferUpdatable(kind: string): boolean;
  23445. /**
  23446. * Gets a specific vertex buffer
  23447. * @param kind defines the data kind (Position, normal, etc...)
  23448. * @returns a VertexBuffer
  23449. */
  23450. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23451. /**
  23452. * Returns all vertex buffers
  23453. * @return an object holding all vertex buffers indexed by kind
  23454. */
  23455. getVertexBuffers(): Nullable<{
  23456. [key: string]: VertexBuffer;
  23457. }>;
  23458. /**
  23459. * Gets a boolean indicating if specific vertex buffer is present
  23460. * @param kind defines the data kind (Position, normal, etc...)
  23461. * @returns true if data is present
  23462. */
  23463. isVerticesDataPresent(kind: string): boolean;
  23464. /**
  23465. * Gets a list of all attached data kinds (Position, normal, etc...)
  23466. * @returns a list of string containing all kinds
  23467. */
  23468. getVerticesDataKinds(): string[];
  23469. /**
  23470. * Update index buffer
  23471. * @param indices defines the indices to store in the index buffer
  23472. * @param offset defines the offset in the target buffer where to store the data
  23473. * @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)
  23474. */
  23475. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23476. /**
  23477. * Creates a new index buffer
  23478. * @param indices defines the indices to store in the index buffer
  23479. * @param totalVertices defines the total number of vertices (could be null)
  23480. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23481. */
  23482. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23483. /**
  23484. * Return the total number of indices
  23485. * @returns the total number of indices
  23486. */
  23487. getTotalIndices(): number;
  23488. /**
  23489. * Gets the index buffer array
  23490. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23491. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23492. * @returns the index buffer array
  23493. */
  23494. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23495. /**
  23496. * Gets the index buffer
  23497. * @return the index buffer
  23498. */
  23499. getIndexBuffer(): Nullable<DataBuffer>;
  23500. /** @hidden */
  23501. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23502. /**
  23503. * Release the associated resources for a specific mesh
  23504. * @param mesh defines the source mesh
  23505. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23506. */
  23507. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23508. /**
  23509. * Apply current geometry to a given mesh
  23510. * @param mesh defines the mesh to apply geometry to
  23511. */
  23512. applyToMesh(mesh: Mesh): void;
  23513. private _updateExtend;
  23514. private _applyToMesh;
  23515. private notifyUpdate;
  23516. /**
  23517. * Load the geometry if it was flagged as delay loaded
  23518. * @param scene defines the hosting scene
  23519. * @param onLoaded defines a callback called when the geometry is loaded
  23520. */
  23521. load(scene: Scene, onLoaded?: () => void): void;
  23522. private _queueLoad;
  23523. /**
  23524. * Invert the geometry to move from a right handed system to a left handed one.
  23525. */
  23526. toLeftHanded(): void;
  23527. /** @hidden */
  23528. _resetPointsArrayCache(): void;
  23529. /** @hidden */
  23530. _generatePointsArray(): boolean;
  23531. /**
  23532. * Gets a value indicating if the geometry is disposed
  23533. * @returns true if the geometry was disposed
  23534. */
  23535. isDisposed(): boolean;
  23536. private _disposeVertexArrayObjects;
  23537. /**
  23538. * Free all associated resources
  23539. */
  23540. dispose(): void;
  23541. /**
  23542. * Clone the current geometry into a new geometry
  23543. * @param id defines the unique ID of the new geometry
  23544. * @returns a new geometry object
  23545. */
  23546. copy(id: string): Geometry;
  23547. /**
  23548. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23549. * @return a JSON representation of the current geometry data (without the vertices data)
  23550. */
  23551. serialize(): any;
  23552. private toNumberArray;
  23553. /**
  23554. * Serialize all vertices data into a JSON oject
  23555. * @returns a JSON representation of the current geometry data
  23556. */
  23557. serializeVerticeData(): any;
  23558. /**
  23559. * Extracts a clone of a mesh geometry
  23560. * @param mesh defines the source mesh
  23561. * @param id defines the unique ID of the new geometry object
  23562. * @returns the new geometry object
  23563. */
  23564. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23565. /**
  23566. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23567. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23568. * Be aware Math.random() could cause collisions, but:
  23569. * "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"
  23570. * @returns a string containing a new GUID
  23571. */
  23572. static RandomId(): string;
  23573. /** @hidden */
  23574. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23575. private static _CleanMatricesWeights;
  23576. /**
  23577. * Create a new geometry from persisted data (Using .babylon file format)
  23578. * @param parsedVertexData defines the persisted data
  23579. * @param scene defines the hosting scene
  23580. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23581. * @returns the new geometry object
  23582. */
  23583. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23584. }
  23585. }
  23586. declare module "babylonjs/Meshes/mesh.vertexData" {
  23587. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23588. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23589. import { Geometry } from "babylonjs/Meshes/geometry";
  23590. import { Mesh } from "babylonjs/Meshes/mesh";
  23591. /**
  23592. * Define an interface for all classes that will get and set the data on vertices
  23593. */
  23594. export interface IGetSetVerticesData {
  23595. /**
  23596. * Gets a boolean indicating if specific vertex data is present
  23597. * @param kind defines the vertex data kind to use
  23598. * @returns true is data kind is present
  23599. */
  23600. isVerticesDataPresent(kind: string): boolean;
  23601. /**
  23602. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23603. * @param kind defines the data kind (Position, normal, etc...)
  23604. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23605. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23606. * @returns a float array containing vertex data
  23607. */
  23608. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23609. /**
  23610. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23611. * @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.
  23612. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23613. * @returns the indices array or an empty array if the mesh has no geometry
  23614. */
  23615. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23616. /**
  23617. * Set specific vertex data
  23618. * @param kind defines the data kind (Position, normal, etc...)
  23619. * @param data defines the vertex data to use
  23620. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23621. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23622. */
  23623. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23624. /**
  23625. * Update a specific associated vertex buffer
  23626. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23627. * - VertexBuffer.PositionKind
  23628. * - VertexBuffer.UVKind
  23629. * - VertexBuffer.UV2Kind
  23630. * - VertexBuffer.UV3Kind
  23631. * - VertexBuffer.UV4Kind
  23632. * - VertexBuffer.UV5Kind
  23633. * - VertexBuffer.UV6Kind
  23634. * - VertexBuffer.ColorKind
  23635. * - VertexBuffer.MatricesIndicesKind
  23636. * - VertexBuffer.MatricesIndicesExtraKind
  23637. * - VertexBuffer.MatricesWeightsKind
  23638. * - VertexBuffer.MatricesWeightsExtraKind
  23639. * @param data defines the data source
  23640. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23641. * @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)
  23642. */
  23643. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23644. /**
  23645. * Creates a new index buffer
  23646. * @param indices defines the indices to store in the index buffer
  23647. * @param totalVertices defines the total number of vertices (could be null)
  23648. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23649. */
  23650. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23651. }
  23652. /**
  23653. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23654. */
  23655. export class VertexData {
  23656. /**
  23657. * Mesh side orientation : usually the external or front surface
  23658. */
  23659. static readonly FRONTSIDE: number;
  23660. /**
  23661. * Mesh side orientation : usually the internal or back surface
  23662. */
  23663. static readonly BACKSIDE: number;
  23664. /**
  23665. * Mesh side orientation : both internal and external or front and back surfaces
  23666. */
  23667. static readonly DOUBLESIDE: number;
  23668. /**
  23669. * Mesh side orientation : by default, `FRONTSIDE`
  23670. */
  23671. static readonly DEFAULTSIDE: number;
  23672. /**
  23673. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23674. */
  23675. positions: Nullable<FloatArray>;
  23676. /**
  23677. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23678. */
  23679. normals: Nullable<FloatArray>;
  23680. /**
  23681. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23682. */
  23683. tangents: Nullable<FloatArray>;
  23684. /**
  23685. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23686. */
  23687. uvs: Nullable<FloatArray>;
  23688. /**
  23689. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23690. */
  23691. uvs2: Nullable<FloatArray>;
  23692. /**
  23693. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23694. */
  23695. uvs3: Nullable<FloatArray>;
  23696. /**
  23697. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23698. */
  23699. uvs4: Nullable<FloatArray>;
  23700. /**
  23701. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23702. */
  23703. uvs5: Nullable<FloatArray>;
  23704. /**
  23705. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23706. */
  23707. uvs6: Nullable<FloatArray>;
  23708. /**
  23709. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23710. */
  23711. colors: Nullable<FloatArray>;
  23712. /**
  23713. * 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).
  23714. */
  23715. matricesIndices: Nullable<FloatArray>;
  23716. /**
  23717. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23718. */
  23719. matricesWeights: Nullable<FloatArray>;
  23720. /**
  23721. * An array extending the number of possible indices
  23722. */
  23723. matricesIndicesExtra: Nullable<FloatArray>;
  23724. /**
  23725. * An array extending the number of possible weights when the number of indices is extended
  23726. */
  23727. matricesWeightsExtra: Nullable<FloatArray>;
  23728. /**
  23729. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23730. */
  23731. indices: Nullable<IndicesArray>;
  23732. /**
  23733. * Uses the passed data array to set the set the values for the specified kind of data
  23734. * @param data a linear array of floating numbers
  23735. * @param kind the type of data that is being set, eg positions, colors etc
  23736. */
  23737. set(data: FloatArray, kind: string): void;
  23738. /**
  23739. * Associates the vertexData to the passed Mesh.
  23740. * Sets it as updatable or not (default `false`)
  23741. * @param mesh the mesh the vertexData is applied to
  23742. * @param updatable when used and having the value true allows new data to update the vertexData
  23743. * @returns the VertexData
  23744. */
  23745. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23746. /**
  23747. * Associates the vertexData to the passed Geometry.
  23748. * Sets it as updatable or not (default `false`)
  23749. * @param geometry the geometry the vertexData is applied to
  23750. * @param updatable when used and having the value true allows new data to update the vertexData
  23751. * @returns VertexData
  23752. */
  23753. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23754. /**
  23755. * Updates the associated mesh
  23756. * @param mesh the mesh to be updated
  23757. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23758. * @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
  23759. * @returns VertexData
  23760. */
  23761. updateMesh(mesh: Mesh): VertexData;
  23762. /**
  23763. * Updates the associated geometry
  23764. * @param geometry the geometry to be updated
  23765. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23766. * @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
  23767. * @returns VertexData.
  23768. */
  23769. updateGeometry(geometry: Geometry): VertexData;
  23770. private _applyTo;
  23771. private _update;
  23772. /**
  23773. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23774. * @param matrix the transforming matrix
  23775. * @returns the VertexData
  23776. */
  23777. transform(matrix: Matrix): VertexData;
  23778. /**
  23779. * Merges the passed VertexData into the current one
  23780. * @param other the VertexData to be merged into the current one
  23781. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23782. * @returns the modified VertexData
  23783. */
  23784. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23785. private _mergeElement;
  23786. private _validate;
  23787. /**
  23788. * Serializes the VertexData
  23789. * @returns a serialized object
  23790. */
  23791. serialize(): any;
  23792. /**
  23793. * Extracts the vertexData from a mesh
  23794. * @param mesh the mesh from which to extract the VertexData
  23795. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23796. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23797. * @returns the object VertexData associated to the passed mesh
  23798. */
  23799. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23800. /**
  23801. * Extracts the vertexData from the geometry
  23802. * @param geometry the geometry from which to extract the VertexData
  23803. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23804. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23805. * @returns the object VertexData associated to the passed mesh
  23806. */
  23807. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23808. private static _ExtractFrom;
  23809. /**
  23810. * Creates the VertexData for a Ribbon
  23811. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23812. * * pathArray array of paths, each of which an array of successive Vector3
  23813. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23814. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23815. * * 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
  23816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23817. * * 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)
  23818. * * 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)
  23819. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23820. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23821. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23822. * @returns the VertexData of the ribbon
  23823. */
  23824. static CreateRibbon(options: {
  23825. pathArray: Vector3[][];
  23826. closeArray?: boolean;
  23827. closePath?: boolean;
  23828. offset?: number;
  23829. sideOrientation?: number;
  23830. frontUVs?: Vector4;
  23831. backUVs?: Vector4;
  23832. invertUV?: boolean;
  23833. uvs?: Vector2[];
  23834. colors?: Color4[];
  23835. }): VertexData;
  23836. /**
  23837. * Creates the VertexData for a box
  23838. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23839. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23840. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23841. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23842. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23843. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23844. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23845. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23846. * * 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)
  23847. * * 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)
  23848. * @returns the VertexData of the box
  23849. */
  23850. static CreateBox(options: {
  23851. size?: number;
  23852. width?: number;
  23853. height?: number;
  23854. depth?: number;
  23855. faceUV?: Vector4[];
  23856. faceColors?: Color4[];
  23857. sideOrientation?: number;
  23858. frontUVs?: Vector4;
  23859. backUVs?: Vector4;
  23860. }): VertexData;
  23861. /**
  23862. * Creates the VertexData for a tiled box
  23863. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23864. * * faceTiles sets the pattern, tile size and number of tiles for a face
  23865. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23866. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23867. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23868. * @returns the VertexData of the box
  23869. */
  23870. static CreateTiledBox(options: {
  23871. pattern?: number;
  23872. width?: number;
  23873. height?: number;
  23874. depth?: number;
  23875. tileSize?: number;
  23876. tileWidth?: number;
  23877. tileHeight?: number;
  23878. alignHorizontal?: number;
  23879. alignVertical?: number;
  23880. faceUV?: Vector4[];
  23881. faceColors?: Color4[];
  23882. sideOrientation?: number;
  23883. }): VertexData;
  23884. /**
  23885. * Creates the VertexData for a tiled plane
  23886. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23887. * * pattern a limited pattern arrangement depending on the number
  23888. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  23889. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  23890. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  23891. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23892. * * 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)
  23893. * * 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)
  23894. * @returns the VertexData of the tiled plane
  23895. */
  23896. static CreateTiledPlane(options: {
  23897. pattern?: number;
  23898. tileSize?: number;
  23899. tileWidth?: number;
  23900. tileHeight?: number;
  23901. size?: number;
  23902. width?: number;
  23903. height?: number;
  23904. alignHorizontal?: number;
  23905. alignVertical?: number;
  23906. sideOrientation?: number;
  23907. frontUVs?: Vector4;
  23908. backUVs?: Vector4;
  23909. }): VertexData;
  23910. /**
  23911. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23912. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23913. * * segments sets the number of horizontal strips optional, default 32
  23914. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23915. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23916. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23917. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23918. * * 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
  23919. * * 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
  23920. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23921. * * 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)
  23922. * * 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)
  23923. * @returns the VertexData of the ellipsoid
  23924. */
  23925. static CreateSphere(options: {
  23926. segments?: number;
  23927. diameter?: number;
  23928. diameterX?: number;
  23929. diameterY?: number;
  23930. diameterZ?: number;
  23931. arc?: number;
  23932. slice?: number;
  23933. sideOrientation?: number;
  23934. frontUVs?: Vector4;
  23935. backUVs?: Vector4;
  23936. }): VertexData;
  23937. /**
  23938. * Creates the VertexData for a cylinder, cone or prism
  23939. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23940. * * height sets the height (y direction) of the cylinder, optional, default 2
  23941. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23942. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23943. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23944. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23945. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23946. * * 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
  23947. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23948. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23949. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23950. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23951. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23952. * * 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)
  23953. * * 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)
  23954. * @returns the VertexData of the cylinder, cone or prism
  23955. */
  23956. static CreateCylinder(options: {
  23957. height?: number;
  23958. diameterTop?: number;
  23959. diameterBottom?: number;
  23960. diameter?: number;
  23961. tessellation?: number;
  23962. subdivisions?: number;
  23963. arc?: number;
  23964. faceColors?: Color4[];
  23965. faceUV?: Vector4[];
  23966. hasRings?: boolean;
  23967. enclose?: boolean;
  23968. sideOrientation?: number;
  23969. frontUVs?: Vector4;
  23970. backUVs?: Vector4;
  23971. }): VertexData;
  23972. /**
  23973. * Creates the VertexData for a torus
  23974. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23975. * * diameter the diameter of the torus, optional default 1
  23976. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23977. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23978. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23979. * * 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)
  23980. * * 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)
  23981. * @returns the VertexData of the torus
  23982. */
  23983. static CreateTorus(options: {
  23984. diameter?: number;
  23985. thickness?: number;
  23986. tessellation?: number;
  23987. sideOrientation?: number;
  23988. frontUVs?: Vector4;
  23989. backUVs?: Vector4;
  23990. }): VertexData;
  23991. /**
  23992. * Creates the VertexData of the LineSystem
  23993. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23994. * - lines an array of lines, each line being an array of successive Vector3
  23995. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23996. * @returns the VertexData of the LineSystem
  23997. */
  23998. static CreateLineSystem(options: {
  23999. lines: Vector3[][];
  24000. colors?: Nullable<Color4[][]>;
  24001. }): VertexData;
  24002. /**
  24003. * Create the VertexData for a DashedLines
  24004. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  24005. * - points an array successive Vector3
  24006. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  24007. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  24008. * - dashNb the intended total number of dashes, optional, default 200
  24009. * @returns the VertexData for the DashedLines
  24010. */
  24011. static CreateDashedLines(options: {
  24012. points: Vector3[];
  24013. dashSize?: number;
  24014. gapSize?: number;
  24015. dashNb?: number;
  24016. }): VertexData;
  24017. /**
  24018. * Creates the VertexData for a Ground
  24019. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24020. * - width the width (x direction) of the ground, optional, default 1
  24021. * - height the height (z direction) of the ground, optional, default 1
  24022. * - subdivisions the number of subdivisions per side, optional, default 1
  24023. * @returns the VertexData of the Ground
  24024. */
  24025. static CreateGround(options: {
  24026. width?: number;
  24027. height?: number;
  24028. subdivisions?: number;
  24029. subdivisionsX?: number;
  24030. subdivisionsY?: number;
  24031. }): VertexData;
  24032. /**
  24033. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  24034. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  24035. * * xmin the ground minimum X coordinate, optional, default -1
  24036. * * zmin the ground minimum Z coordinate, optional, default -1
  24037. * * xmax the ground maximum X coordinate, optional, default 1
  24038. * * zmax the ground maximum Z coordinate, optional, default 1
  24039. * * 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}
  24040. * * 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}
  24041. * @returns the VertexData of the TiledGround
  24042. */
  24043. static CreateTiledGround(options: {
  24044. xmin: number;
  24045. zmin: number;
  24046. xmax: number;
  24047. zmax: number;
  24048. subdivisions?: {
  24049. w: number;
  24050. h: number;
  24051. };
  24052. precision?: {
  24053. w: number;
  24054. h: number;
  24055. };
  24056. }): VertexData;
  24057. /**
  24058. * Creates the VertexData of the Ground designed from a heightmap
  24059. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  24060. * * width the width (x direction) of the ground
  24061. * * height the height (z direction) of the ground
  24062. * * subdivisions the number of subdivisions per side
  24063. * * minHeight the minimum altitude on the ground, optional, default 0
  24064. * * maxHeight the maximum altitude on the ground, optional default 1
  24065. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  24066. * * buffer the array holding the image color data
  24067. * * bufferWidth the width of image
  24068. * * bufferHeight the height of image
  24069. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  24070. * @returns the VertexData of the Ground designed from a heightmap
  24071. */
  24072. static CreateGroundFromHeightMap(options: {
  24073. width: number;
  24074. height: number;
  24075. subdivisions: number;
  24076. minHeight: number;
  24077. maxHeight: number;
  24078. colorFilter: Color3;
  24079. buffer: Uint8Array;
  24080. bufferWidth: number;
  24081. bufferHeight: number;
  24082. alphaFilter: number;
  24083. }): VertexData;
  24084. /**
  24085. * Creates the VertexData for a Plane
  24086. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  24087. * * size sets the width and height of the plane to the value of size, optional default 1
  24088. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  24089. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  24090. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24091. * * 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)
  24092. * * 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)
  24093. * @returns the VertexData of the box
  24094. */
  24095. static CreatePlane(options: {
  24096. size?: number;
  24097. width?: number;
  24098. height?: number;
  24099. sideOrientation?: number;
  24100. frontUVs?: Vector4;
  24101. backUVs?: Vector4;
  24102. }): VertexData;
  24103. /**
  24104. * Creates the VertexData of the Disc or regular Polygon
  24105. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  24106. * * radius the radius of the disc, optional default 0.5
  24107. * * tessellation the number of polygon sides, optional, default 64
  24108. * * 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
  24109. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24110. * * 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)
  24111. * * 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)
  24112. * @returns the VertexData of the box
  24113. */
  24114. static CreateDisc(options: {
  24115. radius?: number;
  24116. tessellation?: number;
  24117. arc?: number;
  24118. sideOrientation?: number;
  24119. frontUVs?: Vector4;
  24120. backUVs?: Vector4;
  24121. }): VertexData;
  24122. /**
  24123. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  24124. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  24125. * @param polygon a mesh built from polygonTriangulation.build()
  24126. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24127. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24128. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24129. * @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)
  24130. * @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)
  24131. * @returns the VertexData of the Polygon
  24132. */
  24133. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  24134. /**
  24135. * Creates the VertexData of the IcoSphere
  24136. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  24137. * * radius the radius of the IcoSphere, optional default 1
  24138. * * radiusX allows stretching in the x direction, optional, default radius
  24139. * * radiusY allows stretching in the y direction, optional, default radius
  24140. * * radiusZ allows stretching in the z direction, optional, default radius
  24141. * * flat when true creates a flat shaded mesh, optional, default true
  24142. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24143. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24144. * * 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)
  24145. * * 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)
  24146. * @returns the VertexData of the IcoSphere
  24147. */
  24148. static CreateIcoSphere(options: {
  24149. radius?: number;
  24150. radiusX?: number;
  24151. radiusY?: number;
  24152. radiusZ?: number;
  24153. flat?: boolean;
  24154. subdivisions?: number;
  24155. sideOrientation?: number;
  24156. frontUVs?: Vector4;
  24157. backUVs?: Vector4;
  24158. }): VertexData;
  24159. /**
  24160. * Creates the VertexData for a Polyhedron
  24161. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  24162. * * type provided types are:
  24163. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  24164. * * 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)
  24165. * * size the size of the IcoSphere, optional default 1
  24166. * * sizeX allows stretching in the x direction, optional, default size
  24167. * * sizeY allows stretching in the y direction, optional, default size
  24168. * * sizeZ allows stretching in the z direction, optional, default size
  24169. * * 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
  24170. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  24171. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  24172. * * flat when true creates a flat shaded mesh, optional, default true
  24173. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  24174. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24175. * * 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)
  24176. * * 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)
  24177. * @returns the VertexData of the Polyhedron
  24178. */
  24179. static CreatePolyhedron(options: {
  24180. type?: number;
  24181. size?: number;
  24182. sizeX?: number;
  24183. sizeY?: number;
  24184. sizeZ?: number;
  24185. custom?: any;
  24186. faceUV?: Vector4[];
  24187. faceColors?: Color4[];
  24188. flat?: boolean;
  24189. sideOrientation?: number;
  24190. frontUVs?: Vector4;
  24191. backUVs?: Vector4;
  24192. }): VertexData;
  24193. /**
  24194. * Creates the VertexData for a TorusKnot
  24195. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  24196. * * radius the radius of the torus knot, optional, default 2
  24197. * * tube the thickness of the tube, optional, default 0.5
  24198. * * radialSegments the number of sides on each tube segments, optional, default 32
  24199. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  24200. * * p the number of windings around the z axis, optional, default 2
  24201. * * q the number of windings around the x axis, optional, default 3
  24202. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  24203. * * 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)
  24204. * * 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)
  24205. * @returns the VertexData of the Torus Knot
  24206. */
  24207. static CreateTorusKnot(options: {
  24208. radius?: number;
  24209. tube?: number;
  24210. radialSegments?: number;
  24211. tubularSegments?: number;
  24212. p?: number;
  24213. q?: number;
  24214. sideOrientation?: number;
  24215. frontUVs?: Vector4;
  24216. backUVs?: Vector4;
  24217. }): VertexData;
  24218. /**
  24219. * Compute normals for given positions and indices
  24220. * @param positions an array of vertex positions, [...., x, y, z, ......]
  24221. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  24222. * @param normals an array of vertex normals, [...., x, y, z, ......]
  24223. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  24224. * * facetNormals : optional array of facet normals (vector3)
  24225. * * facetPositions : optional array of facet positions (vector3)
  24226. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  24227. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  24228. * * bInfo : optional bounding info, required for facetPartitioning computation
  24229. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  24230. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  24231. * * useRightHandedSystem: optional boolean to for right handed system computation
  24232. * * depthSort : optional boolean to enable the facet depth sort computation
  24233. * * distanceTo : optional Vector3 to compute the facet depth from this location
  24234. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  24235. */
  24236. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  24237. facetNormals?: any;
  24238. facetPositions?: any;
  24239. facetPartitioning?: any;
  24240. ratio?: number;
  24241. bInfo?: any;
  24242. bbSize?: Vector3;
  24243. subDiv?: any;
  24244. useRightHandedSystem?: boolean;
  24245. depthSort?: boolean;
  24246. distanceTo?: Vector3;
  24247. depthSortedFacets?: any;
  24248. }): void;
  24249. /** @hidden */
  24250. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  24251. /**
  24252. * Applies VertexData created from the imported parameters to the geometry
  24253. * @param parsedVertexData the parsed data from an imported file
  24254. * @param geometry the geometry to apply the VertexData to
  24255. */
  24256. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  24257. }
  24258. }
  24259. declare module "babylonjs/Meshes/Builders/discBuilder" {
  24260. import { Nullable } from "babylonjs/types";
  24261. import { Scene } from "babylonjs/scene";
  24262. import { Vector4 } from "babylonjs/Maths/math";
  24263. import { Mesh } from "babylonjs/Meshes/mesh";
  24264. /**
  24265. * Class containing static functions to help procedurally build meshes
  24266. */
  24267. export class DiscBuilder {
  24268. /**
  24269. * Creates a plane polygonal mesh. By default, this is a disc
  24270. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24271. * * 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
  24272. * * 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
  24273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24276. * @param name defines the name of the mesh
  24277. * @param options defines the options used to create the mesh
  24278. * @param scene defines the hosting scene
  24279. * @returns the plane polygonal mesh
  24280. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24281. */
  24282. static CreateDisc(name: string, options: {
  24283. radius?: number;
  24284. tessellation?: number;
  24285. arc?: number;
  24286. updatable?: boolean;
  24287. sideOrientation?: number;
  24288. frontUVs?: Vector4;
  24289. backUVs?: Vector4;
  24290. }, scene?: Nullable<Scene>): Mesh;
  24291. }
  24292. }
  24293. declare module "babylonjs/Particles/solidParticleSystem" {
  24294. import { Vector3 } from "babylonjs/Maths/math";
  24295. import { Mesh } from "babylonjs/Meshes/mesh";
  24296. import { Scene, IDisposable } from "babylonjs/scene";
  24297. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24298. /**
  24299. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24300. *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.
  24301. * The SPS is also a particle system. It provides some methods to manage the particles.
  24302. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24303. *
  24304. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24305. */
  24306. export class SolidParticleSystem implements IDisposable {
  24307. /**
  24308. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24309. * Example : var p = SPS.particles[i];
  24310. */
  24311. particles: SolidParticle[];
  24312. /**
  24313. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24314. */
  24315. nbParticles: number;
  24316. /**
  24317. * If the particles must ever face the camera (default false). Useful for planar particles.
  24318. */
  24319. billboard: boolean;
  24320. /**
  24321. * Recompute normals when adding a shape
  24322. */
  24323. recomputeNormals: boolean;
  24324. /**
  24325. * This a counter ofr your own usage. It's not set by any SPS functions.
  24326. */
  24327. counter: number;
  24328. /**
  24329. * The SPS name. This name is also given to the underlying mesh.
  24330. */
  24331. name: string;
  24332. /**
  24333. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24334. */
  24335. mesh: Mesh;
  24336. /**
  24337. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24338. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24339. */
  24340. vars: any;
  24341. /**
  24342. * This array is populated when the SPS is set as 'pickable'.
  24343. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24344. * Each element of this array is an object `{idx: int, faceId: int}`.
  24345. * `idx` is the picked particle index in the `SPS.particles` array
  24346. * `faceId` is the picked face index counted within this particle.
  24347. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24348. */
  24349. pickedParticles: {
  24350. idx: number;
  24351. faceId: number;
  24352. }[];
  24353. /**
  24354. * This array is populated when `enableDepthSort` is set to true.
  24355. * Each element of this array is an instance of the class DepthSortedParticle.
  24356. */
  24357. depthSortedParticles: DepthSortedParticle[];
  24358. /**
  24359. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24360. * @hidden
  24361. */
  24362. _bSphereOnly: boolean;
  24363. /**
  24364. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24365. * @hidden
  24366. */
  24367. _bSphereRadiusFactor: number;
  24368. private _scene;
  24369. private _positions;
  24370. private _indices;
  24371. private _normals;
  24372. private _colors;
  24373. private _uvs;
  24374. private _indices32;
  24375. private _positions32;
  24376. private _normals32;
  24377. private _fixedNormal32;
  24378. private _colors32;
  24379. private _uvs32;
  24380. private _index;
  24381. private _updatable;
  24382. private _pickable;
  24383. private _isVisibilityBoxLocked;
  24384. private _alwaysVisible;
  24385. private _depthSort;
  24386. private _shapeCounter;
  24387. private _copy;
  24388. private _color;
  24389. private _computeParticleColor;
  24390. private _computeParticleTexture;
  24391. private _computeParticleRotation;
  24392. private _computeParticleVertex;
  24393. private _computeBoundingBox;
  24394. private _depthSortParticles;
  24395. private _camera;
  24396. private _mustUnrotateFixedNormals;
  24397. private _particlesIntersect;
  24398. private _needs32Bits;
  24399. /**
  24400. * Creates a SPS (Solid Particle System) object.
  24401. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24402. * @param scene (Scene) is the scene in which the SPS is added.
  24403. * @param options defines the options of the sps e.g.
  24404. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24405. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24406. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24407. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24408. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24409. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24410. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24411. */
  24412. constructor(name: string, scene: Scene, options?: {
  24413. updatable?: boolean;
  24414. isPickable?: boolean;
  24415. enableDepthSort?: boolean;
  24416. particleIntersection?: boolean;
  24417. boundingSphereOnly?: boolean;
  24418. bSphereRadiusFactor?: number;
  24419. });
  24420. /**
  24421. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24422. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24423. * @returns the created mesh
  24424. */
  24425. buildMesh(): Mesh;
  24426. /**
  24427. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24428. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24429. * Thus the particles generated from `digest()` have their property `position` set yet.
  24430. * @param mesh ( Mesh ) is the mesh to be digested
  24431. * @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
  24432. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24433. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24434. * @returns the current SPS
  24435. */
  24436. digest(mesh: Mesh, options?: {
  24437. facetNb?: number;
  24438. number?: number;
  24439. delta?: number;
  24440. }): SolidParticleSystem;
  24441. private _unrotateFixedNormals;
  24442. private _resetCopy;
  24443. private _meshBuilder;
  24444. private _posToShape;
  24445. private _uvsToShapeUV;
  24446. private _addParticle;
  24447. /**
  24448. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24449. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24450. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24451. * @param nb (positive integer) the number of particles to be created from this model
  24452. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24453. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24454. * @returns the number of shapes in the system
  24455. */
  24456. addShape(mesh: Mesh, nb: number, options?: {
  24457. positionFunction?: any;
  24458. vertexFunction?: any;
  24459. }): number;
  24460. private _rebuildParticle;
  24461. /**
  24462. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24463. * @returns the SPS.
  24464. */
  24465. rebuildMesh(): SolidParticleSystem;
  24466. /**
  24467. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24468. * This method calls `updateParticle()` for each particle of the SPS.
  24469. * For an animated SPS, it is usually called within the render loop.
  24470. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24471. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24472. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24473. * @returns the SPS.
  24474. */
  24475. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24476. /**
  24477. * Disposes the SPS.
  24478. */
  24479. dispose(): void;
  24480. /**
  24481. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24482. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24483. * @returns the SPS.
  24484. */
  24485. refreshVisibleSize(): SolidParticleSystem;
  24486. /**
  24487. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24488. * @param size the size (float) of the visibility box
  24489. * note : this doesn't lock the SPS mesh bounding box.
  24490. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24491. */
  24492. setVisibilityBox(size: number): void;
  24493. /**
  24494. * Gets whether the SPS as always visible or not
  24495. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24496. */
  24497. /**
  24498. * Sets the SPS as always visible or not
  24499. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24500. */
  24501. isAlwaysVisible: boolean;
  24502. /**
  24503. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24504. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24505. */
  24506. /**
  24507. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24508. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24509. */
  24510. isVisibilityBoxLocked: boolean;
  24511. /**
  24512. * Tells to `setParticles()` to compute the particle rotations or not.
  24513. * Default value : true. The SPS is faster when it's set to false.
  24514. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24515. */
  24516. /**
  24517. * Gets if `setParticles()` computes the particle rotations or not.
  24518. * Default value : true. The SPS is faster when it's set to false.
  24519. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24520. */
  24521. computeParticleRotation: boolean;
  24522. /**
  24523. * Tells to `setParticles()` to compute the particle colors or not.
  24524. * Default value : true. The SPS is faster when it's set to false.
  24525. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24526. */
  24527. /**
  24528. * Gets if `setParticles()` computes the particle colors or not.
  24529. * Default value : true. The SPS is faster when it's set to false.
  24530. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24531. */
  24532. computeParticleColor: boolean;
  24533. /**
  24534. * Gets if `setParticles()` computes the particle textures or not.
  24535. * Default value : true. The SPS is faster when it's set to false.
  24536. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24537. */
  24538. computeParticleTexture: boolean;
  24539. /**
  24540. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24541. * Default value : false. The SPS is faster when it's set to false.
  24542. * Note : the particle custom vertex positions aren't stored values.
  24543. */
  24544. /**
  24545. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24546. * Default value : false. The SPS is faster when it's set to false.
  24547. * Note : the particle custom vertex positions aren't stored values.
  24548. */
  24549. computeParticleVertex: boolean;
  24550. /**
  24551. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24552. */
  24553. /**
  24554. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24555. */
  24556. computeBoundingBox: boolean;
  24557. /**
  24558. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24559. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24560. * Default : `true`
  24561. */
  24562. /**
  24563. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24564. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24565. * Default : `true`
  24566. */
  24567. depthSortParticles: boolean;
  24568. /**
  24569. * This function does nothing. It may be overwritten to set all the particle first values.
  24570. * The SPS doesn't call this function, you may have to call it by your own.
  24571. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24572. */
  24573. initParticles(): void;
  24574. /**
  24575. * This function does nothing. It may be overwritten to recycle a particle.
  24576. * The SPS doesn't call this function, you may have to call it by your own.
  24577. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24578. * @param particle The particle to recycle
  24579. * @returns the recycled particle
  24580. */
  24581. recycleParticle(particle: SolidParticle): SolidParticle;
  24582. /**
  24583. * Updates a particle : this function should be overwritten by the user.
  24584. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24585. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24586. * @example : just set a particle position or velocity and recycle conditions
  24587. * @param particle The particle to update
  24588. * @returns the updated particle
  24589. */
  24590. updateParticle(particle: SolidParticle): SolidParticle;
  24591. /**
  24592. * Updates a vertex of a particle : it can be overwritten by the user.
  24593. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24594. * @param particle the current particle
  24595. * @param vertex the current index of the current particle
  24596. * @param pt the index of the current vertex in the particle shape
  24597. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24598. * @example : just set a vertex particle position
  24599. * @returns the updated vertex
  24600. */
  24601. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24602. /**
  24603. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24604. * This does nothing and may be overwritten by the user.
  24605. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24606. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24607. * @param update the boolean update value actually passed to setParticles()
  24608. */
  24609. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24610. /**
  24611. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24612. * This will be passed three parameters.
  24613. * This does nothing and may be overwritten by the user.
  24614. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24615. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24616. * @param update the boolean update value actually passed to setParticles()
  24617. */
  24618. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24619. }
  24620. }
  24621. declare module "babylonjs/Particles/solidParticle" {
  24622. import { Nullable } from "babylonjs/types";
  24623. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24624. import { Mesh } from "babylonjs/Meshes/mesh";
  24625. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24626. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24627. /**
  24628. * Represents one particle of a solid particle system.
  24629. */
  24630. export class SolidParticle {
  24631. /**
  24632. * particle global index
  24633. */
  24634. idx: number;
  24635. /**
  24636. * The color of the particle
  24637. */
  24638. color: Nullable<Color4>;
  24639. /**
  24640. * The world space position of the particle.
  24641. */
  24642. position: Vector3;
  24643. /**
  24644. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24645. */
  24646. rotation: Vector3;
  24647. /**
  24648. * The world space rotation quaternion of the particle.
  24649. */
  24650. rotationQuaternion: Nullable<Quaternion>;
  24651. /**
  24652. * The scaling of the particle.
  24653. */
  24654. scaling: Vector3;
  24655. /**
  24656. * The uvs of the particle.
  24657. */
  24658. uvs: Vector4;
  24659. /**
  24660. * The current speed of the particle.
  24661. */
  24662. velocity: Vector3;
  24663. /**
  24664. * The pivot point in the particle local space.
  24665. */
  24666. pivot: Vector3;
  24667. /**
  24668. * Must the particle be translated from its pivot point in its local space ?
  24669. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24670. * Default : false
  24671. */
  24672. translateFromPivot: boolean;
  24673. /**
  24674. * Is the particle active or not ?
  24675. */
  24676. alive: boolean;
  24677. /**
  24678. * Is the particle visible or not ?
  24679. */
  24680. isVisible: boolean;
  24681. /**
  24682. * Index of this particle in the global "positions" array (Internal use)
  24683. * @hidden
  24684. */
  24685. _pos: number;
  24686. /**
  24687. * @hidden Index of this particle in the global "indices" array (Internal use)
  24688. */
  24689. _ind: number;
  24690. /**
  24691. * @hidden ModelShape of this particle (Internal use)
  24692. */
  24693. _model: ModelShape;
  24694. /**
  24695. * ModelShape id of this particle
  24696. */
  24697. shapeId: number;
  24698. /**
  24699. * Index of the particle in its shape id (Internal use)
  24700. */
  24701. idxInShape: number;
  24702. /**
  24703. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24704. */
  24705. _modelBoundingInfo: BoundingInfo;
  24706. /**
  24707. * @hidden Particle BoundingInfo object (Internal use)
  24708. */
  24709. _boundingInfo: BoundingInfo;
  24710. /**
  24711. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24712. */
  24713. _sps: SolidParticleSystem;
  24714. /**
  24715. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24716. */
  24717. _stillInvisible: boolean;
  24718. /**
  24719. * @hidden Last computed particle rotation matrix
  24720. */
  24721. _rotationMatrix: number[];
  24722. /**
  24723. * Parent particle Id, if any.
  24724. * Default null.
  24725. */
  24726. parentId: Nullable<number>;
  24727. /**
  24728. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24729. * The possible values are :
  24730. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24731. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24732. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24733. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24734. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24735. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24736. * */
  24737. cullingStrategy: number;
  24738. /**
  24739. * @hidden Internal global position in the SPS.
  24740. */
  24741. _globalPosition: Vector3;
  24742. /**
  24743. * Creates a Solid Particle object.
  24744. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24745. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24746. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24747. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24748. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24749. * @param shapeId (integer) is the model shape identifier in the SPS.
  24750. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24751. * @param sps defines the sps it is associated to
  24752. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24753. */
  24754. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24755. /**
  24756. * Legacy support, changed scale to scaling
  24757. */
  24758. /**
  24759. * Legacy support, changed scale to scaling
  24760. */
  24761. scale: Vector3;
  24762. /**
  24763. * Legacy support, changed quaternion to rotationQuaternion
  24764. */
  24765. /**
  24766. * Legacy support, changed quaternion to rotationQuaternion
  24767. */
  24768. quaternion: Nullable<Quaternion>;
  24769. /**
  24770. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24771. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24772. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24773. * @returns true if it intersects
  24774. */
  24775. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24776. /**
  24777. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24778. * A particle is in the frustum if its bounding box intersects the frustum
  24779. * @param frustumPlanes defines the frustum to test
  24780. * @returns true if the particle is in the frustum planes
  24781. */
  24782. isInFrustum(frustumPlanes: Plane[]): boolean;
  24783. /**
  24784. * get the rotation matrix of the particle
  24785. * @hidden
  24786. */
  24787. getRotationMatrix(m: Matrix): void;
  24788. }
  24789. /**
  24790. * Represents the shape of the model used by one particle of a solid particle system.
  24791. * SPS internal tool, don't use it manually.
  24792. */
  24793. export class ModelShape {
  24794. /**
  24795. * The shape id
  24796. * @hidden
  24797. */
  24798. shapeID: number;
  24799. /**
  24800. * flat array of model positions (internal use)
  24801. * @hidden
  24802. */
  24803. _shape: Vector3[];
  24804. /**
  24805. * flat array of model UVs (internal use)
  24806. * @hidden
  24807. */
  24808. _shapeUV: number[];
  24809. /**
  24810. * length of the shape in the model indices array (internal use)
  24811. * @hidden
  24812. */
  24813. _indicesLength: number;
  24814. /**
  24815. * Custom position function (internal use)
  24816. * @hidden
  24817. */
  24818. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24819. /**
  24820. * Custom vertex function (internal use)
  24821. * @hidden
  24822. */
  24823. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24824. /**
  24825. * 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.
  24826. * SPS internal tool, don't use it manually.
  24827. * @hidden
  24828. */
  24829. 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>);
  24830. }
  24831. /**
  24832. * Represents a Depth Sorted Particle in the solid particle system.
  24833. */
  24834. export class DepthSortedParticle {
  24835. /**
  24836. * Index of the particle in the "indices" array
  24837. */
  24838. ind: number;
  24839. /**
  24840. * Length of the particle shape in the "indices" array
  24841. */
  24842. indicesLength: number;
  24843. /**
  24844. * Squared distance from the particle to the camera
  24845. */
  24846. sqDistance: number;
  24847. }
  24848. }
  24849. declare module "babylonjs/Collisions/meshCollisionData" {
  24850. import { Collider } from "babylonjs/Collisions/collider";
  24851. import { Vector3 } from "babylonjs/Maths/math";
  24852. import { Nullable } from "babylonjs/types";
  24853. import { Observer } from "babylonjs/Misc/observable";
  24854. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24855. /**
  24856. * @hidden
  24857. */
  24858. export class _MeshCollisionData {
  24859. _checkCollisions: boolean;
  24860. _collisionMask: number;
  24861. _collisionGroup: number;
  24862. _collider: Nullable<Collider>;
  24863. _oldPositionForCollisions: Vector3;
  24864. _diffPositionForCollisions: Vector3;
  24865. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  24866. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  24867. }
  24868. }
  24869. declare module "babylonjs/Meshes/abstractMesh" {
  24870. import { Observable } from "babylonjs/Misc/observable";
  24871. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24872. import { Camera } from "babylonjs/Cameras/camera";
  24873. import { Scene, IDisposable } from "babylonjs/scene";
  24874. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24875. import { Node } from "babylonjs/node";
  24876. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24877. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24878. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24879. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24880. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24881. import { Material } from "babylonjs/Materials/material";
  24882. import { Light } from "babylonjs/Lights/light";
  24883. import { Skeleton } from "babylonjs/Bones/skeleton";
  24884. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24885. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24886. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24887. import { Ray } from "babylonjs/Culling/ray";
  24888. import { Collider } from "babylonjs/Collisions/collider";
  24889. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24890. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24891. /** @hidden */
  24892. class _FacetDataStorage {
  24893. facetPositions: Vector3[];
  24894. facetNormals: Vector3[];
  24895. facetPartitioning: number[][];
  24896. facetNb: number;
  24897. partitioningSubdivisions: number;
  24898. partitioningBBoxRatio: number;
  24899. facetDataEnabled: boolean;
  24900. facetParameters: any;
  24901. bbSize: Vector3;
  24902. subDiv: {
  24903. max: number;
  24904. X: number;
  24905. Y: number;
  24906. Z: number;
  24907. };
  24908. facetDepthSort: boolean;
  24909. facetDepthSortEnabled: boolean;
  24910. depthSortedIndices: IndicesArray;
  24911. depthSortedFacets: {
  24912. ind: number;
  24913. sqDistance: number;
  24914. }[];
  24915. facetDepthSortFunction: (f1: {
  24916. ind: number;
  24917. sqDistance: number;
  24918. }, f2: {
  24919. ind: number;
  24920. sqDistance: number;
  24921. }) => number;
  24922. facetDepthSortFrom: Vector3;
  24923. facetDepthSortOrigin: Vector3;
  24924. invertedMatrix: Matrix;
  24925. }
  24926. /**
  24927. * @hidden
  24928. **/
  24929. class _InternalAbstractMeshDataInfo {
  24930. _hasVertexAlpha: boolean;
  24931. _useVertexColors: boolean;
  24932. _numBoneInfluencers: number;
  24933. _applyFog: boolean;
  24934. _receiveShadows: boolean;
  24935. _facetData: _FacetDataStorage;
  24936. _visibility: number;
  24937. _skeleton: Nullable<Skeleton>;
  24938. _layerMask: number;
  24939. _computeBonesUsingShaders: boolean;
  24940. _isActive: boolean;
  24941. _onlyForInstances: boolean;
  24942. _isActiveIntermediate: boolean;
  24943. _onlyForInstancesIntermediate: boolean;
  24944. }
  24945. /**
  24946. * Class used to store all common mesh properties
  24947. */
  24948. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24949. /** No occlusion */
  24950. static OCCLUSION_TYPE_NONE: number;
  24951. /** Occlusion set to optimisitic */
  24952. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24953. /** Occlusion set to strict */
  24954. static OCCLUSION_TYPE_STRICT: number;
  24955. /** Use an accurante occlusion algorithm */
  24956. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24957. /** Use a conservative occlusion algorithm */
  24958. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24959. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24960. * Test order :
  24961. * Is the bounding sphere outside the frustum ?
  24962. * If not, are the bounding box vertices outside the frustum ?
  24963. * It not, then the cullable object is in the frustum.
  24964. */
  24965. static readonly CULLINGSTRATEGY_STANDARD: number;
  24966. /** Culling strategy : Bounding Sphere Only.
  24967. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24968. * It's also less accurate than the standard because some not visible objects can still be selected.
  24969. * Test : is the bounding sphere outside the frustum ?
  24970. * If not, then the cullable object is in the frustum.
  24971. */
  24972. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24973. /** Culling strategy : Optimistic Inclusion.
  24974. * This in an inclusion test first, then the standard exclusion test.
  24975. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24976. * 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.
  24977. * Anyway, it's as accurate as the standard strategy.
  24978. * Test :
  24979. * Is the cullable object bounding sphere center in the frustum ?
  24980. * If not, apply the default culling strategy.
  24981. */
  24982. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24983. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24984. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24985. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24986. * 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.
  24987. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24988. * Test :
  24989. * Is the cullable object bounding sphere center in the frustum ?
  24990. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24991. */
  24992. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24993. /**
  24994. * No billboard
  24995. */
  24996. static readonly BILLBOARDMODE_NONE: number;
  24997. /** Billboard on X axis */
  24998. static readonly BILLBOARDMODE_X: number;
  24999. /** Billboard on Y axis */
  25000. static readonly BILLBOARDMODE_Y: number;
  25001. /** Billboard on Z axis */
  25002. static readonly BILLBOARDMODE_Z: number;
  25003. /** Billboard on all axes */
  25004. static readonly BILLBOARDMODE_ALL: number;
  25005. /** @hidden */
  25006. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25007. /**
  25008. * The culling strategy to use to check whether the mesh must be rendered or not.
  25009. * This value can be changed at any time and will be used on the next render mesh selection.
  25010. * The possible values are :
  25011. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25012. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25013. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25014. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25015. * Please read each static variable documentation to get details about the culling process.
  25016. * */
  25017. cullingStrategy: number;
  25018. /**
  25019. * Gets the number of facets in the mesh
  25020. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25021. */
  25022. readonly facetNb: number;
  25023. /**
  25024. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25025. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25026. */
  25027. partitioningSubdivisions: number;
  25028. /**
  25029. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25030. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25031. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25032. */
  25033. partitioningBBoxRatio: number;
  25034. /**
  25035. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25036. * Works only for updatable meshes.
  25037. * Doesn't work with multi-materials
  25038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25039. */
  25040. mustDepthSortFacets: boolean;
  25041. /**
  25042. * The location (Vector3) where the facet depth sort must be computed from.
  25043. * By default, the active camera position.
  25044. * Used only when facet depth sort is enabled
  25045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25046. */
  25047. facetDepthSortFrom: Vector3;
  25048. /**
  25049. * gets a boolean indicating if facetData is enabled
  25050. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25051. */
  25052. readonly isFacetDataEnabled: boolean;
  25053. /** @hidden */
  25054. _updateNonUniformScalingState(value: boolean): boolean;
  25055. /**
  25056. * An event triggered when this mesh collides with another one
  25057. */
  25058. onCollideObservable: Observable<AbstractMesh>;
  25059. /** Set a function to call when this mesh collides with another one */
  25060. onCollide: () => void;
  25061. /**
  25062. * An event triggered when the collision's position changes
  25063. */
  25064. onCollisionPositionChangeObservable: Observable<Vector3>;
  25065. /** Set a function to call when the collision's position changes */
  25066. onCollisionPositionChange: () => void;
  25067. /**
  25068. * An event triggered when material is changed
  25069. */
  25070. onMaterialChangedObservable: Observable<AbstractMesh>;
  25071. /**
  25072. * Gets or sets the orientation for POV movement & rotation
  25073. */
  25074. definedFacingForward: boolean;
  25075. /** @hidden */
  25076. _occlusionQuery: Nullable<WebGLQuery>;
  25077. /** @hidden */
  25078. _renderingGroup: Nullable<RenderingGroup>;
  25079. /**
  25080. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25081. */
  25082. /**
  25083. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25084. */
  25085. visibility: number;
  25086. /** Gets or sets the alpha index used to sort transparent meshes
  25087. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25088. */
  25089. alphaIndex: number;
  25090. /**
  25091. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25092. */
  25093. isVisible: boolean;
  25094. /**
  25095. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25096. */
  25097. isPickable: boolean;
  25098. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25099. showSubMeshesBoundingBox: boolean;
  25100. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25101. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25102. */
  25103. isBlocker: boolean;
  25104. /**
  25105. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25106. */
  25107. enablePointerMoveEvents: boolean;
  25108. /**
  25109. * Specifies the rendering group id for this mesh (0 by default)
  25110. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25111. */
  25112. renderingGroupId: number;
  25113. private _material;
  25114. /** Gets or sets current material */
  25115. material: Nullable<Material>;
  25116. /**
  25117. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25118. * @see http://doc.babylonjs.com/babylon101/shadows
  25119. */
  25120. receiveShadows: boolean;
  25121. /** Defines color to use when rendering outline */
  25122. outlineColor: Color3;
  25123. /** Define width to use when rendering outline */
  25124. outlineWidth: number;
  25125. /** Defines color to use when rendering overlay */
  25126. overlayColor: Color3;
  25127. /** Defines alpha to use when rendering overlay */
  25128. overlayAlpha: number;
  25129. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25130. hasVertexAlpha: boolean;
  25131. /** 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) */
  25132. useVertexColors: boolean;
  25133. /**
  25134. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25135. */
  25136. computeBonesUsingShaders: boolean;
  25137. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25138. numBoneInfluencers: number;
  25139. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25140. applyFog: boolean;
  25141. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25142. useOctreeForRenderingSelection: boolean;
  25143. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25144. useOctreeForPicking: boolean;
  25145. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25146. useOctreeForCollisions: boolean;
  25147. /**
  25148. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25149. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25150. */
  25151. layerMask: number;
  25152. /**
  25153. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25154. */
  25155. alwaysSelectAsActiveMesh: boolean;
  25156. /**
  25157. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25158. */
  25159. doNotSyncBoundingInfo: boolean;
  25160. /**
  25161. * Gets or sets the current action manager
  25162. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25163. */
  25164. actionManager: Nullable<AbstractActionManager>;
  25165. private _meshCollisionData;
  25166. /**
  25167. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25168. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25169. */
  25170. ellipsoid: Vector3;
  25171. /**
  25172. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25173. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25174. */
  25175. ellipsoidOffset: Vector3;
  25176. /**
  25177. * Gets or sets a collision mask used to mask collisions (default is -1).
  25178. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25179. */
  25180. collisionMask: number;
  25181. /**
  25182. * Gets or sets the current collision group mask (-1 by default).
  25183. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25184. */
  25185. collisionGroup: number;
  25186. /**
  25187. * Defines edge width used when edgesRenderer is enabled
  25188. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25189. */
  25190. edgesWidth: number;
  25191. /**
  25192. * Defines edge color used when edgesRenderer is enabled
  25193. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25194. */
  25195. edgesColor: Color4;
  25196. /** @hidden */
  25197. _edgesRenderer: Nullable<IEdgesRenderer>;
  25198. /** @hidden */
  25199. _masterMesh: Nullable<AbstractMesh>;
  25200. /** @hidden */
  25201. _boundingInfo: Nullable<BoundingInfo>;
  25202. /** @hidden */
  25203. _renderId: number;
  25204. /**
  25205. * Gets or sets the list of subMeshes
  25206. * @see http://doc.babylonjs.com/how_to/multi_materials
  25207. */
  25208. subMeshes: SubMesh[];
  25209. /** @hidden */
  25210. _intersectionsInProgress: AbstractMesh[];
  25211. /** @hidden */
  25212. _unIndexed: boolean;
  25213. /** @hidden */
  25214. _lightSources: Light[];
  25215. /** Gets the list of lights affecting that mesh */
  25216. readonly lightSources: Light[];
  25217. /** @hidden */
  25218. readonly _positions: Nullable<Vector3[]>;
  25219. /** @hidden */
  25220. _waitingData: {
  25221. lods: Nullable<any>;
  25222. actions: Nullable<any>;
  25223. freezeWorldMatrix: Nullable<boolean>;
  25224. };
  25225. /** @hidden */
  25226. _bonesTransformMatrices: Nullable<Float32Array>;
  25227. /**
  25228. * Gets or sets a skeleton to apply skining transformations
  25229. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25230. */
  25231. skeleton: Nullable<Skeleton>;
  25232. /**
  25233. * An event triggered when the mesh is rebuilt.
  25234. */
  25235. onRebuildObservable: Observable<AbstractMesh>;
  25236. /**
  25237. * Creates a new AbstractMesh
  25238. * @param name defines the name of the mesh
  25239. * @param scene defines the hosting scene
  25240. */
  25241. constructor(name: string, scene?: Nullable<Scene>);
  25242. /**
  25243. * Returns the string "AbstractMesh"
  25244. * @returns "AbstractMesh"
  25245. */
  25246. getClassName(): string;
  25247. /**
  25248. * Gets a string representation of the current mesh
  25249. * @param fullDetails defines a boolean indicating if full details must be included
  25250. * @returns a string representation of the current mesh
  25251. */
  25252. toString(fullDetails?: boolean): string;
  25253. /**
  25254. * @hidden
  25255. */
  25256. protected _getEffectiveParent(): Nullable<Node>;
  25257. /** @hidden */
  25258. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25259. /** @hidden */
  25260. _rebuild(): void;
  25261. /** @hidden */
  25262. _resyncLightSources(): void;
  25263. /** @hidden */
  25264. _resyncLighSource(light: Light): void;
  25265. /** @hidden */
  25266. _unBindEffect(): void;
  25267. /** @hidden */
  25268. _removeLightSource(light: Light): void;
  25269. private _markSubMeshesAsDirty;
  25270. /** @hidden */
  25271. _markSubMeshesAsLightDirty(): void;
  25272. /** @hidden */
  25273. _markSubMeshesAsAttributesDirty(): void;
  25274. /** @hidden */
  25275. _markSubMeshesAsMiscDirty(): void;
  25276. /**
  25277. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25278. */
  25279. scaling: Vector3;
  25280. /**
  25281. * Returns true if the mesh is blocked. Implemented by child classes
  25282. */
  25283. readonly isBlocked: boolean;
  25284. /**
  25285. * Returns the mesh itself by default. Implemented by child classes
  25286. * @param camera defines the camera to use to pick the right LOD level
  25287. * @returns the currentAbstractMesh
  25288. */
  25289. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25290. /**
  25291. * Returns 0 by default. Implemented by child classes
  25292. * @returns an integer
  25293. */
  25294. getTotalVertices(): number;
  25295. /**
  25296. * Returns a positive integer : the total number of indices in this mesh geometry.
  25297. * @returns the numner of indices or zero if the mesh has no geometry.
  25298. */
  25299. getTotalIndices(): number;
  25300. /**
  25301. * Returns null by default. Implemented by child classes
  25302. * @returns null
  25303. */
  25304. getIndices(): Nullable<IndicesArray>;
  25305. /**
  25306. * Returns the array of the requested vertex data kind. Implemented by child classes
  25307. * @param kind defines the vertex data kind to use
  25308. * @returns null
  25309. */
  25310. getVerticesData(kind: string): Nullable<FloatArray>;
  25311. /**
  25312. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25313. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25314. * Note that a new underlying VertexBuffer object is created each call.
  25315. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25316. * @param kind defines vertex data kind:
  25317. * * VertexBuffer.PositionKind
  25318. * * VertexBuffer.UVKind
  25319. * * VertexBuffer.UV2Kind
  25320. * * VertexBuffer.UV3Kind
  25321. * * VertexBuffer.UV4Kind
  25322. * * VertexBuffer.UV5Kind
  25323. * * VertexBuffer.UV6Kind
  25324. * * VertexBuffer.ColorKind
  25325. * * VertexBuffer.MatricesIndicesKind
  25326. * * VertexBuffer.MatricesIndicesExtraKind
  25327. * * VertexBuffer.MatricesWeightsKind
  25328. * * VertexBuffer.MatricesWeightsExtraKind
  25329. * @param data defines the data source
  25330. * @param updatable defines if the data must be flagged as updatable (or static)
  25331. * @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
  25332. * @returns the current mesh
  25333. */
  25334. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25335. /**
  25336. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25337. * If the mesh has no geometry, it is simply returned as it is.
  25338. * @param kind defines vertex data kind:
  25339. * * VertexBuffer.PositionKind
  25340. * * VertexBuffer.UVKind
  25341. * * VertexBuffer.UV2Kind
  25342. * * VertexBuffer.UV3Kind
  25343. * * VertexBuffer.UV4Kind
  25344. * * VertexBuffer.UV5Kind
  25345. * * VertexBuffer.UV6Kind
  25346. * * VertexBuffer.ColorKind
  25347. * * VertexBuffer.MatricesIndicesKind
  25348. * * VertexBuffer.MatricesIndicesExtraKind
  25349. * * VertexBuffer.MatricesWeightsKind
  25350. * * VertexBuffer.MatricesWeightsExtraKind
  25351. * @param data defines the data source
  25352. * @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
  25353. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25354. * @returns the current mesh
  25355. */
  25356. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25357. /**
  25358. * Sets the mesh indices,
  25359. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25360. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25361. * @param totalVertices Defines the total number of vertices
  25362. * @returns the current mesh
  25363. */
  25364. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25365. /**
  25366. * Gets a boolean indicating if specific vertex data is present
  25367. * @param kind defines the vertex data kind to use
  25368. * @returns true is data kind is present
  25369. */
  25370. isVerticesDataPresent(kind: string): boolean;
  25371. /**
  25372. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25373. * @returns a BoundingInfo
  25374. */
  25375. getBoundingInfo(): BoundingInfo;
  25376. /**
  25377. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25378. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25379. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25380. * @returns the current mesh
  25381. */
  25382. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25383. /**
  25384. * Overwrite the current bounding info
  25385. * @param boundingInfo defines the new bounding info
  25386. * @returns the current mesh
  25387. */
  25388. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25389. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25390. readonly useBones: boolean;
  25391. /** @hidden */
  25392. _preActivate(): void;
  25393. /** @hidden */
  25394. _preActivateForIntermediateRendering(renderId: number): void;
  25395. /** @hidden */
  25396. _activate(renderId: number, intermediateRendering: boolean): boolean;
  25397. /** @hidden */
  25398. _postActivate(): void;
  25399. /** @hidden */
  25400. _freeze(): void;
  25401. /** @hidden */
  25402. _unFreeze(): void;
  25403. /**
  25404. * Gets the current world matrix
  25405. * @returns a Matrix
  25406. */
  25407. getWorldMatrix(): Matrix;
  25408. /** @hidden */
  25409. _getWorldMatrixDeterminant(): number;
  25410. /**
  25411. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25412. */
  25413. readonly isAnInstance: boolean;
  25414. /**
  25415. * Perform relative position change from the point of view of behind the front of the mesh.
  25416. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25417. * Supports definition of mesh facing forward or backward
  25418. * @param amountRight defines the distance on the right axis
  25419. * @param amountUp defines the distance on the up axis
  25420. * @param amountForward defines the distance on the forward axis
  25421. * @returns the current mesh
  25422. */
  25423. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25424. /**
  25425. * Calculate relative position change from the point of view of behind the front of the mesh.
  25426. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25427. * Supports definition of mesh facing forward or backward
  25428. * @param amountRight defines the distance on the right axis
  25429. * @param amountUp defines the distance on the up axis
  25430. * @param amountForward defines the distance on the forward axis
  25431. * @returns the new displacement vector
  25432. */
  25433. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25434. /**
  25435. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25436. * Supports definition of mesh facing forward or backward
  25437. * @param flipBack defines the flip
  25438. * @param twirlClockwise defines the twirl
  25439. * @param tiltRight defines the tilt
  25440. * @returns the current mesh
  25441. */
  25442. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25443. /**
  25444. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25445. * Supports definition of mesh facing forward or backward.
  25446. * @param flipBack defines the flip
  25447. * @param twirlClockwise defines the twirl
  25448. * @param tiltRight defines the tilt
  25449. * @returns the new rotation vector
  25450. */
  25451. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25452. /**
  25453. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25454. * This means the mesh underlying bounding box and sphere are recomputed.
  25455. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25456. * @returns the current mesh
  25457. */
  25458. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25459. /** @hidden */
  25460. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25461. /** @hidden */
  25462. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25463. /** @hidden */
  25464. _updateBoundingInfo(): AbstractMesh;
  25465. /** @hidden */
  25466. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25467. /** @hidden */
  25468. protected _afterComputeWorldMatrix(): void;
  25469. /** @hidden */
  25470. readonly _effectiveMesh: AbstractMesh;
  25471. /**
  25472. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25473. * A mesh is in the frustum if its bounding box intersects the frustum
  25474. * @param frustumPlanes defines the frustum to test
  25475. * @returns true if the mesh is in the frustum planes
  25476. */
  25477. isInFrustum(frustumPlanes: Plane[]): boolean;
  25478. /**
  25479. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25480. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25481. * @param frustumPlanes defines the frustum to test
  25482. * @returns true if the mesh is completely in the frustum planes
  25483. */
  25484. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25485. /**
  25486. * True if the mesh intersects another mesh or a SolidParticle object
  25487. * @param mesh defines a target mesh or SolidParticle to test
  25488. * @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)
  25489. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25490. * @returns true if there is an intersection
  25491. */
  25492. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25493. /**
  25494. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25495. * @param point defines the point to test
  25496. * @returns true if there is an intersection
  25497. */
  25498. intersectsPoint(point: Vector3): boolean;
  25499. /**
  25500. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25501. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25502. */
  25503. checkCollisions: boolean;
  25504. /**
  25505. * Gets Collider object used to compute collisions (not physics)
  25506. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25507. */
  25508. readonly collider: Nullable<Collider>;
  25509. /**
  25510. * Move the mesh using collision engine
  25511. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25512. * @param displacement defines the requested displacement vector
  25513. * @returns the current mesh
  25514. */
  25515. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25516. private _onCollisionPositionChange;
  25517. /** @hidden */
  25518. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25519. /** @hidden */
  25520. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25521. /** @hidden */
  25522. _checkCollision(collider: Collider): AbstractMesh;
  25523. /** @hidden */
  25524. _generatePointsArray(): boolean;
  25525. /**
  25526. * Checks if the passed Ray intersects with the mesh
  25527. * @param ray defines the ray to use
  25528. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25529. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25530. * @returns the picking info
  25531. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25532. */
  25533. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25534. /**
  25535. * Clones the current mesh
  25536. * @param name defines the mesh name
  25537. * @param newParent defines the new mesh parent
  25538. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25539. * @returns the new mesh
  25540. */
  25541. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25542. /**
  25543. * Disposes all the submeshes of the current meshnp
  25544. * @returns the current mesh
  25545. */
  25546. releaseSubMeshes(): AbstractMesh;
  25547. /**
  25548. * Releases resources associated with this abstract mesh.
  25549. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25550. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25551. */
  25552. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25553. /**
  25554. * Adds the passed mesh as a child to the current mesh
  25555. * @param mesh defines the child mesh
  25556. * @returns the current mesh
  25557. */
  25558. addChild(mesh: AbstractMesh): AbstractMesh;
  25559. /**
  25560. * Removes the passed mesh from the current mesh children list
  25561. * @param mesh defines the child mesh
  25562. * @returns the current mesh
  25563. */
  25564. removeChild(mesh: AbstractMesh): AbstractMesh;
  25565. /** @hidden */
  25566. private _initFacetData;
  25567. /**
  25568. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25569. * This method can be called within the render loop.
  25570. * 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
  25571. * @returns the current mesh
  25572. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25573. */
  25574. updateFacetData(): AbstractMesh;
  25575. /**
  25576. * Returns the facetLocalNormals array.
  25577. * The normals are expressed in the mesh local spac
  25578. * @returns an array of Vector3
  25579. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25580. */
  25581. getFacetLocalNormals(): Vector3[];
  25582. /**
  25583. * Returns the facetLocalPositions array.
  25584. * The facet positions are expressed in the mesh local space
  25585. * @returns an array of Vector3
  25586. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25587. */
  25588. getFacetLocalPositions(): Vector3[];
  25589. /**
  25590. * Returns the facetLocalPartioning array
  25591. * @returns an array of array of numbers
  25592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25593. */
  25594. getFacetLocalPartitioning(): number[][];
  25595. /**
  25596. * Returns the i-th facet position in the world system.
  25597. * This method allocates a new Vector3 per call
  25598. * @param i defines the facet index
  25599. * @returns a new Vector3
  25600. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25601. */
  25602. getFacetPosition(i: number): Vector3;
  25603. /**
  25604. * Sets the reference Vector3 with the i-th facet position in the world system
  25605. * @param i defines the facet index
  25606. * @param ref defines the target vector
  25607. * @returns the current mesh
  25608. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25609. */
  25610. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25611. /**
  25612. * Returns the i-th facet normal in the world system.
  25613. * This method allocates a new Vector3 per call
  25614. * @param i defines the facet index
  25615. * @returns a new Vector3
  25616. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25617. */
  25618. getFacetNormal(i: number): Vector3;
  25619. /**
  25620. * Sets the reference Vector3 with the i-th facet normal in the world system
  25621. * @param i defines the facet index
  25622. * @param ref defines the target vector
  25623. * @returns the current mesh
  25624. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25625. */
  25626. getFacetNormalToRef(i: number, ref: Vector3): this;
  25627. /**
  25628. * 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)
  25629. * @param x defines x coordinate
  25630. * @param y defines y coordinate
  25631. * @param z defines z coordinate
  25632. * @returns the array of facet indexes
  25633. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25634. */
  25635. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25636. /**
  25637. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25638. * @param projected sets as the (x,y,z) world projection on the facet
  25639. * @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
  25640. * @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
  25641. * @param x defines x coordinate
  25642. * @param y defines y coordinate
  25643. * @param z defines z coordinate
  25644. * @returns the face index if found (or null instead)
  25645. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25646. */
  25647. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25648. /**
  25649. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25650. * @param projected sets as the (x,y,z) local projection on the facet
  25651. * @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
  25652. * @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
  25653. * @param x defines x coordinate
  25654. * @param y defines y coordinate
  25655. * @param z defines z coordinate
  25656. * @returns the face index if found (or null instead)
  25657. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25658. */
  25659. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25660. /**
  25661. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25662. * @returns the parameters
  25663. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25664. */
  25665. getFacetDataParameters(): any;
  25666. /**
  25667. * Disables the feature FacetData and frees the related memory
  25668. * @returns the current mesh
  25669. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25670. */
  25671. disableFacetData(): AbstractMesh;
  25672. /**
  25673. * Updates the AbstractMesh indices array
  25674. * @param indices defines the data source
  25675. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25676. * @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)
  25677. * @returns the current mesh
  25678. */
  25679. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25680. /**
  25681. * Creates new normals data for the mesh
  25682. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25683. * @returns the current mesh
  25684. */
  25685. createNormals(updatable: boolean): AbstractMesh;
  25686. /**
  25687. * Align the mesh with a normal
  25688. * @param normal defines the normal to use
  25689. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25690. * @returns the current mesh
  25691. */
  25692. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25693. /** @hidden */
  25694. _checkOcclusionQuery(): boolean;
  25695. /**
  25696. * Disables the mesh edge rendering mode
  25697. * @returns the currentAbstractMesh
  25698. */
  25699. disableEdgesRendering(): AbstractMesh;
  25700. /**
  25701. * Enables the edge rendering mode on the mesh.
  25702. * This mode makes the mesh edges visible
  25703. * @param epsilon defines the maximal distance between two angles to detect a face
  25704. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25705. * @returns the currentAbstractMesh
  25706. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25707. */
  25708. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25709. }
  25710. }
  25711. declare module "babylonjs/Actions/actionEvent" {
  25712. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25713. import { Nullable } from "babylonjs/types";
  25714. import { Sprite } from "babylonjs/Sprites/sprite";
  25715. import { Scene } from "babylonjs/scene";
  25716. import { Vector2 } from "babylonjs/Maths/math";
  25717. /**
  25718. * Interface used to define ActionEvent
  25719. */
  25720. export interface IActionEvent {
  25721. /** The mesh or sprite that triggered the action */
  25722. source: any;
  25723. /** The X mouse cursor position at the time of the event */
  25724. pointerX: number;
  25725. /** The Y mouse cursor position at the time of the event */
  25726. pointerY: number;
  25727. /** The mesh that is currently pointed at (can be null) */
  25728. meshUnderPointer: Nullable<AbstractMesh>;
  25729. /** the original (browser) event that triggered the ActionEvent */
  25730. sourceEvent?: any;
  25731. /** additional data for the event */
  25732. additionalData?: any;
  25733. }
  25734. /**
  25735. * ActionEvent is the event being sent when an action is triggered.
  25736. */
  25737. export class ActionEvent implements IActionEvent {
  25738. /** The mesh or sprite that triggered the action */
  25739. source: any;
  25740. /** The X mouse cursor position at the time of the event */
  25741. pointerX: number;
  25742. /** The Y mouse cursor position at the time of the event */
  25743. pointerY: number;
  25744. /** The mesh that is currently pointed at (can be null) */
  25745. meshUnderPointer: Nullable<AbstractMesh>;
  25746. /** the original (browser) event that triggered the ActionEvent */
  25747. sourceEvent?: any;
  25748. /** additional data for the event */
  25749. additionalData?: any;
  25750. /**
  25751. * Creates a new ActionEvent
  25752. * @param source The mesh or sprite that triggered the action
  25753. * @param pointerX The X mouse cursor position at the time of the event
  25754. * @param pointerY The Y mouse cursor position at the time of the event
  25755. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25756. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25757. * @param additionalData additional data for the event
  25758. */
  25759. constructor(
  25760. /** The mesh or sprite that triggered the action */
  25761. source: any,
  25762. /** The X mouse cursor position at the time of the event */
  25763. pointerX: number,
  25764. /** The Y mouse cursor position at the time of the event */
  25765. pointerY: number,
  25766. /** The mesh that is currently pointed at (can be null) */
  25767. meshUnderPointer: Nullable<AbstractMesh>,
  25768. /** the original (browser) event that triggered the ActionEvent */
  25769. sourceEvent?: any,
  25770. /** additional data for the event */
  25771. additionalData?: any);
  25772. /**
  25773. * Helper function to auto-create an ActionEvent from a source mesh.
  25774. * @param source The source mesh that triggered the event
  25775. * @param evt The original (browser) event
  25776. * @param additionalData additional data for the event
  25777. * @returns the new ActionEvent
  25778. */
  25779. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25780. /**
  25781. * Helper function to auto-create an ActionEvent from a source sprite
  25782. * @param source The source sprite that triggered the event
  25783. * @param scene Scene associated with the sprite
  25784. * @param evt The original (browser) event
  25785. * @param additionalData additional data for the event
  25786. * @returns the new ActionEvent
  25787. */
  25788. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25789. /**
  25790. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25791. * @param scene the scene where the event occurred
  25792. * @param evt The original (browser) event
  25793. * @returns the new ActionEvent
  25794. */
  25795. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25796. /**
  25797. * Helper function to auto-create an ActionEvent from a primitive
  25798. * @param prim defines the target primitive
  25799. * @param pointerPos defines the pointer position
  25800. * @param evt The original (browser) event
  25801. * @param additionalData additional data for the event
  25802. * @returns the new ActionEvent
  25803. */
  25804. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25805. }
  25806. }
  25807. declare module "babylonjs/Actions/abstractActionManager" {
  25808. import { IDisposable } from "babylonjs/scene";
  25809. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25810. import { IAction } from "babylonjs/Actions/action";
  25811. import { Nullable } from "babylonjs/types";
  25812. /**
  25813. * Abstract class used to decouple action Manager from scene and meshes.
  25814. * Do not instantiate.
  25815. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25816. */
  25817. export abstract class AbstractActionManager implements IDisposable {
  25818. /** Gets the list of active triggers */
  25819. static Triggers: {
  25820. [key: string]: number;
  25821. };
  25822. /** Gets the cursor to use when hovering items */
  25823. hoverCursor: string;
  25824. /** Gets the list of actions */
  25825. actions: IAction[];
  25826. /**
  25827. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25828. */
  25829. isRecursive: boolean;
  25830. /**
  25831. * Releases all associated resources
  25832. */
  25833. abstract dispose(): void;
  25834. /**
  25835. * Does this action manager has pointer triggers
  25836. */
  25837. abstract readonly hasPointerTriggers: boolean;
  25838. /**
  25839. * Does this action manager has pick triggers
  25840. */
  25841. abstract readonly hasPickTriggers: boolean;
  25842. /**
  25843. * Process a specific trigger
  25844. * @param trigger defines the trigger to process
  25845. * @param evt defines the event details to be processed
  25846. */
  25847. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25848. /**
  25849. * Does this action manager handles actions of any of the given triggers
  25850. * @param triggers defines the triggers to be tested
  25851. * @return a boolean indicating whether one (or more) of the triggers is handled
  25852. */
  25853. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25854. /**
  25855. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25856. * speed.
  25857. * @param triggerA defines the trigger to be tested
  25858. * @param triggerB defines the trigger to be tested
  25859. * @return a boolean indicating whether one (or more) of the triggers is handled
  25860. */
  25861. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25862. /**
  25863. * Does this action manager handles actions of a given trigger
  25864. * @param trigger defines the trigger to be tested
  25865. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25866. * @return whether the trigger is handled
  25867. */
  25868. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25869. /**
  25870. * Serialize this manager to a JSON object
  25871. * @param name defines the property name to store this manager
  25872. * @returns a JSON representation of this manager
  25873. */
  25874. abstract serialize(name: string): any;
  25875. /**
  25876. * Registers an action to this action manager
  25877. * @param action defines the action to be registered
  25878. * @return the action amended (prepared) after registration
  25879. */
  25880. abstract registerAction(action: IAction): Nullable<IAction>;
  25881. /**
  25882. * Unregisters an action to this action manager
  25883. * @param action defines the action to be unregistered
  25884. * @return a boolean indicating whether the action has been unregistered
  25885. */
  25886. abstract unregisterAction(action: IAction): Boolean;
  25887. /**
  25888. * Does exist one action manager with at least one trigger
  25889. **/
  25890. static readonly HasTriggers: boolean;
  25891. /**
  25892. * Does exist one action manager with at least one pick trigger
  25893. **/
  25894. static readonly HasPickTriggers: boolean;
  25895. /**
  25896. * Does exist one action manager that handles actions of a given trigger
  25897. * @param trigger defines the trigger to be tested
  25898. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25899. **/
  25900. static HasSpecificTrigger(trigger: number): boolean;
  25901. }
  25902. }
  25903. declare module "babylonjs/node" {
  25904. import { Scene } from "babylonjs/scene";
  25905. import { Nullable } from "babylonjs/types";
  25906. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25907. import { Engine } from "babylonjs/Engines/engine";
  25908. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25909. import { Observable } from "babylonjs/Misc/observable";
  25910. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25911. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25912. import { Animatable } from "babylonjs/Animations/animatable";
  25913. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25914. import { Animation } from "babylonjs/Animations/animation";
  25915. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25917. /**
  25918. * Defines how a node can be built from a string name.
  25919. */
  25920. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25921. /**
  25922. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25923. */
  25924. export class Node implements IBehaviorAware<Node> {
  25925. /** @hidden */
  25926. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25927. private static _NodeConstructors;
  25928. /**
  25929. * Add a new node constructor
  25930. * @param type defines the type name of the node to construct
  25931. * @param constructorFunc defines the constructor function
  25932. */
  25933. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25934. /**
  25935. * Returns a node constructor based on type name
  25936. * @param type defines the type name
  25937. * @param name defines the new node name
  25938. * @param scene defines the hosting scene
  25939. * @param options defines optional options to transmit to constructors
  25940. * @returns the new constructor or null
  25941. */
  25942. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25943. /**
  25944. * Gets or sets the name of the node
  25945. */
  25946. name: string;
  25947. /**
  25948. * Gets or sets the id of the node
  25949. */
  25950. id: string;
  25951. /**
  25952. * Gets or sets the unique id of the node
  25953. */
  25954. uniqueId: number;
  25955. /**
  25956. * Gets or sets a string used to store user defined state for the node
  25957. */
  25958. state: string;
  25959. /**
  25960. * Gets or sets an object used to store user defined information for the node
  25961. */
  25962. metadata: any;
  25963. /**
  25964. * For internal use only. Please do not use.
  25965. */
  25966. reservedDataStore: any;
  25967. /**
  25968. * List of inspectable custom properties (used by the Inspector)
  25969. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25970. */
  25971. inspectableCustomProperties: IInspectable[];
  25972. /**
  25973. * Gets or sets a boolean used to define if the node must be serialized
  25974. */
  25975. doNotSerialize: boolean;
  25976. /** @hidden */
  25977. _isDisposed: boolean;
  25978. /**
  25979. * Gets a list of Animations associated with the node
  25980. */
  25981. animations: import("babylonjs/Animations/animation").Animation[];
  25982. protected _ranges: {
  25983. [name: string]: Nullable<AnimationRange>;
  25984. };
  25985. /**
  25986. * Callback raised when the node is ready to be used
  25987. */
  25988. onReady: Nullable<(node: Node) => void>;
  25989. private _isEnabled;
  25990. private _isParentEnabled;
  25991. private _isReady;
  25992. /** @hidden */
  25993. _currentRenderId: number;
  25994. private _parentUpdateId;
  25995. /** @hidden */
  25996. _childUpdateId: number;
  25997. /** @hidden */
  25998. _waitingParentId: Nullable<string>;
  25999. /** @hidden */
  26000. _scene: Scene;
  26001. /** @hidden */
  26002. _cache: any;
  26003. private _parentNode;
  26004. private _children;
  26005. /** @hidden */
  26006. _worldMatrix: Matrix;
  26007. /** @hidden */
  26008. _worldMatrixDeterminant: number;
  26009. /** @hidden */
  26010. _worldMatrixDeterminantIsDirty: boolean;
  26011. /** @hidden */
  26012. private _sceneRootNodesIndex;
  26013. /**
  26014. * Gets a boolean indicating if the node has been disposed
  26015. * @returns true if the node was disposed
  26016. */
  26017. isDisposed(): boolean;
  26018. /**
  26019. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26020. * @see https://doc.babylonjs.com/how_to/parenting
  26021. */
  26022. parent: Nullable<Node>;
  26023. private addToSceneRootNodes;
  26024. private removeFromSceneRootNodes;
  26025. private _animationPropertiesOverride;
  26026. /**
  26027. * Gets or sets the animation properties override
  26028. */
  26029. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26030. /**
  26031. * Gets a string idenfifying the name of the class
  26032. * @returns "Node" string
  26033. */
  26034. getClassName(): string;
  26035. /** @hidden */
  26036. readonly _isNode: boolean;
  26037. /**
  26038. * An event triggered when the mesh is disposed
  26039. */
  26040. onDisposeObservable: Observable<Node>;
  26041. private _onDisposeObserver;
  26042. /**
  26043. * Sets a callback that will be raised when the node will be disposed
  26044. */
  26045. onDispose: () => void;
  26046. /**
  26047. * Creates a new Node
  26048. * @param name the name and id to be given to this node
  26049. * @param scene the scene this node will be added to
  26050. * @param addToRootNodes the node will be added to scene.rootNodes
  26051. */
  26052. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26053. /**
  26054. * Gets the scene of the node
  26055. * @returns a scene
  26056. */
  26057. getScene(): Scene;
  26058. /**
  26059. * Gets the engine of the node
  26060. * @returns a Engine
  26061. */
  26062. getEngine(): Engine;
  26063. private _behaviors;
  26064. /**
  26065. * Attach a behavior to the node
  26066. * @see http://doc.babylonjs.com/features/behaviour
  26067. * @param behavior defines the behavior to attach
  26068. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26069. * @returns the current Node
  26070. */
  26071. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26072. /**
  26073. * Remove an attached behavior
  26074. * @see http://doc.babylonjs.com/features/behaviour
  26075. * @param behavior defines the behavior to attach
  26076. * @returns the current Node
  26077. */
  26078. removeBehavior(behavior: Behavior<Node>): Node;
  26079. /**
  26080. * Gets the list of attached behaviors
  26081. * @see http://doc.babylonjs.com/features/behaviour
  26082. */
  26083. readonly behaviors: Behavior<Node>[];
  26084. /**
  26085. * Gets an attached behavior by name
  26086. * @param name defines the name of the behavior to look for
  26087. * @see http://doc.babylonjs.com/features/behaviour
  26088. * @returns null if behavior was not found else the requested behavior
  26089. */
  26090. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26091. /**
  26092. * Returns the latest update of the World matrix
  26093. * @returns a Matrix
  26094. */
  26095. getWorldMatrix(): Matrix;
  26096. /** @hidden */
  26097. _getWorldMatrixDeterminant(): number;
  26098. /**
  26099. * Returns directly the latest state of the mesh World matrix.
  26100. * A Matrix is returned.
  26101. */
  26102. readonly worldMatrixFromCache: Matrix;
  26103. /** @hidden */
  26104. _initCache(): void;
  26105. /** @hidden */
  26106. updateCache(force?: boolean): void;
  26107. /** @hidden */
  26108. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26109. /** @hidden */
  26110. _updateCache(ignoreParentClass?: boolean): void;
  26111. /** @hidden */
  26112. _isSynchronized(): boolean;
  26113. /** @hidden */
  26114. _markSyncedWithParent(): void;
  26115. /** @hidden */
  26116. isSynchronizedWithParent(): boolean;
  26117. /** @hidden */
  26118. isSynchronized(): boolean;
  26119. /**
  26120. * Is this node ready to be used/rendered
  26121. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26122. * @return true if the node is ready
  26123. */
  26124. isReady(completeCheck?: boolean): boolean;
  26125. /**
  26126. * Is this node enabled?
  26127. * 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
  26128. * @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
  26129. * @return whether this node (and its parent) is enabled
  26130. */
  26131. isEnabled(checkAncestors?: boolean): boolean;
  26132. /** @hidden */
  26133. protected _syncParentEnabledState(): void;
  26134. /**
  26135. * Set the enabled state of this node
  26136. * @param value defines the new enabled state
  26137. */
  26138. setEnabled(value: boolean): void;
  26139. /**
  26140. * Is this node a descendant of the given node?
  26141. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26142. * @param ancestor defines the parent node to inspect
  26143. * @returns a boolean indicating if this node is a descendant of the given node
  26144. */
  26145. isDescendantOf(ancestor: Node): boolean;
  26146. /** @hidden */
  26147. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26148. /**
  26149. * Will return all nodes that have this node as ascendant
  26150. * @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
  26151. * @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
  26152. * @return all children nodes of all types
  26153. */
  26154. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26155. /**
  26156. * Get all child-meshes of this node
  26157. * @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)
  26158. * @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
  26159. * @returns an array of AbstractMesh
  26160. */
  26161. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26162. /**
  26163. * Get all direct children of this node
  26164. * @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
  26165. * @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)
  26166. * @returns an array of Node
  26167. */
  26168. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26169. /** @hidden */
  26170. _setReady(state: boolean): void;
  26171. /**
  26172. * Get an animation by name
  26173. * @param name defines the name of the animation to look for
  26174. * @returns null if not found else the requested animation
  26175. */
  26176. getAnimationByName(name: string): Nullable<Animation>;
  26177. /**
  26178. * Creates an animation range for this node
  26179. * @param name defines the name of the range
  26180. * @param from defines the starting key
  26181. * @param to defines the end key
  26182. */
  26183. createAnimationRange(name: string, from: number, to: number): void;
  26184. /**
  26185. * Delete a specific animation range
  26186. * @param name defines the name of the range to delete
  26187. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26188. */
  26189. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26190. /**
  26191. * Get an animation range by name
  26192. * @param name defines the name of the animation range to look for
  26193. * @returns null if not found else the requested animation range
  26194. */
  26195. getAnimationRange(name: string): Nullable<AnimationRange>;
  26196. /**
  26197. * Gets the list of all animation ranges defined on this node
  26198. * @returns an array
  26199. */
  26200. getAnimationRanges(): Nullable<AnimationRange>[];
  26201. /**
  26202. * Will start the animation sequence
  26203. * @param name defines the range frames for animation sequence
  26204. * @param loop defines if the animation should loop (false by default)
  26205. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26206. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26207. * @returns the object created for this animation. If range does not exist, it will return null
  26208. */
  26209. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26210. /**
  26211. * Serialize animation ranges into a JSON compatible object
  26212. * @returns serialization object
  26213. */
  26214. serializeAnimationRanges(): any;
  26215. /**
  26216. * Computes the world matrix of the node
  26217. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26218. * @returns the world matrix
  26219. */
  26220. computeWorldMatrix(force?: boolean): Matrix;
  26221. /**
  26222. * Releases resources associated with this node.
  26223. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26224. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26225. */
  26226. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26227. /**
  26228. * Parse animation range data from a serialization object and store them into a given node
  26229. * @param node defines where to store the animation ranges
  26230. * @param parsedNode defines the serialization object to read data from
  26231. * @param scene defines the hosting scene
  26232. */
  26233. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26234. /**
  26235. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26236. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26237. * @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
  26238. * @returns the new bounding vectors
  26239. */
  26240. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26241. min: Vector3;
  26242. max: Vector3;
  26243. };
  26244. }
  26245. }
  26246. declare module "babylonjs/Animations/animation" {
  26247. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  26248. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  26249. import { Nullable } from "babylonjs/types";
  26250. import { Scene } from "babylonjs/scene";
  26251. import { IAnimatable } from "babylonjs/Misc/tools";
  26252. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  26253. import { AnimationRange } from "babylonjs/Animations/animationRange";
  26254. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  26255. import { Node } from "babylonjs/node";
  26256. import { Animatable } from "babylonjs/Animations/animatable";
  26257. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  26258. /**
  26259. * @hidden
  26260. */
  26261. export class _IAnimationState {
  26262. key: number;
  26263. repeatCount: number;
  26264. workValue?: any;
  26265. loopMode?: number;
  26266. offsetValue?: any;
  26267. highLimitValue?: any;
  26268. }
  26269. /**
  26270. * Class used to store any kind of animation
  26271. */
  26272. export class Animation {
  26273. /**Name of the animation */
  26274. name: string;
  26275. /**Property to animate */
  26276. targetProperty: string;
  26277. /**The frames per second of the animation */
  26278. framePerSecond: number;
  26279. /**The data type of the animation */
  26280. dataType: number;
  26281. /**The loop mode of the animation */
  26282. loopMode?: number | undefined;
  26283. /**Specifies if blending should be enabled */
  26284. enableBlending?: boolean | undefined;
  26285. /**
  26286. * Use matrix interpolation instead of using direct key value when animating matrices
  26287. */
  26288. static AllowMatricesInterpolation: boolean;
  26289. /**
  26290. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26291. */
  26292. static AllowMatrixDecomposeForInterpolation: boolean;
  26293. /**
  26294. * Stores the key frames of the animation
  26295. */
  26296. private _keys;
  26297. /**
  26298. * Stores the easing function of the animation
  26299. */
  26300. private _easingFunction;
  26301. /**
  26302. * @hidden Internal use only
  26303. */
  26304. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  26305. /**
  26306. * The set of event that will be linked to this animation
  26307. */
  26308. private _events;
  26309. /**
  26310. * Stores an array of target property paths
  26311. */
  26312. targetPropertyPath: string[];
  26313. /**
  26314. * Stores the blending speed of the animation
  26315. */
  26316. blendingSpeed: number;
  26317. /**
  26318. * Stores the animation ranges for the animation
  26319. */
  26320. private _ranges;
  26321. /**
  26322. * @hidden Internal use
  26323. */
  26324. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26325. /**
  26326. * Sets up an animation
  26327. * @param property The property to animate
  26328. * @param animationType The animation type to apply
  26329. * @param framePerSecond The frames per second of the animation
  26330. * @param easingFunction The easing function used in the animation
  26331. * @returns The created animation
  26332. */
  26333. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26334. /**
  26335. * Create and start an animation on a node
  26336. * @param name defines the name of the global animation that will be run on all nodes
  26337. * @param node defines the root node where the animation will take place
  26338. * @param targetProperty defines property to animate
  26339. * @param framePerSecond defines the number of frame per second yo use
  26340. * @param totalFrame defines the number of frames in total
  26341. * @param from defines the initial value
  26342. * @param to defines the final value
  26343. * @param loopMode defines which loop mode you want to use (off by default)
  26344. * @param easingFunction defines the easing function to use (linear by default)
  26345. * @param onAnimationEnd defines the callback to call when animation end
  26346. * @returns the animatable created for this animation
  26347. */
  26348. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26349. /**
  26350. * Create and start an animation on a node and its descendants
  26351. * @param name defines the name of the global animation that will be run on all nodes
  26352. * @param node defines the root node where the animation will take place
  26353. * @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
  26354. * @param targetProperty defines property to animate
  26355. * @param framePerSecond defines the number of frame per second to use
  26356. * @param totalFrame defines the number of frames in total
  26357. * @param from defines the initial value
  26358. * @param to defines the final value
  26359. * @param loopMode defines which loop mode you want to use (off by default)
  26360. * @param easingFunction defines the easing function to use (linear by default)
  26361. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26362. * @returns the list of animatables created for all nodes
  26363. * @example https://www.babylonjs-playground.com/#MH0VLI
  26364. */
  26365. 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[]>;
  26366. /**
  26367. * Creates a new animation, merges it with the existing animations and starts it
  26368. * @param name Name of the animation
  26369. * @param node Node which contains the scene that begins the animations
  26370. * @param targetProperty Specifies which property to animate
  26371. * @param framePerSecond The frames per second of the animation
  26372. * @param totalFrame The total number of frames
  26373. * @param from The frame at the beginning of the animation
  26374. * @param to The frame at the end of the animation
  26375. * @param loopMode Specifies the loop mode of the animation
  26376. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26377. * @param onAnimationEnd Callback to run once the animation is complete
  26378. * @returns Nullable animation
  26379. */
  26380. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26381. /**
  26382. * Transition property of an host to the target Value
  26383. * @param property The property to transition
  26384. * @param targetValue The target Value of the property
  26385. * @param host The object where the property to animate belongs
  26386. * @param scene Scene used to run the animation
  26387. * @param frameRate Framerate (in frame/s) to use
  26388. * @param transition The transition type we want to use
  26389. * @param duration The duration of the animation, in milliseconds
  26390. * @param onAnimationEnd Callback trigger at the end of the animation
  26391. * @returns Nullable animation
  26392. */
  26393. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26394. /**
  26395. * Return the array of runtime animations currently using this animation
  26396. */
  26397. readonly runtimeAnimations: RuntimeAnimation[];
  26398. /**
  26399. * Specifies if any of the runtime animations are currently running
  26400. */
  26401. readonly hasRunningRuntimeAnimations: boolean;
  26402. /**
  26403. * Initializes the animation
  26404. * @param name Name of the animation
  26405. * @param targetProperty Property to animate
  26406. * @param framePerSecond The frames per second of the animation
  26407. * @param dataType The data type of the animation
  26408. * @param loopMode The loop mode of the animation
  26409. * @param enableBlending Specifies if blending should be enabled
  26410. */
  26411. constructor(
  26412. /**Name of the animation */
  26413. name: string,
  26414. /**Property to animate */
  26415. targetProperty: string,
  26416. /**The frames per second of the animation */
  26417. framePerSecond: number,
  26418. /**The data type of the animation */
  26419. dataType: number,
  26420. /**The loop mode of the animation */
  26421. loopMode?: number | undefined,
  26422. /**Specifies if blending should be enabled */
  26423. enableBlending?: boolean | undefined);
  26424. /**
  26425. * Converts the animation to a string
  26426. * @param fullDetails support for multiple levels of logging within scene loading
  26427. * @returns String form of the animation
  26428. */
  26429. toString(fullDetails?: boolean): string;
  26430. /**
  26431. * Add an event to this animation
  26432. * @param event Event to add
  26433. */
  26434. addEvent(event: AnimationEvent): void;
  26435. /**
  26436. * Remove all events found at the given frame
  26437. * @param frame The frame to remove events from
  26438. */
  26439. removeEvents(frame: number): void;
  26440. /**
  26441. * Retrieves all the events from the animation
  26442. * @returns Events from the animation
  26443. */
  26444. getEvents(): AnimationEvent[];
  26445. /**
  26446. * Creates an animation range
  26447. * @param name Name of the animation range
  26448. * @param from Starting frame of the animation range
  26449. * @param to Ending frame of the animation
  26450. */
  26451. createRange(name: string, from: number, to: number): void;
  26452. /**
  26453. * Deletes an animation range by name
  26454. * @param name Name of the animation range to delete
  26455. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26456. */
  26457. deleteRange(name: string, deleteFrames?: boolean): void;
  26458. /**
  26459. * Gets the animation range by name, or null if not defined
  26460. * @param name Name of the animation range
  26461. * @returns Nullable animation range
  26462. */
  26463. getRange(name: string): Nullable<AnimationRange>;
  26464. /**
  26465. * Gets the key frames from the animation
  26466. * @returns The key frames of the animation
  26467. */
  26468. getKeys(): Array<IAnimationKey>;
  26469. /**
  26470. * Gets the highest frame rate of the animation
  26471. * @returns Highest frame rate of the animation
  26472. */
  26473. getHighestFrame(): number;
  26474. /**
  26475. * Gets the easing function of the animation
  26476. * @returns Easing function of the animation
  26477. */
  26478. getEasingFunction(): IEasingFunction;
  26479. /**
  26480. * Sets the easing function of the animation
  26481. * @param easingFunction A custom mathematical formula for animation
  26482. */
  26483. setEasingFunction(easingFunction: EasingFunction): void;
  26484. /**
  26485. * Interpolates a scalar linearly
  26486. * @param startValue Start value of the animation curve
  26487. * @param endValue End value of the animation curve
  26488. * @param gradient Scalar amount to interpolate
  26489. * @returns Interpolated scalar value
  26490. */
  26491. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26492. /**
  26493. * Interpolates a scalar cubically
  26494. * @param startValue Start value of the animation curve
  26495. * @param outTangent End tangent of the animation
  26496. * @param endValue End value of the animation curve
  26497. * @param inTangent Start tangent of the animation curve
  26498. * @param gradient Scalar amount to interpolate
  26499. * @returns Interpolated scalar value
  26500. */
  26501. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26502. /**
  26503. * Interpolates a quaternion using a spherical linear interpolation
  26504. * @param startValue Start value of the animation curve
  26505. * @param endValue End value of the animation curve
  26506. * @param gradient Scalar amount to interpolate
  26507. * @returns Interpolated quaternion value
  26508. */
  26509. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26510. /**
  26511. * Interpolates a quaternion cubically
  26512. * @param startValue Start value of the animation curve
  26513. * @param outTangent End tangent of the animation curve
  26514. * @param endValue End value of the animation curve
  26515. * @param inTangent Start tangent of the animation curve
  26516. * @param gradient Scalar amount to interpolate
  26517. * @returns Interpolated quaternion value
  26518. */
  26519. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26520. /**
  26521. * Interpolates a Vector3 linearl
  26522. * @param startValue Start value of the animation curve
  26523. * @param endValue End value of the animation curve
  26524. * @param gradient Scalar amount to interpolate
  26525. * @returns Interpolated scalar value
  26526. */
  26527. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26528. /**
  26529. * Interpolates a Vector3 cubically
  26530. * @param startValue Start value of the animation curve
  26531. * @param outTangent End tangent of the animation
  26532. * @param endValue End value of the animation curve
  26533. * @param inTangent Start tangent of the animation curve
  26534. * @param gradient Scalar amount to interpolate
  26535. * @returns InterpolatedVector3 value
  26536. */
  26537. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26538. /**
  26539. * Interpolates a Vector2 linearly
  26540. * @param startValue Start value of the animation curve
  26541. * @param endValue End value of the animation curve
  26542. * @param gradient Scalar amount to interpolate
  26543. * @returns Interpolated Vector2 value
  26544. */
  26545. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26546. /**
  26547. * Interpolates a Vector2 cubically
  26548. * @param startValue Start value of the animation curve
  26549. * @param outTangent End tangent of the animation
  26550. * @param endValue End value of the animation curve
  26551. * @param inTangent Start tangent of the animation curve
  26552. * @param gradient Scalar amount to interpolate
  26553. * @returns Interpolated Vector2 value
  26554. */
  26555. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26556. /**
  26557. * Interpolates a size linearly
  26558. * @param startValue Start value of the animation curve
  26559. * @param endValue End value of the animation curve
  26560. * @param gradient Scalar amount to interpolate
  26561. * @returns Interpolated Size value
  26562. */
  26563. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26564. /**
  26565. * Interpolates a Color3 linearly
  26566. * @param startValue Start value of the animation curve
  26567. * @param endValue End value of the animation curve
  26568. * @param gradient Scalar amount to interpolate
  26569. * @returns Interpolated Color3 value
  26570. */
  26571. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26572. /**
  26573. * @hidden Internal use only
  26574. */
  26575. _getKeyValue(value: any): any;
  26576. /**
  26577. * @hidden Internal use only
  26578. */
  26579. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26580. /**
  26581. * Defines the function to use to interpolate matrices
  26582. * @param startValue defines the start matrix
  26583. * @param endValue defines the end matrix
  26584. * @param gradient defines the gradient between both matrices
  26585. * @param result defines an optional target matrix where to store the interpolation
  26586. * @returns the interpolated matrix
  26587. */
  26588. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26589. /**
  26590. * Makes a copy of the animation
  26591. * @returns Cloned animation
  26592. */
  26593. clone(): Animation;
  26594. /**
  26595. * Sets the key frames of the animation
  26596. * @param values The animation key frames to set
  26597. */
  26598. setKeys(values: Array<IAnimationKey>): void;
  26599. /**
  26600. * Serializes the animation to an object
  26601. * @returns Serialized object
  26602. */
  26603. serialize(): any;
  26604. /**
  26605. * Float animation type
  26606. */
  26607. private static _ANIMATIONTYPE_FLOAT;
  26608. /**
  26609. * Vector3 animation type
  26610. */
  26611. private static _ANIMATIONTYPE_VECTOR3;
  26612. /**
  26613. * Quaternion animation type
  26614. */
  26615. private static _ANIMATIONTYPE_QUATERNION;
  26616. /**
  26617. * Matrix animation type
  26618. */
  26619. private static _ANIMATIONTYPE_MATRIX;
  26620. /**
  26621. * Color3 animation type
  26622. */
  26623. private static _ANIMATIONTYPE_COLOR3;
  26624. /**
  26625. * Vector2 animation type
  26626. */
  26627. private static _ANIMATIONTYPE_VECTOR2;
  26628. /**
  26629. * Size animation type
  26630. */
  26631. private static _ANIMATIONTYPE_SIZE;
  26632. /**
  26633. * Relative Loop Mode
  26634. */
  26635. private static _ANIMATIONLOOPMODE_RELATIVE;
  26636. /**
  26637. * Cycle Loop Mode
  26638. */
  26639. private static _ANIMATIONLOOPMODE_CYCLE;
  26640. /**
  26641. * Constant Loop Mode
  26642. */
  26643. private static _ANIMATIONLOOPMODE_CONSTANT;
  26644. /**
  26645. * Get the float animation type
  26646. */
  26647. static readonly ANIMATIONTYPE_FLOAT: number;
  26648. /**
  26649. * Get the Vector3 animation type
  26650. */
  26651. static readonly ANIMATIONTYPE_VECTOR3: number;
  26652. /**
  26653. * Get the Vector2 animation type
  26654. */
  26655. static readonly ANIMATIONTYPE_VECTOR2: number;
  26656. /**
  26657. * Get the Size animation type
  26658. */
  26659. static readonly ANIMATIONTYPE_SIZE: number;
  26660. /**
  26661. * Get the Quaternion animation type
  26662. */
  26663. static readonly ANIMATIONTYPE_QUATERNION: number;
  26664. /**
  26665. * Get the Matrix animation type
  26666. */
  26667. static readonly ANIMATIONTYPE_MATRIX: number;
  26668. /**
  26669. * Get the Color3 animation type
  26670. */
  26671. static readonly ANIMATIONTYPE_COLOR3: number;
  26672. /**
  26673. * Get the Relative Loop Mode
  26674. */
  26675. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26676. /**
  26677. * Get the Cycle Loop Mode
  26678. */
  26679. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26680. /**
  26681. * Get the Constant Loop Mode
  26682. */
  26683. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26684. /** @hidden */
  26685. static _UniversalLerp(left: any, right: any, amount: number): any;
  26686. /**
  26687. * Parses an animation object and creates an animation
  26688. * @param parsedAnimation Parsed animation object
  26689. * @returns Animation object
  26690. */
  26691. static Parse(parsedAnimation: any): Animation;
  26692. /**
  26693. * Appends the serialized animations from the source animations
  26694. * @param source Source containing the animations
  26695. * @param destination Target to store the animations
  26696. */
  26697. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26698. }
  26699. }
  26700. declare module "babylonjs/Materials/Textures/baseTexture" {
  26701. import { Observable } from "babylonjs/Misc/observable";
  26702. import { IAnimatable } from "babylonjs/Misc/tools";
  26703. import { Nullable } from "babylonjs/types";
  26704. import { Scene } from "babylonjs/scene";
  26705. import { Matrix, ISize } from "babylonjs/Maths/math";
  26706. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26707. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26708. /**
  26709. * Base class of all the textures in babylon.
  26710. * It groups all the common properties the materials, post process, lights... might need
  26711. * in order to make a correct use of the texture.
  26712. */
  26713. export class BaseTexture implements IAnimatable {
  26714. /**
  26715. * Default anisotropic filtering level for the application.
  26716. * It is set to 4 as a good tradeoff between perf and quality.
  26717. */
  26718. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26719. /**
  26720. * Gets or sets the unique id of the texture
  26721. */
  26722. uniqueId: number;
  26723. /**
  26724. * Define the name of the texture.
  26725. */
  26726. name: string;
  26727. /**
  26728. * Gets or sets an object used to store user defined information.
  26729. */
  26730. metadata: any;
  26731. /**
  26732. * For internal use only. Please do not use.
  26733. */
  26734. reservedDataStore: any;
  26735. private _hasAlpha;
  26736. /**
  26737. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26738. */
  26739. hasAlpha: boolean;
  26740. /**
  26741. * Defines if the alpha value should be determined via the rgb values.
  26742. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26743. */
  26744. getAlphaFromRGB: boolean;
  26745. /**
  26746. * Intensity or strength of the texture.
  26747. * It is commonly used by materials to fine tune the intensity of the texture
  26748. */
  26749. level: number;
  26750. /**
  26751. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26752. * This is part of the texture as textures usually maps to one uv set.
  26753. */
  26754. coordinatesIndex: number;
  26755. private _coordinatesMode;
  26756. /**
  26757. * How a texture is mapped.
  26758. *
  26759. * | Value | Type | Description |
  26760. * | ----- | ----------------------------------- | ----------- |
  26761. * | 0 | EXPLICIT_MODE | |
  26762. * | 1 | SPHERICAL_MODE | |
  26763. * | 2 | PLANAR_MODE | |
  26764. * | 3 | CUBIC_MODE | |
  26765. * | 4 | PROJECTION_MODE | |
  26766. * | 5 | SKYBOX_MODE | |
  26767. * | 6 | INVCUBIC_MODE | |
  26768. * | 7 | EQUIRECTANGULAR_MODE | |
  26769. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26770. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26771. */
  26772. coordinatesMode: number;
  26773. /**
  26774. * | Value | Type | Description |
  26775. * | ----- | ------------------ | ----------- |
  26776. * | 0 | CLAMP_ADDRESSMODE | |
  26777. * | 1 | WRAP_ADDRESSMODE | |
  26778. * | 2 | MIRROR_ADDRESSMODE | |
  26779. */
  26780. wrapU: number;
  26781. /**
  26782. * | Value | Type | Description |
  26783. * | ----- | ------------------ | ----------- |
  26784. * | 0 | CLAMP_ADDRESSMODE | |
  26785. * | 1 | WRAP_ADDRESSMODE | |
  26786. * | 2 | MIRROR_ADDRESSMODE | |
  26787. */
  26788. wrapV: number;
  26789. /**
  26790. * | Value | Type | Description |
  26791. * | ----- | ------------------ | ----------- |
  26792. * | 0 | CLAMP_ADDRESSMODE | |
  26793. * | 1 | WRAP_ADDRESSMODE | |
  26794. * | 2 | MIRROR_ADDRESSMODE | |
  26795. */
  26796. wrapR: number;
  26797. /**
  26798. * With compliant hardware and browser (supporting anisotropic filtering)
  26799. * this defines the level of anisotropic filtering in the texture.
  26800. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26801. */
  26802. anisotropicFilteringLevel: number;
  26803. /**
  26804. * Define if the texture is a cube texture or if false a 2d texture.
  26805. */
  26806. isCube: boolean;
  26807. /**
  26808. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26809. */
  26810. is3D: boolean;
  26811. /**
  26812. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26813. * HDR texture are usually stored in linear space.
  26814. * This only impacts the PBR and Background materials
  26815. */
  26816. gammaSpace: boolean;
  26817. /**
  26818. * Gets whether or not the texture contains RGBD data.
  26819. */
  26820. readonly isRGBD: boolean;
  26821. /**
  26822. * Is Z inverted in the texture (useful in a cube texture).
  26823. */
  26824. invertZ: boolean;
  26825. /**
  26826. * Are mip maps generated for this texture or not.
  26827. */
  26828. readonly noMipmap: boolean;
  26829. /**
  26830. * @hidden
  26831. */
  26832. lodLevelInAlpha: boolean;
  26833. /**
  26834. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26835. */
  26836. lodGenerationOffset: number;
  26837. /**
  26838. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26839. */
  26840. lodGenerationScale: number;
  26841. /**
  26842. * Define if the texture is a render target.
  26843. */
  26844. isRenderTarget: boolean;
  26845. /**
  26846. * Define the unique id of the texture in the scene.
  26847. */
  26848. readonly uid: string;
  26849. /**
  26850. * Return a string representation of the texture.
  26851. * @returns the texture as a string
  26852. */
  26853. toString(): string;
  26854. /**
  26855. * Get the class name of the texture.
  26856. * @returns "BaseTexture"
  26857. */
  26858. getClassName(): string;
  26859. /**
  26860. * Define the list of animation attached to the texture.
  26861. */
  26862. animations: import("babylonjs/Animations/animation").Animation[];
  26863. /**
  26864. * An event triggered when the texture is disposed.
  26865. */
  26866. onDisposeObservable: Observable<BaseTexture>;
  26867. private _onDisposeObserver;
  26868. /**
  26869. * Callback triggered when the texture has been disposed.
  26870. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26871. */
  26872. onDispose: () => void;
  26873. /**
  26874. * Define the current state of the loading sequence when in delayed load mode.
  26875. */
  26876. delayLoadState: number;
  26877. private _scene;
  26878. /** @hidden */
  26879. _texture: Nullable<InternalTexture>;
  26880. private _uid;
  26881. /**
  26882. * Define if the texture is preventinga material to render or not.
  26883. * If not and the texture is not ready, the engine will use a default black texture instead.
  26884. */
  26885. readonly isBlocking: boolean;
  26886. /**
  26887. * Instantiates a new BaseTexture.
  26888. * Base class of all the textures in babylon.
  26889. * It groups all the common properties the materials, post process, lights... might need
  26890. * in order to make a correct use of the texture.
  26891. * @param scene Define the scene the texture blongs to
  26892. */
  26893. constructor(scene: Nullable<Scene>);
  26894. /**
  26895. * Get the scene the texture belongs to.
  26896. * @returns the scene or null if undefined
  26897. */
  26898. getScene(): Nullable<Scene>;
  26899. /**
  26900. * Get the texture transform matrix used to offset tile the texture for istance.
  26901. * @returns the transformation matrix
  26902. */
  26903. getTextureMatrix(): Matrix;
  26904. /**
  26905. * Get the texture reflection matrix used to rotate/transform the reflection.
  26906. * @returns the reflection matrix
  26907. */
  26908. getReflectionTextureMatrix(): Matrix;
  26909. /**
  26910. * Get the underlying lower level texture from Babylon.
  26911. * @returns the insternal texture
  26912. */
  26913. getInternalTexture(): Nullable<InternalTexture>;
  26914. /**
  26915. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26916. * @returns true if ready or not blocking
  26917. */
  26918. isReadyOrNotBlocking(): boolean;
  26919. /**
  26920. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26921. * @returns true if fully ready
  26922. */
  26923. isReady(): boolean;
  26924. private _cachedSize;
  26925. /**
  26926. * Get the size of the texture.
  26927. * @returns the texture size.
  26928. */
  26929. getSize(): ISize;
  26930. /**
  26931. * Get the base size of the texture.
  26932. * It can be different from the size if the texture has been resized for POT for instance
  26933. * @returns the base size
  26934. */
  26935. getBaseSize(): ISize;
  26936. /**
  26937. * Update the sampling mode of the texture.
  26938. * Default is Trilinear mode.
  26939. *
  26940. * | Value | Type | Description |
  26941. * | ----- | ------------------ | ----------- |
  26942. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26943. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26944. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26945. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26946. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26947. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26948. * | 7 | NEAREST_LINEAR | |
  26949. * | 8 | NEAREST_NEAREST | |
  26950. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26951. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26952. * | 11 | LINEAR_LINEAR | |
  26953. * | 12 | LINEAR_NEAREST | |
  26954. *
  26955. * > _mag_: magnification filter (close to the viewer)
  26956. * > _min_: minification filter (far from the viewer)
  26957. * > _mip_: filter used between mip map levels
  26958. *@param samplingMode Define the new sampling mode of the texture
  26959. */
  26960. updateSamplingMode(samplingMode: number): void;
  26961. /**
  26962. * Scales the texture if is `canRescale()`
  26963. * @param ratio the resize factor we want to use to rescale
  26964. */
  26965. scale(ratio: number): void;
  26966. /**
  26967. * Get if the texture can rescale.
  26968. */
  26969. readonly canRescale: boolean;
  26970. /** @hidden */
  26971. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26972. /** @hidden */
  26973. _rebuild(): void;
  26974. /**
  26975. * Triggers the load sequence in delayed load mode.
  26976. */
  26977. delayLoad(): void;
  26978. /**
  26979. * Clones the texture.
  26980. * @returns the cloned texture
  26981. */
  26982. clone(): Nullable<BaseTexture>;
  26983. /**
  26984. * Get the texture underlying type (INT, FLOAT...)
  26985. */
  26986. readonly textureType: number;
  26987. /**
  26988. * Get the texture underlying format (RGB, RGBA...)
  26989. */
  26990. readonly textureFormat: number;
  26991. /**
  26992. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26993. * This will returns an RGBA array buffer containing either in values (0-255) or
  26994. * float values (0-1) depending of the underlying buffer type.
  26995. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26996. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26997. * @param buffer defines a user defined buffer to fill with data (can be null)
  26998. * @returns The Array buffer containing the pixels data.
  26999. */
  27000. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27001. /**
  27002. * Release and destroy the underlying lower level texture aka internalTexture.
  27003. */
  27004. releaseInternalTexture(): void;
  27005. /**
  27006. * Get the polynomial representation of the texture data.
  27007. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27008. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27009. */
  27010. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27011. /** @hidden */
  27012. readonly _lodTextureHigh: Nullable<BaseTexture>;
  27013. /** @hidden */
  27014. readonly _lodTextureMid: Nullable<BaseTexture>;
  27015. /** @hidden */
  27016. readonly _lodTextureLow: Nullable<BaseTexture>;
  27017. /**
  27018. * Dispose the texture and release its associated resources.
  27019. */
  27020. dispose(): void;
  27021. /**
  27022. * Serialize the texture into a JSON representation that can be parsed later on.
  27023. * @returns the JSON representation of the texture
  27024. */
  27025. serialize(): any;
  27026. /**
  27027. * Helper function to be called back once a list of texture contains only ready textures.
  27028. * @param textures Define the list of textures to wait for
  27029. * @param callback Define the callback triggered once the entire list will be ready
  27030. */
  27031. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27032. }
  27033. }
  27034. declare module "babylonjs/Materials/uniformBuffer" {
  27035. import { Nullable, FloatArray } from "babylonjs/types";
  27036. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  27037. import { Engine } from "babylonjs/Engines/engine";
  27038. import { Effect } from "babylonjs/Materials/effect";
  27039. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27040. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27041. /**
  27042. * Uniform buffer objects.
  27043. *
  27044. * Handles blocks of uniform on the GPU.
  27045. *
  27046. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27047. *
  27048. * For more information, please refer to :
  27049. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27050. */
  27051. export class UniformBuffer {
  27052. private _engine;
  27053. private _buffer;
  27054. private _data;
  27055. private _bufferData;
  27056. private _dynamic?;
  27057. private _uniformLocations;
  27058. private _uniformSizes;
  27059. private _uniformLocationPointer;
  27060. private _needSync;
  27061. private _noUBO;
  27062. private _currentEffect;
  27063. private static _MAX_UNIFORM_SIZE;
  27064. private static _tempBuffer;
  27065. /**
  27066. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  27067. * This is dynamic to allow compat with webgl 1 and 2.
  27068. * You will need to pass the name of the uniform as well as the value.
  27069. */
  27070. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  27071. /**
  27072. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  27073. * This is dynamic to allow compat with webgl 1 and 2.
  27074. * You will need to pass the name of the uniform as well as the value.
  27075. */
  27076. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  27077. /**
  27078. * Lambda to Update a single float in a uniform buffer.
  27079. * This is dynamic to allow compat with webgl 1 and 2.
  27080. * You will need to pass the name of the uniform as well as the value.
  27081. */
  27082. updateFloat: (name: string, x: number) => void;
  27083. /**
  27084. * Lambda to Update a vec2 of float in a uniform buffer.
  27085. * This is dynamic to allow compat with webgl 1 and 2.
  27086. * You will need to pass the name of the uniform as well as the value.
  27087. */
  27088. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  27089. /**
  27090. * Lambda to Update a vec3 of float in a uniform buffer.
  27091. * This is dynamic to allow compat with webgl 1 and 2.
  27092. * You will need to pass the name of the uniform as well as the value.
  27093. */
  27094. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  27095. /**
  27096. * Lambda to Update a vec4 of float in a uniform buffer.
  27097. * This is dynamic to allow compat with webgl 1 and 2.
  27098. * You will need to pass the name of the uniform as well as the value.
  27099. */
  27100. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  27101. /**
  27102. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  27103. * This is dynamic to allow compat with webgl 1 and 2.
  27104. * You will need to pass the name of the uniform as well as the value.
  27105. */
  27106. updateMatrix: (name: string, mat: Matrix) => void;
  27107. /**
  27108. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  27109. * This is dynamic to allow compat with webgl 1 and 2.
  27110. * You will need to pass the name of the uniform as well as the value.
  27111. */
  27112. updateVector3: (name: string, vector: Vector3) => void;
  27113. /**
  27114. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  27115. * This is dynamic to allow compat with webgl 1 and 2.
  27116. * You will need to pass the name of the uniform as well as the value.
  27117. */
  27118. updateVector4: (name: string, vector: Vector4) => void;
  27119. /**
  27120. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  27121. * This is dynamic to allow compat with webgl 1 and 2.
  27122. * You will need to pass the name of the uniform as well as the value.
  27123. */
  27124. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  27125. /**
  27126. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  27127. * This is dynamic to allow compat with webgl 1 and 2.
  27128. * You will need to pass the name of the uniform as well as the value.
  27129. */
  27130. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  27131. /**
  27132. * Instantiates a new Uniform buffer objects.
  27133. *
  27134. * Handles blocks of uniform on the GPU.
  27135. *
  27136. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  27137. *
  27138. * For more information, please refer to :
  27139. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  27140. * @param engine Define the engine the buffer is associated with
  27141. * @param data Define the data contained in the buffer
  27142. * @param dynamic Define if the buffer is updatable
  27143. */
  27144. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  27145. /**
  27146. * Indicates if the buffer is using the WebGL2 UBO implementation,
  27147. * or just falling back on setUniformXXX calls.
  27148. */
  27149. readonly useUbo: boolean;
  27150. /**
  27151. * Indicates if the WebGL underlying uniform buffer is in sync
  27152. * with the javascript cache data.
  27153. */
  27154. readonly isSync: boolean;
  27155. /**
  27156. * Indicates if the WebGL underlying uniform buffer is dynamic.
  27157. * Also, a dynamic UniformBuffer will disable cache verification and always
  27158. * update the underlying WebGL uniform buffer to the GPU.
  27159. * @returns if Dynamic, otherwise false
  27160. */
  27161. isDynamic(): boolean;
  27162. /**
  27163. * The data cache on JS side.
  27164. * @returns the underlying data as a float array
  27165. */
  27166. getData(): Float32Array;
  27167. /**
  27168. * The underlying WebGL Uniform buffer.
  27169. * @returns the webgl buffer
  27170. */
  27171. getBuffer(): Nullable<DataBuffer>;
  27172. /**
  27173. * std140 layout specifies how to align data within an UBO structure.
  27174. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  27175. * for specs.
  27176. */
  27177. private _fillAlignment;
  27178. /**
  27179. * Adds an uniform in the buffer.
  27180. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  27181. * for the layout to be correct !
  27182. * @param name Name of the uniform, as used in the uniform block in the shader.
  27183. * @param size Data size, or data directly.
  27184. */
  27185. addUniform(name: string, size: number | number[]): void;
  27186. /**
  27187. * Adds a Matrix 4x4 to the uniform buffer.
  27188. * @param name Name of the uniform, as used in the uniform block in the shader.
  27189. * @param mat A 4x4 matrix.
  27190. */
  27191. addMatrix(name: string, mat: Matrix): void;
  27192. /**
  27193. * Adds a vec2 to the uniform buffer.
  27194. * @param name Name of the uniform, as used in the uniform block in the shader.
  27195. * @param x Define the x component value of the vec2
  27196. * @param y Define the y component value of the vec2
  27197. */
  27198. addFloat2(name: string, x: number, y: number): void;
  27199. /**
  27200. * Adds a vec3 to the uniform buffer.
  27201. * @param name Name of the uniform, as used in the uniform block in the shader.
  27202. * @param x Define the x component value of the vec3
  27203. * @param y Define the y component value of the vec3
  27204. * @param z Define the z component value of the vec3
  27205. */
  27206. addFloat3(name: string, x: number, y: number, z: number): void;
  27207. /**
  27208. * Adds a vec3 to the uniform buffer.
  27209. * @param name Name of the uniform, as used in the uniform block in the shader.
  27210. * @param color Define the vec3 from a Color
  27211. */
  27212. addColor3(name: string, color: Color3): void;
  27213. /**
  27214. * Adds a vec4 to the uniform buffer.
  27215. * @param name Name of the uniform, as used in the uniform block in the shader.
  27216. * @param color Define the rgb components from a Color
  27217. * @param alpha Define the a component of the vec4
  27218. */
  27219. addColor4(name: string, color: Color3, alpha: number): void;
  27220. /**
  27221. * Adds a vec3 to the uniform buffer.
  27222. * @param name Name of the uniform, as used in the uniform block in the shader.
  27223. * @param vector Define the vec3 components from a Vector
  27224. */
  27225. addVector3(name: string, vector: Vector3): void;
  27226. /**
  27227. * Adds a Matrix 3x3 to the uniform buffer.
  27228. * @param name Name of the uniform, as used in the uniform block in the shader.
  27229. */
  27230. addMatrix3x3(name: string): void;
  27231. /**
  27232. * Adds a Matrix 2x2 to the uniform buffer.
  27233. * @param name Name of the uniform, as used in the uniform block in the shader.
  27234. */
  27235. addMatrix2x2(name: string): void;
  27236. /**
  27237. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  27238. */
  27239. create(): void;
  27240. /** @hidden */
  27241. _rebuild(): void;
  27242. /**
  27243. * Updates the WebGL Uniform Buffer on the GPU.
  27244. * If the `dynamic` flag is set to true, no cache comparison is done.
  27245. * Otherwise, the buffer will be updated only if the cache differs.
  27246. */
  27247. update(): void;
  27248. /**
  27249. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  27250. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27251. * @param data Define the flattened data
  27252. * @param size Define the size of the data.
  27253. */
  27254. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  27255. private _updateMatrix3x3ForUniform;
  27256. private _updateMatrix3x3ForEffect;
  27257. private _updateMatrix2x2ForEffect;
  27258. private _updateMatrix2x2ForUniform;
  27259. private _updateFloatForEffect;
  27260. private _updateFloatForUniform;
  27261. private _updateFloat2ForEffect;
  27262. private _updateFloat2ForUniform;
  27263. private _updateFloat3ForEffect;
  27264. private _updateFloat3ForUniform;
  27265. private _updateFloat4ForEffect;
  27266. private _updateFloat4ForUniform;
  27267. private _updateMatrixForEffect;
  27268. private _updateMatrixForUniform;
  27269. private _updateVector3ForEffect;
  27270. private _updateVector3ForUniform;
  27271. private _updateVector4ForEffect;
  27272. private _updateVector4ForUniform;
  27273. private _updateColor3ForEffect;
  27274. private _updateColor3ForUniform;
  27275. private _updateColor4ForEffect;
  27276. private _updateColor4ForUniform;
  27277. /**
  27278. * Sets a sampler uniform on the effect.
  27279. * @param name Define the name of the sampler.
  27280. * @param texture Define the texture to set in the sampler
  27281. */
  27282. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  27283. /**
  27284. * Directly updates the value of the uniform in the cache AND on the GPU.
  27285. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  27286. * @param data Define the flattened data
  27287. */
  27288. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  27289. /**
  27290. * Binds this uniform buffer to an effect.
  27291. * @param effect Define the effect to bind the buffer to
  27292. * @param name Name of the uniform block in the shader.
  27293. */
  27294. bindToEffect(effect: Effect, name: string): void;
  27295. /**
  27296. * Disposes the uniform buffer.
  27297. */
  27298. dispose(): void;
  27299. }
  27300. }
  27301. declare module "babylonjs/Audio/analyser" {
  27302. import { Scene } from "babylonjs/scene";
  27303. /**
  27304. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27305. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27306. */
  27307. export class Analyser {
  27308. /**
  27309. * Gets or sets the smoothing
  27310. * @ignorenaming
  27311. */
  27312. SMOOTHING: number;
  27313. /**
  27314. * Gets or sets the FFT table size
  27315. * @ignorenaming
  27316. */
  27317. FFT_SIZE: number;
  27318. /**
  27319. * Gets or sets the bar graph amplitude
  27320. * @ignorenaming
  27321. */
  27322. BARGRAPHAMPLITUDE: number;
  27323. /**
  27324. * Gets or sets the position of the debug canvas
  27325. * @ignorenaming
  27326. */
  27327. DEBUGCANVASPOS: {
  27328. x: number;
  27329. y: number;
  27330. };
  27331. /**
  27332. * Gets or sets the debug canvas size
  27333. * @ignorenaming
  27334. */
  27335. DEBUGCANVASSIZE: {
  27336. width: number;
  27337. height: number;
  27338. };
  27339. private _byteFreqs;
  27340. private _byteTime;
  27341. private _floatFreqs;
  27342. private _webAudioAnalyser;
  27343. private _debugCanvas;
  27344. private _debugCanvasContext;
  27345. private _scene;
  27346. private _registerFunc;
  27347. private _audioEngine;
  27348. /**
  27349. * Creates a new analyser
  27350. * @param scene defines hosting scene
  27351. */
  27352. constructor(scene: Scene);
  27353. /**
  27354. * Get the number of data values you will have to play with for the visualization
  27355. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27356. * @returns a number
  27357. */
  27358. getFrequencyBinCount(): number;
  27359. /**
  27360. * Gets the current frequency data as a byte array
  27361. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27362. * @returns a Uint8Array
  27363. */
  27364. getByteFrequencyData(): Uint8Array;
  27365. /**
  27366. * Gets the current waveform as a byte array
  27367. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27368. * @returns a Uint8Array
  27369. */
  27370. getByteTimeDomainData(): Uint8Array;
  27371. /**
  27372. * Gets the current frequency data as a float array
  27373. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27374. * @returns a Float32Array
  27375. */
  27376. getFloatFrequencyData(): Float32Array;
  27377. /**
  27378. * Renders the debug canvas
  27379. */
  27380. drawDebugCanvas(): void;
  27381. /**
  27382. * Stops rendering the debug canvas and removes it
  27383. */
  27384. stopDebugCanvas(): void;
  27385. /**
  27386. * Connects two audio nodes
  27387. * @param inputAudioNode defines first node to connect
  27388. * @param outputAudioNode defines second node to connect
  27389. */
  27390. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27391. /**
  27392. * Releases all associated resources
  27393. */
  27394. dispose(): void;
  27395. }
  27396. }
  27397. declare module "babylonjs/Audio/audioEngine" {
  27398. import { IDisposable } from "babylonjs/scene";
  27399. import { Analyser } from "babylonjs/Audio/analyser";
  27400. import { Nullable } from "babylonjs/types";
  27401. import { Observable } from "babylonjs/Misc/observable";
  27402. /**
  27403. * This represents an audio engine and it is responsible
  27404. * to play, synchronize and analyse sounds throughout the application.
  27405. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27406. */
  27407. export interface IAudioEngine extends IDisposable {
  27408. /**
  27409. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27410. */
  27411. readonly canUseWebAudio: boolean;
  27412. /**
  27413. * Gets the current AudioContext if available.
  27414. */
  27415. readonly audioContext: Nullable<AudioContext>;
  27416. /**
  27417. * The master gain node defines the global audio volume of your audio engine.
  27418. */
  27419. readonly masterGain: GainNode;
  27420. /**
  27421. * Gets whether or not mp3 are supported by your browser.
  27422. */
  27423. readonly isMP3supported: boolean;
  27424. /**
  27425. * Gets whether or not ogg are supported by your browser.
  27426. */
  27427. readonly isOGGsupported: boolean;
  27428. /**
  27429. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27430. * @ignoreNaming
  27431. */
  27432. WarnedWebAudioUnsupported: boolean;
  27433. /**
  27434. * Defines if the audio engine relies on a custom unlocked button.
  27435. * In this case, the embedded button will not be displayed.
  27436. */
  27437. useCustomUnlockedButton: boolean;
  27438. /**
  27439. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27440. */
  27441. readonly unlocked: boolean;
  27442. /**
  27443. * Event raised when audio has been unlocked on the browser.
  27444. */
  27445. onAudioUnlockedObservable: Observable<AudioEngine>;
  27446. /**
  27447. * Event raised when audio has been locked on the browser.
  27448. */
  27449. onAudioLockedObservable: Observable<AudioEngine>;
  27450. /**
  27451. * Flags the audio engine in Locked state.
  27452. * This happens due to new browser policies preventing audio to autoplay.
  27453. */
  27454. lock(): void;
  27455. /**
  27456. * Unlocks the audio engine once a user action has been done on the dom.
  27457. * This is helpful to resume play once browser policies have been satisfied.
  27458. */
  27459. unlock(): void;
  27460. }
  27461. /**
  27462. * This represents the default audio engine used in babylon.
  27463. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27464. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27465. */
  27466. export class AudioEngine implements IAudioEngine {
  27467. private _audioContext;
  27468. private _audioContextInitialized;
  27469. private _muteButton;
  27470. private _hostElement;
  27471. /**
  27472. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27473. */
  27474. canUseWebAudio: boolean;
  27475. /**
  27476. * The master gain node defines the global audio volume of your audio engine.
  27477. */
  27478. masterGain: GainNode;
  27479. /**
  27480. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27481. * @ignoreNaming
  27482. */
  27483. WarnedWebAudioUnsupported: boolean;
  27484. /**
  27485. * Gets whether or not mp3 are supported by your browser.
  27486. */
  27487. isMP3supported: boolean;
  27488. /**
  27489. * Gets whether or not ogg are supported by your browser.
  27490. */
  27491. isOGGsupported: boolean;
  27492. /**
  27493. * Gets whether audio has been unlocked on the device.
  27494. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27495. * a user interaction has happened.
  27496. */
  27497. unlocked: boolean;
  27498. /**
  27499. * Defines if the audio engine relies on a custom unlocked button.
  27500. * In this case, the embedded button will not be displayed.
  27501. */
  27502. useCustomUnlockedButton: boolean;
  27503. /**
  27504. * Event raised when audio has been unlocked on the browser.
  27505. */
  27506. onAudioUnlockedObservable: Observable<AudioEngine>;
  27507. /**
  27508. * Event raised when audio has been locked on the browser.
  27509. */
  27510. onAudioLockedObservable: Observable<AudioEngine>;
  27511. /**
  27512. * Gets the current AudioContext if available.
  27513. */
  27514. readonly audioContext: Nullable<AudioContext>;
  27515. private _connectedAnalyser;
  27516. /**
  27517. * Instantiates a new audio engine.
  27518. *
  27519. * There should be only one per page as some browsers restrict the number
  27520. * of audio contexts you can create.
  27521. * @param hostElement defines the host element where to display the mute icon if necessary
  27522. */
  27523. constructor(hostElement?: Nullable<HTMLElement>);
  27524. /**
  27525. * Flags the audio engine in Locked state.
  27526. * This happens due to new browser policies preventing audio to autoplay.
  27527. */
  27528. lock(): void;
  27529. /**
  27530. * Unlocks the audio engine once a user action has been done on the dom.
  27531. * This is helpful to resume play once browser policies have been satisfied.
  27532. */
  27533. unlock(): void;
  27534. private _resumeAudioContext;
  27535. private _initializeAudioContext;
  27536. private _tryToRun;
  27537. private _triggerRunningState;
  27538. private _triggerSuspendedState;
  27539. private _displayMuteButton;
  27540. private _moveButtonToTopLeft;
  27541. private _onResize;
  27542. private _hideMuteButton;
  27543. /**
  27544. * Destroy and release the resources associated with the audio ccontext.
  27545. */
  27546. dispose(): void;
  27547. /**
  27548. * Gets the global volume sets on the master gain.
  27549. * @returns the global volume if set or -1 otherwise
  27550. */
  27551. getGlobalVolume(): number;
  27552. /**
  27553. * Sets the global volume of your experience (sets on the master gain).
  27554. * @param newVolume Defines the new global volume of the application
  27555. */
  27556. setGlobalVolume(newVolume: number): void;
  27557. /**
  27558. * Connect the audio engine to an audio analyser allowing some amazing
  27559. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27560. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27561. * @param analyser The analyser to connect to the engine
  27562. */
  27563. connectToAnalyser(analyser: Analyser): void;
  27564. }
  27565. }
  27566. declare module "babylonjs/Loading/loadingScreen" {
  27567. /**
  27568. * Interface used to present a loading screen while loading a scene
  27569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27570. */
  27571. export interface ILoadingScreen {
  27572. /**
  27573. * Function called to display the loading screen
  27574. */
  27575. displayLoadingUI: () => void;
  27576. /**
  27577. * Function called to hide the loading screen
  27578. */
  27579. hideLoadingUI: () => void;
  27580. /**
  27581. * Gets or sets the color to use for the background
  27582. */
  27583. loadingUIBackgroundColor: string;
  27584. /**
  27585. * Gets or sets the text to display while loading
  27586. */
  27587. loadingUIText: string;
  27588. }
  27589. /**
  27590. * Class used for the default loading screen
  27591. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27592. */
  27593. export class DefaultLoadingScreen implements ILoadingScreen {
  27594. private _renderingCanvas;
  27595. private _loadingText;
  27596. private _loadingDivBackgroundColor;
  27597. private _loadingDiv;
  27598. private _loadingTextDiv;
  27599. /** Gets or sets the logo url to use for the default loading screen */
  27600. static DefaultLogoUrl: string;
  27601. /** Gets or sets the spinner url to use for the default loading screen */
  27602. static DefaultSpinnerUrl: string;
  27603. /**
  27604. * Creates a new default loading screen
  27605. * @param _renderingCanvas defines the canvas used to render the scene
  27606. * @param _loadingText defines the default text to display
  27607. * @param _loadingDivBackgroundColor defines the default background color
  27608. */
  27609. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27610. /**
  27611. * Function called to display the loading screen
  27612. */
  27613. displayLoadingUI(): void;
  27614. /**
  27615. * Function called to hide the loading screen
  27616. */
  27617. hideLoadingUI(): void;
  27618. /**
  27619. * Gets or sets the text to display while loading
  27620. */
  27621. loadingUIText: string;
  27622. /**
  27623. * Gets or sets the color to use for the background
  27624. */
  27625. loadingUIBackgroundColor: string;
  27626. private _resizeLoadingUI;
  27627. }
  27628. }
  27629. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  27630. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27631. import { Engine } from "babylonjs/Engines/engine";
  27632. import { Nullable } from "babylonjs/types";
  27633. /** @hidden */
  27634. export class WebGLPipelineContext implements IPipelineContext {
  27635. engine: Engine;
  27636. program: Nullable<WebGLProgram>;
  27637. context?: WebGLRenderingContext;
  27638. vertexShader?: WebGLShader;
  27639. fragmentShader?: WebGLShader;
  27640. isParallelCompiled: boolean;
  27641. onCompiled?: () => void;
  27642. transformFeedback?: WebGLTransformFeedback | null;
  27643. readonly isAsync: boolean;
  27644. readonly isReady: boolean;
  27645. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  27646. }
  27647. }
  27648. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  27649. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27650. /** @hidden */
  27651. export class WebGLDataBuffer extends DataBuffer {
  27652. private _buffer;
  27653. constructor(resource: WebGLBuffer);
  27654. readonly underlyingResource: any;
  27655. }
  27656. }
  27657. declare module "babylonjs/Materials/Textures/videoTexture" {
  27658. import { Observable } from "babylonjs/Misc/observable";
  27659. import { Nullable } from "babylonjs/types";
  27660. import { Scene } from "babylonjs/scene";
  27661. import { Texture } from "babylonjs/Materials/Textures/texture";
  27662. /**
  27663. * Settings for finer control over video usage
  27664. */
  27665. export interface VideoTextureSettings {
  27666. /**
  27667. * Applies `autoplay` to video, if specified
  27668. */
  27669. autoPlay?: boolean;
  27670. /**
  27671. * Applies `loop` to video, if specified
  27672. */
  27673. loop?: boolean;
  27674. /**
  27675. * Automatically updates internal texture from video at every frame in the render loop
  27676. */
  27677. autoUpdateTexture: boolean;
  27678. /**
  27679. * Image src displayed during the video loading or until the user interacts with the video.
  27680. */
  27681. poster?: string;
  27682. }
  27683. /**
  27684. * If you want to display a video in your scene, this is the special texture for that.
  27685. * This special texture works similar to other textures, with the exception of a few parameters.
  27686. * @see https://doc.babylonjs.com/how_to/video_texture
  27687. */
  27688. export class VideoTexture extends Texture {
  27689. /**
  27690. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27691. */
  27692. readonly autoUpdateTexture: boolean;
  27693. /**
  27694. * The video instance used by the texture internally
  27695. */
  27696. readonly video: HTMLVideoElement;
  27697. private _onUserActionRequestedObservable;
  27698. /**
  27699. * Event triggerd when a dom action is required by the user to play the video.
  27700. * This happens due to recent changes in browser policies preventing video to auto start.
  27701. */
  27702. readonly onUserActionRequestedObservable: Observable<Texture>;
  27703. private _generateMipMaps;
  27704. private _engine;
  27705. private _stillImageCaptured;
  27706. private _displayingPosterTexture;
  27707. private _settings;
  27708. private _createInternalTextureOnEvent;
  27709. /**
  27710. * Creates a video texture.
  27711. * If you want to display a video in your scene, this is the special texture for that.
  27712. * This special texture works similar to other textures, with the exception of a few parameters.
  27713. * @see https://doc.babylonjs.com/how_to/video_texture
  27714. * @param name optional name, will detect from video source, if not defined
  27715. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27716. * @param scene is obviously the current scene.
  27717. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27718. * @param invertY is false by default but can be used to invert video on Y axis
  27719. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27720. * @param settings allows finer control over video usage
  27721. */
  27722. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27723. private _getName;
  27724. private _getVideo;
  27725. private _createInternalTexture;
  27726. private reset;
  27727. /**
  27728. * @hidden Internal method to initiate `update`.
  27729. */
  27730. _rebuild(): void;
  27731. /**
  27732. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27733. */
  27734. update(): void;
  27735. /**
  27736. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27737. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27738. */
  27739. updateTexture(isVisible: boolean): void;
  27740. protected _updateInternalTexture: () => void;
  27741. /**
  27742. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27743. * @param url New url.
  27744. */
  27745. updateURL(url: string): void;
  27746. /**
  27747. * Dispose the texture and release its associated resources.
  27748. */
  27749. dispose(): void;
  27750. /**
  27751. * Creates a video texture straight from a stream.
  27752. * @param scene Define the scene the texture should be created in
  27753. * @param stream Define the stream the texture should be created from
  27754. * @returns The created video texture as a promise
  27755. */
  27756. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27757. /**
  27758. * Creates a video texture straight from your WebCam video feed.
  27759. * @param scene Define the scene the texture should be created in
  27760. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27761. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27762. * @returns The created video texture as a promise
  27763. */
  27764. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27765. minWidth: number;
  27766. maxWidth: number;
  27767. minHeight: number;
  27768. maxHeight: number;
  27769. deviceId: string;
  27770. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27771. /**
  27772. * Creates a video texture straight from your WebCam video feed.
  27773. * @param scene Define the scene the texture should be created in
  27774. * @param onReady Define a callback to triggered once the texture will be ready
  27775. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27776. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27777. */
  27778. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27779. minWidth: number;
  27780. maxWidth: number;
  27781. minHeight: number;
  27782. maxHeight: number;
  27783. deviceId: string;
  27784. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27785. }
  27786. }
  27787. declare module "babylonjs/Engines/engine" {
  27788. import { Observable } from "babylonjs/Misc/observable";
  27789. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27790. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27791. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27792. import { Camera } from "babylonjs/Cameras/camera";
  27793. import { Scene } from "babylonjs/scene";
  27794. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27795. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27796. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27797. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27798. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27799. import { Material } from "babylonjs/Materials/material";
  27800. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27801. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27802. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27803. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27804. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27805. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27806. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27807. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27808. import { WebRequest } from "babylonjs/Misc/webRequest";
  27809. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  27810. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  27811. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  27812. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27813. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27814. /**
  27815. * Interface for attribute information associated with buffer instanciation
  27816. */
  27817. export class InstancingAttributeInfo {
  27818. /**
  27819. * Index/offset of the attribute in the vertex shader
  27820. */
  27821. index: number;
  27822. /**
  27823. * size of the attribute, 1, 2, 3 or 4
  27824. */
  27825. attributeSize: number;
  27826. /**
  27827. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27828. * default is FLOAT
  27829. */
  27830. attribyteType: number;
  27831. /**
  27832. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27833. */
  27834. normalized: boolean;
  27835. /**
  27836. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27837. */
  27838. offset: number;
  27839. /**
  27840. * Name of the GLSL attribute, for debugging purpose only
  27841. */
  27842. attributeName: string;
  27843. }
  27844. /**
  27845. * Define options used to create a depth texture
  27846. */
  27847. export class DepthTextureCreationOptions {
  27848. /** Specifies whether or not a stencil should be allocated in the texture */
  27849. generateStencil?: boolean;
  27850. /** Specifies whether or not bilinear filtering is enable on the texture */
  27851. bilinearFiltering?: boolean;
  27852. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27853. comparisonFunction?: number;
  27854. /** Specifies if the created texture is a cube texture */
  27855. isCube?: boolean;
  27856. }
  27857. /**
  27858. * Class used to describe the capabilities of the engine relatively to the current browser
  27859. */
  27860. export class EngineCapabilities {
  27861. /** Maximum textures units per fragment shader */
  27862. maxTexturesImageUnits: number;
  27863. /** Maximum texture units per vertex shader */
  27864. maxVertexTextureImageUnits: number;
  27865. /** Maximum textures units in the entire pipeline */
  27866. maxCombinedTexturesImageUnits: number;
  27867. /** Maximum texture size */
  27868. maxTextureSize: number;
  27869. /** Maximum cube texture size */
  27870. maxCubemapTextureSize: number;
  27871. /** Maximum render texture size */
  27872. maxRenderTextureSize: number;
  27873. /** Maximum number of vertex attributes */
  27874. maxVertexAttribs: number;
  27875. /** Maximum number of varyings */
  27876. maxVaryingVectors: number;
  27877. /** Maximum number of uniforms per vertex shader */
  27878. maxVertexUniformVectors: number;
  27879. /** Maximum number of uniforms per fragment shader */
  27880. maxFragmentUniformVectors: number;
  27881. /** Defines if standard derivates (dx/dy) are supported */
  27882. standardDerivatives: boolean;
  27883. /** Defines if s3tc texture compression is supported */
  27884. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27885. /** Defines if pvrtc texture compression is supported */
  27886. pvrtc: any;
  27887. /** Defines if etc1 texture compression is supported */
  27888. etc1: any;
  27889. /** Defines if etc2 texture compression is supported */
  27890. etc2: any;
  27891. /** Defines if astc texture compression is supported */
  27892. astc: any;
  27893. /** Defines if float textures are supported */
  27894. textureFloat: boolean;
  27895. /** Defines if vertex array objects are supported */
  27896. vertexArrayObject: boolean;
  27897. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27898. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27899. /** Gets the maximum level of anisotropy supported */
  27900. maxAnisotropy: number;
  27901. /** Defines if instancing is supported */
  27902. instancedArrays: boolean;
  27903. /** Defines if 32 bits indices are supported */
  27904. uintIndices: boolean;
  27905. /** Defines if high precision shaders are supported */
  27906. highPrecisionShaderSupported: boolean;
  27907. /** Defines if depth reading in the fragment shader is supported */
  27908. fragmentDepthSupported: boolean;
  27909. /** Defines if float texture linear filtering is supported*/
  27910. textureFloatLinearFiltering: boolean;
  27911. /** Defines if rendering to float textures is supported */
  27912. textureFloatRender: boolean;
  27913. /** Defines if half float textures are supported*/
  27914. textureHalfFloat: boolean;
  27915. /** Defines if half float texture linear filtering is supported*/
  27916. textureHalfFloatLinearFiltering: boolean;
  27917. /** Defines if rendering to half float textures is supported */
  27918. textureHalfFloatRender: boolean;
  27919. /** Defines if textureLOD shader command is supported */
  27920. textureLOD: boolean;
  27921. /** Defines if draw buffers extension is supported */
  27922. drawBuffersExtension: boolean;
  27923. /** Defines if depth textures are supported */
  27924. depthTextureExtension: boolean;
  27925. /** Defines if float color buffer are supported */
  27926. colorBufferFloat: boolean;
  27927. /** Gets disjoint timer query extension (null if not supported) */
  27928. timerQuery: EXT_disjoint_timer_query;
  27929. /** Defines if timestamp can be used with timer query */
  27930. canUseTimestampForTimerQuery: boolean;
  27931. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27932. multiview: any;
  27933. /** Function used to let the system compiles shaders in background */
  27934. parallelShaderCompile: {
  27935. COMPLETION_STATUS_KHR: number;
  27936. };
  27937. }
  27938. /** Interface defining initialization parameters for Engine class */
  27939. export interface EngineOptions extends WebGLContextAttributes {
  27940. /**
  27941. * Defines if the engine should no exceed a specified device ratio
  27942. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27943. */
  27944. limitDeviceRatio?: number;
  27945. /**
  27946. * Defines if webvr should be enabled automatically
  27947. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27948. */
  27949. autoEnableWebVR?: boolean;
  27950. /**
  27951. * Defines if webgl2 should be turned off even if supported
  27952. * @see http://doc.babylonjs.com/features/webgl2
  27953. */
  27954. disableWebGL2Support?: boolean;
  27955. /**
  27956. * Defines if webaudio should be initialized as well
  27957. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27958. */
  27959. audioEngine?: boolean;
  27960. /**
  27961. * Defines if animations should run using a deterministic lock step
  27962. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27963. */
  27964. deterministicLockstep?: boolean;
  27965. /** Defines the maximum steps to use with deterministic lock step mode */
  27966. lockstepMaxSteps?: number;
  27967. /**
  27968. * Defines that engine should ignore context lost events
  27969. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27970. */
  27971. doNotHandleContextLost?: boolean;
  27972. /**
  27973. * Defines that engine should ignore modifying touch action attribute and style
  27974. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27975. */
  27976. doNotHandleTouchAction?: boolean;
  27977. /**
  27978. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27979. */
  27980. useHighPrecisionFloats?: boolean;
  27981. }
  27982. /**
  27983. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27984. */
  27985. export class Engine {
  27986. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27987. static ExceptionList: ({
  27988. key: string;
  27989. capture: string;
  27990. captureConstraint: number;
  27991. targets: string[];
  27992. } | {
  27993. key: string;
  27994. capture: null;
  27995. captureConstraint: null;
  27996. targets: string[];
  27997. })[];
  27998. /** Gets the list of created engines */
  27999. static readonly Instances: Engine[];
  28000. /**
  28001. * Gets the latest created engine
  28002. */
  28003. static readonly LastCreatedEngine: Nullable<Engine>;
  28004. /**
  28005. * Gets the latest created scene
  28006. */
  28007. static readonly LastCreatedScene: Nullable<Scene>;
  28008. /**
  28009. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  28010. * @param flag defines which part of the materials must be marked as dirty
  28011. * @param predicate defines a predicate used to filter which materials should be affected
  28012. */
  28013. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  28014. /**
  28015. * Hidden
  28016. */
  28017. static _TextureLoaders: IInternalTextureLoader[];
  28018. /** Defines that alpha blending is disabled */
  28019. static readonly ALPHA_DISABLE: number;
  28020. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  28021. static readonly ALPHA_ADD: number;
  28022. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  28023. static readonly ALPHA_COMBINE: number;
  28024. /** Defines that alpha blending to DEST - SRC * DEST */
  28025. static readonly ALPHA_SUBTRACT: number;
  28026. /** Defines that alpha blending to SRC * DEST */
  28027. static readonly ALPHA_MULTIPLY: number;
  28028. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  28029. static readonly ALPHA_MAXIMIZED: number;
  28030. /** Defines that alpha blending to SRC + DEST */
  28031. static readonly ALPHA_ONEONE: number;
  28032. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  28033. static readonly ALPHA_PREMULTIPLIED: number;
  28034. /**
  28035. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  28036. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  28037. */
  28038. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  28039. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  28040. static readonly ALPHA_INTERPOLATE: number;
  28041. /**
  28042. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  28043. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  28044. */
  28045. static readonly ALPHA_SCREENMODE: number;
  28046. /** Defines that the ressource is not delayed*/
  28047. static readonly DELAYLOADSTATE_NONE: number;
  28048. /** Defines that the ressource was successfully delay loaded */
  28049. static readonly DELAYLOADSTATE_LOADED: number;
  28050. /** Defines that the ressource is currently delay loading */
  28051. static readonly DELAYLOADSTATE_LOADING: number;
  28052. /** Defines that the ressource is delayed and has not started loading */
  28053. static readonly DELAYLOADSTATE_NOTLOADED: number;
  28054. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  28055. static readonly NEVER: number;
  28056. /** 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 */
  28057. static readonly ALWAYS: number;
  28058. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  28059. static readonly LESS: number;
  28060. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  28061. static readonly EQUAL: number;
  28062. /** 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 */
  28063. static readonly LEQUAL: number;
  28064. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  28065. static readonly GREATER: number;
  28066. /** 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 */
  28067. static readonly GEQUAL: number;
  28068. /** 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 */
  28069. static readonly NOTEQUAL: number;
  28070. /** Passed to stencilOperation to specify that stencil value must be kept */
  28071. static readonly KEEP: number;
  28072. /** Passed to stencilOperation to specify that stencil value must be replaced */
  28073. static readonly REPLACE: number;
  28074. /** Passed to stencilOperation to specify that stencil value must be incremented */
  28075. static readonly INCR: number;
  28076. /** Passed to stencilOperation to specify that stencil value must be decremented */
  28077. static readonly DECR: number;
  28078. /** Passed to stencilOperation to specify that stencil value must be inverted */
  28079. static readonly INVERT: number;
  28080. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  28081. static readonly INCR_WRAP: number;
  28082. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  28083. static readonly DECR_WRAP: number;
  28084. /** Texture is not repeating outside of 0..1 UVs */
  28085. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  28086. /** Texture is repeating outside of 0..1 UVs */
  28087. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  28088. /** Texture is repeating and mirrored */
  28089. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  28090. /** ALPHA */
  28091. static readonly TEXTUREFORMAT_ALPHA: number;
  28092. /** LUMINANCE */
  28093. static readonly TEXTUREFORMAT_LUMINANCE: number;
  28094. /** LUMINANCE_ALPHA */
  28095. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  28096. /** RGB */
  28097. static readonly TEXTUREFORMAT_RGB: number;
  28098. /** RGBA */
  28099. static readonly TEXTUREFORMAT_RGBA: number;
  28100. /** RED */
  28101. static readonly TEXTUREFORMAT_RED: number;
  28102. /** RED (2nd reference) */
  28103. static readonly TEXTUREFORMAT_R: number;
  28104. /** RG */
  28105. static readonly TEXTUREFORMAT_RG: number;
  28106. /** RED_INTEGER */
  28107. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  28108. /** RED_INTEGER (2nd reference) */
  28109. static readonly TEXTUREFORMAT_R_INTEGER: number;
  28110. /** RG_INTEGER */
  28111. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  28112. /** RGB_INTEGER */
  28113. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  28114. /** RGBA_INTEGER */
  28115. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  28116. /** UNSIGNED_BYTE */
  28117. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  28118. /** UNSIGNED_BYTE (2nd reference) */
  28119. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  28120. /** FLOAT */
  28121. static readonly TEXTURETYPE_FLOAT: number;
  28122. /** HALF_FLOAT */
  28123. static readonly TEXTURETYPE_HALF_FLOAT: number;
  28124. /** BYTE */
  28125. static readonly TEXTURETYPE_BYTE: number;
  28126. /** SHORT */
  28127. static readonly TEXTURETYPE_SHORT: number;
  28128. /** UNSIGNED_SHORT */
  28129. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  28130. /** INT */
  28131. static readonly TEXTURETYPE_INT: number;
  28132. /** UNSIGNED_INT */
  28133. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  28134. /** UNSIGNED_SHORT_4_4_4_4 */
  28135. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  28136. /** UNSIGNED_SHORT_5_5_5_1 */
  28137. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  28138. /** UNSIGNED_SHORT_5_6_5 */
  28139. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  28140. /** UNSIGNED_INT_2_10_10_10_REV */
  28141. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  28142. /** UNSIGNED_INT_24_8 */
  28143. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  28144. /** UNSIGNED_INT_10F_11F_11F_REV */
  28145. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  28146. /** UNSIGNED_INT_5_9_9_9_REV */
  28147. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  28148. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  28149. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  28150. /** nearest is mag = nearest and min = nearest and mip = linear */
  28151. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  28152. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28153. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  28154. /** Trilinear is mag = linear and min = linear and mip = linear */
  28155. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  28156. /** nearest is mag = nearest and min = nearest and mip = linear */
  28157. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  28158. /** Bilinear is mag = linear and min = linear and mip = nearest */
  28159. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  28160. /** Trilinear is mag = linear and min = linear and mip = linear */
  28161. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  28162. /** mag = nearest and min = nearest and mip = nearest */
  28163. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  28164. /** mag = nearest and min = linear and mip = nearest */
  28165. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  28166. /** mag = nearest and min = linear and mip = linear */
  28167. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  28168. /** mag = nearest and min = linear and mip = none */
  28169. static readonly TEXTURE_NEAREST_LINEAR: number;
  28170. /** mag = nearest and min = nearest and mip = none */
  28171. static readonly TEXTURE_NEAREST_NEAREST: number;
  28172. /** mag = linear and min = nearest and mip = nearest */
  28173. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  28174. /** mag = linear and min = nearest and mip = linear */
  28175. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  28176. /** mag = linear and min = linear and mip = none */
  28177. static readonly TEXTURE_LINEAR_LINEAR: number;
  28178. /** mag = linear and min = nearest and mip = none */
  28179. static readonly TEXTURE_LINEAR_NEAREST: number;
  28180. /** Explicit coordinates mode */
  28181. static readonly TEXTURE_EXPLICIT_MODE: number;
  28182. /** Spherical coordinates mode */
  28183. static readonly TEXTURE_SPHERICAL_MODE: number;
  28184. /** Planar coordinates mode */
  28185. static readonly TEXTURE_PLANAR_MODE: number;
  28186. /** Cubic coordinates mode */
  28187. static readonly TEXTURE_CUBIC_MODE: number;
  28188. /** Projection coordinates mode */
  28189. static readonly TEXTURE_PROJECTION_MODE: number;
  28190. /** Skybox coordinates mode */
  28191. static readonly TEXTURE_SKYBOX_MODE: number;
  28192. /** Inverse Cubic coordinates mode */
  28193. static readonly TEXTURE_INVCUBIC_MODE: number;
  28194. /** Equirectangular coordinates mode */
  28195. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  28196. /** Equirectangular Fixed coordinates mode */
  28197. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  28198. /** Equirectangular Fixed Mirrored coordinates mode */
  28199. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  28200. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  28201. static readonly SCALEMODE_FLOOR: number;
  28202. /** Defines that texture rescaling will look for the nearest power of 2 size */
  28203. static readonly SCALEMODE_NEAREST: number;
  28204. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  28205. static readonly SCALEMODE_CEILING: number;
  28206. /**
  28207. * Returns the current npm package of the sdk
  28208. */
  28209. static readonly NpmPackage: string;
  28210. /**
  28211. * Returns the current version of the framework
  28212. */
  28213. static readonly Version: string;
  28214. /**
  28215. * Returns a string describing the current engine
  28216. */
  28217. readonly description: string;
  28218. /**
  28219. * Gets or sets the epsilon value used by collision engine
  28220. */
  28221. static CollisionsEpsilon: number;
  28222. /**
  28223. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28224. */
  28225. static ShadersRepository: string;
  28226. /**
  28227. * Method called to create the default loading screen.
  28228. * This can be overriden in your own app.
  28229. * @param canvas The rendering canvas element
  28230. * @returns The loading screen
  28231. */
  28232. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28233. /**
  28234. * Method called to create the default rescale post process on each engine.
  28235. */
  28236. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28237. /**
  28238. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28239. */
  28240. forcePOTTextures: boolean;
  28241. /**
  28242. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28243. */
  28244. isFullscreen: boolean;
  28245. /**
  28246. * Gets a boolean indicating if the pointer is currently locked
  28247. */
  28248. isPointerLock: boolean;
  28249. /**
  28250. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28251. */
  28252. cullBackFaces: boolean;
  28253. /**
  28254. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28255. */
  28256. renderEvenInBackground: boolean;
  28257. /**
  28258. * Gets or sets a boolean indicating that cache can be kept between frames
  28259. */
  28260. preventCacheWipeBetweenFrames: boolean;
  28261. /**
  28262. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28263. **/
  28264. enableOfflineSupport: boolean;
  28265. /**
  28266. * 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)
  28267. **/
  28268. disableManifestCheck: boolean;
  28269. /**
  28270. * Gets the list of created scenes
  28271. */
  28272. scenes: Scene[];
  28273. /**
  28274. * Event raised when a new scene is created
  28275. */
  28276. onNewSceneAddedObservable: Observable<Scene>;
  28277. /**
  28278. * Gets the list of created postprocesses
  28279. */
  28280. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28281. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28282. validateShaderPrograms: boolean;
  28283. /**
  28284. * Observable event triggered each time the rendering canvas is resized
  28285. */
  28286. onResizeObservable: Observable<Engine>;
  28287. /**
  28288. * Observable event triggered each time the canvas loses focus
  28289. */
  28290. onCanvasBlurObservable: Observable<Engine>;
  28291. /**
  28292. * Observable event triggered each time the canvas gains focus
  28293. */
  28294. onCanvasFocusObservable: Observable<Engine>;
  28295. /**
  28296. * Observable event triggered each time the canvas receives pointerout event
  28297. */
  28298. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28299. /**
  28300. * Observable event triggered before each texture is initialized
  28301. */
  28302. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28303. /**
  28304. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28305. */
  28306. disableUniformBuffers: boolean;
  28307. /** @hidden */
  28308. _uniformBuffers: UniformBuffer[];
  28309. /**
  28310. * Gets a boolean indicating that the engine supports uniform buffers
  28311. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28312. */
  28313. readonly supportsUniformBuffers: boolean;
  28314. /**
  28315. * Observable raised when the engine begins a new frame
  28316. */
  28317. onBeginFrameObservable: Observable<Engine>;
  28318. /**
  28319. * If set, will be used to request the next animation frame for the render loop
  28320. */
  28321. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28322. /**
  28323. * Observable raised when the engine ends the current frame
  28324. */
  28325. onEndFrameObservable: Observable<Engine>;
  28326. /**
  28327. * Observable raised when the engine is about to compile a shader
  28328. */
  28329. onBeforeShaderCompilationObservable: Observable<Engine>;
  28330. /**
  28331. * Observable raised when the engine has jsut compiled a shader
  28332. */
  28333. onAfterShaderCompilationObservable: Observable<Engine>;
  28334. /** @hidden */
  28335. _gl: WebGLRenderingContext;
  28336. private _renderingCanvas;
  28337. private _windowIsBackground;
  28338. private _webGLVersion;
  28339. protected _highPrecisionShadersAllowed: boolean;
  28340. /** @hidden */
  28341. readonly _shouldUseHighPrecisionShader: boolean;
  28342. /**
  28343. * Gets a boolean indicating that only power of 2 textures are supported
  28344. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28345. */
  28346. readonly needPOTTextures: boolean;
  28347. /** @hidden */
  28348. _badOS: boolean;
  28349. /** @hidden */
  28350. _badDesktopOS: boolean;
  28351. /**
  28352. * Gets the audio engine
  28353. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28354. * @ignorenaming
  28355. */
  28356. static audioEngine: IAudioEngine;
  28357. /**
  28358. * Default AudioEngine factory responsible of creating the Audio Engine.
  28359. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28360. */
  28361. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28362. /**
  28363. * Default offline support factory responsible of creating a tool used to store data locally.
  28364. * By default, this will create a Database object if the workload has been embedded.
  28365. */
  28366. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28367. private _onFocus;
  28368. private _onBlur;
  28369. private _onCanvasPointerOut;
  28370. private _onCanvasBlur;
  28371. private _onCanvasFocus;
  28372. private _onFullscreenChange;
  28373. private _onPointerLockChange;
  28374. private _hardwareScalingLevel;
  28375. /** @hidden */
  28376. _caps: EngineCapabilities;
  28377. private _pointerLockRequested;
  28378. private _isStencilEnable;
  28379. private _colorWrite;
  28380. private _loadingScreen;
  28381. /** @hidden */
  28382. _drawCalls: PerfCounter;
  28383. private _glVersion;
  28384. private _glRenderer;
  28385. private _glVendor;
  28386. private _videoTextureSupported;
  28387. private _renderingQueueLaunched;
  28388. private _activeRenderLoops;
  28389. private _deterministicLockstep;
  28390. private _lockstepMaxSteps;
  28391. /**
  28392. * Observable signaled when a context lost event is raised
  28393. */
  28394. onContextLostObservable: Observable<Engine>;
  28395. /**
  28396. * Observable signaled when a context restored event is raised
  28397. */
  28398. onContextRestoredObservable: Observable<Engine>;
  28399. private _onContextLost;
  28400. private _onContextRestored;
  28401. private _contextWasLost;
  28402. /** @hidden */
  28403. _doNotHandleContextLost: boolean;
  28404. /**
  28405. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28406. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28407. */
  28408. doNotHandleContextLost: boolean;
  28409. private _performanceMonitor;
  28410. private _fps;
  28411. private _deltaTime;
  28412. /**
  28413. * Turn this value on if you want to pause FPS computation when in background
  28414. */
  28415. disablePerformanceMonitorInBackground: boolean;
  28416. /**
  28417. * Gets the performance monitor attached to this engine
  28418. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28419. */
  28420. readonly performanceMonitor: PerformanceMonitor;
  28421. /**
  28422. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28423. */
  28424. disableVertexArrayObjects: boolean;
  28425. /** @hidden */
  28426. protected _depthCullingState: _DepthCullingState;
  28427. /** @hidden */
  28428. protected _stencilState: _StencilState;
  28429. /** @hidden */
  28430. protected _alphaState: _AlphaState;
  28431. /** @hidden */
  28432. protected _alphaMode: number;
  28433. /** @hidden */
  28434. _internalTexturesCache: InternalTexture[];
  28435. /** @hidden */
  28436. protected _activeChannel: number;
  28437. private _currentTextureChannel;
  28438. /** @hidden */
  28439. protected _boundTexturesCache: {
  28440. [key: string]: Nullable<InternalTexture>;
  28441. };
  28442. /** @hidden */
  28443. protected _currentEffect: Nullable<Effect>;
  28444. /** @hidden */
  28445. protected _currentProgram: Nullable<WebGLProgram>;
  28446. private _compiledEffects;
  28447. private _vertexAttribArraysEnabled;
  28448. /** @hidden */
  28449. protected _cachedViewport: Nullable<Viewport>;
  28450. private _cachedVertexArrayObject;
  28451. /** @hidden */
  28452. protected _cachedVertexBuffers: any;
  28453. /** @hidden */
  28454. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  28455. /** @hidden */
  28456. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28457. /** @hidden */
  28458. _currentRenderTarget: Nullable<InternalTexture>;
  28459. private _uintIndicesCurrentlySet;
  28460. private _currentBoundBuffer;
  28461. /** @hidden */
  28462. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28463. private _currentBufferPointers;
  28464. private _currentInstanceLocations;
  28465. private _currentInstanceBuffers;
  28466. private _textureUnits;
  28467. /** @hidden */
  28468. _workingCanvas: Nullable<HTMLCanvasElement>;
  28469. /** @hidden */
  28470. _workingContext: Nullable<CanvasRenderingContext2D>;
  28471. private _rescalePostProcess;
  28472. private _dummyFramebuffer;
  28473. private _externalData;
  28474. /** @hidden */
  28475. _bindedRenderFunction: any;
  28476. private _vaoRecordInProgress;
  28477. private _mustWipeVertexAttributes;
  28478. private _emptyTexture;
  28479. private _emptyCubeTexture;
  28480. private _emptyTexture3D;
  28481. /** @hidden */
  28482. _frameHandler: number;
  28483. private _nextFreeTextureSlots;
  28484. private _maxSimultaneousTextures;
  28485. private _activeRequests;
  28486. private _texturesSupported;
  28487. /** @hidden */
  28488. _textureFormatInUse: Nullable<string>;
  28489. /**
  28490. * Gets the list of texture formats supported
  28491. */
  28492. readonly texturesSupported: Array<string>;
  28493. /**
  28494. * Gets the list of texture formats in use
  28495. */
  28496. readonly textureFormatInUse: Nullable<string>;
  28497. /**
  28498. * Gets the current viewport
  28499. */
  28500. readonly currentViewport: Nullable<Viewport>;
  28501. /**
  28502. * Gets the default empty texture
  28503. */
  28504. readonly emptyTexture: InternalTexture;
  28505. /**
  28506. * Gets the default empty 3D texture
  28507. */
  28508. readonly emptyTexture3D: InternalTexture;
  28509. /**
  28510. * Gets the default empty cube texture
  28511. */
  28512. readonly emptyCubeTexture: InternalTexture;
  28513. /**
  28514. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28515. */
  28516. readonly premultipliedAlpha: boolean;
  28517. /**
  28518. * Creates a new engine
  28519. * @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
  28520. * @param antialias defines enable antialiasing (default: false)
  28521. * @param options defines further options to be sent to the getContext() function
  28522. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28523. */
  28524. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28525. /**
  28526. * Initializes a webVR display and starts listening to display change events
  28527. * The onVRDisplayChangedObservable will be notified upon these changes
  28528. * @returns The onVRDisplayChangedObservable
  28529. */
  28530. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28531. /** @hidden */
  28532. _prepareVRComponent(): void;
  28533. /** @hidden */
  28534. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  28535. /** @hidden */
  28536. _submitVRFrame(): void;
  28537. /**
  28538. * Call this function to leave webVR mode
  28539. * Will do nothing if webVR is not supported or if there is no webVR device
  28540. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28541. */
  28542. disableVR(): void;
  28543. /**
  28544. * Gets a boolean indicating that the system is in VR mode and is presenting
  28545. * @returns true if VR mode is engaged
  28546. */
  28547. isVRPresenting(): boolean;
  28548. /** @hidden */
  28549. _requestVRFrame(): void;
  28550. private _disableTouchAction;
  28551. private _rebuildInternalTextures;
  28552. private _rebuildEffects;
  28553. /**
  28554. * Gets a boolean indicating if all created effects are ready
  28555. * @returns true if all effects are ready
  28556. */
  28557. areAllEffectsReady(): boolean;
  28558. private _rebuildBuffers;
  28559. private _initGLContext;
  28560. /**
  28561. * Gets version of the current webGL context
  28562. */
  28563. readonly webGLVersion: number;
  28564. /**
  28565. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28566. */
  28567. readonly isStencilEnable: boolean;
  28568. /** @hidden */
  28569. _prepareWorkingCanvas(): void;
  28570. /**
  28571. * Reset the texture cache to empty state
  28572. */
  28573. resetTextureCache(): void;
  28574. /**
  28575. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28576. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28577. * @returns true if engine is in deterministic lock step mode
  28578. */
  28579. isDeterministicLockStep(): boolean;
  28580. /**
  28581. * Gets the max steps when engine is running in deterministic lock step
  28582. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28583. * @returns the max steps
  28584. */
  28585. getLockstepMaxSteps(): number;
  28586. /**
  28587. * Gets an object containing information about the current webGL context
  28588. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28589. */
  28590. getGlInfo(): {
  28591. vendor: string;
  28592. renderer: string;
  28593. version: string;
  28594. };
  28595. /**
  28596. * Gets current aspect ratio
  28597. * @param camera defines the camera to use to get the aspect ratio
  28598. * @param useScreen defines if screen size must be used (or the current render target if any)
  28599. * @returns a number defining the aspect ratio
  28600. */
  28601. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28602. /**
  28603. * Gets current screen aspect ratio
  28604. * @returns a number defining the aspect ratio
  28605. */
  28606. getScreenAspectRatio(): number;
  28607. /**
  28608. * Gets the current render width
  28609. * @param useScreen defines if screen size must be used (or the current render target if any)
  28610. * @returns a number defining the current render width
  28611. */
  28612. getRenderWidth(useScreen?: boolean): number;
  28613. /**
  28614. * Gets the current render height
  28615. * @param useScreen defines if screen size must be used (or the current render target if any)
  28616. * @returns a number defining the current render height
  28617. */
  28618. getRenderHeight(useScreen?: boolean): number;
  28619. /**
  28620. * Gets the HTML canvas attached with the current webGL context
  28621. * @returns a HTML canvas
  28622. */
  28623. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28624. /**
  28625. * Gets the client rect of the HTML canvas attached with the current webGL context
  28626. * @returns a client rectanglee
  28627. */
  28628. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28629. /**
  28630. * Defines the hardware scaling level.
  28631. * By default the hardware scaling level is computed from the window device ratio.
  28632. * 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.
  28633. * @param level defines the level to use
  28634. */
  28635. setHardwareScalingLevel(level: number): void;
  28636. /**
  28637. * Gets the current hardware scaling level.
  28638. * By default the hardware scaling level is computed from the window device ratio.
  28639. * 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.
  28640. * @returns a number indicating the current hardware scaling level
  28641. */
  28642. getHardwareScalingLevel(): number;
  28643. /**
  28644. * Gets the list of loaded textures
  28645. * @returns an array containing all loaded textures
  28646. */
  28647. getLoadedTexturesCache(): InternalTexture[];
  28648. /**
  28649. * Gets the object containing all engine capabilities
  28650. * @returns the EngineCapabilities object
  28651. */
  28652. getCaps(): EngineCapabilities;
  28653. /**
  28654. * Gets the current depth function
  28655. * @returns a number defining the depth function
  28656. */
  28657. getDepthFunction(): Nullable<number>;
  28658. /**
  28659. * Sets the current depth function
  28660. * @param depthFunc defines the function to use
  28661. */
  28662. setDepthFunction(depthFunc: number): void;
  28663. /**
  28664. * Sets the current depth function to GREATER
  28665. */
  28666. setDepthFunctionToGreater(): void;
  28667. /**
  28668. * Sets the current depth function to GEQUAL
  28669. */
  28670. setDepthFunctionToGreaterOrEqual(): void;
  28671. /**
  28672. * Sets the current depth function to LESS
  28673. */
  28674. setDepthFunctionToLess(): void;
  28675. private _cachedStencilBuffer;
  28676. private _cachedStencilFunction;
  28677. private _cachedStencilMask;
  28678. private _cachedStencilOperationPass;
  28679. private _cachedStencilOperationFail;
  28680. private _cachedStencilOperationDepthFail;
  28681. private _cachedStencilReference;
  28682. /**
  28683. * Caches the the state of the stencil buffer
  28684. */
  28685. cacheStencilState(): void;
  28686. /**
  28687. * Restores the state of the stencil buffer
  28688. */
  28689. restoreStencilState(): void;
  28690. /**
  28691. * Sets the current depth function to LEQUAL
  28692. */
  28693. setDepthFunctionToLessOrEqual(): void;
  28694. /**
  28695. * Gets a boolean indicating if stencil buffer is enabled
  28696. * @returns the current stencil buffer state
  28697. */
  28698. getStencilBuffer(): boolean;
  28699. /**
  28700. * Enable or disable the stencil buffer
  28701. * @param enable defines if the stencil buffer must be enabled or disabled
  28702. */
  28703. setStencilBuffer(enable: boolean): void;
  28704. /**
  28705. * Gets the current stencil mask
  28706. * @returns a number defining the new stencil mask to use
  28707. */
  28708. getStencilMask(): number;
  28709. /**
  28710. * Sets the current stencil mask
  28711. * @param mask defines the new stencil mask to use
  28712. */
  28713. setStencilMask(mask: number): void;
  28714. /**
  28715. * Gets the current stencil function
  28716. * @returns a number defining the stencil function to use
  28717. */
  28718. getStencilFunction(): number;
  28719. /**
  28720. * Gets the current stencil reference value
  28721. * @returns a number defining the stencil reference value to use
  28722. */
  28723. getStencilFunctionReference(): number;
  28724. /**
  28725. * Gets the current stencil mask
  28726. * @returns a number defining the stencil mask to use
  28727. */
  28728. getStencilFunctionMask(): number;
  28729. /**
  28730. * Sets the current stencil function
  28731. * @param stencilFunc defines the new stencil function to use
  28732. */
  28733. setStencilFunction(stencilFunc: number): void;
  28734. /**
  28735. * Sets the current stencil reference
  28736. * @param reference defines the new stencil reference to use
  28737. */
  28738. setStencilFunctionReference(reference: number): void;
  28739. /**
  28740. * Sets the current stencil mask
  28741. * @param mask defines the new stencil mask to use
  28742. */
  28743. setStencilFunctionMask(mask: number): void;
  28744. /**
  28745. * Gets the current stencil operation when stencil fails
  28746. * @returns a number defining stencil operation to use when stencil fails
  28747. */
  28748. getStencilOperationFail(): number;
  28749. /**
  28750. * Gets the current stencil operation when depth fails
  28751. * @returns a number defining stencil operation to use when depth fails
  28752. */
  28753. getStencilOperationDepthFail(): number;
  28754. /**
  28755. * Gets the current stencil operation when stencil passes
  28756. * @returns a number defining stencil operation to use when stencil passes
  28757. */
  28758. getStencilOperationPass(): number;
  28759. /**
  28760. * Sets the stencil operation to use when stencil fails
  28761. * @param operation defines the stencil operation to use when stencil fails
  28762. */
  28763. setStencilOperationFail(operation: number): void;
  28764. /**
  28765. * Sets the stencil operation to use when depth fails
  28766. * @param operation defines the stencil operation to use when depth fails
  28767. */
  28768. setStencilOperationDepthFail(operation: number): void;
  28769. /**
  28770. * Sets the stencil operation to use when stencil passes
  28771. * @param operation defines the stencil operation to use when stencil passes
  28772. */
  28773. setStencilOperationPass(operation: number): void;
  28774. /**
  28775. * Sets a boolean indicating if the dithering state is enabled or disabled
  28776. * @param value defines the dithering state
  28777. */
  28778. setDitheringState(value: boolean): void;
  28779. /**
  28780. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28781. * @param value defines the rasterizer state
  28782. */
  28783. setRasterizerState(value: boolean): void;
  28784. /**
  28785. * stop executing a render loop function and remove it from the execution array
  28786. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28787. */
  28788. stopRenderLoop(renderFunction?: () => void): void;
  28789. /** @hidden */
  28790. _renderLoop(): void;
  28791. /**
  28792. * Register and execute a render loop. The engine can have more than one render function
  28793. * @param renderFunction defines the function to continuously execute
  28794. */
  28795. runRenderLoop(renderFunction: () => void): void;
  28796. /**
  28797. * Toggle full screen mode
  28798. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28799. */
  28800. switchFullscreen(requestPointerLock: boolean): void;
  28801. /**
  28802. * Enters full screen mode
  28803. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28804. */
  28805. enterFullscreen(requestPointerLock: boolean): void;
  28806. /**
  28807. * Exits full screen mode
  28808. */
  28809. exitFullscreen(): void;
  28810. /**
  28811. * Clear the current render buffer or the current render target (if any is set up)
  28812. * @param color defines the color to use
  28813. * @param backBuffer defines if the back buffer must be cleared
  28814. * @param depth defines if the depth buffer must be cleared
  28815. * @param stencil defines if the stencil buffer must be cleared
  28816. */
  28817. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28818. /**
  28819. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28820. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28821. * @param y defines the y-coordinate of the corner of the clear rectangle
  28822. * @param width defines the width of the clear rectangle
  28823. * @param height defines the height of the clear rectangle
  28824. * @param clearColor defines the clear color
  28825. */
  28826. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28827. /**
  28828. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28829. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28830. * @param y defines the y-coordinate of the corner of the clear rectangle
  28831. * @param width defines the width of the clear rectangle
  28832. * @param height defines the height of the clear rectangle
  28833. */
  28834. enableScissor(x: number, y: number, width: number, height: number): void;
  28835. /**
  28836. * Disable previously set scissor test rectangle
  28837. */
  28838. disableScissor(): void;
  28839. private _viewportCached;
  28840. /** @hidden */
  28841. _viewport(x: number, y: number, width: number, height: number): void;
  28842. /**
  28843. * Set the WebGL's viewport
  28844. * @param viewport defines the viewport element to be used
  28845. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28846. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28847. */
  28848. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28849. /**
  28850. * Directly set the WebGL Viewport
  28851. * @param x defines the x coordinate of the viewport (in screen space)
  28852. * @param y defines the y coordinate of the viewport (in screen space)
  28853. * @param width defines the width of the viewport (in screen space)
  28854. * @param height defines the height of the viewport (in screen space)
  28855. * @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
  28856. */
  28857. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28858. /**
  28859. * Begin a new frame
  28860. */
  28861. beginFrame(): void;
  28862. /**
  28863. * Enf the current frame
  28864. */
  28865. endFrame(): void;
  28866. /**
  28867. * Resize the view according to the canvas' size
  28868. */
  28869. resize(): void;
  28870. /**
  28871. * Force a specific size of the canvas
  28872. * @param width defines the new canvas' width
  28873. * @param height defines the new canvas' height
  28874. */
  28875. setSize(width: number, height: number): void;
  28876. /**
  28877. * Binds the frame buffer to the specified texture.
  28878. * @param texture The texture to render to or null for the default canvas
  28879. * @param faceIndex The face of the texture to render to in case of cube texture
  28880. * @param requiredWidth The width of the target to render to
  28881. * @param requiredHeight The height of the target to render to
  28882. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28883. * @param depthStencilTexture The depth stencil texture to use to render
  28884. * @param lodLevel defines le lod level to bind to the frame buffer
  28885. */
  28886. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28887. /** @hidden */
  28888. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  28889. /**
  28890. * Unbind the current render target texture from the webGL context
  28891. * @param texture defines the render target texture to unbind
  28892. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28893. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28894. */
  28895. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28896. /**
  28897. * Force the mipmap generation for the given render target texture
  28898. * @param texture defines the render target texture to use
  28899. */
  28900. generateMipMapsForCubemap(texture: InternalTexture): void;
  28901. /**
  28902. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28903. */
  28904. flushFramebuffer(): void;
  28905. /**
  28906. * Unbind the current render target and bind the default framebuffer
  28907. */
  28908. restoreDefaultFramebuffer(): void;
  28909. /**
  28910. * Create an uniform buffer
  28911. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28912. * @param elements defines the content of the uniform buffer
  28913. * @returns the webGL uniform buffer
  28914. */
  28915. createUniformBuffer(elements: FloatArray): DataBuffer;
  28916. /**
  28917. * Create a dynamic uniform buffer
  28918. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28919. * @param elements defines the content of the uniform buffer
  28920. * @returns the webGL uniform buffer
  28921. */
  28922. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  28923. /**
  28924. * Update an existing uniform buffer
  28925. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28926. * @param uniformBuffer defines the target uniform buffer
  28927. * @param elements defines the content to update
  28928. * @param offset defines the offset in the uniform buffer where update should start
  28929. * @param count defines the size of the data to update
  28930. */
  28931. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28932. private _resetVertexBufferBinding;
  28933. /**
  28934. * Creates a vertex buffer
  28935. * @param data the data for the vertex buffer
  28936. * @returns the new WebGL static buffer
  28937. */
  28938. createVertexBuffer(data: DataArray): DataBuffer;
  28939. /**
  28940. * Creates a dynamic vertex buffer
  28941. * @param data the data for the dynamic vertex buffer
  28942. * @returns the new WebGL dynamic buffer
  28943. */
  28944. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  28945. /**
  28946. * Update a dynamic index buffer
  28947. * @param indexBuffer defines the target index buffer
  28948. * @param indices defines the data to update
  28949. * @param offset defines the offset in the target index buffer where update should start
  28950. */
  28951. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  28952. /**
  28953. * Updates a dynamic vertex buffer.
  28954. * @param vertexBuffer the vertex buffer to update
  28955. * @param data the data used to update the vertex buffer
  28956. * @param byteOffset the byte offset of the data
  28957. * @param byteLength the byte length of the data
  28958. */
  28959. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28960. private _resetIndexBufferBinding;
  28961. /**
  28962. * Creates a new index buffer
  28963. * @param indices defines the content of the index buffer
  28964. * @param updatable defines if the index buffer must be updatable
  28965. * @returns a new webGL buffer
  28966. */
  28967. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  28968. /**
  28969. * Bind a webGL buffer to the webGL context
  28970. * @param buffer defines the buffer to bind
  28971. */
  28972. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  28973. /**
  28974. * Bind an uniform buffer to the current webGL context
  28975. * @param buffer defines the buffer to bind
  28976. */
  28977. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  28978. /**
  28979. * Bind a buffer to the current webGL context at a given location
  28980. * @param buffer defines the buffer to bind
  28981. * @param location defines the index where to bind the buffer
  28982. */
  28983. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  28984. /**
  28985. * Bind a specific block at a given index in a specific shader program
  28986. * @param pipelineContext defines the pipeline context to use
  28987. * @param blockName defines the block name
  28988. * @param index defines the index where to bind the block
  28989. */
  28990. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  28991. private bindIndexBuffer;
  28992. private bindBuffer;
  28993. /**
  28994. * update the bound buffer with the given data
  28995. * @param data defines the data to update
  28996. */
  28997. updateArrayBuffer(data: Float32Array): void;
  28998. private _vertexAttribPointer;
  28999. private _bindIndexBufferWithCache;
  29000. private _bindVertexBuffersAttributes;
  29001. /**
  29002. * Records a vertex array object
  29003. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29004. * @param vertexBuffers defines the list of vertex buffers to store
  29005. * @param indexBuffer defines the index buffer to store
  29006. * @param effect defines the effect to store
  29007. * @returns the new vertex array object
  29008. */
  29009. recordVertexArrayObject(vertexBuffers: {
  29010. [key: string]: VertexBuffer;
  29011. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  29012. /**
  29013. * Bind a specific vertex array object
  29014. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29015. * @param vertexArrayObject defines the vertex array object to bind
  29016. * @param indexBuffer defines the index buffer to bind
  29017. */
  29018. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  29019. /**
  29020. * Bind webGl buffers directly to the webGL context
  29021. * @param vertexBuffer defines the vertex buffer to bind
  29022. * @param indexBuffer defines the index buffer to bind
  29023. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29024. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29025. * @param effect defines the effect associated with the vertex buffer
  29026. */
  29027. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  29028. private _unbindVertexArrayObject;
  29029. /**
  29030. * Bind a list of vertex buffers to the webGL context
  29031. * @param vertexBuffers defines the list of vertex buffers to bind
  29032. * @param indexBuffer defines the index buffer to bind
  29033. * @param effect defines the effect associated with the vertex buffers
  29034. */
  29035. bindBuffers(vertexBuffers: {
  29036. [key: string]: Nullable<VertexBuffer>;
  29037. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  29038. /**
  29039. * Unbind all instance attributes
  29040. */
  29041. unbindInstanceAttributes(): void;
  29042. /**
  29043. * Release and free the memory of a vertex array object
  29044. * @param vao defines the vertex array object to delete
  29045. */
  29046. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  29047. /** @hidden */
  29048. _releaseBuffer(buffer: DataBuffer): boolean;
  29049. /**
  29050. * Creates a webGL buffer to use with instanciation
  29051. * @param capacity defines the size of the buffer
  29052. * @returns the webGL buffer
  29053. */
  29054. createInstancesBuffer(capacity: number): DataBuffer;
  29055. /**
  29056. * Delete a webGL buffer used with instanciation
  29057. * @param buffer defines the webGL buffer to delete
  29058. */
  29059. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  29060. /**
  29061. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29062. * @param instancesBuffer defines the webGL buffer to update and bind
  29063. * @param data defines the data to store in the buffer
  29064. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29065. */
  29066. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  29067. /**
  29068. * Apply all cached states (depth, culling, stencil and alpha)
  29069. */
  29070. applyStates(): void;
  29071. /**
  29072. * Send a draw order
  29073. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29074. * @param indexStart defines the starting index
  29075. * @param indexCount defines the number of index to draw
  29076. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29077. */
  29078. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  29079. /**
  29080. * Draw a list of points
  29081. * @param verticesStart defines the index of first vertex to draw
  29082. * @param verticesCount defines the count of vertices to draw
  29083. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29084. */
  29085. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29086. /**
  29087. * Draw a list of unindexed primitives
  29088. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29089. * @param verticesStart defines the index of first vertex to draw
  29090. * @param verticesCount defines the count of vertices to draw
  29091. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29092. */
  29093. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29094. /**
  29095. * Draw a list of indexed primitives
  29096. * @param fillMode defines the primitive to use
  29097. * @param indexStart defines the starting index
  29098. * @param indexCount defines the number of index to draw
  29099. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29100. */
  29101. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  29102. /**
  29103. * Draw a list of unindexed primitives
  29104. * @param fillMode defines the primitive to use
  29105. * @param verticesStart defines the index of first vertex to draw
  29106. * @param verticesCount defines the count of vertices to draw
  29107. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29108. */
  29109. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  29110. private _drawMode;
  29111. /** @hidden */
  29112. _releaseEffect(effect: Effect): void;
  29113. /** @hidden */
  29114. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  29115. /**
  29116. * Create a new effect (used to store vertex/fragment shaders)
  29117. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29118. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29119. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29120. * @param samplers defines an array of string used to represent textures
  29121. * @param defines defines the string containing the defines to use to compile the shaders
  29122. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29123. * @param onCompiled defines a function to call when the effect creation is successful
  29124. * @param onError defines a function to call when the effect creation has failed
  29125. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29126. * @returns the new Effect
  29127. */
  29128. 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;
  29129. private _compileShader;
  29130. private _compileRawShader;
  29131. /**
  29132. * Directly creates a webGL program
  29133. * @param pipelineContext defines the pipeline context to attach to
  29134. * @param vertexCode defines the vertex shader code to use
  29135. * @param fragmentCode defines the fragment shader code to use
  29136. * @param context defines the webGL context to use (if not set, the current one will be used)
  29137. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29138. * @returns the new webGL program
  29139. */
  29140. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29141. /**
  29142. * Creates a webGL program
  29143. * @param pipelineContext defines the pipeline context to attach to
  29144. * @param vertexCode defines the vertex shader code to use
  29145. * @param fragmentCode defines the fragment shader code to use
  29146. * @param defines defines the string containing the defines to use to compile the shaders
  29147. * @param context defines the webGL context to use (if not set, the current one will be used)
  29148. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  29149. * @returns the new webGL program
  29150. */
  29151. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  29152. /**
  29153. * Creates a new pipeline context
  29154. * @returns the new pipeline
  29155. */
  29156. createPipelineContext(): WebGLPipelineContext;
  29157. private _createShaderProgram;
  29158. private _finalizePipelineContext;
  29159. /** @hidden */
  29160. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  29161. /** @hidden */
  29162. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  29163. /** @hidden */
  29164. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  29165. /**
  29166. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  29167. * @param pipelineContext defines the pipeline context to use
  29168. * @param uniformsNames defines the list of uniform names
  29169. * @returns an array of webGL uniform locations
  29170. */
  29171. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  29172. /**
  29173. * Gets the lsit of active attributes for a given webGL program
  29174. * @param pipelineContext defines the pipeline context to use
  29175. * @param attributesNames defines the list of attribute names to get
  29176. * @returns an array of indices indicating the offset of each attribute
  29177. */
  29178. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  29179. /**
  29180. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29181. * @param effect defines the effect to activate
  29182. */
  29183. enableEffect(effect: Nullable<Effect>): void;
  29184. /**
  29185. * Set the value of an uniform to an array of int32
  29186. * @param uniform defines the webGL uniform location where to store the value
  29187. * @param array defines the array of int32 to store
  29188. */
  29189. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29190. /**
  29191. * Set the value of an uniform to an array of int32 (stored as vec2)
  29192. * @param uniform defines the webGL uniform location where to store the value
  29193. * @param array defines the array of int32 to store
  29194. */
  29195. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29196. /**
  29197. * Set the value of an uniform to an array of int32 (stored as vec3)
  29198. * @param uniform defines the webGL uniform location where to store the value
  29199. * @param array defines the array of int32 to store
  29200. */
  29201. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29202. /**
  29203. * Set the value of an uniform to an array of int32 (stored as vec4)
  29204. * @param uniform defines the webGL uniform location where to store the value
  29205. * @param array defines the array of int32 to store
  29206. */
  29207. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29208. /**
  29209. * Set the value of an uniform to an array of float32
  29210. * @param uniform defines the webGL uniform location where to store the value
  29211. * @param array defines the array of float32 to store
  29212. */
  29213. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29214. /**
  29215. * Set the value of an uniform to an array of float32 (stored as vec2)
  29216. * @param uniform defines the webGL uniform location where to store the value
  29217. * @param array defines the array of float32 to store
  29218. */
  29219. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29220. /**
  29221. * Set the value of an uniform to an array of float32 (stored as vec3)
  29222. * @param uniform defines the webGL uniform location where to store the value
  29223. * @param array defines the array of float32 to store
  29224. */
  29225. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29226. /**
  29227. * Set the value of an uniform to an array of float32 (stored as vec4)
  29228. * @param uniform defines the webGL uniform location where to store the value
  29229. * @param array defines the array of float32 to store
  29230. */
  29231. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29232. /**
  29233. * Set the value of an uniform to an array of number
  29234. * @param uniform defines the webGL uniform location where to store the value
  29235. * @param array defines the array of number to store
  29236. */
  29237. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29238. /**
  29239. * Set the value of an uniform to an array of number (stored as vec2)
  29240. * @param uniform defines the webGL uniform location where to store the value
  29241. * @param array defines the array of number to store
  29242. */
  29243. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29244. /**
  29245. * Set the value of an uniform to an array of number (stored as vec3)
  29246. * @param uniform defines the webGL uniform location where to store the value
  29247. * @param array defines the array of number to store
  29248. */
  29249. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29250. /**
  29251. * Set the value of an uniform to an array of number (stored as vec4)
  29252. * @param uniform defines the webGL uniform location where to store the value
  29253. * @param array defines the array of number to store
  29254. */
  29255. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29256. /**
  29257. * Set the value of an uniform to an array of float32 (stored as matrices)
  29258. * @param uniform defines the webGL uniform location where to store the value
  29259. * @param matrices defines the array of float32 to store
  29260. */
  29261. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29262. /**
  29263. * Set the value of an uniform to a matrix
  29264. * @param uniform defines the webGL uniform location where to store the value
  29265. * @param matrix defines the matrix to store
  29266. */
  29267. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29268. /**
  29269. * Set the value of an uniform to a matrix (3x3)
  29270. * @param uniform defines the webGL uniform location where to store the value
  29271. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29272. */
  29273. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29274. /**
  29275. * Set the value of an uniform to a matrix (2x2)
  29276. * @param uniform defines the webGL uniform location where to store the value
  29277. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29278. */
  29279. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29280. /**
  29281. * Set the value of an uniform to a number (int)
  29282. * @param uniform defines the webGL uniform location where to store the value
  29283. * @param value defines the int number to store
  29284. */
  29285. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29286. /**
  29287. * Set the value of an uniform to a number (float)
  29288. * @param uniform defines the webGL uniform location where to store the value
  29289. * @param value defines the float number to store
  29290. */
  29291. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29292. /**
  29293. * Set the value of an uniform to a vec2
  29294. * @param uniform defines the webGL uniform location where to store the value
  29295. * @param x defines the 1st component of the value
  29296. * @param y defines the 2nd component of the value
  29297. */
  29298. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29299. /**
  29300. * Set the value of an uniform to a vec3
  29301. * @param uniform defines the webGL uniform location where to store the value
  29302. * @param x defines the 1st component of the value
  29303. * @param y defines the 2nd component of the value
  29304. * @param z defines the 3rd component of the value
  29305. */
  29306. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29307. /**
  29308. * Set the value of an uniform to a boolean
  29309. * @param uniform defines the webGL uniform location where to store the value
  29310. * @param bool defines the boolean to store
  29311. */
  29312. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29313. /**
  29314. * Set the value of an uniform to a vec4
  29315. * @param uniform defines the webGL uniform location where to store the value
  29316. * @param x defines the 1st component of the value
  29317. * @param y defines the 2nd component of the value
  29318. * @param z defines the 3rd component of the value
  29319. * @param w defines the 4th component of the value
  29320. */
  29321. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29322. /**
  29323. * Set the value of an uniform to a Color3
  29324. * @param uniform defines the webGL uniform location where to store the value
  29325. * @param color3 defines the color to store
  29326. */
  29327. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29328. /**
  29329. * Set the value of an uniform to a Color3 and an alpha value
  29330. * @param uniform defines the webGL uniform location where to store the value
  29331. * @param color3 defines the color to store
  29332. * @param alpha defines the alpha component to store
  29333. */
  29334. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29335. /**
  29336. * Sets a Color4 on a uniform variable
  29337. * @param uniform defines the uniform location
  29338. * @param color4 defines the value to be set
  29339. */
  29340. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29341. /**
  29342. * Set various states to the webGL context
  29343. * @param culling defines backface culling state
  29344. * @param zOffset defines the value to apply to zOffset (0 by default)
  29345. * @param force defines if states must be applied even if cache is up to date
  29346. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29347. */
  29348. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29349. /**
  29350. * Set the z offset to apply to current rendering
  29351. * @param value defines the offset to apply
  29352. */
  29353. setZOffset(value: number): void;
  29354. /**
  29355. * Gets the current value of the zOffset
  29356. * @returns the current zOffset state
  29357. */
  29358. getZOffset(): number;
  29359. /**
  29360. * Enable or disable depth buffering
  29361. * @param enable defines the state to set
  29362. */
  29363. setDepthBuffer(enable: boolean): void;
  29364. /**
  29365. * Gets a boolean indicating if depth writing is enabled
  29366. * @returns the current depth writing state
  29367. */
  29368. getDepthWrite(): boolean;
  29369. /**
  29370. * Enable or disable depth writing
  29371. * @param enable defines the state to set
  29372. */
  29373. setDepthWrite(enable: boolean): void;
  29374. /**
  29375. * Enable or disable color writing
  29376. * @param enable defines the state to set
  29377. */
  29378. setColorWrite(enable: boolean): void;
  29379. /**
  29380. * Gets a boolean indicating if color writing is enabled
  29381. * @returns the current color writing state
  29382. */
  29383. getColorWrite(): boolean;
  29384. /**
  29385. * Sets alpha constants used by some alpha blending modes
  29386. * @param r defines the red component
  29387. * @param g defines the green component
  29388. * @param b defines the blue component
  29389. * @param a defines the alpha component
  29390. */
  29391. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29392. /**
  29393. * Sets the current alpha mode
  29394. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29395. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29396. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29397. */
  29398. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29399. /**
  29400. * Gets the current alpha mode
  29401. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29402. * @returns the current alpha mode
  29403. */
  29404. getAlphaMode(): number;
  29405. /**
  29406. * Clears the list of texture accessible through engine.
  29407. * This can help preventing texture load conflict due to name collision.
  29408. */
  29409. clearInternalTexturesCache(): void;
  29410. /**
  29411. * Force the entire cache to be cleared
  29412. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29413. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29414. */
  29415. wipeCaches(bruteForce?: boolean): void;
  29416. /**
  29417. * Set the compressed texture format to use, based on the formats you have, and the formats
  29418. * supported by the hardware / browser.
  29419. *
  29420. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29421. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29422. * to API arguments needed to compressed textures. This puts the burden on the container
  29423. * generator to house the arcane code for determining these for current & future formats.
  29424. *
  29425. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29426. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29427. *
  29428. * Note: The result of this call is not taken into account when a texture is base64.
  29429. *
  29430. * @param formatsAvailable defines the list of those format families you have created
  29431. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29432. *
  29433. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29434. * @returns The extension selected.
  29435. */
  29436. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29437. /** @hidden */
  29438. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29439. min: number;
  29440. mag: number;
  29441. };
  29442. /** @hidden */
  29443. _createTexture(): WebGLTexture;
  29444. /**
  29445. * Usually called from Texture.ts.
  29446. * Passed information to create a WebGLTexture
  29447. * @param urlArg defines a value which contains one of the following:
  29448. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29449. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29450. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29451. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29452. * @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)
  29453. * @param scene needed for loading to the correct scene
  29454. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29455. * @param onLoad optional callback to be called upon successful completion
  29456. * @param onError optional callback to be called upon failure
  29457. * @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
  29458. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29459. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29460. * @param forcedExtension defines the extension to use to pick the right loader
  29461. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29462. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29463. */
  29464. 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;
  29465. private _rescaleTexture;
  29466. private _unpackFlipYCached;
  29467. /**
  29468. * In case you are sharing the context with other applications, it might
  29469. * be interested to not cache the unpack flip y state to ensure a consistent
  29470. * value would be set.
  29471. */
  29472. enableUnpackFlipYCached: boolean;
  29473. /** @hidden */
  29474. _unpackFlipY(value: boolean): void;
  29475. /** @hidden */
  29476. _getUnpackAlignement(): number;
  29477. /**
  29478. * Creates a dynamic texture
  29479. * @param width defines the width of the texture
  29480. * @param height defines the height of the texture
  29481. * @param generateMipMaps defines if the engine should generate the mip levels
  29482. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29483. * @returns the dynamic texture inside an InternalTexture
  29484. */
  29485. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29486. /**
  29487. * Update the sampling mode of a given texture
  29488. * @param samplingMode defines the required sampling mode
  29489. * @param texture defines the texture to update
  29490. */
  29491. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29492. /**
  29493. * Update the content of a dynamic texture
  29494. * @param texture defines the texture to update
  29495. * @param canvas defines the canvas containing the source
  29496. * @param invertY defines if data must be stored with Y axis inverted
  29497. * @param premulAlpha defines if alpha is stored as premultiplied
  29498. * @param format defines the format of the data
  29499. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29500. */
  29501. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29502. /**
  29503. * Update a video texture
  29504. * @param texture defines the texture to update
  29505. * @param video defines the video element to use
  29506. * @param invertY defines if data must be stored with Y axis inverted
  29507. */
  29508. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29509. /**
  29510. * Updates a depth texture Comparison Mode and Function.
  29511. * If the comparison Function is equal to 0, the mode will be set to none.
  29512. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29513. * @param texture The texture to set the comparison function for
  29514. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29515. */
  29516. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29517. /** @hidden */
  29518. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  29519. width: number;
  29520. height: number;
  29521. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  29522. /**
  29523. * Creates a depth stencil texture.
  29524. * This is only available in WebGL 2 or with the depth texture extension available.
  29525. * @param size The size of face edge in the texture.
  29526. * @param options The options defining the texture.
  29527. * @returns The texture
  29528. */
  29529. createDepthStencilTexture(size: number | {
  29530. width: number;
  29531. height: number;
  29532. }, options: DepthTextureCreationOptions): InternalTexture;
  29533. /**
  29534. * Creates a depth stencil texture.
  29535. * This is only available in WebGL 2 or with the depth texture extension available.
  29536. * @param size The size of face edge in the texture.
  29537. * @param options The options defining the texture.
  29538. * @returns The texture
  29539. */
  29540. private _createDepthStencilTexture;
  29541. /**
  29542. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29543. * @param renderTarget The render target to set the frame buffer for
  29544. */
  29545. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29546. /**
  29547. * Creates a new render target texture
  29548. * @param size defines the size of the texture
  29549. * @param options defines the options used to create the texture
  29550. * @returns a new render target texture stored in an InternalTexture
  29551. */
  29552. createRenderTargetTexture(size: number | {
  29553. width: number;
  29554. height: number;
  29555. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29556. /** @hidden */
  29557. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  29558. /**
  29559. * Updates the sample count of a render target texture
  29560. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29561. * @param texture defines the texture to update
  29562. * @param samples defines the sample count to set
  29563. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29564. */
  29565. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29566. /** @hidden */
  29567. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29568. /** @hidden */
  29569. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29570. /** @hidden */
  29571. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29572. /** @hidden */
  29573. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29574. /**
  29575. * @hidden
  29576. */
  29577. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29578. private _prepareWebGLTextureContinuation;
  29579. private _prepareWebGLTexture;
  29580. /** @hidden */
  29581. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29582. /** @hidden */
  29583. _releaseFramebufferObjects(texture: InternalTexture): void;
  29584. /** @hidden */
  29585. _releaseTexture(texture: InternalTexture): void;
  29586. private setProgram;
  29587. private _boundUniforms;
  29588. /**
  29589. * Binds an effect to the webGL context
  29590. * @param effect defines the effect to bind
  29591. */
  29592. bindSamplers(effect: Effect): void;
  29593. private _activateCurrentTexture;
  29594. /** @hidden */
  29595. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29596. /** @hidden */
  29597. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29598. /**
  29599. * Sets a texture to the webGL context from a postprocess
  29600. * @param channel defines the channel to use
  29601. * @param postProcess defines the source postprocess
  29602. */
  29603. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29604. /**
  29605. * Binds the output of the passed in post process to the texture channel specified
  29606. * @param channel The channel the texture should be bound to
  29607. * @param postProcess The post process which's output should be bound
  29608. */
  29609. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29610. /**
  29611. * Unbind all textures from the webGL context
  29612. */
  29613. unbindAllTextures(): void;
  29614. /**
  29615. * Sets a texture to the according uniform.
  29616. * @param channel The texture channel
  29617. * @param uniform The uniform to set
  29618. * @param texture The texture to apply
  29619. */
  29620. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29621. /**
  29622. * Sets a depth stencil texture from a render target to the according uniform.
  29623. * @param channel The texture channel
  29624. * @param uniform The uniform to set
  29625. * @param texture The render target texture containing the depth stencil texture to apply
  29626. */
  29627. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29628. private _bindSamplerUniformToChannel;
  29629. private _getTextureWrapMode;
  29630. private _setTexture;
  29631. /**
  29632. * Sets an array of texture to the webGL context
  29633. * @param channel defines the channel where the texture array must be set
  29634. * @param uniform defines the associated uniform location
  29635. * @param textures defines the array of textures to bind
  29636. */
  29637. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29638. /** @hidden */
  29639. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29640. private _setTextureParameterFloat;
  29641. private _setTextureParameterInteger;
  29642. /**
  29643. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29644. * @param x defines the x coordinate of the rectangle where pixels must be read
  29645. * @param y defines the y coordinate of the rectangle where pixels must be read
  29646. * @param width defines the width of the rectangle where pixels must be read
  29647. * @param height defines the height of the rectangle where pixels must be read
  29648. * @returns a Uint8Array containing RGBA colors
  29649. */
  29650. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29651. /**
  29652. * Add an externaly attached data from its key.
  29653. * This method call will fail and return false, if such key already exists.
  29654. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29655. * @param key the unique key that identifies the data
  29656. * @param data the data object to associate to the key for this Engine instance
  29657. * @return true if no such key were already present and the data was added successfully, false otherwise
  29658. */
  29659. addExternalData<T>(key: string, data: T): boolean;
  29660. /**
  29661. * Get an externaly attached data from its key
  29662. * @param key the unique key that identifies the data
  29663. * @return the associated data, if present (can be null), or undefined if not present
  29664. */
  29665. getExternalData<T>(key: string): T;
  29666. /**
  29667. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29668. * @param key the unique key that identifies the data
  29669. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29670. * @return the associated data, can be null if the factory returned null.
  29671. */
  29672. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29673. /**
  29674. * Remove an externaly attached data from the Engine instance
  29675. * @param key the unique key that identifies the data
  29676. * @return true if the data was successfully removed, false if it doesn't exist
  29677. */
  29678. removeExternalData(key: string): boolean;
  29679. /**
  29680. * Unbind all vertex attributes from the webGL context
  29681. */
  29682. unbindAllAttributes(): void;
  29683. /**
  29684. * 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
  29685. */
  29686. releaseEffects(): void;
  29687. /**
  29688. * Dispose and release all associated resources
  29689. */
  29690. dispose(): void;
  29691. /**
  29692. * Display the loading screen
  29693. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29694. */
  29695. displayLoadingUI(): void;
  29696. /**
  29697. * Hide the loading screen
  29698. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29699. */
  29700. hideLoadingUI(): void;
  29701. /**
  29702. * Gets the current loading screen object
  29703. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29704. */
  29705. /**
  29706. * Sets the current loading screen object
  29707. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29708. */
  29709. loadingScreen: ILoadingScreen;
  29710. /**
  29711. * Sets the current loading screen text
  29712. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29713. */
  29714. loadingUIText: string;
  29715. /**
  29716. * Sets the current loading screen background color
  29717. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29718. */
  29719. loadingUIBackgroundColor: string;
  29720. /**
  29721. * Attach a new callback raised when context lost event is fired
  29722. * @param callback defines the callback to call
  29723. */
  29724. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29725. /**
  29726. * Attach a new callback raised when context restored event is fired
  29727. * @param callback defines the callback to call
  29728. */
  29729. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29730. /**
  29731. * Gets the source code of the vertex shader associated with a specific webGL program
  29732. * @param program defines the program to use
  29733. * @returns a string containing the source code of the vertex shader associated with the program
  29734. */
  29735. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29736. /**
  29737. * Gets the source code of the fragment shader associated with a specific webGL program
  29738. * @param program defines the program to use
  29739. * @returns a string containing the source code of the fragment shader associated with the program
  29740. */
  29741. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29742. /**
  29743. * Get the current error code of the webGL context
  29744. * @returns the error code
  29745. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29746. */
  29747. getError(): number;
  29748. /**
  29749. * Gets the current framerate
  29750. * @returns a number representing the framerate
  29751. */
  29752. getFps(): number;
  29753. /**
  29754. * Gets the time spent between current and previous frame
  29755. * @returns a number representing the delta time in ms
  29756. */
  29757. getDeltaTime(): number;
  29758. private _measureFps;
  29759. /** @hidden */
  29760. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29761. private _canRenderToFloatFramebuffer;
  29762. private _canRenderToHalfFloatFramebuffer;
  29763. private _canRenderToFramebuffer;
  29764. /** @hidden */
  29765. _getWebGLTextureType(type: number): number;
  29766. /** @hidden */
  29767. _getInternalFormat(format: number): number;
  29768. /** @hidden */
  29769. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29770. /** @hidden */
  29771. _getRGBAMultiSampleBufferFormat(type: number): number;
  29772. /** @hidden */
  29773. _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;
  29774. /** @hidden */
  29775. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29776. /**
  29777. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29778. * @returns true if the engine can be created
  29779. * @ignorenaming
  29780. */
  29781. static isSupported(): boolean;
  29782. }
  29783. }
  29784. declare module "babylonjs/Materials/effect" {
  29785. import { Observable } from "babylonjs/Misc/observable";
  29786. import { Nullable } from "babylonjs/types";
  29787. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29788. import { IDisposable } from "babylonjs/scene";
  29789. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29790. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29791. import { Engine } from "babylonjs/Engines/engine";
  29792. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29793. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29794. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29795. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29796. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29797. /**
  29798. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29799. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29800. */
  29801. export class EffectFallbacks {
  29802. private _defines;
  29803. private _currentRank;
  29804. private _maxRank;
  29805. private _mesh;
  29806. /**
  29807. * Removes the fallback from the bound mesh.
  29808. */
  29809. unBindMesh(): void;
  29810. /**
  29811. * Adds a fallback on the specified property.
  29812. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29813. * @param define The name of the define in the shader
  29814. */
  29815. addFallback(rank: number, define: string): void;
  29816. /**
  29817. * Sets the mesh to use CPU skinning when needing to fallback.
  29818. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29819. * @param mesh The mesh to use the fallbacks.
  29820. */
  29821. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29822. /**
  29823. * Checks to see if more fallbacks are still availible.
  29824. */
  29825. readonly isMoreFallbacks: boolean;
  29826. /**
  29827. * Removes the defines that shoould be removed when falling back.
  29828. * @param currentDefines defines the current define statements for the shader.
  29829. * @param effect defines the current effect we try to compile
  29830. * @returns The resulting defines with defines of the current rank removed.
  29831. */
  29832. reduce(currentDefines: string, effect: Effect): string;
  29833. }
  29834. /**
  29835. * Options to be used when creating an effect.
  29836. */
  29837. export class EffectCreationOptions {
  29838. /**
  29839. * Atrributes that will be used in the shader.
  29840. */
  29841. attributes: string[];
  29842. /**
  29843. * Uniform varible names that will be set in the shader.
  29844. */
  29845. uniformsNames: string[];
  29846. /**
  29847. * Uniform buffer varible names that will be set in the shader.
  29848. */
  29849. uniformBuffersNames: string[];
  29850. /**
  29851. * Sampler texture variable names that will be set in the shader.
  29852. */
  29853. samplers: string[];
  29854. /**
  29855. * Define statements that will be set in the shader.
  29856. */
  29857. defines: any;
  29858. /**
  29859. * Possible fallbacks for this effect to improve performance when needed.
  29860. */
  29861. fallbacks: Nullable<EffectFallbacks>;
  29862. /**
  29863. * Callback that will be called when the shader is compiled.
  29864. */
  29865. onCompiled: Nullable<(effect: Effect) => void>;
  29866. /**
  29867. * Callback that will be called if an error occurs during shader compilation.
  29868. */
  29869. onError: Nullable<(effect: Effect, errors: string) => void>;
  29870. /**
  29871. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29872. */
  29873. indexParameters: any;
  29874. /**
  29875. * Max number of lights that can be used in the shader.
  29876. */
  29877. maxSimultaneousLights: number;
  29878. /**
  29879. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29880. */
  29881. transformFeedbackVaryings: Nullable<string[]>;
  29882. }
  29883. /**
  29884. * Effect containing vertex and fragment shader that can be executed on an object.
  29885. */
  29886. export class Effect implements IDisposable {
  29887. /**
  29888. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29889. */
  29890. static ShadersRepository: string;
  29891. /**
  29892. * Name of the effect.
  29893. */
  29894. name: any;
  29895. /**
  29896. * String container all the define statements that should be set on the shader.
  29897. */
  29898. defines: string;
  29899. /**
  29900. * Callback that will be called when the shader is compiled.
  29901. */
  29902. onCompiled: Nullable<(effect: Effect) => void>;
  29903. /**
  29904. * Callback that will be called if an error occurs during shader compilation.
  29905. */
  29906. onError: Nullable<(effect: Effect, errors: string) => void>;
  29907. /**
  29908. * Callback that will be called when effect is bound.
  29909. */
  29910. onBind: Nullable<(effect: Effect) => void>;
  29911. /**
  29912. * Unique ID of the effect.
  29913. */
  29914. uniqueId: number;
  29915. /**
  29916. * Observable that will be called when the shader is compiled.
  29917. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29918. */
  29919. onCompileObservable: Observable<Effect>;
  29920. /**
  29921. * Observable that will be called if an error occurs during shader compilation.
  29922. */
  29923. onErrorObservable: Observable<Effect>;
  29924. /** @hidden */
  29925. _onBindObservable: Nullable<Observable<Effect>>;
  29926. /**
  29927. * Observable that will be called when effect is bound.
  29928. */
  29929. readonly onBindObservable: Observable<Effect>;
  29930. /** @hidden */
  29931. _bonesComputationForcedToCPU: boolean;
  29932. private static _uniqueIdSeed;
  29933. private _engine;
  29934. private _uniformBuffersNames;
  29935. private _uniformsNames;
  29936. private _samplerList;
  29937. private _samplers;
  29938. private _isReady;
  29939. private _compilationError;
  29940. private _attributesNames;
  29941. private _attributes;
  29942. private _uniforms;
  29943. /**
  29944. * Key for the effect.
  29945. * @hidden
  29946. */
  29947. _key: string;
  29948. private _indexParameters;
  29949. private _fallbacks;
  29950. private _vertexSourceCode;
  29951. private _fragmentSourceCode;
  29952. private _vertexSourceCodeOverride;
  29953. private _fragmentSourceCodeOverride;
  29954. private _transformFeedbackVaryings;
  29955. /**
  29956. * Compiled shader to webGL program.
  29957. * @hidden
  29958. */
  29959. _pipelineContext: Nullable<IPipelineContext>;
  29960. private _valueCache;
  29961. private static _baseCache;
  29962. /**
  29963. * Instantiates an effect.
  29964. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29965. * @param baseName Name of the effect.
  29966. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29967. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29968. * @param samplers List of sampler variables that will be passed to the shader.
  29969. * @param engine Engine to be used to render the effect
  29970. * @param defines Define statements to be added to the shader.
  29971. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29972. * @param onCompiled Callback that will be called when the shader is compiled.
  29973. * @param onError Callback that will be called if an error occurs during shader compilation.
  29974. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29975. */
  29976. 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);
  29977. /**
  29978. * Unique key for this effect
  29979. */
  29980. readonly key: string;
  29981. /**
  29982. * If the effect has been compiled and prepared.
  29983. * @returns if the effect is compiled and prepared.
  29984. */
  29985. isReady(): boolean;
  29986. /**
  29987. * The engine the effect was initialized with.
  29988. * @returns the engine.
  29989. */
  29990. getEngine(): Engine;
  29991. /**
  29992. * The pipeline context for this effect
  29993. * @returns the associated pipeline context
  29994. */
  29995. getPipelineContext(): Nullable<IPipelineContext>;
  29996. /**
  29997. * The set of names of attribute variables for the shader.
  29998. * @returns An array of attribute names.
  29999. */
  30000. getAttributesNames(): string[];
  30001. /**
  30002. * Returns the attribute at the given index.
  30003. * @param index The index of the attribute.
  30004. * @returns The location of the attribute.
  30005. */
  30006. getAttributeLocation(index: number): number;
  30007. /**
  30008. * Returns the attribute based on the name of the variable.
  30009. * @param name of the attribute to look up.
  30010. * @returns the attribute location.
  30011. */
  30012. getAttributeLocationByName(name: string): number;
  30013. /**
  30014. * The number of attributes.
  30015. * @returns the numnber of attributes.
  30016. */
  30017. getAttributesCount(): number;
  30018. /**
  30019. * Gets the index of a uniform variable.
  30020. * @param uniformName of the uniform to look up.
  30021. * @returns the index.
  30022. */
  30023. getUniformIndex(uniformName: string): number;
  30024. /**
  30025. * Returns the attribute based on the name of the variable.
  30026. * @param uniformName of the uniform to look up.
  30027. * @returns the location of the uniform.
  30028. */
  30029. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  30030. /**
  30031. * Returns an array of sampler variable names
  30032. * @returns The array of sampler variable neames.
  30033. */
  30034. getSamplers(): string[];
  30035. /**
  30036. * The error from the last compilation.
  30037. * @returns the error string.
  30038. */
  30039. getCompilationError(): string;
  30040. /**
  30041. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  30042. * @param func The callback to be used.
  30043. */
  30044. executeWhenCompiled(func: (effect: Effect) => void): void;
  30045. private _checkIsReady;
  30046. /** @hidden */
  30047. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  30048. /** @hidden */
  30049. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  30050. /** @hidden */
  30051. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  30052. private _processShaderConversion;
  30053. private _processIncludes;
  30054. private _processPrecision;
  30055. /**
  30056. * Recompiles the webGL program
  30057. * @param vertexSourceCode The source code for the vertex shader.
  30058. * @param fragmentSourceCode The source code for the fragment shader.
  30059. * @param onCompiled Callback called when completed.
  30060. * @param onError Callback called on error.
  30061. * @hidden
  30062. */
  30063. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  30064. /**
  30065. * Prepares the effect
  30066. * @hidden
  30067. */
  30068. _prepareEffect(): void;
  30069. /**
  30070. * Checks if the effect is supported. (Must be called after compilation)
  30071. */
  30072. readonly isSupported: boolean;
  30073. /**
  30074. * Binds a texture to the engine to be used as output of the shader.
  30075. * @param channel Name of the output variable.
  30076. * @param texture Texture to bind.
  30077. * @hidden
  30078. */
  30079. _bindTexture(channel: string, texture: InternalTexture): void;
  30080. /**
  30081. * Sets a texture on the engine to be used in the shader.
  30082. * @param channel Name of the sampler variable.
  30083. * @param texture Texture to set.
  30084. */
  30085. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  30086. /**
  30087. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  30088. * @param channel Name of the sampler variable.
  30089. * @param texture Texture to set.
  30090. */
  30091. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  30092. /**
  30093. * Sets an array of textures on the engine to be used in the shader.
  30094. * @param channel Name of the variable.
  30095. * @param textures Textures to set.
  30096. */
  30097. setTextureArray(channel: string, textures: BaseTexture[]): void;
  30098. /**
  30099. * 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)
  30100. * @param channel Name of the sampler variable.
  30101. * @param postProcess Post process to get the input texture from.
  30102. */
  30103. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  30104. /**
  30105. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  30106. * 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)
  30107. * @param channel Name of the sampler variable.
  30108. * @param postProcess Post process to get the output texture from.
  30109. */
  30110. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  30111. /** @hidden */
  30112. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  30113. /** @hidden */
  30114. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  30115. /** @hidden */
  30116. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  30117. /** @hidden */
  30118. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  30119. /**
  30120. * Binds a buffer to a uniform.
  30121. * @param buffer Buffer to bind.
  30122. * @param name Name of the uniform variable to bind to.
  30123. */
  30124. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  30125. /**
  30126. * Binds block to a uniform.
  30127. * @param blockName Name of the block to bind.
  30128. * @param index Index to bind.
  30129. */
  30130. bindUniformBlock(blockName: string, index: number): void;
  30131. /**
  30132. * Sets an interger value on a uniform variable.
  30133. * @param uniformName Name of the variable.
  30134. * @param value Value to be set.
  30135. * @returns this effect.
  30136. */
  30137. setInt(uniformName: string, value: number): Effect;
  30138. /**
  30139. * Sets an int array on a uniform variable.
  30140. * @param uniformName Name of the variable.
  30141. * @param array array to be set.
  30142. * @returns this effect.
  30143. */
  30144. setIntArray(uniformName: string, array: Int32Array): Effect;
  30145. /**
  30146. * 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)
  30147. * @param uniformName Name of the variable.
  30148. * @param array array to be set.
  30149. * @returns this effect.
  30150. */
  30151. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30152. /**
  30153. * 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)
  30154. * @param uniformName Name of the variable.
  30155. * @param array array to be set.
  30156. * @returns this effect.
  30157. */
  30158. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30159. /**
  30160. * 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)
  30161. * @param uniformName Name of the variable.
  30162. * @param array array to be set.
  30163. * @returns this effect.
  30164. */
  30165. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30166. /**
  30167. * Sets an float array on a uniform variable.
  30168. * @param uniformName Name of the variable.
  30169. * @param array array to be set.
  30170. * @returns this effect.
  30171. */
  30172. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30173. /**
  30174. * 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)
  30175. * @param uniformName Name of the variable.
  30176. * @param array array to be set.
  30177. * @returns this effect.
  30178. */
  30179. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30180. /**
  30181. * 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)
  30182. * @param uniformName Name of the variable.
  30183. * @param array array to be set.
  30184. * @returns this effect.
  30185. */
  30186. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30187. /**
  30188. * 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)
  30189. * @param uniformName Name of the variable.
  30190. * @param array array to be set.
  30191. * @returns this effect.
  30192. */
  30193. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30194. /**
  30195. * Sets an array on a uniform variable.
  30196. * @param uniformName Name of the variable.
  30197. * @param array array to be set.
  30198. * @returns this effect.
  30199. */
  30200. setArray(uniformName: string, array: number[]): Effect;
  30201. /**
  30202. * 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)
  30203. * @param uniformName Name of the variable.
  30204. * @param array array to be set.
  30205. * @returns this effect.
  30206. */
  30207. setArray2(uniformName: string, array: number[]): Effect;
  30208. /**
  30209. * 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)
  30210. * @param uniformName Name of the variable.
  30211. * @param array array to be set.
  30212. * @returns this effect.
  30213. */
  30214. setArray3(uniformName: string, array: number[]): Effect;
  30215. /**
  30216. * 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)
  30217. * @param uniformName Name of the variable.
  30218. * @param array array to be set.
  30219. * @returns this effect.
  30220. */
  30221. setArray4(uniformName: string, array: number[]): Effect;
  30222. /**
  30223. * Sets matrices on a uniform variable.
  30224. * @param uniformName Name of the variable.
  30225. * @param matrices matrices to be set.
  30226. * @returns this effect.
  30227. */
  30228. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30229. /**
  30230. * Sets matrix on a uniform variable.
  30231. * @param uniformName Name of the variable.
  30232. * @param matrix matrix to be set.
  30233. * @returns this effect.
  30234. */
  30235. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30236. /**
  30237. * 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)
  30238. * @param uniformName Name of the variable.
  30239. * @param matrix matrix to be set.
  30240. * @returns this effect.
  30241. */
  30242. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30243. /**
  30244. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30245. * @param uniformName Name of the variable.
  30246. * @param matrix matrix to be set.
  30247. * @returns this effect.
  30248. */
  30249. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30250. /**
  30251. * Sets a float on a uniform variable.
  30252. * @param uniformName Name of the variable.
  30253. * @param value value to be set.
  30254. * @returns this effect.
  30255. */
  30256. setFloat(uniformName: string, value: number): Effect;
  30257. /**
  30258. * Sets a boolean on a uniform variable.
  30259. * @param uniformName Name of the variable.
  30260. * @param bool value to be set.
  30261. * @returns this effect.
  30262. */
  30263. setBool(uniformName: string, bool: boolean): Effect;
  30264. /**
  30265. * Sets a Vector2 on a uniform variable.
  30266. * @param uniformName Name of the variable.
  30267. * @param vector2 vector2 to be set.
  30268. * @returns this effect.
  30269. */
  30270. setVector2(uniformName: string, vector2: Vector2): Effect;
  30271. /**
  30272. * Sets a float2 on a uniform variable.
  30273. * @param uniformName Name of the variable.
  30274. * @param x First float in float2.
  30275. * @param y Second float in float2.
  30276. * @returns this effect.
  30277. */
  30278. setFloat2(uniformName: string, x: number, y: number): Effect;
  30279. /**
  30280. * Sets a Vector3 on a uniform variable.
  30281. * @param uniformName Name of the variable.
  30282. * @param vector3 Value to be set.
  30283. * @returns this effect.
  30284. */
  30285. setVector3(uniformName: string, vector3: Vector3): Effect;
  30286. /**
  30287. * Sets a float3 on a uniform variable.
  30288. * @param uniformName Name of the variable.
  30289. * @param x First float in float3.
  30290. * @param y Second float in float3.
  30291. * @param z Third float in float3.
  30292. * @returns this effect.
  30293. */
  30294. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30295. /**
  30296. * Sets a Vector4 on a uniform variable.
  30297. * @param uniformName Name of the variable.
  30298. * @param vector4 Value to be set.
  30299. * @returns this effect.
  30300. */
  30301. setVector4(uniformName: string, vector4: Vector4): Effect;
  30302. /**
  30303. * Sets a float4 on a uniform variable.
  30304. * @param uniformName Name of the variable.
  30305. * @param x First float in float4.
  30306. * @param y Second float in float4.
  30307. * @param z Third float in float4.
  30308. * @param w Fourth float in float4.
  30309. * @returns this effect.
  30310. */
  30311. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30312. /**
  30313. * Sets a Color3 on a uniform variable.
  30314. * @param uniformName Name of the variable.
  30315. * @param color3 Value to be set.
  30316. * @returns this effect.
  30317. */
  30318. setColor3(uniformName: string, color3: Color3): Effect;
  30319. /**
  30320. * Sets a Color4 on a uniform variable.
  30321. * @param uniformName Name of the variable.
  30322. * @param color3 Value to be set.
  30323. * @param alpha Alpha value to be set.
  30324. * @returns this effect.
  30325. */
  30326. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30327. /**
  30328. * Sets a Color4 on a uniform variable
  30329. * @param uniformName defines the name of the variable
  30330. * @param color4 defines the value to be set
  30331. * @returns this effect.
  30332. */
  30333. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30334. /** Release all associated resources */
  30335. dispose(): void;
  30336. /**
  30337. * This function will add a new shader to the shader store
  30338. * @param name the name of the shader
  30339. * @param pixelShader optional pixel shader content
  30340. * @param vertexShader optional vertex shader content
  30341. */
  30342. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30343. /**
  30344. * Store of each shader (The can be looked up using effect.key)
  30345. */
  30346. static ShadersStore: {
  30347. [key: string]: string;
  30348. };
  30349. /**
  30350. * Store of each included file for a shader (The can be looked up using effect.key)
  30351. */
  30352. static IncludesShadersStore: {
  30353. [key: string]: string;
  30354. };
  30355. /**
  30356. * Resets the cache of effects.
  30357. */
  30358. static ResetCache(): void;
  30359. }
  30360. }
  30361. declare module "babylonjs/Materials/colorCurves" {
  30362. import { Effect } from "babylonjs/Materials/effect";
  30363. /**
  30364. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30365. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30366. * 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;
  30367. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30368. */
  30369. export class ColorCurves {
  30370. private _dirty;
  30371. private _tempColor;
  30372. private _globalCurve;
  30373. private _highlightsCurve;
  30374. private _midtonesCurve;
  30375. private _shadowsCurve;
  30376. private _positiveCurve;
  30377. private _negativeCurve;
  30378. private _globalHue;
  30379. private _globalDensity;
  30380. private _globalSaturation;
  30381. private _globalExposure;
  30382. /**
  30383. * Gets the global Hue value.
  30384. * 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).
  30385. */
  30386. /**
  30387. * Sets the global Hue value.
  30388. * 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).
  30389. */
  30390. globalHue: number;
  30391. /**
  30392. * Gets the global Density value.
  30393. * 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.
  30394. * Values less than zero provide a filter of opposite hue.
  30395. */
  30396. /**
  30397. * Sets the global Density value.
  30398. * 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.
  30399. * Values less than zero provide a filter of opposite hue.
  30400. */
  30401. globalDensity: number;
  30402. /**
  30403. * Gets the global Saturation value.
  30404. * 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.
  30405. */
  30406. /**
  30407. * Sets the global Saturation value.
  30408. * 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.
  30409. */
  30410. globalSaturation: number;
  30411. /**
  30412. * Gets the global Exposure value.
  30413. * 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.
  30414. */
  30415. /**
  30416. * Sets the global Exposure value.
  30417. * 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.
  30418. */
  30419. globalExposure: number;
  30420. private _highlightsHue;
  30421. private _highlightsDensity;
  30422. private _highlightsSaturation;
  30423. private _highlightsExposure;
  30424. /**
  30425. * Gets the highlights Hue value.
  30426. * 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).
  30427. */
  30428. /**
  30429. * Sets the highlights Hue value.
  30430. * 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).
  30431. */
  30432. highlightsHue: number;
  30433. /**
  30434. * Gets the highlights Density value.
  30435. * 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.
  30436. * Values less than zero provide a filter of opposite hue.
  30437. */
  30438. /**
  30439. * Sets the highlights Density value.
  30440. * 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.
  30441. * Values less than zero provide a filter of opposite hue.
  30442. */
  30443. highlightsDensity: number;
  30444. /**
  30445. * Gets the highlights Saturation value.
  30446. * 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.
  30447. */
  30448. /**
  30449. * Sets the highlights Saturation value.
  30450. * 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.
  30451. */
  30452. highlightsSaturation: number;
  30453. /**
  30454. * Gets the highlights Exposure value.
  30455. * 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.
  30456. */
  30457. /**
  30458. * Sets the highlights Exposure value.
  30459. * 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.
  30460. */
  30461. highlightsExposure: number;
  30462. private _midtonesHue;
  30463. private _midtonesDensity;
  30464. private _midtonesSaturation;
  30465. private _midtonesExposure;
  30466. /**
  30467. * Gets the midtones Hue value.
  30468. * 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).
  30469. */
  30470. /**
  30471. * Sets the midtones Hue value.
  30472. * 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).
  30473. */
  30474. midtonesHue: number;
  30475. /**
  30476. * Gets the midtones Density value.
  30477. * 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.
  30478. * Values less than zero provide a filter of opposite hue.
  30479. */
  30480. /**
  30481. * Sets the midtones Density value.
  30482. * 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.
  30483. * Values less than zero provide a filter of opposite hue.
  30484. */
  30485. midtonesDensity: number;
  30486. /**
  30487. * Gets the midtones Saturation value.
  30488. * 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.
  30489. */
  30490. /**
  30491. * Sets the midtones Saturation value.
  30492. * 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.
  30493. */
  30494. midtonesSaturation: number;
  30495. /**
  30496. * Gets the midtones Exposure value.
  30497. * 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.
  30498. */
  30499. /**
  30500. * Sets the midtones Exposure value.
  30501. * 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.
  30502. */
  30503. midtonesExposure: number;
  30504. private _shadowsHue;
  30505. private _shadowsDensity;
  30506. private _shadowsSaturation;
  30507. private _shadowsExposure;
  30508. /**
  30509. * Gets the shadows Hue value.
  30510. * 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).
  30511. */
  30512. /**
  30513. * Sets the shadows Hue value.
  30514. * 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).
  30515. */
  30516. shadowsHue: number;
  30517. /**
  30518. * Gets the shadows Density value.
  30519. * 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.
  30520. * Values less than zero provide a filter of opposite hue.
  30521. */
  30522. /**
  30523. * Sets the shadows Density value.
  30524. * 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.
  30525. * Values less than zero provide a filter of opposite hue.
  30526. */
  30527. shadowsDensity: number;
  30528. /**
  30529. * Gets the shadows Saturation value.
  30530. * 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.
  30531. */
  30532. /**
  30533. * Sets the shadows Saturation value.
  30534. * 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.
  30535. */
  30536. shadowsSaturation: number;
  30537. /**
  30538. * Gets the shadows Exposure value.
  30539. * 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.
  30540. */
  30541. /**
  30542. * Sets the shadows Exposure value.
  30543. * 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.
  30544. */
  30545. shadowsExposure: number;
  30546. /**
  30547. * Returns the class name
  30548. * @returns The class name
  30549. */
  30550. getClassName(): string;
  30551. /**
  30552. * Binds the color curves to the shader.
  30553. * @param colorCurves The color curve to bind
  30554. * @param effect The effect to bind to
  30555. * @param positiveUniform The positive uniform shader parameter
  30556. * @param neutralUniform The neutral uniform shader parameter
  30557. * @param negativeUniform The negative uniform shader parameter
  30558. */
  30559. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30560. /**
  30561. * Prepare the list of uniforms associated with the ColorCurves effects.
  30562. * @param uniformsList The list of uniforms used in the effect
  30563. */
  30564. static PrepareUniforms(uniformsList: string[]): void;
  30565. /**
  30566. * Returns color grading data based on a hue, density, saturation and exposure value.
  30567. * @param filterHue The hue of the color filter.
  30568. * @param filterDensity The density of the color filter.
  30569. * @param saturation The saturation.
  30570. * @param exposure The exposure.
  30571. * @param result The result data container.
  30572. */
  30573. private getColorGradingDataToRef;
  30574. /**
  30575. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30576. * @param value The input slider value in range [-100,100].
  30577. * @returns Adjusted value.
  30578. */
  30579. private static applyColorGradingSliderNonlinear;
  30580. /**
  30581. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30582. * @param hue The hue (H) input.
  30583. * @param saturation The saturation (S) input.
  30584. * @param brightness The brightness (B) input.
  30585. * @result An RGBA color represented as Vector4.
  30586. */
  30587. private static fromHSBToRef;
  30588. /**
  30589. * Returns a value clamped between min and max
  30590. * @param value The value to clamp
  30591. * @param min The minimum of value
  30592. * @param max The maximum of value
  30593. * @returns The clamped value.
  30594. */
  30595. private static clamp;
  30596. /**
  30597. * Clones the current color curve instance.
  30598. * @return The cloned curves
  30599. */
  30600. clone(): ColorCurves;
  30601. /**
  30602. * Serializes the current color curve instance to a json representation.
  30603. * @return a JSON representation
  30604. */
  30605. serialize(): any;
  30606. /**
  30607. * Parses the color curve from a json representation.
  30608. * @param source the JSON source to parse
  30609. * @return The parsed curves
  30610. */
  30611. static Parse(source: any): ColorCurves;
  30612. }
  30613. }
  30614. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30615. import { Observable } from "babylonjs/Misc/observable";
  30616. import { Nullable } from "babylonjs/types";
  30617. import { Color4 } from "babylonjs/Maths/math";
  30618. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30619. import { Effect } from "babylonjs/Materials/effect";
  30620. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30621. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30622. /**
  30623. * Interface to follow in your material defines to integrate easily the
  30624. * Image proccessing functions.
  30625. * @hidden
  30626. */
  30627. export interface IImageProcessingConfigurationDefines {
  30628. IMAGEPROCESSING: boolean;
  30629. VIGNETTE: boolean;
  30630. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30631. VIGNETTEBLENDMODEOPAQUE: boolean;
  30632. TONEMAPPING: boolean;
  30633. TONEMAPPING_ACES: boolean;
  30634. CONTRAST: boolean;
  30635. EXPOSURE: boolean;
  30636. COLORCURVES: boolean;
  30637. COLORGRADING: boolean;
  30638. COLORGRADING3D: boolean;
  30639. SAMPLER3DGREENDEPTH: boolean;
  30640. SAMPLER3DBGRMAP: boolean;
  30641. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30642. }
  30643. /**
  30644. * @hidden
  30645. */
  30646. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30647. IMAGEPROCESSING: boolean;
  30648. VIGNETTE: boolean;
  30649. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30650. VIGNETTEBLENDMODEOPAQUE: boolean;
  30651. TONEMAPPING: boolean;
  30652. TONEMAPPING_ACES: boolean;
  30653. CONTRAST: boolean;
  30654. COLORCURVES: boolean;
  30655. COLORGRADING: boolean;
  30656. COLORGRADING3D: boolean;
  30657. SAMPLER3DGREENDEPTH: boolean;
  30658. SAMPLER3DBGRMAP: boolean;
  30659. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30660. EXPOSURE: boolean;
  30661. constructor();
  30662. }
  30663. /**
  30664. * This groups together the common properties used for image processing either in direct forward pass
  30665. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30666. * or not.
  30667. */
  30668. export class ImageProcessingConfiguration {
  30669. /**
  30670. * Default tone mapping applied in BabylonJS.
  30671. */
  30672. static readonly TONEMAPPING_STANDARD: number;
  30673. /**
  30674. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30675. * to other engines rendering to increase portability.
  30676. */
  30677. static readonly TONEMAPPING_ACES: number;
  30678. /**
  30679. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30680. */
  30681. colorCurves: Nullable<ColorCurves>;
  30682. private _colorCurvesEnabled;
  30683. /**
  30684. * Gets wether the color curves effect is enabled.
  30685. */
  30686. /**
  30687. * Sets wether the color curves effect is enabled.
  30688. */
  30689. colorCurvesEnabled: boolean;
  30690. private _colorGradingTexture;
  30691. /**
  30692. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30693. */
  30694. /**
  30695. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30696. */
  30697. colorGradingTexture: Nullable<BaseTexture>;
  30698. private _colorGradingEnabled;
  30699. /**
  30700. * Gets wether the color grading effect is enabled.
  30701. */
  30702. /**
  30703. * Sets wether the color grading effect is enabled.
  30704. */
  30705. colorGradingEnabled: boolean;
  30706. private _colorGradingWithGreenDepth;
  30707. /**
  30708. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30709. */
  30710. /**
  30711. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30712. */
  30713. colorGradingWithGreenDepth: boolean;
  30714. private _colorGradingBGR;
  30715. /**
  30716. * Gets wether the color grading texture contains BGR values.
  30717. */
  30718. /**
  30719. * Sets wether the color grading texture contains BGR values.
  30720. */
  30721. colorGradingBGR: boolean;
  30722. /** @hidden */
  30723. _exposure: number;
  30724. /**
  30725. * Gets the Exposure used in the effect.
  30726. */
  30727. /**
  30728. * Sets the Exposure used in the effect.
  30729. */
  30730. exposure: number;
  30731. private _toneMappingEnabled;
  30732. /**
  30733. * Gets wether the tone mapping effect is enabled.
  30734. */
  30735. /**
  30736. * Sets wether the tone mapping effect is enabled.
  30737. */
  30738. toneMappingEnabled: boolean;
  30739. private _toneMappingType;
  30740. /**
  30741. * Gets the type of tone mapping effect.
  30742. */
  30743. /**
  30744. * Sets the type of tone mapping effect used in BabylonJS.
  30745. */
  30746. toneMappingType: number;
  30747. protected _contrast: number;
  30748. /**
  30749. * Gets the contrast used in the effect.
  30750. */
  30751. /**
  30752. * Sets the contrast used in the effect.
  30753. */
  30754. contrast: number;
  30755. /**
  30756. * Vignette stretch size.
  30757. */
  30758. vignetteStretch: number;
  30759. /**
  30760. * Vignette centre X Offset.
  30761. */
  30762. vignetteCentreX: number;
  30763. /**
  30764. * Vignette centre Y Offset.
  30765. */
  30766. vignetteCentreY: number;
  30767. /**
  30768. * Vignette weight or intensity of the vignette effect.
  30769. */
  30770. vignetteWeight: number;
  30771. /**
  30772. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30773. * if vignetteEnabled is set to true.
  30774. */
  30775. vignetteColor: Color4;
  30776. /**
  30777. * Camera field of view used by the Vignette effect.
  30778. */
  30779. vignetteCameraFov: number;
  30780. private _vignetteBlendMode;
  30781. /**
  30782. * Gets the vignette blend mode allowing different kind of effect.
  30783. */
  30784. /**
  30785. * Sets the vignette blend mode allowing different kind of effect.
  30786. */
  30787. vignetteBlendMode: number;
  30788. private _vignetteEnabled;
  30789. /**
  30790. * Gets wether the vignette effect is enabled.
  30791. */
  30792. /**
  30793. * Sets wether the vignette effect is enabled.
  30794. */
  30795. vignetteEnabled: boolean;
  30796. private _applyByPostProcess;
  30797. /**
  30798. * Gets wether the image processing is applied through a post process or not.
  30799. */
  30800. /**
  30801. * Sets wether the image processing is applied through a post process or not.
  30802. */
  30803. applyByPostProcess: boolean;
  30804. private _isEnabled;
  30805. /**
  30806. * Gets wether the image processing is enabled or not.
  30807. */
  30808. /**
  30809. * Sets wether the image processing is enabled or not.
  30810. */
  30811. isEnabled: boolean;
  30812. /**
  30813. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30814. */
  30815. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30816. /**
  30817. * Method called each time the image processing information changes requires to recompile the effect.
  30818. */
  30819. protected _updateParameters(): void;
  30820. /**
  30821. * Gets the current class name.
  30822. * @return "ImageProcessingConfiguration"
  30823. */
  30824. getClassName(): string;
  30825. /**
  30826. * Prepare the list of uniforms associated with the Image Processing effects.
  30827. * @param uniforms The list of uniforms used in the effect
  30828. * @param defines the list of defines currently in use
  30829. */
  30830. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30831. /**
  30832. * Prepare the list of samplers associated with the Image Processing effects.
  30833. * @param samplersList The list of uniforms used in the effect
  30834. * @param defines the list of defines currently in use
  30835. */
  30836. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30837. /**
  30838. * Prepare the list of defines associated to the shader.
  30839. * @param defines the list of defines to complete
  30840. * @param forPostProcess Define if we are currently in post process mode or not
  30841. */
  30842. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30843. /**
  30844. * Returns true if all the image processing information are ready.
  30845. * @returns True if ready, otherwise, false
  30846. */
  30847. isReady(): boolean;
  30848. /**
  30849. * Binds the image processing to the shader.
  30850. * @param effect The effect to bind to
  30851. * @param aspectRatio Define the current aspect ratio of the effect
  30852. */
  30853. bind(effect: Effect, aspectRatio?: number): void;
  30854. /**
  30855. * Clones the current image processing instance.
  30856. * @return The cloned image processing
  30857. */
  30858. clone(): ImageProcessingConfiguration;
  30859. /**
  30860. * Serializes the current image processing instance to a json representation.
  30861. * @return a JSON representation
  30862. */
  30863. serialize(): any;
  30864. /**
  30865. * Parses the image processing from a json representation.
  30866. * @param source the JSON source to parse
  30867. * @return The parsed image processing
  30868. */
  30869. static Parse(source: any): ImageProcessingConfiguration;
  30870. private static _VIGNETTEMODE_MULTIPLY;
  30871. private static _VIGNETTEMODE_OPAQUE;
  30872. /**
  30873. * Used to apply the vignette as a mix with the pixel color.
  30874. */
  30875. static readonly VIGNETTEMODE_MULTIPLY: number;
  30876. /**
  30877. * Used to apply the vignette as a replacement of the pixel color.
  30878. */
  30879. static readonly VIGNETTEMODE_OPAQUE: number;
  30880. }
  30881. }
  30882. declare module "babylonjs/Materials/fresnelParameters" {
  30883. import { Color3 } from "babylonjs/Maths/math";
  30884. /**
  30885. * This represents all the required information to add a fresnel effect on a material:
  30886. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30887. */
  30888. export class FresnelParameters {
  30889. private _isEnabled;
  30890. /**
  30891. * Define if the fresnel effect is enable or not.
  30892. */
  30893. isEnabled: boolean;
  30894. /**
  30895. * Define the color used on edges (grazing angle)
  30896. */
  30897. leftColor: Color3;
  30898. /**
  30899. * Define the color used on center
  30900. */
  30901. rightColor: Color3;
  30902. /**
  30903. * Define bias applied to computed fresnel term
  30904. */
  30905. bias: number;
  30906. /**
  30907. * Defined the power exponent applied to fresnel term
  30908. */
  30909. power: number;
  30910. /**
  30911. * Clones the current fresnel and its valuues
  30912. * @returns a clone fresnel configuration
  30913. */
  30914. clone(): FresnelParameters;
  30915. /**
  30916. * Serializes the current fresnel parameters to a JSON representation.
  30917. * @return the JSON serialization
  30918. */
  30919. serialize(): any;
  30920. /**
  30921. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30922. * @param parsedFresnelParameters Define the JSON representation
  30923. * @returns the parsed parameters
  30924. */
  30925. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30926. }
  30927. }
  30928. declare module "babylonjs/Misc/decorators" {
  30929. import { Nullable } from "babylonjs/types";
  30930. import { Scene } from "babylonjs/scene";
  30931. import { IAnimatable } from "babylonjs/Misc/tools";
  30932. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30933. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30934. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30935. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30936. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30937. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30938. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30939. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30940. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30941. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30942. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30943. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30944. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30945. /**
  30946. * Decorator used to define property that can be serialized as reference to a camera
  30947. * @param sourceName defines the name of the property to decorate
  30948. */
  30949. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30950. /**
  30951. * Class used to help serialization objects
  30952. */
  30953. export class SerializationHelper {
  30954. /** hidden */
  30955. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30956. /** hidden */
  30957. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30958. /** hidden */
  30959. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30960. /** hidden */
  30961. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30962. /**
  30963. * Appends the serialized animations from the source animations
  30964. * @param source Source containing the animations
  30965. * @param destination Target to store the animations
  30966. */
  30967. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30968. /**
  30969. * Static function used to serialized a specific entity
  30970. * @param entity defines the entity to serialize
  30971. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30972. * @returns a JSON compatible object representing the serialization of the entity
  30973. */
  30974. static Serialize<T>(entity: T, serializationObject?: any): any;
  30975. /**
  30976. * Creates a new entity from a serialization data object
  30977. * @param creationFunction defines a function used to instanciated the new entity
  30978. * @param source defines the source serialization data
  30979. * @param scene defines the hosting scene
  30980. * @param rootUrl defines the root url for resources
  30981. * @returns a new entity
  30982. */
  30983. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30984. /**
  30985. * Clones an object
  30986. * @param creationFunction defines the function used to instanciate the new object
  30987. * @param source defines the source object
  30988. * @returns the cloned object
  30989. */
  30990. static Clone<T>(creationFunction: () => T, source: T): T;
  30991. /**
  30992. * Instanciates a new object based on a source one (some data will be shared between both object)
  30993. * @param creationFunction defines the function used to instanciate the new object
  30994. * @param source defines the source object
  30995. * @returns the new object
  30996. */
  30997. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30998. }
  30999. }
  31000. declare module "babylonjs/Cameras/camera" {
  31001. import { SmartArray } from "babylonjs/Misc/smartArray";
  31002. import { Observable } from "babylonjs/Misc/observable";
  31003. import { Nullable } from "babylonjs/types";
  31004. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  31005. import { Scene } from "babylonjs/scene";
  31006. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  31007. import { Node } from "babylonjs/node";
  31008. import { Mesh } from "babylonjs/Meshes/mesh";
  31009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31010. import { ICullable } from "babylonjs/Culling/boundingInfo";
  31011. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31012. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31013. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  31014. import { Ray } from "babylonjs/Culling/ray";
  31015. /**
  31016. * This is the base class of all the camera used in the application.
  31017. * @see http://doc.babylonjs.com/features/cameras
  31018. */
  31019. export class Camera extends Node {
  31020. /** @hidden */
  31021. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  31022. /**
  31023. * This is the default projection mode used by the cameras.
  31024. * It helps recreating a feeling of perspective and better appreciate depth.
  31025. * This is the best way to simulate real life cameras.
  31026. */
  31027. static readonly PERSPECTIVE_CAMERA: number;
  31028. /**
  31029. * This helps creating camera with an orthographic mode.
  31030. * 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.
  31031. */
  31032. static readonly ORTHOGRAPHIC_CAMERA: number;
  31033. /**
  31034. * This is the default FOV mode for perspective cameras.
  31035. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  31036. */
  31037. static readonly FOVMODE_VERTICAL_FIXED: number;
  31038. /**
  31039. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  31040. */
  31041. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  31042. /**
  31043. * This specifies ther is no need for a camera rig.
  31044. * Basically only one eye is rendered corresponding to the camera.
  31045. */
  31046. static readonly RIG_MODE_NONE: number;
  31047. /**
  31048. * Simulates a camera Rig with one blue eye and one red eye.
  31049. * This can be use with 3d blue and red glasses.
  31050. */
  31051. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  31052. /**
  31053. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  31054. */
  31055. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  31056. /**
  31057. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  31058. */
  31059. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  31060. /**
  31061. * Defines that both eyes of the camera will be rendered over under each other.
  31062. */
  31063. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  31064. /**
  31065. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  31066. */
  31067. static readonly RIG_MODE_VR: number;
  31068. /**
  31069. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  31070. */
  31071. static readonly RIG_MODE_WEBVR: number;
  31072. /**
  31073. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  31074. */
  31075. static readonly RIG_MODE_CUSTOM: number;
  31076. /**
  31077. * Defines if by default attaching controls should prevent the default javascript event to continue.
  31078. */
  31079. static ForceAttachControlToAlwaysPreventDefault: boolean;
  31080. /**
  31081. * Define the input manager associated with the camera.
  31082. */
  31083. inputs: CameraInputsManager<Camera>;
  31084. /** @hidden */
  31085. _position: Vector3;
  31086. /**
  31087. * Define the current local position of the camera in the scene
  31088. */
  31089. position: Vector3;
  31090. /**
  31091. * The vector the camera should consider as up.
  31092. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  31093. */
  31094. upVector: Vector3;
  31095. /**
  31096. * Define the current limit on the left side for an orthographic camera
  31097. * In scene unit
  31098. */
  31099. orthoLeft: Nullable<number>;
  31100. /**
  31101. * Define the current limit on the right side for an orthographic camera
  31102. * In scene unit
  31103. */
  31104. orthoRight: Nullable<number>;
  31105. /**
  31106. * Define the current limit on the bottom side for an orthographic camera
  31107. * In scene unit
  31108. */
  31109. orthoBottom: Nullable<number>;
  31110. /**
  31111. * Define the current limit on the top side for an orthographic camera
  31112. * In scene unit
  31113. */
  31114. orthoTop: Nullable<number>;
  31115. /**
  31116. * Field Of View is set in Radians. (default is 0.8)
  31117. */
  31118. fov: number;
  31119. /**
  31120. * Define the minimum distance the camera can see from.
  31121. * This is important to note that the depth buffer are not infinite and the closer it starts
  31122. * the more your scene might encounter depth fighting issue.
  31123. */
  31124. minZ: number;
  31125. /**
  31126. * Define the maximum distance the camera can see to.
  31127. * This is important to note that the depth buffer are not infinite and the further it end
  31128. * the more your scene might encounter depth fighting issue.
  31129. */
  31130. maxZ: number;
  31131. /**
  31132. * Define the default inertia of the camera.
  31133. * This helps giving a smooth feeling to the camera movement.
  31134. */
  31135. inertia: number;
  31136. /**
  31137. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31138. */
  31139. mode: number;
  31140. /**
  31141. * Define wether the camera is intermediate.
  31142. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31143. */
  31144. isIntermediate: boolean;
  31145. /**
  31146. * Define the viewport of the camera.
  31147. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31148. */
  31149. viewport: Viewport;
  31150. /**
  31151. * Restricts the camera to viewing objects with the same layerMask.
  31152. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31153. */
  31154. layerMask: number;
  31155. /**
  31156. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31157. */
  31158. fovMode: number;
  31159. /**
  31160. * Rig mode of the camera.
  31161. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31162. * This is normally controlled byt the camera themselves as internal use.
  31163. */
  31164. cameraRigMode: number;
  31165. /**
  31166. * Defines the distance between both "eyes" in case of a RIG
  31167. */
  31168. interaxialDistance: number;
  31169. /**
  31170. * Defines if stereoscopic rendering is done side by side or over under.
  31171. */
  31172. isStereoscopicSideBySide: boolean;
  31173. /**
  31174. * 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
  31175. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31176. * else in the scene.
  31177. */
  31178. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31179. /**
  31180. * When set, the camera will render to this render target instead of the default canvas
  31181. */
  31182. outputRenderTarget: Nullable<RenderTargetTexture>;
  31183. /**
  31184. * Observable triggered when the camera view matrix has changed.
  31185. */
  31186. onViewMatrixChangedObservable: Observable<Camera>;
  31187. /**
  31188. * Observable triggered when the camera Projection matrix has changed.
  31189. */
  31190. onProjectionMatrixChangedObservable: Observable<Camera>;
  31191. /**
  31192. * Observable triggered when the inputs have been processed.
  31193. */
  31194. onAfterCheckInputsObservable: Observable<Camera>;
  31195. /**
  31196. * Observable triggered when reset has been called and applied to the camera.
  31197. */
  31198. onRestoreStateObservable: Observable<Camera>;
  31199. /** @hidden */
  31200. _cameraRigParams: any;
  31201. /** @hidden */
  31202. _rigCameras: Camera[];
  31203. /** @hidden */
  31204. _rigPostProcess: Nullable<PostProcess>;
  31205. protected _webvrViewMatrix: Matrix;
  31206. /** @hidden */
  31207. _skipRendering: boolean;
  31208. /** @hidden */
  31209. _projectionMatrix: Matrix;
  31210. /** @hidden */
  31211. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31212. /** @hidden */
  31213. _activeMeshes: SmartArray<AbstractMesh>;
  31214. protected _globalPosition: Vector3;
  31215. /** hidden */
  31216. _computedViewMatrix: Matrix;
  31217. private _doNotComputeProjectionMatrix;
  31218. private _transformMatrix;
  31219. private _frustumPlanes;
  31220. private _refreshFrustumPlanes;
  31221. private _storedFov;
  31222. private _stateStored;
  31223. /**
  31224. * Instantiates a new camera object.
  31225. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31226. * @see http://doc.babylonjs.com/features/cameras
  31227. * @param name Defines the name of the camera in the scene
  31228. * @param position Defines the position of the camera
  31229. * @param scene Defines the scene the camera belongs too
  31230. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31231. */
  31232. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31233. /**
  31234. * Store current camera state (fov, position, etc..)
  31235. * @returns the camera
  31236. */
  31237. storeState(): Camera;
  31238. /**
  31239. * Restores the camera state values if it has been stored. You must call storeState() first
  31240. */
  31241. protected _restoreStateValues(): boolean;
  31242. /**
  31243. * Restored camera state. You must call storeState() first.
  31244. * @returns true if restored and false otherwise
  31245. */
  31246. restoreState(): boolean;
  31247. /**
  31248. * Gets the class name of the camera.
  31249. * @returns the class name
  31250. */
  31251. getClassName(): string;
  31252. /** @hidden */
  31253. readonly _isCamera: boolean;
  31254. /**
  31255. * Gets a string representation of the camera useful for debug purpose.
  31256. * @param fullDetails Defines that a more verboe level of logging is required
  31257. * @returns the string representation
  31258. */
  31259. toString(fullDetails?: boolean): string;
  31260. /**
  31261. * Gets the current world space position of the camera.
  31262. */
  31263. readonly globalPosition: Vector3;
  31264. /**
  31265. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31266. * @returns the active meshe list
  31267. */
  31268. getActiveMeshes(): SmartArray<AbstractMesh>;
  31269. /**
  31270. * Check wether a mesh is part of the current active mesh list of the camera
  31271. * @param mesh Defines the mesh to check
  31272. * @returns true if active, false otherwise
  31273. */
  31274. isActiveMesh(mesh: Mesh): boolean;
  31275. /**
  31276. * Is this camera ready to be used/rendered
  31277. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31278. * @return true if the camera is ready
  31279. */
  31280. isReady(completeCheck?: boolean): boolean;
  31281. /** @hidden */
  31282. _initCache(): void;
  31283. /** @hidden */
  31284. _updateCache(ignoreParentClass?: boolean): void;
  31285. /** @hidden */
  31286. _isSynchronized(): boolean;
  31287. /** @hidden */
  31288. _isSynchronizedViewMatrix(): boolean;
  31289. /** @hidden */
  31290. _isSynchronizedProjectionMatrix(): boolean;
  31291. /**
  31292. * Attach the input controls to a specific dom element to get the input from.
  31293. * @param element Defines the element the controls should be listened from
  31294. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31295. */
  31296. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31297. /**
  31298. * Detach the current controls from the specified dom element.
  31299. * @param element Defines the element to stop listening the inputs from
  31300. */
  31301. detachControl(element: HTMLElement): void;
  31302. /**
  31303. * Update the camera state according to the different inputs gathered during the frame.
  31304. */
  31305. update(): void;
  31306. /** @hidden */
  31307. _checkInputs(): void;
  31308. /** @hidden */
  31309. readonly rigCameras: Camera[];
  31310. /**
  31311. * Gets the post process used by the rig cameras
  31312. */
  31313. readonly rigPostProcess: Nullable<PostProcess>;
  31314. /**
  31315. * Internal, gets the first post proces.
  31316. * @returns the first post process to be run on this camera.
  31317. */
  31318. _getFirstPostProcess(): Nullable<PostProcess>;
  31319. private _cascadePostProcessesToRigCams;
  31320. /**
  31321. * Attach a post process to the camera.
  31322. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31323. * @param postProcess The post process to attach to the camera
  31324. * @param insertAt The position of the post process in case several of them are in use in the scene
  31325. * @returns the position the post process has been inserted at
  31326. */
  31327. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31328. /**
  31329. * Detach a post process to the camera.
  31330. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31331. * @param postProcess The post process to detach from the camera
  31332. */
  31333. detachPostProcess(postProcess: PostProcess): void;
  31334. /**
  31335. * Gets the current world matrix of the camera
  31336. */
  31337. getWorldMatrix(): Matrix;
  31338. /** @hidden */
  31339. _getViewMatrix(): Matrix;
  31340. /**
  31341. * Gets the current view matrix of the camera.
  31342. * @param force forces the camera to recompute the matrix without looking at the cached state
  31343. * @returns the view matrix
  31344. */
  31345. getViewMatrix(force?: boolean): Matrix;
  31346. /**
  31347. * Freeze the projection matrix.
  31348. * It will prevent the cache check of the camera projection compute and can speed up perf
  31349. * if no parameter of the camera are meant to change
  31350. * @param projection Defines manually a projection if necessary
  31351. */
  31352. freezeProjectionMatrix(projection?: Matrix): void;
  31353. /**
  31354. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31355. */
  31356. unfreezeProjectionMatrix(): void;
  31357. /**
  31358. * Gets the current projection matrix of the camera.
  31359. * @param force forces the camera to recompute the matrix without looking at the cached state
  31360. * @returns the projection matrix
  31361. */
  31362. getProjectionMatrix(force?: boolean): Matrix;
  31363. /**
  31364. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31365. * @returns a Matrix
  31366. */
  31367. getTransformationMatrix(): Matrix;
  31368. private _updateFrustumPlanes;
  31369. /**
  31370. * Checks if a cullable object (mesh...) is in the camera frustum
  31371. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31372. * @param target The object to check
  31373. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  31374. * @returns true if the object is in frustum otherwise false
  31375. */
  31376. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  31377. /**
  31378. * Checks if a cullable object (mesh...) is in the camera frustum
  31379. * Unlike isInFrustum this cheks the full bounding box
  31380. * @param target The object to check
  31381. * @returns true if the object is in frustum otherwise false
  31382. */
  31383. isCompletelyInFrustum(target: ICullable): boolean;
  31384. /**
  31385. * Gets a ray in the forward direction from the camera.
  31386. * @param length Defines the length of the ray to create
  31387. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31388. * @param origin Defines the start point of the ray which defaults to the camera position
  31389. * @returns the forward ray
  31390. */
  31391. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31392. /**
  31393. * Releases resources associated with this node.
  31394. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31395. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31396. */
  31397. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31398. /** @hidden */
  31399. _isLeftCamera: boolean;
  31400. /**
  31401. * Gets the left camera of a rig setup in case of Rigged Camera
  31402. */
  31403. readonly isLeftCamera: boolean;
  31404. /** @hidden */
  31405. _isRightCamera: boolean;
  31406. /**
  31407. * Gets the right camera of a rig setup in case of Rigged Camera
  31408. */
  31409. readonly isRightCamera: boolean;
  31410. /**
  31411. * Gets the left camera of a rig setup in case of Rigged Camera
  31412. */
  31413. readonly leftCamera: Nullable<FreeCamera>;
  31414. /**
  31415. * Gets the right camera of a rig setup in case of Rigged Camera
  31416. */
  31417. readonly rightCamera: Nullable<FreeCamera>;
  31418. /**
  31419. * Gets the left camera target of a rig setup in case of Rigged Camera
  31420. * @returns the target position
  31421. */
  31422. getLeftTarget(): Nullable<Vector3>;
  31423. /**
  31424. * Gets the right camera target of a rig setup in case of Rigged Camera
  31425. * @returns the target position
  31426. */
  31427. getRightTarget(): Nullable<Vector3>;
  31428. /**
  31429. * @hidden
  31430. */
  31431. setCameraRigMode(mode: number, rigParams: any): void;
  31432. /** @hidden */
  31433. static _setStereoscopicRigMode(camera: Camera): void;
  31434. /** @hidden */
  31435. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31436. /** @hidden */
  31437. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31438. /** @hidden */
  31439. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31440. /** @hidden */
  31441. _getVRProjectionMatrix(): Matrix;
  31442. protected _updateCameraRotationMatrix(): void;
  31443. protected _updateWebVRCameraRotationMatrix(): void;
  31444. /**
  31445. * This function MUST be overwritten by the different WebVR cameras available.
  31446. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31447. * @hidden
  31448. */
  31449. _getWebVRProjectionMatrix(): Matrix;
  31450. /**
  31451. * This function MUST be overwritten by the different WebVR cameras available.
  31452. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31453. * @hidden
  31454. */
  31455. _getWebVRViewMatrix(): Matrix;
  31456. /** @hidden */
  31457. setCameraRigParameter(name: string, value: any): void;
  31458. /**
  31459. * needs to be overridden by children so sub has required properties to be copied
  31460. * @hidden
  31461. */
  31462. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31463. /**
  31464. * May need to be overridden by children
  31465. * @hidden
  31466. */
  31467. _updateRigCameras(): void;
  31468. /** @hidden */
  31469. _setupInputs(): void;
  31470. /**
  31471. * Serialiaze the camera setup to a json represention
  31472. * @returns the JSON representation
  31473. */
  31474. serialize(): any;
  31475. /**
  31476. * Clones the current camera.
  31477. * @param name The cloned camera name
  31478. * @returns the cloned camera
  31479. */
  31480. clone(name: string): Camera;
  31481. /**
  31482. * Gets the direction of the camera relative to a given local axis.
  31483. * @param localAxis Defines the reference axis to provide a relative direction.
  31484. * @return the direction
  31485. */
  31486. getDirection(localAxis: Vector3): Vector3;
  31487. /**
  31488. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31489. * @param localAxis Defines the reference axis to provide a relative direction.
  31490. * @param result Defines the vector to store the result in
  31491. */
  31492. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31493. /**
  31494. * Gets a camera constructor for a given camera type
  31495. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31496. * @param name The name of the camera the result will be able to instantiate
  31497. * @param scene The scene the result will construct the camera in
  31498. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31499. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31500. * @returns a factory method to construc the camera
  31501. */
  31502. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31503. /**
  31504. * Compute the world matrix of the camera.
  31505. * @returns the camera workd matrix
  31506. */
  31507. computeWorldMatrix(): Matrix;
  31508. /**
  31509. * Parse a JSON and creates the camera from the parsed information
  31510. * @param parsedCamera The JSON to parse
  31511. * @param scene The scene to instantiate the camera in
  31512. * @returns the newly constructed camera
  31513. */
  31514. static Parse(parsedCamera: any, scene: Scene): Camera;
  31515. }
  31516. }
  31517. declare module "babylonjs/Misc/tools" {
  31518. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31519. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31520. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31521. import { Observable } from "babylonjs/Misc/observable";
  31522. import { DomManagement } from "babylonjs/Misc/domManagement";
  31523. import { WebRequest } from "babylonjs/Misc/webRequest";
  31524. import { Camera } from "babylonjs/Cameras/camera";
  31525. import { Engine } from "babylonjs/Engines/engine";
  31526. import { Animation } from "babylonjs/Animations/animation";
  31527. /**
  31528. * Interface for any object that can request an animation frame
  31529. */
  31530. export interface ICustomAnimationFrameRequester {
  31531. /**
  31532. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31533. */
  31534. renderFunction?: Function;
  31535. /**
  31536. * Called to request the next frame to render to
  31537. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31538. */
  31539. requestAnimationFrame: Function;
  31540. /**
  31541. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31542. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31543. */
  31544. requestID?: number;
  31545. }
  31546. /**
  31547. * Interface containing an array of animations
  31548. */
  31549. export interface IAnimatable {
  31550. /**
  31551. * Array of animations
  31552. */
  31553. animations: Nullable<Array<Animation>>;
  31554. }
  31555. /** Interface used by value gradients (color, factor, ...) */
  31556. export interface IValueGradient {
  31557. /**
  31558. * Gets or sets the gradient value (between 0 and 1)
  31559. */
  31560. gradient: number;
  31561. }
  31562. /** Class used to store color4 gradient */
  31563. export class ColorGradient implements IValueGradient {
  31564. /**
  31565. * Gets or sets the gradient value (between 0 and 1)
  31566. */
  31567. gradient: number;
  31568. /**
  31569. * Gets or sets first associated color
  31570. */
  31571. color1: Color4;
  31572. /**
  31573. * Gets or sets second associated color
  31574. */
  31575. color2?: Color4;
  31576. /**
  31577. * Will get a color picked randomly between color1 and color2.
  31578. * If color2 is undefined then color1 will be used
  31579. * @param result defines the target Color4 to store the result in
  31580. */
  31581. getColorToRef(result: Color4): void;
  31582. }
  31583. /** Class used to store color 3 gradient */
  31584. export class Color3Gradient implements IValueGradient {
  31585. /**
  31586. * Gets or sets the gradient value (between 0 and 1)
  31587. */
  31588. gradient: number;
  31589. /**
  31590. * Gets or sets the associated color
  31591. */
  31592. color: Color3;
  31593. }
  31594. /** Class used to store factor gradient */
  31595. export class FactorGradient implements IValueGradient {
  31596. /**
  31597. * Gets or sets the gradient value (between 0 and 1)
  31598. */
  31599. gradient: number;
  31600. /**
  31601. * Gets or sets first associated factor
  31602. */
  31603. factor1: number;
  31604. /**
  31605. * Gets or sets second associated factor
  31606. */
  31607. factor2?: number;
  31608. /**
  31609. * Will get a number picked randomly between factor1 and factor2.
  31610. * If factor2 is undefined then factor1 will be used
  31611. * @returns the picked number
  31612. */
  31613. getFactor(): number;
  31614. }
  31615. /**
  31616. * @ignore
  31617. * Application error to support additional information when loading a file
  31618. */
  31619. export class LoadFileError extends Error {
  31620. /** defines the optional web request */
  31621. request?: WebRequest | undefined;
  31622. private static _setPrototypeOf;
  31623. /**
  31624. * Creates a new LoadFileError
  31625. * @param message defines the message of the error
  31626. * @param request defines the optional web request
  31627. */
  31628. constructor(message: string,
  31629. /** defines the optional web request */
  31630. request?: WebRequest | undefined);
  31631. }
  31632. /**
  31633. * Class used to define a retry strategy when error happens while loading assets
  31634. */
  31635. export class RetryStrategy {
  31636. /**
  31637. * Function used to defines an exponential back off strategy
  31638. * @param maxRetries defines the maximum number of retries (3 by default)
  31639. * @param baseInterval defines the interval between retries
  31640. * @returns the strategy function to use
  31641. */
  31642. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31643. }
  31644. /**
  31645. * File request interface
  31646. */
  31647. export interface IFileRequest {
  31648. /**
  31649. * Raised when the request is complete (success or error).
  31650. */
  31651. onCompleteObservable: Observable<IFileRequest>;
  31652. /**
  31653. * Aborts the request for a file.
  31654. */
  31655. abort: () => void;
  31656. }
  31657. /**
  31658. * Class containing a set of static utilities functions
  31659. */
  31660. export class Tools {
  31661. /**
  31662. * Gets or sets the base URL to use to load assets
  31663. */
  31664. static BaseUrl: string;
  31665. /**
  31666. * Enable/Disable Custom HTTP Request Headers globally.
  31667. * default = false
  31668. * @see CustomRequestHeaders
  31669. */
  31670. static UseCustomRequestHeaders: boolean;
  31671. /**
  31672. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31673. * i.e. when loading files, where the server/service expects an Authorization header
  31674. */
  31675. static CustomRequestHeaders: {
  31676. [key: string]: string;
  31677. };
  31678. /**
  31679. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31680. */
  31681. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31682. /**
  31683. * Default behaviour for cors in the application.
  31684. * It can be a string if the expected behavior is identical in the entire app.
  31685. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31686. */
  31687. static CorsBehavior: string | ((url: string | string[]) => string);
  31688. /**
  31689. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31690. * @ignorenaming
  31691. */
  31692. static UseFallbackTexture: boolean;
  31693. /**
  31694. * Use this object to register external classes like custom textures or material
  31695. * to allow the laoders to instantiate them
  31696. */
  31697. static RegisteredExternalClasses: {
  31698. [key: string]: Object;
  31699. };
  31700. /**
  31701. * Texture content used if a texture cannot loaded
  31702. * @ignorenaming
  31703. */
  31704. static fallbackTexture: string;
  31705. /**
  31706. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31707. * @param u defines the coordinate on X axis
  31708. * @param v defines the coordinate on Y axis
  31709. * @param width defines the width of the source data
  31710. * @param height defines the height of the source data
  31711. * @param pixels defines the source byte array
  31712. * @param color defines the output color
  31713. */
  31714. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31715. /**
  31716. * Interpolates between a and b via alpha
  31717. * @param a The lower value (returned when alpha = 0)
  31718. * @param b The upper value (returned when alpha = 1)
  31719. * @param alpha The interpolation-factor
  31720. * @return The mixed value
  31721. */
  31722. static Mix(a: number, b: number, alpha: number): number;
  31723. /**
  31724. * Tries to instantiate a new object from a given class name
  31725. * @param className defines the class name to instantiate
  31726. * @returns the new object or null if the system was not able to do the instantiation
  31727. */
  31728. static Instantiate(className: string): any;
  31729. /**
  31730. * Provides a slice function that will work even on IE
  31731. * @param data defines the array to slice
  31732. * @param start defines the start of the data (optional)
  31733. * @param end defines the end of the data (optional)
  31734. * @returns the new sliced array
  31735. */
  31736. static Slice<T>(data: T, start?: number, end?: number): T;
  31737. /**
  31738. * Polyfill for setImmediate
  31739. * @param action defines the action to execute after the current execution block
  31740. */
  31741. static SetImmediate(action: () => void): void;
  31742. /**
  31743. * Function indicating if a number is an exponent of 2
  31744. * @param value defines the value to test
  31745. * @returns true if the value is an exponent of 2
  31746. */
  31747. static IsExponentOfTwo(value: number): boolean;
  31748. private static _tmpFloatArray;
  31749. /**
  31750. * Returns the nearest 32-bit single precision float representation of a Number
  31751. * @param value A Number. If the parameter is of a different type, it will get converted
  31752. * to a number or to NaN if it cannot be converted
  31753. * @returns number
  31754. */
  31755. static FloatRound(value: number): number;
  31756. /**
  31757. * Find the next highest power of two.
  31758. * @param x Number to start search from.
  31759. * @return Next highest power of two.
  31760. */
  31761. static CeilingPOT(x: number): number;
  31762. /**
  31763. * Find the next lowest power of two.
  31764. * @param x Number to start search from.
  31765. * @return Next lowest power of two.
  31766. */
  31767. static FloorPOT(x: number): number;
  31768. /**
  31769. * Find the nearest power of two.
  31770. * @param x Number to start search from.
  31771. * @return Next nearest power of two.
  31772. */
  31773. static NearestPOT(x: number): number;
  31774. /**
  31775. * Get the closest exponent of two
  31776. * @param value defines the value to approximate
  31777. * @param max defines the maximum value to return
  31778. * @param mode defines how to define the closest value
  31779. * @returns closest exponent of two of the given value
  31780. */
  31781. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31782. /**
  31783. * Extracts the filename from a path
  31784. * @param path defines the path to use
  31785. * @returns the filename
  31786. */
  31787. static GetFilename(path: string): string;
  31788. /**
  31789. * Extracts the "folder" part of a path (everything before the filename).
  31790. * @param uri The URI to extract the info from
  31791. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31792. * @returns The "folder" part of the path
  31793. */
  31794. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31795. /**
  31796. * Extracts text content from a DOM element hierarchy
  31797. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31798. */
  31799. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31800. /**
  31801. * Convert an angle in radians to degrees
  31802. * @param angle defines the angle to convert
  31803. * @returns the angle in degrees
  31804. */
  31805. static ToDegrees(angle: number): number;
  31806. /**
  31807. * Convert an angle in degrees to radians
  31808. * @param angle defines the angle to convert
  31809. * @returns the angle in radians
  31810. */
  31811. static ToRadians(angle: number): number;
  31812. /**
  31813. * Encode a buffer to a base64 string
  31814. * @param buffer defines the buffer to encode
  31815. * @returns the encoded string
  31816. */
  31817. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31818. /**
  31819. * Extracts minimum and maximum values from a list of indexed positions
  31820. * @param positions defines the positions to use
  31821. * @param indices defines the indices to the positions
  31822. * @param indexStart defines the start index
  31823. * @param indexCount defines the end index
  31824. * @param bias defines bias value to add to the result
  31825. * @return minimum and maximum values
  31826. */
  31827. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31828. minimum: Vector3;
  31829. maximum: Vector3;
  31830. };
  31831. /**
  31832. * Extracts minimum and maximum values from a list of positions
  31833. * @param positions defines the positions to use
  31834. * @param start defines the start index in the positions array
  31835. * @param count defines the number of positions to handle
  31836. * @param bias defines bias value to add to the result
  31837. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31838. * @return minimum and maximum values
  31839. */
  31840. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31841. minimum: Vector3;
  31842. maximum: Vector3;
  31843. };
  31844. /**
  31845. * Returns an array if obj is not an array
  31846. * @param obj defines the object to evaluate as an array
  31847. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31848. * @returns either obj directly if obj is an array or a new array containing obj
  31849. */
  31850. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31851. /**
  31852. * Gets the pointer prefix to use
  31853. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31854. */
  31855. static GetPointerPrefix(): string;
  31856. /**
  31857. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31858. * @param func - the function to be called
  31859. * @param requester - the object that will request the next frame. Falls back to window.
  31860. * @returns frame number
  31861. */
  31862. static QueueNewFrame(func: () => void, requester?: any): number;
  31863. /**
  31864. * Ask the browser to promote the current element to fullscreen rendering mode
  31865. * @param element defines the DOM element to promote
  31866. */
  31867. static RequestFullscreen(element: HTMLElement): void;
  31868. /**
  31869. * Asks the browser to exit fullscreen mode
  31870. */
  31871. static ExitFullscreen(): void;
  31872. /**
  31873. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31874. * @param url define the url we are trying
  31875. * @param element define the dom element where to configure the cors policy
  31876. */
  31877. static SetCorsBehavior(url: string | string[], element: {
  31878. crossOrigin: string | null;
  31879. }): void;
  31880. /**
  31881. * Removes unwanted characters from an url
  31882. * @param url defines the url to clean
  31883. * @returns the cleaned url
  31884. */
  31885. static CleanUrl(url: string): string;
  31886. /**
  31887. * Gets or sets a function used to pre-process url before using them to load assets
  31888. */
  31889. static PreprocessUrl: (url: string) => string;
  31890. /**
  31891. * Loads an image as an HTMLImageElement.
  31892. * @param input url string, ArrayBuffer, or Blob to load
  31893. * @param onLoad callback called when the image successfully loads
  31894. * @param onError callback called when the image fails to load
  31895. * @param offlineProvider offline provider for caching
  31896. * @returns the HTMLImageElement of the loaded image
  31897. */
  31898. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31899. /**
  31900. * Loads a file
  31901. * @param url url string, ArrayBuffer, or Blob to load
  31902. * @param onSuccess callback called when the file successfully loads
  31903. * @param onProgress callback called while file is loading (if the server supports this mode)
  31904. * @param offlineProvider defines the offline provider for caching
  31905. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31906. * @param onError callback called when the file fails to load
  31907. * @returns a file request object
  31908. */
  31909. 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;
  31910. /**
  31911. * Load a script (identified by an url). When the url returns, the
  31912. * content of this file is added into a new script element, attached to the DOM (body element)
  31913. * @param scriptUrl defines the url of the script to laod
  31914. * @param onSuccess defines the callback called when the script is loaded
  31915. * @param onError defines the callback to call if an error occurs
  31916. * @param scriptId defines the id of the script element
  31917. */
  31918. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31919. /**
  31920. * Load an asynchronous script (identified by an url). When the url returns, the
  31921. * content of this file is added into a new script element, attached to the DOM (body element)
  31922. * @param scriptUrl defines the url of the script to laod
  31923. * @param scriptId defines the id of the script element
  31924. * @returns a promise request object
  31925. */
  31926. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31927. /**
  31928. * Loads a file from a blob
  31929. * @param fileToLoad defines the blob to use
  31930. * @param callback defines the callback to call when data is loaded
  31931. * @param progressCallback defines the callback to call during loading process
  31932. * @returns a file request object
  31933. */
  31934. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31935. /**
  31936. * Loads a file
  31937. * @param fileToLoad defines the file to load
  31938. * @param callback defines the callback to call when data is loaded
  31939. * @param progressCallBack defines the callback to call during loading process
  31940. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31941. * @returns a file request object
  31942. */
  31943. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31944. /**
  31945. * Creates a data url from a given string content
  31946. * @param content defines the content to convert
  31947. * @returns the new data url link
  31948. */
  31949. static FileAsURL(content: string): string;
  31950. /**
  31951. * Format the given number to a specific decimal format
  31952. * @param value defines the number to format
  31953. * @param decimals defines the number of decimals to use
  31954. * @returns the formatted string
  31955. */
  31956. static Format(value: number, decimals?: number): string;
  31957. /**
  31958. * Checks if a given vector is inside a specific range
  31959. * @param v defines the vector to test
  31960. * @param min defines the minimum range
  31961. * @param max defines the maximum range
  31962. */
  31963. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31964. /**
  31965. * Tries to copy an object by duplicating every property
  31966. * @param source defines the source object
  31967. * @param destination defines the target object
  31968. * @param doNotCopyList defines a list of properties to avoid
  31969. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31970. */
  31971. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31972. /**
  31973. * Gets a boolean indicating if the given object has no own property
  31974. * @param obj defines the object to test
  31975. * @returns true if object has no own property
  31976. */
  31977. static IsEmpty(obj: any): boolean;
  31978. /**
  31979. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31980. * @param str Source string
  31981. * @param suffix Suffix to search for in the source string
  31982. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31983. */
  31984. static EndsWith(str: string, suffix: string): boolean;
  31985. /**
  31986. * Function used to register events at window level
  31987. * @param events defines the events to register
  31988. */
  31989. static RegisterTopRootEvents(events: {
  31990. name: string;
  31991. handler: Nullable<(e: FocusEvent) => any>;
  31992. }[]): void;
  31993. /**
  31994. * Function used to unregister events from window level
  31995. * @param events defines the events to unregister
  31996. */
  31997. static UnregisterTopRootEvents(events: {
  31998. name: string;
  31999. handler: Nullable<(e: FocusEvent) => any>;
  32000. }[]): void;
  32001. /**
  32002. * @ignore
  32003. */
  32004. static _ScreenshotCanvas: HTMLCanvasElement;
  32005. /**
  32006. * Dumps the current bound framebuffer
  32007. * @param width defines the rendering width
  32008. * @param height defines the rendering height
  32009. * @param engine defines the hosting engine
  32010. * @param successCallback defines the callback triggered once the data are available
  32011. * @param mimeType defines the mime type of the result
  32012. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  32013. */
  32014. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32015. /**
  32016. * Converts the canvas data to blob.
  32017. * This acts as a polyfill for browsers not supporting the to blob function.
  32018. * @param canvas Defines the canvas to extract the data from
  32019. * @param successCallback Defines the callback triggered once the data are available
  32020. * @param mimeType Defines the mime type of the result
  32021. */
  32022. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  32023. /**
  32024. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  32025. * @param successCallback defines the callback triggered once the data are available
  32026. * @param mimeType defines the mime type of the result
  32027. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  32028. */
  32029. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  32030. /**
  32031. * Downloads a blob in the browser
  32032. * @param blob defines the blob to download
  32033. * @param fileName defines the name of the downloaded file
  32034. */
  32035. static Download(blob: Blob, fileName: string): void;
  32036. /**
  32037. * Captures a screenshot of the current rendering
  32038. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32039. * @param engine defines the rendering engine
  32040. * @param camera defines the source camera
  32041. * @param size This parameter can be set to a single number or to an object with the
  32042. * following (optional) properties: precision, width, height. If a single number is passed,
  32043. * it will be used for both width and height. If an object is passed, the screenshot size
  32044. * will be derived from the parameters. The precision property is a multiplier allowing
  32045. * rendering at a higher or lower resolution
  32046. * @param successCallback defines the callback receives a single parameter which contains the
  32047. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32048. * src parameter of an <img> to display it
  32049. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  32050. * Check your browser for supported MIME types
  32051. */
  32052. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  32053. /**
  32054. * Generates an image screenshot from the specified camera.
  32055. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  32056. * @param engine The engine to use for rendering
  32057. * @param camera The camera to use for rendering
  32058. * @param size This parameter can be set to a single number or to an object with the
  32059. * following (optional) properties: precision, width, height. If a single number is passed,
  32060. * it will be used for both width and height. If an object is passed, the screenshot size
  32061. * will be derived from the parameters. The precision property is a multiplier allowing
  32062. * rendering at a higher or lower resolution
  32063. * @param successCallback The callback receives a single parameter which contains the
  32064. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  32065. * src parameter of an <img> to display it
  32066. * @param mimeType The MIME type of the screenshot image (default: image/png).
  32067. * Check your browser for supported MIME types
  32068. * @param samples Texture samples (default: 1)
  32069. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  32070. * @param fileName A name for for the downloaded file.
  32071. */
  32072. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  32073. /**
  32074. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  32075. * Be aware Math.random() could cause collisions, but:
  32076. * "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"
  32077. * @returns a pseudo random id
  32078. */
  32079. static RandomId(): string;
  32080. /**
  32081. * Test if the given uri is a base64 string
  32082. * @param uri The uri to test
  32083. * @return True if the uri is a base64 string or false otherwise
  32084. */
  32085. static IsBase64(uri: string): boolean;
  32086. /**
  32087. * Decode the given base64 uri.
  32088. * @param uri The uri to decode
  32089. * @return The decoded base64 data.
  32090. */
  32091. static DecodeBase64(uri: string): ArrayBuffer;
  32092. /**
  32093. * Gets the absolute url.
  32094. * @param url the input url
  32095. * @return the absolute url
  32096. */
  32097. static GetAbsoluteUrl(url: string): string;
  32098. /**
  32099. * No log
  32100. */
  32101. static readonly NoneLogLevel: number;
  32102. /**
  32103. * Only message logs
  32104. */
  32105. static readonly MessageLogLevel: number;
  32106. /**
  32107. * Only warning logs
  32108. */
  32109. static readonly WarningLogLevel: number;
  32110. /**
  32111. * Only error logs
  32112. */
  32113. static readonly ErrorLogLevel: number;
  32114. /**
  32115. * All logs
  32116. */
  32117. static readonly AllLogLevel: number;
  32118. /**
  32119. * Gets a value indicating the number of loading errors
  32120. * @ignorenaming
  32121. */
  32122. static readonly errorsCount: number;
  32123. /**
  32124. * Callback called when a new log is added
  32125. */
  32126. static OnNewCacheEntry: (entry: string) => void;
  32127. /**
  32128. * Log a message to the console
  32129. * @param message defines the message to log
  32130. */
  32131. static Log(message: string): void;
  32132. /**
  32133. * Write a warning message to the console
  32134. * @param message defines the message to log
  32135. */
  32136. static Warn(message: string): void;
  32137. /**
  32138. * Write an error message to the console
  32139. * @param message defines the message to log
  32140. */
  32141. static Error(message: string): void;
  32142. /**
  32143. * Gets current log cache (list of logs)
  32144. */
  32145. static readonly LogCache: string;
  32146. /**
  32147. * Clears the log cache
  32148. */
  32149. static ClearLogCache(): void;
  32150. /**
  32151. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32152. */
  32153. static LogLevels: number;
  32154. /**
  32155. * Checks if the loaded document was accessed via `file:`-Protocol.
  32156. * @returns boolean
  32157. */
  32158. static IsFileURL(): boolean;
  32159. /**
  32160. * Checks if the window object exists
  32161. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32162. */
  32163. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32164. /**
  32165. * No performance log
  32166. */
  32167. static readonly PerformanceNoneLogLevel: number;
  32168. /**
  32169. * Use user marks to log performance
  32170. */
  32171. static readonly PerformanceUserMarkLogLevel: number;
  32172. /**
  32173. * Log performance to the console
  32174. */
  32175. static readonly PerformanceConsoleLogLevel: number;
  32176. private static _performance;
  32177. /**
  32178. * Sets the current performance log level
  32179. */
  32180. static PerformanceLogLevel: number;
  32181. private static _StartPerformanceCounterDisabled;
  32182. private static _EndPerformanceCounterDisabled;
  32183. private static _StartUserMark;
  32184. private static _EndUserMark;
  32185. private static _StartPerformanceConsole;
  32186. private static _EndPerformanceConsole;
  32187. /**
  32188. * Starts a performance counter
  32189. */
  32190. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32191. /**
  32192. * Ends a specific performance coutner
  32193. */
  32194. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32195. /**
  32196. * Gets either window.performance.now() if supported or Date.now() else
  32197. */
  32198. static readonly Now: number;
  32199. /**
  32200. * This method will return the name of the class used to create the instance of the given object.
  32201. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32202. * @param object the object to get the class name from
  32203. * @param isType defines if the object is actually a type
  32204. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32205. */
  32206. static GetClassName(object: any, isType?: boolean): string;
  32207. /**
  32208. * Gets the first element of an array satisfying a given predicate
  32209. * @param array defines the array to browse
  32210. * @param predicate defines the predicate to use
  32211. * @returns null if not found or the element
  32212. */
  32213. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32214. /**
  32215. * This method will return the name of the full name of the class, including its owning module (if any).
  32216. * 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).
  32217. * @param object the object to get the class name from
  32218. * @param isType defines if the object is actually a type
  32219. * @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.
  32220. * @ignorenaming
  32221. */
  32222. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32223. /**
  32224. * Returns a promise that resolves after the given amount of time.
  32225. * @param delay Number of milliseconds to delay
  32226. * @returns Promise that resolves after the given amount of time
  32227. */
  32228. static DelayAsync(delay: number): Promise<void>;
  32229. /**
  32230. * Gets the current gradient from an array of IValueGradient
  32231. * @param ratio defines the current ratio to get
  32232. * @param gradients defines the array of IValueGradient
  32233. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32234. */
  32235. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32236. }
  32237. /**
  32238. * This class is used to track a performance counter which is number based.
  32239. * The user has access to many properties which give statistics of different nature.
  32240. *
  32241. * The implementer can track two kinds of Performance Counter: time and count.
  32242. * 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.
  32243. * 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.
  32244. */
  32245. export class PerfCounter {
  32246. /**
  32247. * Gets or sets a global boolean to turn on and off all the counters
  32248. */
  32249. static Enabled: boolean;
  32250. /**
  32251. * Returns the smallest value ever
  32252. */
  32253. readonly min: number;
  32254. /**
  32255. * Returns the biggest value ever
  32256. */
  32257. readonly max: number;
  32258. /**
  32259. * Returns the average value since the performance counter is running
  32260. */
  32261. readonly average: number;
  32262. /**
  32263. * Returns the average value of the last second the counter was monitored
  32264. */
  32265. readonly lastSecAverage: number;
  32266. /**
  32267. * Returns the current value
  32268. */
  32269. readonly current: number;
  32270. /**
  32271. * Gets the accumulated total
  32272. */
  32273. readonly total: number;
  32274. /**
  32275. * Gets the total value count
  32276. */
  32277. readonly count: number;
  32278. /**
  32279. * Creates a new counter
  32280. */
  32281. constructor();
  32282. /**
  32283. * Call this method to start monitoring a new frame.
  32284. * 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.
  32285. */
  32286. fetchNewFrame(): void;
  32287. /**
  32288. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32289. * @param newCount the count value to add to the monitored count
  32290. * @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.
  32291. */
  32292. addCount(newCount: number, fetchResult: boolean): void;
  32293. /**
  32294. * Start monitoring this performance counter
  32295. */
  32296. beginMonitoring(): void;
  32297. /**
  32298. * Compute the time lapsed since the previous beginMonitoring() call.
  32299. * @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
  32300. */
  32301. endMonitoring(newFrame?: boolean): void;
  32302. private _fetchResult;
  32303. private _startMonitoringTime;
  32304. private _min;
  32305. private _max;
  32306. private _average;
  32307. private _current;
  32308. private _totalValueCount;
  32309. private _totalAccumulated;
  32310. private _lastSecAverage;
  32311. private _lastSecAccumulated;
  32312. private _lastSecTime;
  32313. private _lastSecValueCount;
  32314. }
  32315. /**
  32316. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32317. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32318. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32319. * @param name The name of the class, case should be preserved
  32320. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32321. */
  32322. export function className(name: string, module?: string): (target: Object) => void;
  32323. /**
  32324. * An implementation of a loop for asynchronous functions.
  32325. */
  32326. export class AsyncLoop {
  32327. /**
  32328. * Defines the number of iterations for the loop
  32329. */
  32330. iterations: number;
  32331. /**
  32332. * Defines the current index of the loop.
  32333. */
  32334. index: number;
  32335. private _done;
  32336. private _fn;
  32337. private _successCallback;
  32338. /**
  32339. * Constructor.
  32340. * @param iterations the number of iterations.
  32341. * @param func the function to run each iteration
  32342. * @param successCallback the callback that will be called upon succesful execution
  32343. * @param offset starting offset.
  32344. */
  32345. constructor(
  32346. /**
  32347. * Defines the number of iterations for the loop
  32348. */
  32349. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32350. /**
  32351. * Execute the next iteration. Must be called after the last iteration was finished.
  32352. */
  32353. executeNext(): void;
  32354. /**
  32355. * Break the loop and run the success callback.
  32356. */
  32357. breakLoop(): void;
  32358. /**
  32359. * Create and run an async loop.
  32360. * @param iterations the number of iterations.
  32361. * @param fn the function to run each iteration
  32362. * @param successCallback the callback that will be called upon succesful execution
  32363. * @param offset starting offset.
  32364. * @returns the created async loop object
  32365. */
  32366. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32367. /**
  32368. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32369. * @param iterations total number of iterations
  32370. * @param syncedIterations number of synchronous iterations in each async iteration.
  32371. * @param fn the function to call each iteration.
  32372. * @param callback a success call back that will be called when iterating stops.
  32373. * @param breakFunction a break condition (optional)
  32374. * @param timeout timeout settings for the setTimeout function. default - 0.
  32375. * @returns the created async loop object
  32376. */
  32377. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32378. }
  32379. }
  32380. declare module "babylonjs/Collisions/collisionCoordinator" {
  32381. import { Nullable } from "babylonjs/types";
  32382. import { Scene } from "babylonjs/scene";
  32383. import { Vector3 } from "babylonjs/Maths/math";
  32384. import { Collider } from "babylonjs/Collisions/collider";
  32385. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32386. /** @hidden */
  32387. export interface ICollisionCoordinator {
  32388. createCollider(): Collider;
  32389. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32390. init(scene: Scene): void;
  32391. }
  32392. /** @hidden */
  32393. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32394. private _scene;
  32395. private _scaledPosition;
  32396. private _scaledVelocity;
  32397. private _finalPosition;
  32398. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32399. createCollider(): Collider;
  32400. init(scene: Scene): void;
  32401. private _collideWithWorld;
  32402. }
  32403. }
  32404. declare module "babylonjs/Inputs/scene.inputManager" {
  32405. import { Nullable } from "babylonjs/types";
  32406. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32407. import { Vector2 } from "babylonjs/Maths/math";
  32408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32409. import { Scene } from "babylonjs/scene";
  32410. /**
  32411. * Class used to manage all inputs for the scene.
  32412. */
  32413. export class InputManager {
  32414. /** The distance in pixel that you have to move to prevent some events */
  32415. static DragMovementThreshold: number;
  32416. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32417. static LongPressDelay: number;
  32418. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32419. static DoubleClickDelay: number;
  32420. /** If you need to check double click without raising a single click at first click, enable this flag */
  32421. static ExclusiveDoubleClickMode: boolean;
  32422. private _wheelEventName;
  32423. private _onPointerMove;
  32424. private _onPointerDown;
  32425. private _onPointerUp;
  32426. private _initClickEvent;
  32427. private _initActionManager;
  32428. private _delayedSimpleClick;
  32429. private _delayedSimpleClickTimeout;
  32430. private _previousDelayedSimpleClickTimeout;
  32431. private _meshPickProceed;
  32432. private _previousButtonPressed;
  32433. private _currentPickResult;
  32434. private _previousPickResult;
  32435. private _totalPointersPressed;
  32436. private _doubleClickOccured;
  32437. private _pointerOverMesh;
  32438. private _pickedDownMesh;
  32439. private _pickedUpMesh;
  32440. private _pointerX;
  32441. private _pointerY;
  32442. private _unTranslatedPointerX;
  32443. private _unTranslatedPointerY;
  32444. private _startingPointerPosition;
  32445. private _previousStartingPointerPosition;
  32446. private _startingPointerTime;
  32447. private _previousStartingPointerTime;
  32448. private _pointerCaptures;
  32449. private _onKeyDown;
  32450. private _onKeyUp;
  32451. private _onCanvasFocusObserver;
  32452. private _onCanvasBlurObserver;
  32453. private _scene;
  32454. /**
  32455. * Creates a new InputManager
  32456. * @param scene defines the hosting scene
  32457. */
  32458. constructor(scene: Scene);
  32459. /**
  32460. * Gets the mesh that is currently under the pointer
  32461. */
  32462. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32463. /**
  32464. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  32465. */
  32466. readonly unTranslatedPointer: Vector2;
  32467. /**
  32468. * Gets or sets the current on-screen X position of the pointer
  32469. */
  32470. pointerX: number;
  32471. /**
  32472. * Gets or sets the current on-screen Y position of the pointer
  32473. */
  32474. pointerY: number;
  32475. private _updatePointerPosition;
  32476. private _processPointerMove;
  32477. private _setRayOnPointerInfo;
  32478. private _checkPrePointerObservable;
  32479. /**
  32480. * Use this method to simulate a pointer move on a mesh
  32481. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32482. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32483. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32484. */
  32485. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32486. /**
  32487. * Use this method to simulate a pointer down on a mesh
  32488. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32489. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32490. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32491. */
  32492. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  32493. private _processPointerDown;
  32494. /** @hidden */
  32495. _isPointerSwiping(): boolean;
  32496. /**
  32497. * Use this method to simulate a pointer up on a mesh
  32498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32501. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32502. */
  32503. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  32504. private _processPointerUp;
  32505. /**
  32506. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32507. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32508. * @returns true if the pointer was captured
  32509. */
  32510. isPointerCaptured(pointerId?: number): boolean;
  32511. /**
  32512. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32513. * @param attachUp defines if you want to attach events to pointerup
  32514. * @param attachDown defines if you want to attach events to pointerdown
  32515. * @param attachMove defines if you want to attach events to pointermove
  32516. */
  32517. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32518. /**
  32519. * Detaches all event handlers
  32520. */
  32521. detachControl(): void;
  32522. /**
  32523. * Force the value of meshUnderPointer
  32524. * @param mesh defines the mesh to use
  32525. */
  32526. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  32527. /**
  32528. * Gets the mesh under the pointer
  32529. * @returns a Mesh or null if no mesh is under the pointer
  32530. */
  32531. getPointerOverMesh(): Nullable<AbstractMesh>;
  32532. }
  32533. }
  32534. declare module "babylonjs/Animations/animationGroup" {
  32535. import { Animatable } from "babylonjs/Animations/animatable";
  32536. import { Animation } from "babylonjs/Animations/animation";
  32537. import { Scene, IDisposable } from "babylonjs/scene";
  32538. import { Observable } from "babylonjs/Misc/observable";
  32539. import { Nullable } from "babylonjs/types";
  32540. import "babylonjs/Animations/animatable";
  32541. /**
  32542. * This class defines the direct association between an animation and a target
  32543. */
  32544. export class TargetedAnimation {
  32545. /**
  32546. * Animation to perform
  32547. */
  32548. animation: Animation;
  32549. /**
  32550. * Target to animate
  32551. */
  32552. target: any;
  32553. /**
  32554. * Serialize the object
  32555. * @returns the JSON object representing the current entity
  32556. */
  32557. serialize(): any;
  32558. }
  32559. /**
  32560. * Use this class to create coordinated animations on multiple targets
  32561. */
  32562. export class AnimationGroup implements IDisposable {
  32563. /** The name of the animation group */
  32564. name: string;
  32565. private _scene;
  32566. private _targetedAnimations;
  32567. private _animatables;
  32568. private _from;
  32569. private _to;
  32570. private _isStarted;
  32571. private _isPaused;
  32572. private _speedRatio;
  32573. private _loopAnimation;
  32574. /**
  32575. * Gets or sets the unique id of the node
  32576. */
  32577. uniqueId: number;
  32578. /**
  32579. * This observable will notify when one animation have ended
  32580. */
  32581. onAnimationEndObservable: Observable<TargetedAnimation>;
  32582. /**
  32583. * Observer raised when one animation loops
  32584. */
  32585. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32586. /**
  32587. * This observable will notify when all animations have ended.
  32588. */
  32589. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32590. /**
  32591. * This observable will notify when all animations have paused.
  32592. */
  32593. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32594. /**
  32595. * This observable will notify when all animations are playing.
  32596. */
  32597. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32598. /**
  32599. * Gets the first frame
  32600. */
  32601. readonly from: number;
  32602. /**
  32603. * Gets the last frame
  32604. */
  32605. readonly to: number;
  32606. /**
  32607. * Define if the animations are started
  32608. */
  32609. readonly isStarted: boolean;
  32610. /**
  32611. * Gets a value indicating that the current group is playing
  32612. */
  32613. readonly isPlaying: boolean;
  32614. /**
  32615. * Gets or sets the speed ratio to use for all animations
  32616. */
  32617. /**
  32618. * Gets or sets the speed ratio to use for all animations
  32619. */
  32620. speedRatio: number;
  32621. /**
  32622. * Gets or sets if all animations should loop or not
  32623. */
  32624. loopAnimation: boolean;
  32625. /**
  32626. * Gets the targeted animations for this animation group
  32627. */
  32628. readonly targetedAnimations: Array<TargetedAnimation>;
  32629. /**
  32630. * returning the list of animatables controlled by this animation group.
  32631. */
  32632. readonly animatables: Array<Animatable>;
  32633. /**
  32634. * Instantiates a new Animation Group.
  32635. * This helps managing several animations at once.
  32636. * @see http://doc.babylonjs.com/how_to/group
  32637. * @param name Defines the name of the group
  32638. * @param scene Defines the scene the group belongs to
  32639. */
  32640. constructor(
  32641. /** The name of the animation group */
  32642. name: string, scene?: Nullable<Scene>);
  32643. /**
  32644. * Add an animation (with its target) in the group
  32645. * @param animation defines the animation we want to add
  32646. * @param target defines the target of the animation
  32647. * @returns the TargetedAnimation object
  32648. */
  32649. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32650. /**
  32651. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32652. * It can add constant keys at begin or end
  32653. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32654. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32655. * @returns the animation group
  32656. */
  32657. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32658. /**
  32659. * Start all animations on given targets
  32660. * @param loop defines if animations must loop
  32661. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32662. * @param from defines the from key (optional)
  32663. * @param to defines the to key (optional)
  32664. * @returns the current animation group
  32665. */
  32666. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32667. /**
  32668. * Pause all animations
  32669. * @returns the animation group
  32670. */
  32671. pause(): AnimationGroup;
  32672. /**
  32673. * Play all animations to initial state
  32674. * This function will start() the animations if they were not started or will restart() them if they were paused
  32675. * @param loop defines if animations must loop
  32676. * @returns the animation group
  32677. */
  32678. play(loop?: boolean): AnimationGroup;
  32679. /**
  32680. * Reset all animations to initial state
  32681. * @returns the animation group
  32682. */
  32683. reset(): AnimationGroup;
  32684. /**
  32685. * Restart animations from key 0
  32686. * @returns the animation group
  32687. */
  32688. restart(): AnimationGroup;
  32689. /**
  32690. * Stop all animations
  32691. * @returns the animation group
  32692. */
  32693. stop(): AnimationGroup;
  32694. /**
  32695. * Set animation weight for all animatables
  32696. * @param weight defines the weight to use
  32697. * @return the animationGroup
  32698. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32699. */
  32700. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32701. /**
  32702. * Synchronize and normalize all animatables with a source animatable
  32703. * @param root defines the root animatable to synchronize with
  32704. * @return the animationGroup
  32705. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32706. */
  32707. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32708. /**
  32709. * Goes to a specific frame in this animation group
  32710. * @param frame the frame number to go to
  32711. * @return the animationGroup
  32712. */
  32713. goToFrame(frame: number): AnimationGroup;
  32714. /**
  32715. * Dispose all associated resources
  32716. */
  32717. dispose(): void;
  32718. private _checkAnimationGroupEnded;
  32719. /**
  32720. * Clone the current animation group and returns a copy
  32721. * @param newName defines the name of the new group
  32722. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32723. * @returns the new aniamtion group
  32724. */
  32725. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32726. /**
  32727. * Serializes the animationGroup to an object
  32728. * @returns Serialized object
  32729. */
  32730. serialize(): any;
  32731. /**
  32732. * Returns a new AnimationGroup object parsed from the source provided.
  32733. * @param parsedAnimationGroup defines the source
  32734. * @param scene defines the scene that will receive the animationGroup
  32735. * @returns a new AnimationGroup
  32736. */
  32737. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32738. /**
  32739. * Returns the string "AnimationGroup"
  32740. * @returns "AnimationGroup"
  32741. */
  32742. getClassName(): string;
  32743. /**
  32744. * Creates a detailled string about the object
  32745. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32746. * @returns a string representing the object
  32747. */
  32748. toString(fullDetails?: boolean): string;
  32749. }
  32750. }
  32751. declare module "babylonjs/scene" {
  32752. import { Nullable } from "babylonjs/types";
  32753. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32754. import { Observable } from "babylonjs/Misc/observable";
  32755. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32756. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32757. import { Geometry } from "babylonjs/Meshes/geometry";
  32758. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32759. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32760. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32761. import { Mesh } from "babylonjs/Meshes/mesh";
  32762. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32763. import { Bone } from "babylonjs/Bones/bone";
  32764. import { Skeleton } from "babylonjs/Bones/skeleton";
  32765. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32766. import { Camera } from "babylonjs/Cameras/camera";
  32767. import { AbstractScene } from "babylonjs/abstractScene";
  32768. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32769. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32770. import { Material } from "babylonjs/Materials/material";
  32771. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32772. import { Effect } from "babylonjs/Materials/effect";
  32773. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32774. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32775. import { Light } from "babylonjs/Lights/light";
  32776. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32777. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32778. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32779. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32780. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32781. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32782. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32783. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32784. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32785. import { Engine } from "babylonjs/Engines/engine";
  32786. import { Node } from "babylonjs/node";
  32787. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32788. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32789. import { WebRequest } from "babylonjs/Misc/webRequest";
  32790. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  32791. import { Ray } from "babylonjs/Culling/ray";
  32792. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32793. import { Animation } from "babylonjs/Animations/animation";
  32794. import { Animatable } from "babylonjs/Animations/animatable";
  32795. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32796. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32797. import { Collider } from "babylonjs/Collisions/collider";
  32798. /**
  32799. * Define an interface for all classes that will hold resources
  32800. */
  32801. export interface IDisposable {
  32802. /**
  32803. * Releases all held resources
  32804. */
  32805. dispose(): void;
  32806. }
  32807. /** Interface defining initialization parameters for Scene class */
  32808. export interface SceneOptions {
  32809. /**
  32810. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32811. * It will improve performance when the number of geometries becomes important.
  32812. */
  32813. useGeometryUniqueIdsMap?: boolean;
  32814. /**
  32815. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32816. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32817. */
  32818. useMaterialMeshMap?: boolean;
  32819. /**
  32820. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32821. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32822. */
  32823. useClonedMeshhMap?: boolean;
  32824. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32825. virtual?: boolean;
  32826. }
  32827. /**
  32828. * Represents a scene to be rendered by the engine.
  32829. * @see http://doc.babylonjs.com/features/scene
  32830. */
  32831. export class Scene extends AbstractScene implements IAnimatable {
  32832. private static _uniqueIdCounter;
  32833. /** The fog is deactivated */
  32834. static readonly FOGMODE_NONE: number;
  32835. /** The fog density is following an exponential function */
  32836. static readonly FOGMODE_EXP: number;
  32837. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32838. static readonly FOGMODE_EXP2: number;
  32839. /** The fog density is following a linear function. */
  32840. static readonly FOGMODE_LINEAR: number;
  32841. /**
  32842. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32843. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32844. */
  32845. static MinDeltaTime: number;
  32846. /**
  32847. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32848. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32849. */
  32850. static MaxDeltaTime: number;
  32851. /**
  32852. * Factory used to create the default material.
  32853. * @param name The name of the material to create
  32854. * @param scene The scene to create the material for
  32855. * @returns The default material
  32856. */
  32857. static DefaultMaterialFactory(scene: Scene): Material;
  32858. /**
  32859. * Factory used to create the a collision coordinator.
  32860. * @returns The collision coordinator
  32861. */
  32862. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32863. /** @hidden */
  32864. _inputManager: InputManager;
  32865. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32866. cameraToUseForPointers: Nullable<Camera>;
  32867. /** @hidden */
  32868. readonly _isScene: boolean;
  32869. /**
  32870. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32871. */
  32872. autoClear: boolean;
  32873. /**
  32874. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32875. */
  32876. autoClearDepthAndStencil: boolean;
  32877. /**
  32878. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32879. */
  32880. clearColor: Color4;
  32881. /**
  32882. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32883. */
  32884. ambientColor: Color3;
  32885. /**
  32886. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32887. * It should only be one of the following (if not the default embedded one):
  32888. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32889. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32890. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32891. * The material properties need to be setup according to the type of texture in use.
  32892. */
  32893. environmentBRDFTexture: BaseTexture;
  32894. /** @hidden */
  32895. protected _environmentTexture: Nullable<BaseTexture>;
  32896. /**
  32897. * Texture used in all pbr material as the reflection texture.
  32898. * As in the majority of the scene they are the same (exception for multi room and so on),
  32899. * this is easier to reference from here than from all the materials.
  32900. */
  32901. /**
  32902. * Texture used in all pbr material as the reflection texture.
  32903. * As in the majority of the scene they are the same (exception for multi room and so on),
  32904. * this is easier to set here than in all the materials.
  32905. */
  32906. environmentTexture: Nullable<BaseTexture>;
  32907. /** @hidden */
  32908. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32909. /**
  32910. * Default image processing configuration used either in the rendering
  32911. * Forward main pass or through the imageProcessingPostProcess if present.
  32912. * As in the majority of the scene they are the same (exception for multi camera),
  32913. * this is easier to reference from here than from all the materials and post process.
  32914. *
  32915. * No setter as we it is a shared configuration, you can set the values instead.
  32916. */
  32917. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32918. private _forceWireframe;
  32919. /**
  32920. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32921. */
  32922. forceWireframe: boolean;
  32923. private _forcePointsCloud;
  32924. /**
  32925. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32926. */
  32927. forcePointsCloud: boolean;
  32928. /**
  32929. * Gets or sets the active clipplane 1
  32930. */
  32931. clipPlane: Nullable<Plane>;
  32932. /**
  32933. * Gets or sets the active clipplane 2
  32934. */
  32935. clipPlane2: Nullable<Plane>;
  32936. /**
  32937. * Gets or sets the active clipplane 3
  32938. */
  32939. clipPlane3: Nullable<Plane>;
  32940. /**
  32941. * Gets or sets the active clipplane 4
  32942. */
  32943. clipPlane4: Nullable<Plane>;
  32944. /**
  32945. * Gets or sets a boolean indicating if animations are enabled
  32946. */
  32947. animationsEnabled: boolean;
  32948. private _animationPropertiesOverride;
  32949. /**
  32950. * Gets or sets the animation properties override
  32951. */
  32952. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32953. /**
  32954. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32955. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32956. */
  32957. useConstantAnimationDeltaTime: boolean;
  32958. /**
  32959. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32960. * Please note that it requires to run a ray cast through the scene on every frame
  32961. */
  32962. constantlyUpdateMeshUnderPointer: boolean;
  32963. /**
  32964. * Defines the HTML cursor to use when hovering over interactive elements
  32965. */
  32966. hoverCursor: string;
  32967. /**
  32968. * Defines the HTML default cursor to use (empty by default)
  32969. */
  32970. defaultCursor: string;
  32971. /**
  32972. * This is used to call preventDefault() on pointer down
  32973. * in order to block unwanted artifacts like system double clicks
  32974. */
  32975. preventDefaultOnPointerDown: boolean;
  32976. /**
  32977. * This is used to call preventDefault() on pointer up
  32978. * in order to block unwanted artifacts like system double clicks
  32979. */
  32980. preventDefaultOnPointerUp: boolean;
  32981. /**
  32982. * Gets or sets user defined metadata
  32983. */
  32984. metadata: any;
  32985. /**
  32986. * For internal use only. Please do not use.
  32987. */
  32988. reservedDataStore: any;
  32989. /**
  32990. * Gets the name of the plugin used to load this scene (null by default)
  32991. */
  32992. loadingPluginName: string;
  32993. /**
  32994. * Use this array to add regular expressions used to disable offline support for specific urls
  32995. */
  32996. disableOfflineSupportExceptionRules: RegExp[];
  32997. /**
  32998. * An event triggered when the scene is disposed.
  32999. */
  33000. onDisposeObservable: Observable<Scene>;
  33001. private _onDisposeObserver;
  33002. /** Sets a function to be executed when this scene is disposed. */
  33003. onDispose: () => void;
  33004. /**
  33005. * An event triggered before rendering the scene (right after animations and physics)
  33006. */
  33007. onBeforeRenderObservable: Observable<Scene>;
  33008. private _onBeforeRenderObserver;
  33009. /** Sets a function to be executed before rendering this scene */
  33010. beforeRender: Nullable<() => void>;
  33011. /**
  33012. * An event triggered after rendering the scene
  33013. */
  33014. onAfterRenderObservable: Observable<Scene>;
  33015. private _onAfterRenderObserver;
  33016. /** Sets a function to be executed after rendering this scene */
  33017. afterRender: Nullable<() => void>;
  33018. /**
  33019. * An event triggered before animating the scene
  33020. */
  33021. onBeforeAnimationsObservable: Observable<Scene>;
  33022. /**
  33023. * An event triggered after animations processing
  33024. */
  33025. onAfterAnimationsObservable: Observable<Scene>;
  33026. /**
  33027. * An event triggered before draw calls are ready to be sent
  33028. */
  33029. onBeforeDrawPhaseObservable: Observable<Scene>;
  33030. /**
  33031. * An event triggered after draw calls have been sent
  33032. */
  33033. onAfterDrawPhaseObservable: Observable<Scene>;
  33034. /**
  33035. * An event triggered when the scene is ready
  33036. */
  33037. onReadyObservable: Observable<Scene>;
  33038. /**
  33039. * An event triggered before rendering a camera
  33040. */
  33041. onBeforeCameraRenderObservable: Observable<Camera>;
  33042. private _onBeforeCameraRenderObserver;
  33043. /** Sets a function to be executed before rendering a camera*/
  33044. beforeCameraRender: () => void;
  33045. /**
  33046. * An event triggered after rendering a camera
  33047. */
  33048. onAfterCameraRenderObservable: Observable<Camera>;
  33049. private _onAfterCameraRenderObserver;
  33050. /** Sets a function to be executed after rendering a camera*/
  33051. afterCameraRender: () => void;
  33052. /**
  33053. * An event triggered when active meshes evaluation is about to start
  33054. */
  33055. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  33056. /**
  33057. * An event triggered when active meshes evaluation is done
  33058. */
  33059. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  33060. /**
  33061. * An event triggered when particles rendering is about to start
  33062. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33063. */
  33064. onBeforeParticlesRenderingObservable: Observable<Scene>;
  33065. /**
  33066. * An event triggered when particles rendering is done
  33067. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  33068. */
  33069. onAfterParticlesRenderingObservable: Observable<Scene>;
  33070. /**
  33071. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  33072. */
  33073. onDataLoadedObservable: Observable<Scene>;
  33074. /**
  33075. * An event triggered when a camera is created
  33076. */
  33077. onNewCameraAddedObservable: Observable<Camera>;
  33078. /**
  33079. * An event triggered when a camera is removed
  33080. */
  33081. onCameraRemovedObservable: Observable<Camera>;
  33082. /**
  33083. * An event triggered when a light is created
  33084. */
  33085. onNewLightAddedObservable: Observable<Light>;
  33086. /**
  33087. * An event triggered when a light is removed
  33088. */
  33089. onLightRemovedObservable: Observable<Light>;
  33090. /**
  33091. * An event triggered when a geometry is created
  33092. */
  33093. onNewGeometryAddedObservable: Observable<Geometry>;
  33094. /**
  33095. * An event triggered when a geometry is removed
  33096. */
  33097. onGeometryRemovedObservable: Observable<Geometry>;
  33098. /**
  33099. * An event triggered when a transform node is created
  33100. */
  33101. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  33102. /**
  33103. * An event triggered when a transform node is removed
  33104. */
  33105. onTransformNodeRemovedObservable: Observable<TransformNode>;
  33106. /**
  33107. * An event triggered when a mesh is created
  33108. */
  33109. onNewMeshAddedObservable: Observable<AbstractMesh>;
  33110. /**
  33111. * An event triggered when a mesh is removed
  33112. */
  33113. onMeshRemovedObservable: Observable<AbstractMesh>;
  33114. /**
  33115. * An event triggered when a skeleton is created
  33116. */
  33117. onNewSkeletonAddedObservable: Observable<Skeleton>;
  33118. /**
  33119. * An event triggered when a skeleton is removed
  33120. */
  33121. onSkeletonRemovedObservable: Observable<Skeleton>;
  33122. /**
  33123. * An event triggered when a material is created
  33124. */
  33125. onNewMaterialAddedObservable: Observable<Material>;
  33126. /**
  33127. * An event triggered when a material is removed
  33128. */
  33129. onMaterialRemovedObservable: Observable<Material>;
  33130. /**
  33131. * An event triggered when a texture is created
  33132. */
  33133. onNewTextureAddedObservable: Observable<BaseTexture>;
  33134. /**
  33135. * An event triggered when a texture is removed
  33136. */
  33137. onTextureRemovedObservable: Observable<BaseTexture>;
  33138. /**
  33139. * An event triggered when render targets are about to be rendered
  33140. * Can happen multiple times per frame.
  33141. */
  33142. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  33143. /**
  33144. * An event triggered when render targets were rendered.
  33145. * Can happen multiple times per frame.
  33146. */
  33147. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  33148. /**
  33149. * An event triggered before calculating deterministic simulation step
  33150. */
  33151. onBeforeStepObservable: Observable<Scene>;
  33152. /**
  33153. * An event triggered after calculating deterministic simulation step
  33154. */
  33155. onAfterStepObservable: Observable<Scene>;
  33156. /**
  33157. * An event triggered when the activeCamera property is updated
  33158. */
  33159. onActiveCameraChanged: Observable<Scene>;
  33160. /**
  33161. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  33162. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33163. * 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)
  33164. */
  33165. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33166. /**
  33167. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  33168. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  33169. * 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)
  33170. */
  33171. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  33172. /**
  33173. * This Observable will when a mesh has been imported into the scene.
  33174. */
  33175. onMeshImportedObservable: Observable<AbstractMesh>;
  33176. /**
  33177. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  33178. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  33179. */
  33180. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  33181. /** @hidden */
  33182. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  33183. /**
  33184. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  33185. */
  33186. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  33187. /**
  33188. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  33189. */
  33190. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  33191. /**
  33192. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  33193. */
  33194. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  33195. /** Callback called when a pointer move is detected */
  33196. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33197. /** Callback called when a pointer down is detected */
  33198. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  33199. /** Callback called when a pointer up is detected */
  33200. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  33201. /** Callback called when a pointer pick is detected */
  33202. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  33203. /**
  33204. * 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).
  33205. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  33206. */
  33207. onPrePointerObservable: Observable<PointerInfoPre>;
  33208. /**
  33209. * Observable event triggered each time an input event is received from the rendering canvas
  33210. */
  33211. onPointerObservable: Observable<PointerInfo>;
  33212. /**
  33213. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  33214. */
  33215. readonly unTranslatedPointer: Vector2;
  33216. /**
  33217. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  33218. */
  33219. static DragMovementThreshold: number;
  33220. /**
  33221. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  33222. */
  33223. static LongPressDelay: number;
  33224. /**
  33225. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  33226. */
  33227. static DoubleClickDelay: number;
  33228. /** If you need to check double click without raising a single click at first click, enable this flag */
  33229. static ExclusiveDoubleClickMode: boolean;
  33230. /** @hidden */
  33231. _mirroredCameraPosition: Nullable<Vector3>;
  33232. /**
  33233. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  33234. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  33235. */
  33236. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  33237. /**
  33238. * Observable event triggered each time an keyboard event is received from the hosting window
  33239. */
  33240. onKeyboardObservable: Observable<KeyboardInfo>;
  33241. private _useRightHandedSystem;
  33242. /**
  33243. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  33244. */
  33245. useRightHandedSystem: boolean;
  33246. private _timeAccumulator;
  33247. private _currentStepId;
  33248. private _currentInternalStep;
  33249. /**
  33250. * Sets the step Id used by deterministic lock step
  33251. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33252. * @param newStepId defines the step Id
  33253. */
  33254. setStepId(newStepId: number): void;
  33255. /**
  33256. * Gets the step Id used by deterministic lock step
  33257. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33258. * @returns the step Id
  33259. */
  33260. getStepId(): number;
  33261. /**
  33262. * Gets the internal step used by deterministic lock step
  33263. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33264. * @returns the internal step
  33265. */
  33266. getInternalStep(): number;
  33267. private _fogEnabled;
  33268. /**
  33269. * Gets or sets a boolean indicating if fog is enabled on this scene
  33270. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33271. * (Default is true)
  33272. */
  33273. fogEnabled: boolean;
  33274. private _fogMode;
  33275. /**
  33276. * Gets or sets the fog mode to use
  33277. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33278. * | mode | value |
  33279. * | --- | --- |
  33280. * | FOGMODE_NONE | 0 |
  33281. * | FOGMODE_EXP | 1 |
  33282. * | FOGMODE_EXP2 | 2 |
  33283. * | FOGMODE_LINEAR | 3 |
  33284. */
  33285. fogMode: number;
  33286. /**
  33287. * Gets or sets the fog color to use
  33288. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33289. * (Default is Color3(0.2, 0.2, 0.3))
  33290. */
  33291. fogColor: Color3;
  33292. /**
  33293. * Gets or sets the fog density to use
  33294. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33295. * (Default is 0.1)
  33296. */
  33297. fogDensity: number;
  33298. /**
  33299. * Gets or sets the fog start distance to use
  33300. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33301. * (Default is 0)
  33302. */
  33303. fogStart: number;
  33304. /**
  33305. * Gets or sets the fog end distance to use
  33306. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33307. * (Default is 1000)
  33308. */
  33309. fogEnd: number;
  33310. private _shadowsEnabled;
  33311. /**
  33312. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33313. */
  33314. shadowsEnabled: boolean;
  33315. private _lightsEnabled;
  33316. /**
  33317. * Gets or sets a boolean indicating if lights are enabled on this scene
  33318. */
  33319. lightsEnabled: boolean;
  33320. /** All of the active cameras added to this scene. */
  33321. activeCameras: Camera[];
  33322. /** @hidden */
  33323. _activeCamera: Nullable<Camera>;
  33324. /** Gets or sets the current active camera */
  33325. activeCamera: Nullable<Camera>;
  33326. private _defaultMaterial;
  33327. /** The default material used on meshes when no material is affected */
  33328. /** The default material used on meshes when no material is affected */
  33329. defaultMaterial: Material;
  33330. private _texturesEnabled;
  33331. /**
  33332. * Gets or sets a boolean indicating if textures are enabled on this scene
  33333. */
  33334. texturesEnabled: boolean;
  33335. /**
  33336. * Gets or sets a boolean indicating if particles are enabled on this scene
  33337. */
  33338. particlesEnabled: boolean;
  33339. /**
  33340. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33341. */
  33342. spritesEnabled: boolean;
  33343. private _skeletonsEnabled;
  33344. /**
  33345. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33346. */
  33347. skeletonsEnabled: boolean;
  33348. /**
  33349. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33350. */
  33351. lensFlaresEnabled: boolean;
  33352. /**
  33353. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33354. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33355. */
  33356. collisionsEnabled: boolean;
  33357. private _collisionCoordinator;
  33358. /** @hidden */
  33359. readonly collisionCoordinator: ICollisionCoordinator;
  33360. /**
  33361. * Defines the gravity applied to this scene (used only for collisions)
  33362. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33363. */
  33364. gravity: Vector3;
  33365. /**
  33366. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33367. */
  33368. postProcessesEnabled: boolean;
  33369. /**
  33370. * The list of postprocesses added to the scene
  33371. */
  33372. postProcesses: PostProcess[];
  33373. /**
  33374. * Gets the current postprocess manager
  33375. */
  33376. postProcessManager: PostProcessManager;
  33377. /**
  33378. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33379. */
  33380. renderTargetsEnabled: boolean;
  33381. /**
  33382. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33383. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33384. */
  33385. dumpNextRenderTargets: boolean;
  33386. /**
  33387. * The list of user defined render targets added to the scene
  33388. */
  33389. customRenderTargets: RenderTargetTexture[];
  33390. /**
  33391. * Defines if texture loading must be delayed
  33392. * If true, textures will only be loaded when they need to be rendered
  33393. */
  33394. useDelayedTextureLoading: boolean;
  33395. /**
  33396. * Gets the list of meshes imported to the scene through SceneLoader
  33397. */
  33398. importedMeshesFiles: String[];
  33399. /**
  33400. * Gets or sets a boolean indicating if probes are enabled on this scene
  33401. */
  33402. probesEnabled: boolean;
  33403. /**
  33404. * Gets or sets the current offline provider to use to store scene data
  33405. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33406. */
  33407. offlineProvider: IOfflineProvider;
  33408. /**
  33409. * Gets or sets the action manager associated with the scene
  33410. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33411. */
  33412. actionManager: AbstractActionManager;
  33413. private _meshesForIntersections;
  33414. /**
  33415. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33416. */
  33417. proceduralTexturesEnabled: boolean;
  33418. private _engine;
  33419. private _totalVertices;
  33420. /** @hidden */
  33421. _activeIndices: PerfCounter;
  33422. /** @hidden */
  33423. _activeParticles: PerfCounter;
  33424. /** @hidden */
  33425. _activeBones: PerfCounter;
  33426. private _animationRatio;
  33427. /** @hidden */
  33428. _animationTimeLast: number;
  33429. /** @hidden */
  33430. _animationTime: number;
  33431. /**
  33432. * Gets or sets a general scale for animation speed
  33433. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33434. */
  33435. animationTimeScale: number;
  33436. /** @hidden */
  33437. _cachedMaterial: Nullable<Material>;
  33438. /** @hidden */
  33439. _cachedEffect: Nullable<Effect>;
  33440. /** @hidden */
  33441. _cachedVisibility: Nullable<number>;
  33442. private _renderId;
  33443. private _frameId;
  33444. private _executeWhenReadyTimeoutId;
  33445. private _intermediateRendering;
  33446. private _viewUpdateFlag;
  33447. private _projectionUpdateFlag;
  33448. /** @hidden */
  33449. _toBeDisposed: Nullable<IDisposable>[];
  33450. private _activeRequests;
  33451. /** @hidden */
  33452. _pendingData: any[];
  33453. private _isDisposed;
  33454. /**
  33455. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33456. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33457. */
  33458. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33459. private _activeMeshes;
  33460. private _processedMaterials;
  33461. private _renderTargets;
  33462. /** @hidden */
  33463. _activeParticleSystems: SmartArray<IParticleSystem>;
  33464. private _activeSkeletons;
  33465. private _softwareSkinnedMeshes;
  33466. private _renderingManager;
  33467. /** @hidden */
  33468. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33469. private _transformMatrix;
  33470. private _sceneUbo;
  33471. /** @hidden */
  33472. _viewMatrix: Matrix;
  33473. private _projectionMatrix;
  33474. /** @hidden */
  33475. _forcedViewPosition: Nullable<Vector3>;
  33476. /** @hidden */
  33477. _frustumPlanes: Plane[];
  33478. /**
  33479. * Gets the list of frustum planes (built from the active camera)
  33480. */
  33481. readonly frustumPlanes: Plane[];
  33482. /**
  33483. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33484. * This is useful if there are more lights that the maximum simulteanous authorized
  33485. */
  33486. requireLightSorting: boolean;
  33487. /** @hidden */
  33488. readonly useMaterialMeshMap: boolean;
  33489. /** @hidden */
  33490. readonly useClonedMeshhMap: boolean;
  33491. private _externalData;
  33492. private _uid;
  33493. /**
  33494. * @hidden
  33495. * Backing store of defined scene components.
  33496. */
  33497. _components: ISceneComponent[];
  33498. /**
  33499. * @hidden
  33500. * Backing store of defined scene components.
  33501. */
  33502. _serializableComponents: ISceneSerializableComponent[];
  33503. /**
  33504. * List of components to register on the next registration step.
  33505. */
  33506. private _transientComponents;
  33507. /**
  33508. * Registers the transient components if needed.
  33509. */
  33510. private _registerTransientComponents;
  33511. /**
  33512. * @hidden
  33513. * Add a component to the scene.
  33514. * Note that the ccomponent could be registered on th next frame if this is called after
  33515. * the register component stage.
  33516. * @param component Defines the component to add to the scene
  33517. */
  33518. _addComponent(component: ISceneComponent): void;
  33519. /**
  33520. * @hidden
  33521. * Gets a component from the scene.
  33522. * @param name defines the name of the component to retrieve
  33523. * @returns the component or null if not present
  33524. */
  33525. _getComponent(name: string): Nullable<ISceneComponent>;
  33526. /**
  33527. * @hidden
  33528. * Defines the actions happening before camera updates.
  33529. */
  33530. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33531. /**
  33532. * @hidden
  33533. * Defines the actions happening before clear the canvas.
  33534. */
  33535. _beforeClearStage: Stage<SimpleStageAction>;
  33536. /**
  33537. * @hidden
  33538. * Defines the actions when collecting render targets for the frame.
  33539. */
  33540. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33541. /**
  33542. * @hidden
  33543. * Defines the actions happening for one camera in the frame.
  33544. */
  33545. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33546. /**
  33547. * @hidden
  33548. * Defines the actions happening during the per mesh ready checks.
  33549. */
  33550. _isReadyForMeshStage: Stage<MeshStageAction>;
  33551. /**
  33552. * @hidden
  33553. * Defines the actions happening before evaluate active mesh checks.
  33554. */
  33555. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33556. /**
  33557. * @hidden
  33558. * Defines the actions happening during the evaluate sub mesh checks.
  33559. */
  33560. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33561. /**
  33562. * @hidden
  33563. * Defines the actions happening during the active mesh stage.
  33564. */
  33565. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33566. /**
  33567. * @hidden
  33568. * Defines the actions happening during the per camera render target step.
  33569. */
  33570. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33571. /**
  33572. * @hidden
  33573. * Defines the actions happening just before the active camera is drawing.
  33574. */
  33575. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33576. /**
  33577. * @hidden
  33578. * Defines the actions happening just before a render target is drawing.
  33579. */
  33580. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33581. /**
  33582. * @hidden
  33583. * Defines the actions happening just before a rendering group is drawing.
  33584. */
  33585. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33586. /**
  33587. * @hidden
  33588. * Defines the actions happening just before a mesh is drawing.
  33589. */
  33590. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33591. /**
  33592. * @hidden
  33593. * Defines the actions happening just after a mesh has been drawn.
  33594. */
  33595. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33596. /**
  33597. * @hidden
  33598. * Defines the actions happening just after a rendering group has been drawn.
  33599. */
  33600. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33601. /**
  33602. * @hidden
  33603. * Defines the actions happening just after the active camera has been drawn.
  33604. */
  33605. _afterCameraDrawStage: Stage<CameraStageAction>;
  33606. /**
  33607. * @hidden
  33608. * Defines the actions happening just after a render target has been drawn.
  33609. */
  33610. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33611. /**
  33612. * @hidden
  33613. * Defines the actions happening just after rendering all cameras and computing intersections.
  33614. */
  33615. _afterRenderStage: Stage<SimpleStageAction>;
  33616. /**
  33617. * @hidden
  33618. * Defines the actions happening when a pointer move event happens.
  33619. */
  33620. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33621. /**
  33622. * @hidden
  33623. * Defines the actions happening when a pointer down event happens.
  33624. */
  33625. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33626. /**
  33627. * @hidden
  33628. * Defines the actions happening when a pointer up event happens.
  33629. */
  33630. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33631. /**
  33632. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33633. */
  33634. private geometriesByUniqueId;
  33635. /**
  33636. * Creates a new Scene
  33637. * @param engine defines the engine to use to render this scene
  33638. * @param options defines the scene options
  33639. */
  33640. constructor(engine: Engine, options?: SceneOptions);
  33641. /**
  33642. * Gets a string idenfifying the name of the class
  33643. * @returns "Scene" string
  33644. */
  33645. getClassName(): string;
  33646. private _defaultMeshCandidates;
  33647. /**
  33648. * @hidden
  33649. */
  33650. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33651. private _defaultSubMeshCandidates;
  33652. /**
  33653. * @hidden
  33654. */
  33655. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33656. /**
  33657. * Sets the default candidate providers for the scene.
  33658. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33659. * and getCollidingSubMeshCandidates to their default function
  33660. */
  33661. setDefaultCandidateProviders(): void;
  33662. /**
  33663. * Gets the mesh that is currently under the pointer
  33664. */
  33665. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33666. /**
  33667. * Gets or sets the current on-screen X position of the pointer
  33668. */
  33669. pointerX: number;
  33670. /**
  33671. * Gets or sets the current on-screen Y position of the pointer
  33672. */
  33673. pointerY: number;
  33674. /**
  33675. * Gets the cached material (ie. the latest rendered one)
  33676. * @returns the cached material
  33677. */
  33678. getCachedMaterial(): Nullable<Material>;
  33679. /**
  33680. * Gets the cached effect (ie. the latest rendered one)
  33681. * @returns the cached effect
  33682. */
  33683. getCachedEffect(): Nullable<Effect>;
  33684. /**
  33685. * Gets the cached visibility state (ie. the latest rendered one)
  33686. * @returns the cached visibility state
  33687. */
  33688. getCachedVisibility(): Nullable<number>;
  33689. /**
  33690. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33691. * @param material defines the current material
  33692. * @param effect defines the current effect
  33693. * @param visibility defines the current visibility state
  33694. * @returns true if one parameter is not cached
  33695. */
  33696. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33697. /**
  33698. * Gets the engine associated with the scene
  33699. * @returns an Engine
  33700. */
  33701. getEngine(): Engine;
  33702. /**
  33703. * Gets the total number of vertices rendered per frame
  33704. * @returns the total number of vertices rendered per frame
  33705. */
  33706. getTotalVertices(): number;
  33707. /**
  33708. * Gets the performance counter for total vertices
  33709. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33710. */
  33711. readonly totalVerticesPerfCounter: PerfCounter;
  33712. /**
  33713. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33714. * @returns the total number of active indices rendered per frame
  33715. */
  33716. getActiveIndices(): number;
  33717. /**
  33718. * Gets the performance counter for active indices
  33719. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33720. */
  33721. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33722. /**
  33723. * Gets the total number of active particles rendered per frame
  33724. * @returns the total number of active particles rendered per frame
  33725. */
  33726. getActiveParticles(): number;
  33727. /**
  33728. * Gets the performance counter for active particles
  33729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33730. */
  33731. readonly activeParticlesPerfCounter: PerfCounter;
  33732. /**
  33733. * Gets the total number of active bones rendered per frame
  33734. * @returns the total number of active bones rendered per frame
  33735. */
  33736. getActiveBones(): number;
  33737. /**
  33738. * Gets the performance counter for active bones
  33739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33740. */
  33741. readonly activeBonesPerfCounter: PerfCounter;
  33742. /**
  33743. * Gets the array of active meshes
  33744. * @returns an array of AbstractMesh
  33745. */
  33746. getActiveMeshes(): SmartArray<AbstractMesh>;
  33747. /**
  33748. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33749. * @returns a number
  33750. */
  33751. getAnimationRatio(): number;
  33752. /**
  33753. * Gets an unique Id for the current render phase
  33754. * @returns a number
  33755. */
  33756. getRenderId(): number;
  33757. /**
  33758. * Gets an unique Id for the current frame
  33759. * @returns a number
  33760. */
  33761. getFrameId(): number;
  33762. /** Call this function if you want to manually increment the render Id*/
  33763. incrementRenderId(): void;
  33764. private _createUbo;
  33765. /**
  33766. * Use this method to simulate a pointer move on a mesh
  33767. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33768. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33769. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33770. * @returns the current scene
  33771. */
  33772. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33773. /**
  33774. * Use this method to simulate a pointer down on a mesh
  33775. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33776. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33777. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33778. * @returns the current scene
  33779. */
  33780. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33781. /**
  33782. * Use this method to simulate a pointer up on a mesh
  33783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33786. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33787. * @returns the current scene
  33788. */
  33789. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33790. /**
  33791. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33792. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33793. * @returns true if the pointer was captured
  33794. */
  33795. isPointerCaptured(pointerId?: number): boolean;
  33796. /**
  33797. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33798. * @param attachUp defines if you want to attach events to pointerup
  33799. * @param attachDown defines if you want to attach events to pointerdown
  33800. * @param attachMove defines if you want to attach events to pointermove
  33801. */
  33802. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33803. /** Detaches all event handlers*/
  33804. detachControl(): void;
  33805. /**
  33806. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33807. * Delay loaded resources are not taking in account
  33808. * @return true if all required resources are ready
  33809. */
  33810. isReady(): boolean;
  33811. /** Resets all cached information relative to material (including effect and visibility) */
  33812. resetCachedMaterial(): void;
  33813. /**
  33814. * Registers a function to be called before every frame render
  33815. * @param func defines the function to register
  33816. */
  33817. registerBeforeRender(func: () => void): void;
  33818. /**
  33819. * Unregisters a function called before every frame render
  33820. * @param func defines the function to unregister
  33821. */
  33822. unregisterBeforeRender(func: () => void): void;
  33823. /**
  33824. * Registers a function to be called after every frame render
  33825. * @param func defines the function to register
  33826. */
  33827. registerAfterRender(func: () => void): void;
  33828. /**
  33829. * Unregisters a function called after every frame render
  33830. * @param func defines the function to unregister
  33831. */
  33832. unregisterAfterRender(func: () => void): void;
  33833. private _executeOnceBeforeRender;
  33834. /**
  33835. * The provided function will run before render once and will be disposed afterwards.
  33836. * A timeout delay can be provided so that the function will be executed in N ms.
  33837. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33838. * @param func The function to be executed.
  33839. * @param timeout optional delay in ms
  33840. */
  33841. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33842. /** @hidden */
  33843. _addPendingData(data: any): void;
  33844. /** @hidden */
  33845. _removePendingData(data: any): void;
  33846. /**
  33847. * Returns the number of items waiting to be loaded
  33848. * @returns the number of items waiting to be loaded
  33849. */
  33850. getWaitingItemsCount(): number;
  33851. /**
  33852. * Returns a boolean indicating if the scene is still loading data
  33853. */
  33854. readonly isLoading: boolean;
  33855. /**
  33856. * Registers a function to be executed when the scene is ready
  33857. * @param {Function} func - the function to be executed
  33858. */
  33859. executeWhenReady(func: () => void): void;
  33860. /**
  33861. * Returns a promise that resolves when the scene is ready
  33862. * @returns A promise that resolves when the scene is ready
  33863. */
  33864. whenReadyAsync(): Promise<void>;
  33865. /** @hidden */
  33866. _checkIsReady(): void;
  33867. /**
  33868. * Gets all animatable attached to the scene
  33869. */
  33870. readonly animatables: Animatable[];
  33871. /**
  33872. * Resets the last animation time frame.
  33873. * Useful to override when animations start running when loading a scene for the first time.
  33874. */
  33875. resetLastAnimationTimeFrame(): void;
  33876. /**
  33877. * Gets the current view matrix
  33878. * @returns a Matrix
  33879. */
  33880. getViewMatrix(): Matrix;
  33881. /**
  33882. * Gets the current projection matrix
  33883. * @returns a Matrix
  33884. */
  33885. getProjectionMatrix(): Matrix;
  33886. /**
  33887. * Gets the current transform matrix
  33888. * @returns a Matrix made of View * Projection
  33889. */
  33890. getTransformMatrix(): Matrix;
  33891. /**
  33892. * Sets the current transform matrix
  33893. * @param viewL defines the View matrix to use
  33894. * @param projectionL defines the Projection matrix to use
  33895. * @param viewR defines the right View matrix to use (if provided)
  33896. * @param projectionR defines the right Projection matrix to use (if provided)
  33897. */
  33898. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33899. /**
  33900. * Gets the uniform buffer used to store scene data
  33901. * @returns a UniformBuffer
  33902. */
  33903. getSceneUniformBuffer(): UniformBuffer;
  33904. /**
  33905. * Gets an unique (relatively to the current scene) Id
  33906. * @returns an unique number for the scene
  33907. */
  33908. getUniqueId(): number;
  33909. /**
  33910. * Add a mesh to the list of scene's meshes
  33911. * @param newMesh defines the mesh to add
  33912. * @param recursive if all child meshes should also be added to the scene
  33913. */
  33914. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33915. /**
  33916. * Remove a mesh for the list of scene's meshes
  33917. * @param toRemove defines the mesh to remove
  33918. * @param recursive if all child meshes should also be removed from the scene
  33919. * @returns the index where the mesh was in the mesh list
  33920. */
  33921. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33922. /**
  33923. * Add a transform node to the list of scene's transform nodes
  33924. * @param newTransformNode defines the transform node to add
  33925. */
  33926. addTransformNode(newTransformNode: TransformNode): void;
  33927. /**
  33928. * Remove a transform node for the list of scene's transform nodes
  33929. * @param toRemove defines the transform node to remove
  33930. * @returns the index where the transform node was in the transform node list
  33931. */
  33932. removeTransformNode(toRemove: TransformNode): number;
  33933. /**
  33934. * Remove a skeleton for the list of scene's skeletons
  33935. * @param toRemove defines the skeleton to remove
  33936. * @returns the index where the skeleton was in the skeleton list
  33937. */
  33938. removeSkeleton(toRemove: Skeleton): number;
  33939. /**
  33940. * Remove a morph target for the list of scene's morph targets
  33941. * @param toRemove defines the morph target to remove
  33942. * @returns the index where the morph target was in the morph target list
  33943. */
  33944. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33945. /**
  33946. * Remove a light for the list of scene's lights
  33947. * @param toRemove defines the light to remove
  33948. * @returns the index where the light was in the light list
  33949. */
  33950. removeLight(toRemove: Light): number;
  33951. /**
  33952. * Remove a camera for the list of scene's cameras
  33953. * @param toRemove defines the camera to remove
  33954. * @returns the index where the camera was in the camera list
  33955. */
  33956. removeCamera(toRemove: Camera): number;
  33957. /**
  33958. * Remove a particle system for the list of scene's particle systems
  33959. * @param toRemove defines the particle system to remove
  33960. * @returns the index where the particle system was in the particle system list
  33961. */
  33962. removeParticleSystem(toRemove: IParticleSystem): number;
  33963. /**
  33964. * Remove a animation for the list of scene's animations
  33965. * @param toRemove defines the animation to remove
  33966. * @returns the index where the animation was in the animation list
  33967. */
  33968. removeAnimation(toRemove: Animation): number;
  33969. /**
  33970. * Will stop the animation of the given target
  33971. * @param target - the target
  33972. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33973. * @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)
  33974. */
  33975. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33976. /**
  33977. * Removes the given animation group from this scene.
  33978. * @param toRemove The animation group to remove
  33979. * @returns The index of the removed animation group
  33980. */
  33981. removeAnimationGroup(toRemove: AnimationGroup): number;
  33982. /**
  33983. * Removes the given multi-material from this scene.
  33984. * @param toRemove The multi-material to remove
  33985. * @returns The index of the removed multi-material
  33986. */
  33987. removeMultiMaterial(toRemove: MultiMaterial): number;
  33988. /**
  33989. * Removes the given material from this scene.
  33990. * @param toRemove The material to remove
  33991. * @returns The index of the removed material
  33992. */
  33993. removeMaterial(toRemove: Material): number;
  33994. /**
  33995. * Removes the given action manager from this scene.
  33996. * @param toRemove The action manager to remove
  33997. * @returns The index of the removed action manager
  33998. */
  33999. removeActionManager(toRemove: AbstractActionManager): number;
  34000. /**
  34001. * Removes the given texture from this scene.
  34002. * @param toRemove The texture to remove
  34003. * @returns The index of the removed texture
  34004. */
  34005. removeTexture(toRemove: BaseTexture): number;
  34006. /**
  34007. * Adds the given light to this scene
  34008. * @param newLight The light to add
  34009. */
  34010. addLight(newLight: Light): void;
  34011. /**
  34012. * Sorts the list list based on light priorities
  34013. */
  34014. sortLightsByPriority(): void;
  34015. /**
  34016. * Adds the given camera to this scene
  34017. * @param newCamera The camera to add
  34018. */
  34019. addCamera(newCamera: Camera): void;
  34020. /**
  34021. * Adds the given skeleton to this scene
  34022. * @param newSkeleton The skeleton to add
  34023. */
  34024. addSkeleton(newSkeleton: Skeleton): void;
  34025. /**
  34026. * Adds the given particle system to this scene
  34027. * @param newParticleSystem The particle system to add
  34028. */
  34029. addParticleSystem(newParticleSystem: IParticleSystem): void;
  34030. /**
  34031. * Adds the given animation to this scene
  34032. * @param newAnimation The animation to add
  34033. */
  34034. addAnimation(newAnimation: Animation): void;
  34035. /**
  34036. * Adds the given animation group to this scene.
  34037. * @param newAnimationGroup The animation group to add
  34038. */
  34039. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  34040. /**
  34041. * Adds the given multi-material to this scene
  34042. * @param newMultiMaterial The multi-material to add
  34043. */
  34044. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  34045. /**
  34046. * Adds the given material to this scene
  34047. * @param newMaterial The material to add
  34048. */
  34049. addMaterial(newMaterial: Material): void;
  34050. /**
  34051. * Adds the given morph target to this scene
  34052. * @param newMorphTargetManager The morph target to add
  34053. */
  34054. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  34055. /**
  34056. * Adds the given geometry to this scene
  34057. * @param newGeometry The geometry to add
  34058. */
  34059. addGeometry(newGeometry: Geometry): void;
  34060. /**
  34061. * Adds the given action manager to this scene
  34062. * @param newActionManager The action manager to add
  34063. */
  34064. addActionManager(newActionManager: AbstractActionManager): void;
  34065. /**
  34066. * Adds the given texture to this scene.
  34067. * @param newTexture The texture to add
  34068. */
  34069. addTexture(newTexture: BaseTexture): void;
  34070. /**
  34071. * Switch active camera
  34072. * @param newCamera defines the new active camera
  34073. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  34074. */
  34075. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  34076. /**
  34077. * sets the active camera of the scene using its ID
  34078. * @param id defines the camera's ID
  34079. * @return the new active camera or null if none found.
  34080. */
  34081. setActiveCameraByID(id: string): Nullable<Camera>;
  34082. /**
  34083. * sets the active camera of the scene using its name
  34084. * @param name defines the camera's name
  34085. * @returns the new active camera or null if none found.
  34086. */
  34087. setActiveCameraByName(name: string): Nullable<Camera>;
  34088. /**
  34089. * get an animation group using its name
  34090. * @param name defines the material's name
  34091. * @return the animation group or null if none found.
  34092. */
  34093. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  34094. /**
  34095. * Get a material using its unique id
  34096. * @param uniqueId defines the material's unique id
  34097. * @return the material or null if none found.
  34098. */
  34099. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  34100. /**
  34101. * get a material using its id
  34102. * @param id defines the material's ID
  34103. * @return the material or null if none found.
  34104. */
  34105. getMaterialByID(id: string): Nullable<Material>;
  34106. /**
  34107. * Gets a material using its name
  34108. * @param name defines the material's name
  34109. * @return the material or null if none found.
  34110. */
  34111. getMaterialByName(name: string): Nullable<Material>;
  34112. /**
  34113. * Gets a camera using its id
  34114. * @param id defines the id to look for
  34115. * @returns the camera or null if not found
  34116. */
  34117. getCameraByID(id: string): Nullable<Camera>;
  34118. /**
  34119. * Gets a camera using its unique id
  34120. * @param uniqueId defines the unique id to look for
  34121. * @returns the camera or null if not found
  34122. */
  34123. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  34124. /**
  34125. * Gets a camera using its name
  34126. * @param name defines the camera's name
  34127. * @return the camera or null if none found.
  34128. */
  34129. getCameraByName(name: string): Nullable<Camera>;
  34130. /**
  34131. * Gets a bone using its id
  34132. * @param id defines the bone's id
  34133. * @return the bone or null if not found
  34134. */
  34135. getBoneByID(id: string): Nullable<Bone>;
  34136. /**
  34137. * Gets a bone using its id
  34138. * @param name defines the bone's name
  34139. * @return the bone or null if not found
  34140. */
  34141. getBoneByName(name: string): Nullable<Bone>;
  34142. /**
  34143. * Gets a light node using its name
  34144. * @param name defines the the light's name
  34145. * @return the light or null if none found.
  34146. */
  34147. getLightByName(name: string): Nullable<Light>;
  34148. /**
  34149. * Gets a light node using its id
  34150. * @param id defines the light's id
  34151. * @return the light or null if none found.
  34152. */
  34153. getLightByID(id: string): Nullable<Light>;
  34154. /**
  34155. * Gets a light node using its scene-generated unique ID
  34156. * @param uniqueId defines the light's unique id
  34157. * @return the light or null if none found.
  34158. */
  34159. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  34160. /**
  34161. * Gets a particle system by id
  34162. * @param id defines the particle system id
  34163. * @return the corresponding system or null if none found
  34164. */
  34165. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  34166. /**
  34167. * Gets a geometry using its ID
  34168. * @param id defines the geometry's id
  34169. * @return the geometry or null if none found.
  34170. */
  34171. getGeometryByID(id: string): Nullable<Geometry>;
  34172. private _getGeometryByUniqueID;
  34173. /**
  34174. * Add a new geometry to this scene
  34175. * @param geometry defines the geometry to be added to the scene.
  34176. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  34177. * @return a boolean defining if the geometry was added or not
  34178. */
  34179. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  34180. /**
  34181. * Removes an existing geometry
  34182. * @param geometry defines the geometry to be removed from the scene
  34183. * @return a boolean defining if the geometry was removed or not
  34184. */
  34185. removeGeometry(geometry: Geometry): boolean;
  34186. /**
  34187. * Gets the list of geometries attached to the scene
  34188. * @returns an array of Geometry
  34189. */
  34190. getGeometries(): Geometry[];
  34191. /**
  34192. * Gets the first added mesh found of a given ID
  34193. * @param id defines the id to search for
  34194. * @return the mesh found or null if not found at all
  34195. */
  34196. getMeshByID(id: string): Nullable<AbstractMesh>;
  34197. /**
  34198. * Gets a list of meshes using their id
  34199. * @param id defines the id to search for
  34200. * @returns a list of meshes
  34201. */
  34202. getMeshesByID(id: string): Array<AbstractMesh>;
  34203. /**
  34204. * Gets the first added transform node found of a given ID
  34205. * @param id defines the id to search for
  34206. * @return the found transform node or null if not found at all.
  34207. */
  34208. getTransformNodeByID(id: string): Nullable<TransformNode>;
  34209. /**
  34210. * Gets a transform node with its auto-generated unique id
  34211. * @param uniqueId efines the unique id to search for
  34212. * @return the found transform node or null if not found at all.
  34213. */
  34214. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  34215. /**
  34216. * Gets a list of transform nodes using their id
  34217. * @param id defines the id to search for
  34218. * @returns a list of transform nodes
  34219. */
  34220. getTransformNodesByID(id: string): Array<TransformNode>;
  34221. /**
  34222. * Gets a mesh with its auto-generated unique id
  34223. * @param uniqueId defines the unique id to search for
  34224. * @return the found mesh or null if not found at all.
  34225. */
  34226. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  34227. /**
  34228. * Gets a the last added mesh using a given id
  34229. * @param id defines the id to search for
  34230. * @return the found mesh or null if not found at all.
  34231. */
  34232. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  34233. /**
  34234. * Gets a the last added node (Mesh, Camera, Light) using a given id
  34235. * @param id defines the id to search for
  34236. * @return the found node or null if not found at all
  34237. */
  34238. getLastEntryByID(id: string): Nullable<Node>;
  34239. /**
  34240. * Gets a node (Mesh, Camera, Light) using a given id
  34241. * @param id defines the id to search for
  34242. * @return the found node or null if not found at all
  34243. */
  34244. getNodeByID(id: string): Nullable<Node>;
  34245. /**
  34246. * Gets a node (Mesh, Camera, Light) using a given name
  34247. * @param name defines the name to search for
  34248. * @return the found node or null if not found at all.
  34249. */
  34250. getNodeByName(name: string): Nullable<Node>;
  34251. /**
  34252. * Gets a mesh using a given name
  34253. * @param name defines the name to search for
  34254. * @return the found mesh or null if not found at all.
  34255. */
  34256. getMeshByName(name: string): Nullable<AbstractMesh>;
  34257. /**
  34258. * Gets a transform node using a given name
  34259. * @param name defines the name to search for
  34260. * @return the found transform node or null if not found at all.
  34261. */
  34262. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34263. /**
  34264. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34265. * @param id defines the id to search for
  34266. * @return the found skeleton or null if not found at all.
  34267. */
  34268. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34269. /**
  34270. * Gets a skeleton using a given auto generated unique id
  34271. * @param uniqueId defines the unique id to search for
  34272. * @return the found skeleton or null if not found at all.
  34273. */
  34274. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34275. /**
  34276. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34277. * @param id defines the id to search for
  34278. * @return the found skeleton or null if not found at all.
  34279. */
  34280. getSkeletonById(id: string): Nullable<Skeleton>;
  34281. /**
  34282. * Gets a skeleton using a given name
  34283. * @param name defines the name to search for
  34284. * @return the found skeleton or null if not found at all.
  34285. */
  34286. getSkeletonByName(name: string): Nullable<Skeleton>;
  34287. /**
  34288. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34289. * @param id defines the id to search for
  34290. * @return the found morph target manager or null if not found at all.
  34291. */
  34292. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34293. /**
  34294. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34295. * @param id defines the id to search for
  34296. * @return the found morph target or null if not found at all.
  34297. */
  34298. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34299. /**
  34300. * Gets a boolean indicating if the given mesh is active
  34301. * @param mesh defines the mesh to look for
  34302. * @returns true if the mesh is in the active list
  34303. */
  34304. isActiveMesh(mesh: AbstractMesh): boolean;
  34305. /**
  34306. * Return a unique id as a string which can serve as an identifier for the scene
  34307. */
  34308. readonly uid: string;
  34309. /**
  34310. * Add an externaly attached data from its key.
  34311. * This method call will fail and return false, if such key already exists.
  34312. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34313. * @param key the unique key that identifies the data
  34314. * @param data the data object to associate to the key for this Engine instance
  34315. * @return true if no such key were already present and the data was added successfully, false otherwise
  34316. */
  34317. addExternalData<T>(key: string, data: T): boolean;
  34318. /**
  34319. * Get an externaly attached data from its key
  34320. * @param key the unique key that identifies the data
  34321. * @return the associated data, if present (can be null), or undefined if not present
  34322. */
  34323. getExternalData<T>(key: string): Nullable<T>;
  34324. /**
  34325. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34326. * @param key the unique key that identifies the data
  34327. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34328. * @return the associated data, can be null if the factory returned null.
  34329. */
  34330. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34331. /**
  34332. * Remove an externaly attached data from the Engine instance
  34333. * @param key the unique key that identifies the data
  34334. * @return true if the data was successfully removed, false if it doesn't exist
  34335. */
  34336. removeExternalData(key: string): boolean;
  34337. private _evaluateSubMesh;
  34338. /**
  34339. * Clear the processed materials smart array preventing retention point in material dispose.
  34340. */
  34341. freeProcessedMaterials(): void;
  34342. private _preventFreeActiveMeshesAndRenderingGroups;
  34343. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34344. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34345. * when disposing several meshes in a row or a hierarchy of meshes.
  34346. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34347. */
  34348. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34349. /**
  34350. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34351. */
  34352. freeActiveMeshes(): void;
  34353. /**
  34354. * Clear the info related to rendering groups preventing retention points during dispose.
  34355. */
  34356. freeRenderingGroups(): void;
  34357. /** @hidden */
  34358. _isInIntermediateRendering(): boolean;
  34359. /**
  34360. * Lambda returning the list of potentially active meshes.
  34361. */
  34362. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34363. /**
  34364. * Lambda returning the list of potentially active sub meshes.
  34365. */
  34366. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34367. /**
  34368. * Lambda returning the list of potentially intersecting sub meshes.
  34369. */
  34370. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34371. /**
  34372. * Lambda returning the list of potentially colliding sub meshes.
  34373. */
  34374. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34375. private _activeMeshesFrozen;
  34376. /**
  34377. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34378. * @returns the current scene
  34379. */
  34380. freezeActiveMeshes(): Scene;
  34381. /**
  34382. * Use this function to restart evaluating active meshes on every frame
  34383. * @returns the current scene
  34384. */
  34385. unfreezeActiveMeshes(): Scene;
  34386. private _evaluateActiveMeshes;
  34387. private _activeMesh;
  34388. /**
  34389. * Update the transform matrix to update from the current active camera
  34390. * @param force defines a boolean used to force the update even if cache is up to date
  34391. */
  34392. updateTransformMatrix(force?: boolean): void;
  34393. private _bindFrameBuffer;
  34394. /** @hidden */
  34395. _allowPostProcessClearColor: boolean;
  34396. /** @hidden */
  34397. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34398. private _processSubCameras;
  34399. private _checkIntersections;
  34400. /** @hidden */
  34401. _advancePhysicsEngineStep(step: number): void;
  34402. /**
  34403. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34404. */
  34405. getDeterministicFrameTime: () => number;
  34406. /** @hidden */
  34407. _animate(): void;
  34408. /** Execute all animations (for a frame) */
  34409. animate(): void;
  34410. /**
  34411. * Render the scene
  34412. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34413. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34414. */
  34415. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34416. /**
  34417. * Freeze all materials
  34418. * A frozen material will not be updatable but should be faster to render
  34419. */
  34420. freezeMaterials(): void;
  34421. /**
  34422. * Unfreeze all materials
  34423. * A frozen material will not be updatable but should be faster to render
  34424. */
  34425. unfreezeMaterials(): void;
  34426. /**
  34427. * Releases all held ressources
  34428. */
  34429. dispose(): void;
  34430. /**
  34431. * Gets if the scene is already disposed
  34432. */
  34433. readonly isDisposed: boolean;
  34434. /**
  34435. * Call this function to reduce memory footprint of the scene.
  34436. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34437. */
  34438. clearCachedVertexData(): void;
  34439. /**
  34440. * This function will remove the local cached buffer data from texture.
  34441. * It will save memory but will prevent the texture from being rebuilt
  34442. */
  34443. cleanCachedTextureBuffer(): void;
  34444. /**
  34445. * Get the world extend vectors with an optional filter
  34446. *
  34447. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34448. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34449. */
  34450. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34451. min: Vector3;
  34452. max: Vector3;
  34453. };
  34454. /**
  34455. * Creates a ray that can be used to pick in the scene
  34456. * @param x defines the x coordinate of the origin (on-screen)
  34457. * @param y defines the y coordinate of the origin (on-screen)
  34458. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34459. * @param camera defines the camera to use for the picking
  34460. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34461. * @returns a Ray
  34462. */
  34463. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34464. /**
  34465. * Creates a ray that can be used to pick in the scene
  34466. * @param x defines the x coordinate of the origin (on-screen)
  34467. * @param y defines the y coordinate of the origin (on-screen)
  34468. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34469. * @param result defines the ray where to store the picking ray
  34470. * @param camera defines the camera to use for the picking
  34471. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34472. * @returns the current scene
  34473. */
  34474. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34475. /**
  34476. * Creates a ray that can be used to pick in the scene
  34477. * @param x defines the x coordinate of the origin (on-screen)
  34478. * @param y defines the y coordinate of the origin (on-screen)
  34479. * @param camera defines the camera to use for the picking
  34480. * @returns a Ray
  34481. */
  34482. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34483. /**
  34484. * Creates a ray that can be used to pick in the scene
  34485. * @param x defines the x coordinate of the origin (on-screen)
  34486. * @param y defines the y coordinate of the origin (on-screen)
  34487. * @param result defines the ray where to store the picking ray
  34488. * @param camera defines the camera to use for the picking
  34489. * @returns the current scene
  34490. */
  34491. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34492. /** Launch a ray to try to pick a mesh in the scene
  34493. * @param x position on screen
  34494. * @param y position on screen
  34495. * @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
  34496. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34497. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34498. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34499. * @returns a PickingInfo
  34500. */
  34501. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34502. /** Use the given ray to pick a mesh in the scene
  34503. * @param ray The ray to use to pick meshes
  34504. * @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
  34505. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34506. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34507. * @returns a PickingInfo
  34508. */
  34509. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34510. /**
  34511. * Launch a ray to try to pick a mesh in the scene
  34512. * @param x X position on screen
  34513. * @param y Y position on screen
  34514. * @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
  34515. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34516. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34517. * @returns an array of PickingInfo
  34518. */
  34519. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34520. /**
  34521. * Launch a ray to try to pick a mesh in the scene
  34522. * @param ray Ray to use
  34523. * @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
  34524. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34525. * @returns an array of PickingInfo
  34526. */
  34527. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34528. /**
  34529. * Force the value of meshUnderPointer
  34530. * @param mesh defines the mesh to use
  34531. */
  34532. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34533. /**
  34534. * Gets the mesh under the pointer
  34535. * @returns a Mesh or null if no mesh is under the pointer
  34536. */
  34537. getPointerOverMesh(): Nullable<AbstractMesh>;
  34538. /** @hidden */
  34539. _rebuildGeometries(): void;
  34540. /** @hidden */
  34541. _rebuildTextures(): void;
  34542. private _getByTags;
  34543. /**
  34544. * Get a list of meshes by tags
  34545. * @param tagsQuery defines the tags query to use
  34546. * @param forEach defines a predicate used to filter results
  34547. * @returns an array of Mesh
  34548. */
  34549. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34550. /**
  34551. * Get a list of cameras by tags
  34552. * @param tagsQuery defines the tags query to use
  34553. * @param forEach defines a predicate used to filter results
  34554. * @returns an array of Camera
  34555. */
  34556. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34557. /**
  34558. * Get a list of lights by tags
  34559. * @param tagsQuery defines the tags query to use
  34560. * @param forEach defines a predicate used to filter results
  34561. * @returns an array of Light
  34562. */
  34563. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34564. /**
  34565. * Get a list of materials by tags
  34566. * @param tagsQuery defines the tags query to use
  34567. * @param forEach defines a predicate used to filter results
  34568. * @returns an array of Material
  34569. */
  34570. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34571. /**
  34572. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34573. * This allowed control for front to back rendering or reversly depending of the special needs.
  34574. *
  34575. * @param renderingGroupId The rendering group id corresponding to its index
  34576. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34577. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34578. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34579. */
  34580. 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;
  34581. /**
  34582. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34583. *
  34584. * @param renderingGroupId The rendering group id corresponding to its index
  34585. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34586. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34587. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34588. */
  34589. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34590. /**
  34591. * Gets the current auto clear configuration for one rendering group of the rendering
  34592. * manager.
  34593. * @param index the rendering group index to get the information for
  34594. * @returns The auto clear setup for the requested rendering group
  34595. */
  34596. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34597. private _blockMaterialDirtyMechanism;
  34598. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34599. blockMaterialDirtyMechanism: boolean;
  34600. /**
  34601. * Will flag all materials as dirty to trigger new shader compilation
  34602. * @param flag defines the flag used to specify which material part must be marked as dirty
  34603. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34604. */
  34605. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34606. /** @hidden */
  34607. _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;
  34608. /** @hidden */
  34609. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34610. }
  34611. }
  34612. declare module "babylonjs/assetContainer" {
  34613. import { AbstractScene } from "babylonjs/abstractScene";
  34614. import { Scene } from "babylonjs/scene";
  34615. import { Mesh } from "babylonjs/Meshes/mesh";
  34616. /**
  34617. * Set of assets to keep when moving a scene into an asset container.
  34618. */
  34619. export class KeepAssets extends AbstractScene {
  34620. }
  34621. /**
  34622. * Container with a set of assets that can be added or removed from a scene.
  34623. */
  34624. export class AssetContainer extends AbstractScene {
  34625. /**
  34626. * The scene the AssetContainer belongs to.
  34627. */
  34628. scene: Scene;
  34629. /**
  34630. * Instantiates an AssetContainer.
  34631. * @param scene The scene the AssetContainer belongs to.
  34632. */
  34633. constructor(scene: Scene);
  34634. /**
  34635. * Adds all the assets from the container to the scene.
  34636. */
  34637. addAllToScene(): void;
  34638. /**
  34639. * Removes all the assets in the container from the scene
  34640. */
  34641. removeAllFromScene(): void;
  34642. /**
  34643. * Disposes all the assets in the container
  34644. */
  34645. dispose(): void;
  34646. private _moveAssets;
  34647. /**
  34648. * Removes all the assets contained in the scene and adds them to the container.
  34649. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34650. */
  34651. moveAllFromScene(keepAssets?: KeepAssets): void;
  34652. /**
  34653. * 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.
  34654. * @returns the root mesh
  34655. */
  34656. createRootMesh(): Mesh;
  34657. }
  34658. }
  34659. declare module "babylonjs/abstractScene" {
  34660. import { Scene } from "babylonjs/scene";
  34661. import { Nullable } from "babylonjs/types";
  34662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34663. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34664. import { Geometry } from "babylonjs/Meshes/geometry";
  34665. import { Skeleton } from "babylonjs/Bones/skeleton";
  34666. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34667. import { AssetContainer } from "babylonjs/assetContainer";
  34668. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34669. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34671. import { Material } from "babylonjs/Materials/material";
  34672. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34673. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34674. import { Camera } from "babylonjs/Cameras/camera";
  34675. import { Light } from "babylonjs/Lights/light";
  34676. import { Node } from "babylonjs/node";
  34677. import { Animation } from "babylonjs/Animations/animation";
  34678. /**
  34679. * Defines how the parser contract is defined.
  34680. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34681. */
  34682. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34683. /**
  34684. * Defines how the individual parser contract is defined.
  34685. * These parser can parse an individual asset
  34686. */
  34687. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34688. /**
  34689. * Base class of the scene acting as a container for the different elements composing a scene.
  34690. * This class is dynamically extended by the different components of the scene increasing
  34691. * flexibility and reducing coupling
  34692. */
  34693. export abstract class AbstractScene {
  34694. /**
  34695. * Stores the list of available parsers in the application.
  34696. */
  34697. private static _BabylonFileParsers;
  34698. /**
  34699. * Stores the list of available individual parsers in the application.
  34700. */
  34701. private static _IndividualBabylonFileParsers;
  34702. /**
  34703. * Adds a parser in the list of available ones
  34704. * @param name Defines the name of the parser
  34705. * @param parser Defines the parser to add
  34706. */
  34707. static AddParser(name: string, parser: BabylonFileParser): void;
  34708. /**
  34709. * Gets a general parser from the list of avaialble ones
  34710. * @param name Defines the name of the parser
  34711. * @returns the requested parser or null
  34712. */
  34713. static GetParser(name: string): Nullable<BabylonFileParser>;
  34714. /**
  34715. * Adds n individual parser in the list of available ones
  34716. * @param name Defines the name of the parser
  34717. * @param parser Defines the parser to add
  34718. */
  34719. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34720. /**
  34721. * Gets an individual parser from the list of avaialble ones
  34722. * @param name Defines the name of the parser
  34723. * @returns the requested parser or null
  34724. */
  34725. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34726. /**
  34727. * Parser json data and populate both a scene and its associated container object
  34728. * @param jsonData Defines the data to parse
  34729. * @param scene Defines the scene to parse the data for
  34730. * @param container Defines the container attached to the parsing sequence
  34731. * @param rootUrl Defines the root url of the data
  34732. */
  34733. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34734. /**
  34735. * Gets the list of root nodes (ie. nodes with no parent)
  34736. */
  34737. rootNodes: Node[];
  34738. /** All of the cameras added to this scene
  34739. * @see http://doc.babylonjs.com/babylon101/cameras
  34740. */
  34741. cameras: Camera[];
  34742. /**
  34743. * All of the lights added to this scene
  34744. * @see http://doc.babylonjs.com/babylon101/lights
  34745. */
  34746. lights: Light[];
  34747. /**
  34748. * All of the (abstract) meshes added to this scene
  34749. */
  34750. meshes: AbstractMesh[];
  34751. /**
  34752. * The list of skeletons added to the scene
  34753. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34754. */
  34755. skeletons: Skeleton[];
  34756. /**
  34757. * All of the particle systems added to this scene
  34758. * @see http://doc.babylonjs.com/babylon101/particles
  34759. */
  34760. particleSystems: IParticleSystem[];
  34761. /**
  34762. * Gets a list of Animations associated with the scene
  34763. */
  34764. animations: Animation[];
  34765. /**
  34766. * All of the animation groups added to this scene
  34767. * @see http://doc.babylonjs.com/how_to/group
  34768. */
  34769. animationGroups: AnimationGroup[];
  34770. /**
  34771. * All of the multi-materials added to this scene
  34772. * @see http://doc.babylonjs.com/how_to/multi_materials
  34773. */
  34774. multiMaterials: MultiMaterial[];
  34775. /**
  34776. * All of the materials added to this scene
  34777. * In the context of a Scene, it is not supposed to be modified manually.
  34778. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34779. * Note also that the order of the Material wihin the array is not significant and might change.
  34780. * @see http://doc.babylonjs.com/babylon101/materials
  34781. */
  34782. materials: Material[];
  34783. /**
  34784. * The list of morph target managers added to the scene
  34785. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34786. */
  34787. morphTargetManagers: MorphTargetManager[];
  34788. /**
  34789. * The list of geometries used in the scene.
  34790. */
  34791. geometries: Geometry[];
  34792. /**
  34793. * All of the tranform nodes added to this scene
  34794. * In the context of a Scene, it is not supposed to be modified manually.
  34795. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34796. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34797. * @see http://doc.babylonjs.com/how_to/transformnode
  34798. */
  34799. transformNodes: TransformNode[];
  34800. /**
  34801. * ActionManagers available on the scene.
  34802. */
  34803. actionManagers: AbstractActionManager[];
  34804. /**
  34805. * Textures to keep.
  34806. */
  34807. textures: BaseTexture[];
  34808. /**
  34809. * Environment texture for the scene
  34810. */
  34811. environmentTexture: Nullable<BaseTexture>;
  34812. }
  34813. }
  34814. declare module "babylonjs/Audio/sound" {
  34815. import { Observable } from "babylonjs/Misc/observable";
  34816. import { Vector3 } from "babylonjs/Maths/math";
  34817. import { Nullable } from "babylonjs/types";
  34818. import { Scene } from "babylonjs/scene";
  34819. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34820. /**
  34821. * Defines a sound that can be played in the application.
  34822. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34823. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34824. */
  34825. export class Sound {
  34826. /**
  34827. * The name of the sound in the scene.
  34828. */
  34829. name: string;
  34830. /**
  34831. * Does the sound autoplay once loaded.
  34832. */
  34833. autoplay: boolean;
  34834. /**
  34835. * Does the sound loop after it finishes playing once.
  34836. */
  34837. loop: boolean;
  34838. /**
  34839. * Does the sound use a custom attenuation curve to simulate the falloff
  34840. * happening when the source gets further away from the camera.
  34841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34842. */
  34843. useCustomAttenuation: boolean;
  34844. /**
  34845. * The sound track id this sound belongs to.
  34846. */
  34847. soundTrackId: number;
  34848. /**
  34849. * Is this sound currently played.
  34850. */
  34851. isPlaying: boolean;
  34852. /**
  34853. * Is this sound currently paused.
  34854. */
  34855. isPaused: boolean;
  34856. /**
  34857. * Does this sound enables spatial sound.
  34858. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34859. */
  34860. spatialSound: boolean;
  34861. /**
  34862. * Define the reference distance the sound should be heard perfectly.
  34863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34864. */
  34865. refDistance: number;
  34866. /**
  34867. * Define the roll off factor of spatial sounds.
  34868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34869. */
  34870. rolloffFactor: number;
  34871. /**
  34872. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34873. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34874. */
  34875. maxDistance: number;
  34876. /**
  34877. * Define the distance attenuation model the sound will follow.
  34878. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34879. */
  34880. distanceModel: string;
  34881. /**
  34882. * @hidden
  34883. * Back Compat
  34884. **/
  34885. onended: () => any;
  34886. /**
  34887. * Observable event when the current playing sound finishes.
  34888. */
  34889. onEndedObservable: Observable<Sound>;
  34890. private _panningModel;
  34891. private _playbackRate;
  34892. private _streaming;
  34893. private _startTime;
  34894. private _startOffset;
  34895. private _position;
  34896. /** @hidden */
  34897. _positionInEmitterSpace: boolean;
  34898. private _localDirection;
  34899. private _volume;
  34900. private _isReadyToPlay;
  34901. private _isDirectional;
  34902. private _readyToPlayCallback;
  34903. private _audioBuffer;
  34904. private _soundSource;
  34905. private _streamingSource;
  34906. private _soundPanner;
  34907. private _soundGain;
  34908. private _inputAudioNode;
  34909. private _outputAudioNode;
  34910. private _coneInnerAngle;
  34911. private _coneOuterAngle;
  34912. private _coneOuterGain;
  34913. private _scene;
  34914. private _connectedTransformNode;
  34915. private _customAttenuationFunction;
  34916. private _registerFunc;
  34917. private _isOutputConnected;
  34918. private _htmlAudioElement;
  34919. private _urlType;
  34920. /** @hidden */
  34921. static _SceneComponentInitialization: (scene: Scene) => void;
  34922. /**
  34923. * Create a sound and attach it to a scene
  34924. * @param name Name of your sound
  34925. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34926. * @param scene defines the scene the sound belongs to
  34927. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34928. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34929. */
  34930. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34931. /**
  34932. * Release the sound and its associated resources
  34933. */
  34934. dispose(): void;
  34935. /**
  34936. * Gets if the sounds is ready to be played or not.
  34937. * @returns true if ready, otherwise false
  34938. */
  34939. isReady(): boolean;
  34940. private _soundLoaded;
  34941. /**
  34942. * Sets the data of the sound from an audiobuffer
  34943. * @param audioBuffer The audioBuffer containing the data
  34944. */
  34945. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34946. /**
  34947. * Updates the current sounds options such as maxdistance, loop...
  34948. * @param options A JSON object containing values named as the object properties
  34949. */
  34950. updateOptions(options: any): void;
  34951. private _createSpatialParameters;
  34952. private _updateSpatialParameters;
  34953. /**
  34954. * Switch the panning model to HRTF:
  34955. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34957. */
  34958. switchPanningModelToHRTF(): void;
  34959. /**
  34960. * Switch the panning model to Equal Power:
  34961. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34962. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34963. */
  34964. switchPanningModelToEqualPower(): void;
  34965. private _switchPanningModel;
  34966. /**
  34967. * Connect this sound to a sound track audio node like gain...
  34968. * @param soundTrackAudioNode the sound track audio node to connect to
  34969. */
  34970. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34971. /**
  34972. * Transform this sound into a directional source
  34973. * @param coneInnerAngle Size of the inner cone in degree
  34974. * @param coneOuterAngle Size of the outer cone in degree
  34975. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34976. */
  34977. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34978. /**
  34979. * Gets or sets the inner angle for the directional cone.
  34980. */
  34981. /**
  34982. * Gets or sets the inner angle for the directional cone.
  34983. */
  34984. directionalConeInnerAngle: number;
  34985. /**
  34986. * Gets or sets the outer angle for the directional cone.
  34987. */
  34988. /**
  34989. * Gets or sets the outer angle for the directional cone.
  34990. */
  34991. directionalConeOuterAngle: number;
  34992. /**
  34993. * Sets the position of the emitter if spatial sound is enabled
  34994. * @param newPosition Defines the new posisiton
  34995. */
  34996. setPosition(newPosition: Vector3): void;
  34997. /**
  34998. * Sets the local direction of the emitter if spatial sound is enabled
  34999. * @param newLocalDirection Defines the new local direction
  35000. */
  35001. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  35002. private _updateDirection;
  35003. /** @hidden */
  35004. updateDistanceFromListener(): void;
  35005. /**
  35006. * Sets a new custom attenuation function for the sound.
  35007. * @param callback Defines the function used for the attenuation
  35008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  35009. */
  35010. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  35011. /**
  35012. * Play the sound
  35013. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  35014. * @param offset (optional) Start the sound setting it at a specific time
  35015. */
  35016. play(time?: number, offset?: number): void;
  35017. private _onended;
  35018. /**
  35019. * Stop the sound
  35020. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  35021. */
  35022. stop(time?: number): void;
  35023. /**
  35024. * Put the sound in pause
  35025. */
  35026. pause(): void;
  35027. /**
  35028. * Sets a dedicated volume for this sounds
  35029. * @param newVolume Define the new volume of the sound
  35030. * @param time Define in how long the sound should be at this value
  35031. */
  35032. setVolume(newVolume: number, time?: number): void;
  35033. /**
  35034. * Set the sound play back rate
  35035. * @param newPlaybackRate Define the playback rate the sound should be played at
  35036. */
  35037. setPlaybackRate(newPlaybackRate: number): void;
  35038. /**
  35039. * Gets the volume of the sound.
  35040. * @returns the volume of the sound
  35041. */
  35042. getVolume(): number;
  35043. /**
  35044. * Attach the sound to a dedicated mesh
  35045. * @param transformNode The transform node to connect the sound with
  35046. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35047. */
  35048. attachToMesh(transformNode: TransformNode): void;
  35049. /**
  35050. * Detach the sound from the previously attached mesh
  35051. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  35052. */
  35053. detachFromMesh(): void;
  35054. private _onRegisterAfterWorldMatrixUpdate;
  35055. /**
  35056. * Clone the current sound in the scene.
  35057. * @returns the new sound clone
  35058. */
  35059. clone(): Nullable<Sound>;
  35060. /**
  35061. * Gets the current underlying audio buffer containing the data
  35062. * @returns the audio buffer
  35063. */
  35064. getAudioBuffer(): Nullable<AudioBuffer>;
  35065. /**
  35066. * Serializes the Sound in a JSON representation
  35067. * @returns the JSON representation of the sound
  35068. */
  35069. serialize(): any;
  35070. /**
  35071. * Parse a JSON representation of a sound to innstantiate in a given scene
  35072. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  35073. * @param scene Define the scene the new parsed sound should be created in
  35074. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  35075. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  35076. * @returns the newly parsed sound
  35077. */
  35078. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  35079. }
  35080. }
  35081. declare module "babylonjs/Actions/directAudioActions" {
  35082. import { Action } from "babylonjs/Actions/action";
  35083. import { Condition } from "babylonjs/Actions/condition";
  35084. import { Sound } from "babylonjs/Audio/sound";
  35085. /**
  35086. * This defines an action helpful to play a defined sound on a triggered action.
  35087. */
  35088. export class PlaySoundAction extends Action {
  35089. private _sound;
  35090. /**
  35091. * Instantiate the action
  35092. * @param triggerOptions defines the trigger options
  35093. * @param sound defines the sound to play
  35094. * @param condition defines the trigger related conditions
  35095. */
  35096. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35097. /** @hidden */
  35098. _prepare(): void;
  35099. /**
  35100. * Execute the action and play the sound.
  35101. */
  35102. execute(): void;
  35103. /**
  35104. * Serializes the actions and its related information.
  35105. * @param parent defines the object to serialize in
  35106. * @returns the serialized object
  35107. */
  35108. serialize(parent: any): any;
  35109. }
  35110. /**
  35111. * This defines an action helpful to stop a defined sound on a triggered action.
  35112. */
  35113. export class StopSoundAction extends Action {
  35114. private _sound;
  35115. /**
  35116. * Instantiate the action
  35117. * @param triggerOptions defines the trigger options
  35118. * @param sound defines the sound to stop
  35119. * @param condition defines the trigger related conditions
  35120. */
  35121. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  35122. /** @hidden */
  35123. _prepare(): void;
  35124. /**
  35125. * Execute the action and stop the sound.
  35126. */
  35127. execute(): void;
  35128. /**
  35129. * Serializes the actions and its related information.
  35130. * @param parent defines the object to serialize in
  35131. * @returns the serialized object
  35132. */
  35133. serialize(parent: any): any;
  35134. }
  35135. }
  35136. declare module "babylonjs/Actions/interpolateValueAction" {
  35137. import { Action } from "babylonjs/Actions/action";
  35138. import { Condition } from "babylonjs/Actions/condition";
  35139. import { Observable } from "babylonjs/Misc/observable";
  35140. /**
  35141. * This defines an action responsible to change the value of a property
  35142. * by interpolating between its current value and the newly set one once triggered.
  35143. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  35144. */
  35145. export class InterpolateValueAction extends Action {
  35146. /**
  35147. * Defines the path of the property where the value should be interpolated
  35148. */
  35149. propertyPath: string;
  35150. /**
  35151. * Defines the target value at the end of the interpolation.
  35152. */
  35153. value: any;
  35154. /**
  35155. * Defines the time it will take for the property to interpolate to the value.
  35156. */
  35157. duration: number;
  35158. /**
  35159. * Defines if the other scene animations should be stopped when the action has been triggered
  35160. */
  35161. stopOtherAnimations?: boolean;
  35162. /**
  35163. * Defines a callback raised once the interpolation animation has been done.
  35164. */
  35165. onInterpolationDone?: () => void;
  35166. /**
  35167. * Observable triggered once the interpolation animation has been done.
  35168. */
  35169. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  35170. private _target;
  35171. private _effectiveTarget;
  35172. private _property;
  35173. /**
  35174. * Instantiate the action
  35175. * @param triggerOptions defines the trigger options
  35176. * @param target defines the object containing the value to interpolate
  35177. * @param propertyPath defines the path to the property in the target object
  35178. * @param value defines the target value at the end of the interpolation
  35179. * @param duration deines the time it will take for the property to interpolate to the value.
  35180. * @param condition defines the trigger related conditions
  35181. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  35182. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  35183. */
  35184. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  35185. /** @hidden */
  35186. _prepare(): void;
  35187. /**
  35188. * Execute the action starts the value interpolation.
  35189. */
  35190. execute(): void;
  35191. /**
  35192. * Serializes the actions and its related information.
  35193. * @param parent defines the object to serialize in
  35194. * @returns the serialized object
  35195. */
  35196. serialize(parent: any): any;
  35197. }
  35198. }
  35199. declare module "babylonjs/Actions/index" {
  35200. export * from "babylonjs/Actions/action";
  35201. export * from "babylonjs/Actions/actionEvent";
  35202. export * from "babylonjs/Actions/actionManager";
  35203. export * from "babylonjs/Actions/condition";
  35204. export * from "babylonjs/Actions/directActions";
  35205. export * from "babylonjs/Actions/directAudioActions";
  35206. export * from "babylonjs/Actions/interpolateValueAction";
  35207. }
  35208. declare module "babylonjs/Animations/index" {
  35209. export * from "babylonjs/Animations/animatable";
  35210. export * from "babylonjs/Animations/animation";
  35211. export * from "babylonjs/Animations/animationGroup";
  35212. export * from "babylonjs/Animations/animationPropertiesOverride";
  35213. export * from "babylonjs/Animations/easing";
  35214. export * from "babylonjs/Animations/runtimeAnimation";
  35215. export * from "babylonjs/Animations/animationEvent";
  35216. export * from "babylonjs/Animations/animationGroup";
  35217. export * from "babylonjs/Animations/animationKey";
  35218. export * from "babylonjs/Animations/animationRange";
  35219. }
  35220. declare module "babylonjs/Audio/soundTrack" {
  35221. import { Sound } from "babylonjs/Audio/sound";
  35222. import { Analyser } from "babylonjs/Audio/analyser";
  35223. import { Scene } from "babylonjs/scene";
  35224. /**
  35225. * Options allowed during the creation of a sound track.
  35226. */
  35227. export interface ISoundTrackOptions {
  35228. /**
  35229. * The volume the sound track should take during creation
  35230. */
  35231. volume?: number;
  35232. /**
  35233. * Define if the sound track is the main sound track of the scene
  35234. */
  35235. mainTrack?: boolean;
  35236. }
  35237. /**
  35238. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  35239. * It will be also used in a future release to apply effects on a specific track.
  35240. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35241. */
  35242. export class SoundTrack {
  35243. /**
  35244. * The unique identifier of the sound track in the scene.
  35245. */
  35246. id: number;
  35247. /**
  35248. * The list of sounds included in the sound track.
  35249. */
  35250. soundCollection: Array<Sound>;
  35251. private _outputAudioNode;
  35252. private _scene;
  35253. private _isMainTrack;
  35254. private _connectedAnalyser;
  35255. private _options;
  35256. private _isInitialized;
  35257. /**
  35258. * Creates a new sound track.
  35259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35260. * @param scene Define the scene the sound track belongs to
  35261. * @param options
  35262. */
  35263. constructor(scene: Scene, options?: ISoundTrackOptions);
  35264. private _initializeSoundTrackAudioGraph;
  35265. /**
  35266. * Release the sound track and its associated resources
  35267. */
  35268. dispose(): void;
  35269. /**
  35270. * Adds a sound to this sound track
  35271. * @param sound define the cound to add
  35272. * @ignoreNaming
  35273. */
  35274. AddSound(sound: Sound): void;
  35275. /**
  35276. * Removes a sound to this sound track
  35277. * @param sound define the cound to remove
  35278. * @ignoreNaming
  35279. */
  35280. RemoveSound(sound: Sound): void;
  35281. /**
  35282. * Set a global volume for the full sound track.
  35283. * @param newVolume Define the new volume of the sound track
  35284. */
  35285. setVolume(newVolume: number): void;
  35286. /**
  35287. * Switch the panning model to HRTF:
  35288. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35289. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35290. */
  35291. switchPanningModelToHRTF(): void;
  35292. /**
  35293. * Switch the panning model to Equal Power:
  35294. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35295. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35296. */
  35297. switchPanningModelToEqualPower(): void;
  35298. /**
  35299. * Connect the sound track to an audio analyser allowing some amazing
  35300. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35301. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35302. * @param analyser The analyser to connect to the engine
  35303. */
  35304. connectToAnalyser(analyser: Analyser): void;
  35305. }
  35306. }
  35307. declare module "babylonjs/Audio/audioSceneComponent" {
  35308. import { Sound } from "babylonjs/Audio/sound";
  35309. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35310. import { Nullable } from "babylonjs/types";
  35311. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35312. import { Scene } from "babylonjs/scene";
  35313. import { AbstractScene } from "babylonjs/abstractScene";
  35314. module "babylonjs/abstractScene" {
  35315. interface AbstractScene {
  35316. /**
  35317. * The list of sounds used in the scene.
  35318. */
  35319. sounds: Nullable<Array<Sound>>;
  35320. }
  35321. }
  35322. module "babylonjs/scene" {
  35323. interface Scene {
  35324. /**
  35325. * @hidden
  35326. * Backing field
  35327. */
  35328. _mainSoundTrack: SoundTrack;
  35329. /**
  35330. * The main sound track played by the scene.
  35331. * It cotains your primary collection of sounds.
  35332. */
  35333. mainSoundTrack: SoundTrack;
  35334. /**
  35335. * The list of sound tracks added to the scene
  35336. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35337. */
  35338. soundTracks: Nullable<Array<SoundTrack>>;
  35339. /**
  35340. * Gets a sound using a given name
  35341. * @param name defines the name to search for
  35342. * @return the found sound or null if not found at all.
  35343. */
  35344. getSoundByName(name: string): Nullable<Sound>;
  35345. /**
  35346. * Gets or sets if audio support is enabled
  35347. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35348. */
  35349. audioEnabled: boolean;
  35350. /**
  35351. * Gets or sets if audio will be output to headphones
  35352. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35353. */
  35354. headphone: boolean;
  35355. }
  35356. }
  35357. /**
  35358. * Defines the sound scene component responsible to manage any sounds
  35359. * in a given scene.
  35360. */
  35361. export class AudioSceneComponent implements ISceneSerializableComponent {
  35362. /**
  35363. * The component name helpfull to identify the component in the list of scene components.
  35364. */
  35365. readonly name: string;
  35366. /**
  35367. * The scene the component belongs to.
  35368. */
  35369. scene: Scene;
  35370. private _audioEnabled;
  35371. /**
  35372. * Gets whether audio is enabled or not.
  35373. * Please use related enable/disable method to switch state.
  35374. */
  35375. readonly audioEnabled: boolean;
  35376. private _headphone;
  35377. /**
  35378. * Gets whether audio is outputing to headphone or not.
  35379. * Please use the according Switch methods to change output.
  35380. */
  35381. readonly headphone: boolean;
  35382. /**
  35383. * Creates a new instance of the component for the given scene
  35384. * @param scene Defines the scene to register the component in
  35385. */
  35386. constructor(scene: Scene);
  35387. /**
  35388. * Registers the component in a given scene
  35389. */
  35390. register(): void;
  35391. /**
  35392. * Rebuilds the elements related to this component in case of
  35393. * context lost for instance.
  35394. */
  35395. rebuild(): void;
  35396. /**
  35397. * Serializes the component data to the specified json object
  35398. * @param serializationObject The object to serialize to
  35399. */
  35400. serialize(serializationObject: any): void;
  35401. /**
  35402. * Adds all the elements from the container to the scene
  35403. * @param container the container holding the elements
  35404. */
  35405. addFromContainer(container: AbstractScene): void;
  35406. /**
  35407. * Removes all the elements in the container from the scene
  35408. * @param container contains the elements to remove
  35409. * @param dispose if the removed element should be disposed (default: false)
  35410. */
  35411. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35412. /**
  35413. * Disposes the component and the associated ressources.
  35414. */
  35415. dispose(): void;
  35416. /**
  35417. * Disables audio in the associated scene.
  35418. */
  35419. disableAudio(): void;
  35420. /**
  35421. * Enables audio in the associated scene.
  35422. */
  35423. enableAudio(): void;
  35424. /**
  35425. * Switch audio to headphone output.
  35426. */
  35427. switchAudioModeForHeadphones(): void;
  35428. /**
  35429. * Switch audio to normal speakers.
  35430. */
  35431. switchAudioModeForNormalSpeakers(): void;
  35432. private _afterRender;
  35433. }
  35434. }
  35435. declare module "babylonjs/Audio/weightedsound" {
  35436. import { Sound } from "babylonjs/Audio/sound";
  35437. /**
  35438. * Wraps one or more Sound objects and selects one with random weight for playback.
  35439. */
  35440. export class WeightedSound {
  35441. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35442. loop: boolean;
  35443. private _coneInnerAngle;
  35444. private _coneOuterAngle;
  35445. private _volume;
  35446. /** A Sound is currently playing. */
  35447. isPlaying: boolean;
  35448. /** A Sound is currently paused. */
  35449. isPaused: boolean;
  35450. private _sounds;
  35451. private _weights;
  35452. private _currentIndex?;
  35453. /**
  35454. * Creates a new WeightedSound from the list of sounds given.
  35455. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35456. * @param sounds Array of Sounds that will be selected from.
  35457. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35458. */
  35459. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35460. /**
  35461. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35462. */
  35463. /**
  35464. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35465. */
  35466. directionalConeInnerAngle: number;
  35467. /**
  35468. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35469. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35470. */
  35471. /**
  35472. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35473. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35474. */
  35475. directionalConeOuterAngle: number;
  35476. /**
  35477. * Playback volume.
  35478. */
  35479. /**
  35480. * Playback volume.
  35481. */
  35482. volume: number;
  35483. private _onended;
  35484. /**
  35485. * Suspend playback
  35486. */
  35487. pause(): void;
  35488. /**
  35489. * Stop playback
  35490. */
  35491. stop(): void;
  35492. /**
  35493. * Start playback.
  35494. * @param startOffset Position the clip head at a specific time in seconds.
  35495. */
  35496. play(startOffset?: number): void;
  35497. }
  35498. }
  35499. declare module "babylonjs/Audio/index" {
  35500. export * from "babylonjs/Audio/analyser";
  35501. export * from "babylonjs/Audio/audioEngine";
  35502. export * from "babylonjs/Audio/audioSceneComponent";
  35503. export * from "babylonjs/Audio/sound";
  35504. export * from "babylonjs/Audio/soundTrack";
  35505. export * from "babylonjs/Audio/weightedsound";
  35506. }
  35507. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35508. import { Behavior } from "babylonjs/Behaviors/behavior";
  35509. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35510. import { BackEase } from "babylonjs/Animations/easing";
  35511. /**
  35512. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35513. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35514. */
  35515. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35516. /**
  35517. * Gets the name of the behavior.
  35518. */
  35519. readonly name: string;
  35520. /**
  35521. * The easing function used by animations
  35522. */
  35523. static EasingFunction: BackEase;
  35524. /**
  35525. * The easing mode used by animations
  35526. */
  35527. static EasingMode: number;
  35528. /**
  35529. * The duration of the animation, in milliseconds
  35530. */
  35531. transitionDuration: number;
  35532. /**
  35533. * Length of the distance animated by the transition when lower radius is reached
  35534. */
  35535. lowerRadiusTransitionRange: number;
  35536. /**
  35537. * Length of the distance animated by the transition when upper radius is reached
  35538. */
  35539. upperRadiusTransitionRange: number;
  35540. private _autoTransitionRange;
  35541. /**
  35542. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35543. */
  35544. /**
  35545. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35546. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35547. */
  35548. autoTransitionRange: boolean;
  35549. private _attachedCamera;
  35550. private _onAfterCheckInputsObserver;
  35551. private _onMeshTargetChangedObserver;
  35552. /**
  35553. * Initializes the behavior.
  35554. */
  35555. init(): void;
  35556. /**
  35557. * Attaches the behavior to its arc rotate camera.
  35558. * @param camera Defines the camera to attach the behavior to
  35559. */
  35560. attach(camera: ArcRotateCamera): void;
  35561. /**
  35562. * Detaches the behavior from its current arc rotate camera.
  35563. */
  35564. detach(): void;
  35565. private _radiusIsAnimating;
  35566. private _radiusBounceTransition;
  35567. private _animatables;
  35568. private _cachedWheelPrecision;
  35569. /**
  35570. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35571. * @param radiusLimit The limit to check against.
  35572. * @return Bool to indicate if at limit.
  35573. */
  35574. private _isRadiusAtLimit;
  35575. /**
  35576. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35577. * @param radiusDelta The delta by which to animate to. Can be negative.
  35578. */
  35579. private _applyBoundRadiusAnimation;
  35580. /**
  35581. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35582. */
  35583. protected _clearAnimationLocks(): void;
  35584. /**
  35585. * Stops and removes all animations that have been applied to the camera
  35586. */
  35587. stopAllAnimations(): void;
  35588. }
  35589. }
  35590. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35591. import { Behavior } from "babylonjs/Behaviors/behavior";
  35592. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35593. import { ExponentialEase } from "babylonjs/Animations/easing";
  35594. import { Nullable } from "babylonjs/types";
  35595. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35596. import { Vector3 } from "babylonjs/Maths/math";
  35597. /**
  35598. * 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.
  35599. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35600. */
  35601. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35602. /**
  35603. * Gets the name of the behavior.
  35604. */
  35605. readonly name: string;
  35606. private _mode;
  35607. private _radiusScale;
  35608. private _positionScale;
  35609. private _defaultElevation;
  35610. private _elevationReturnTime;
  35611. private _elevationReturnWaitTime;
  35612. private _zoomStopsAnimation;
  35613. private _framingTime;
  35614. /**
  35615. * The easing function used by animations
  35616. */
  35617. static EasingFunction: ExponentialEase;
  35618. /**
  35619. * The easing mode used by animations
  35620. */
  35621. static EasingMode: number;
  35622. /**
  35623. * Sets the current mode used by the behavior
  35624. */
  35625. /**
  35626. * Gets current mode used by the behavior.
  35627. */
  35628. mode: number;
  35629. /**
  35630. * Sets the scale applied to the radius (1 by default)
  35631. */
  35632. /**
  35633. * Gets the scale applied to the radius
  35634. */
  35635. radiusScale: number;
  35636. /**
  35637. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35638. */
  35639. /**
  35640. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35641. */
  35642. positionScale: number;
  35643. /**
  35644. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35645. * behaviour is triggered, in radians.
  35646. */
  35647. /**
  35648. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35649. * behaviour is triggered, in radians.
  35650. */
  35651. defaultElevation: number;
  35652. /**
  35653. * Sets the time (in milliseconds) taken to return to the default beta position.
  35654. * Negative value indicates camera should not return to default.
  35655. */
  35656. /**
  35657. * Gets the time (in milliseconds) taken to return to the default beta position.
  35658. * Negative value indicates camera should not return to default.
  35659. */
  35660. elevationReturnTime: number;
  35661. /**
  35662. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35663. */
  35664. /**
  35665. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35666. */
  35667. elevationReturnWaitTime: number;
  35668. /**
  35669. * Sets the flag that indicates if user zooming should stop animation.
  35670. */
  35671. /**
  35672. * Gets the flag that indicates if user zooming should stop animation.
  35673. */
  35674. zoomStopsAnimation: boolean;
  35675. /**
  35676. * Sets the transition time when framing the mesh, in milliseconds
  35677. */
  35678. /**
  35679. * Gets the transition time when framing the mesh, in milliseconds
  35680. */
  35681. framingTime: number;
  35682. /**
  35683. * Define if the behavior should automatically change the configured
  35684. * camera limits and sensibilities.
  35685. */
  35686. autoCorrectCameraLimitsAndSensibility: boolean;
  35687. private _onPrePointerObservableObserver;
  35688. private _onAfterCheckInputsObserver;
  35689. private _onMeshTargetChangedObserver;
  35690. private _attachedCamera;
  35691. private _isPointerDown;
  35692. private _lastInteractionTime;
  35693. /**
  35694. * Initializes the behavior.
  35695. */
  35696. init(): void;
  35697. /**
  35698. * Attaches the behavior to its arc rotate camera.
  35699. * @param camera Defines the camera to attach the behavior to
  35700. */
  35701. attach(camera: ArcRotateCamera): void;
  35702. /**
  35703. * Detaches the behavior from its current arc rotate camera.
  35704. */
  35705. detach(): void;
  35706. private _animatables;
  35707. private _betaIsAnimating;
  35708. private _betaTransition;
  35709. private _radiusTransition;
  35710. private _vectorTransition;
  35711. /**
  35712. * Targets the given mesh and updates zoom level accordingly.
  35713. * @param mesh The mesh to target.
  35714. * @param radius Optional. If a cached radius position already exists, overrides default.
  35715. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35716. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35717. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35718. */
  35719. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35720. /**
  35721. * Targets the given mesh with its children and updates zoom level accordingly.
  35722. * @param mesh The mesh to target.
  35723. * @param radius Optional. If a cached radius position already exists, overrides default.
  35724. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35725. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35726. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35727. */
  35728. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35729. /**
  35730. * Targets the given meshes with their children and updates zoom level accordingly.
  35731. * @param meshes The mesh to target.
  35732. * @param radius Optional. If a cached radius position already exists, overrides default.
  35733. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35734. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35735. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35736. */
  35737. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35738. /**
  35739. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35740. * @param minimumWorld Determines the smaller position of the bounding box extend
  35741. * @param maximumWorld Determines the bigger position of the bounding box extend
  35742. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35743. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35744. */
  35745. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35746. /**
  35747. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35748. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35749. * frustum width.
  35750. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35751. * to fully enclose the mesh in the viewing frustum.
  35752. */
  35753. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35754. /**
  35755. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35756. * is automatically returned to its default position (expected to be above ground plane).
  35757. */
  35758. private _maintainCameraAboveGround;
  35759. /**
  35760. * Returns the frustum slope based on the canvas ratio and camera FOV
  35761. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35762. */
  35763. private _getFrustumSlope;
  35764. /**
  35765. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35766. */
  35767. private _clearAnimationLocks;
  35768. /**
  35769. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35770. */
  35771. private _applyUserInteraction;
  35772. /**
  35773. * Stops and removes all animations that have been applied to the camera
  35774. */
  35775. stopAllAnimations(): void;
  35776. /**
  35777. * Gets a value indicating if the user is moving the camera
  35778. */
  35779. readonly isUserIsMoving: boolean;
  35780. /**
  35781. * The camera can move all the way towards the mesh.
  35782. */
  35783. static IgnoreBoundsSizeMode: number;
  35784. /**
  35785. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35786. */
  35787. static FitFrustumSidesMode: number;
  35788. }
  35789. }
  35790. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35791. import { Nullable } from "babylonjs/types";
  35792. import { Camera } from "babylonjs/Cameras/camera";
  35793. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35794. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35795. /**
  35796. * Base class for Camera Pointer Inputs.
  35797. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35798. * for example usage.
  35799. */
  35800. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35801. /**
  35802. * Defines the camera the input is attached to.
  35803. */
  35804. abstract camera: Camera;
  35805. /**
  35806. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35807. */
  35808. protected _altKey: boolean;
  35809. protected _ctrlKey: boolean;
  35810. protected _metaKey: boolean;
  35811. protected _shiftKey: boolean;
  35812. /**
  35813. * Which mouse buttons were pressed at time of last mouse event.
  35814. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35815. */
  35816. protected _buttonsPressed: number;
  35817. /**
  35818. * Defines the buttons associated with the input to handle camera move.
  35819. */
  35820. buttons: number[];
  35821. /**
  35822. * Attach the input controls to a specific dom element to get the input from.
  35823. * @param element Defines the element the controls should be listened from
  35824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35825. */
  35826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35827. /**
  35828. * Detach the current controls from the specified dom element.
  35829. * @param element Defines the element to stop listening the inputs from
  35830. */
  35831. detachControl(element: Nullable<HTMLElement>): void;
  35832. /**
  35833. * Gets the class name of the current input.
  35834. * @returns the class name
  35835. */
  35836. getClassName(): string;
  35837. /**
  35838. * Get the friendly name associated with the input class.
  35839. * @returns the input friendly name
  35840. */
  35841. getSimpleName(): string;
  35842. /**
  35843. * Called on pointer POINTERDOUBLETAP event.
  35844. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35845. */
  35846. protected onDoubleTap(type: string): void;
  35847. /**
  35848. * Called on pointer POINTERMOVE event if only a single touch is active.
  35849. * Override this method to provide functionality.
  35850. */
  35851. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35852. /**
  35853. * Called on pointer POINTERMOVE event if multiple touches are active.
  35854. * Override this method to provide functionality.
  35855. */
  35856. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35857. /**
  35858. * Called on JS contextmenu event.
  35859. * Override this method to provide functionality.
  35860. */
  35861. protected onContextMenu(evt: PointerEvent): void;
  35862. /**
  35863. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35864. * press.
  35865. * Override this method to provide functionality.
  35866. */
  35867. protected onButtonDown(evt: PointerEvent): void;
  35868. /**
  35869. * Called each time a new POINTERUP event occurs. Ie, for each button
  35870. * release.
  35871. * Override this method to provide functionality.
  35872. */
  35873. protected onButtonUp(evt: PointerEvent): void;
  35874. /**
  35875. * Called when window becomes inactive.
  35876. * Override this method to provide functionality.
  35877. */
  35878. protected onLostFocus(): void;
  35879. private _pointerInput;
  35880. private _observer;
  35881. private _onLostFocus;
  35882. private pointA;
  35883. private pointB;
  35884. }
  35885. }
  35886. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35887. import { Nullable } from "babylonjs/types";
  35888. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35889. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35890. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35891. /**
  35892. * Manage the pointers inputs to control an arc rotate camera.
  35893. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35894. */
  35895. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35896. /**
  35897. * Defines the camera the input is attached to.
  35898. */
  35899. camera: ArcRotateCamera;
  35900. /**
  35901. * Gets the class name of the current input.
  35902. * @returns the class name
  35903. */
  35904. getClassName(): string;
  35905. /**
  35906. * Defines the buttons associated with the input to handle camera move.
  35907. */
  35908. buttons: number[];
  35909. /**
  35910. * Defines the pointer angular sensibility along the X axis or how fast is
  35911. * the camera rotating.
  35912. */
  35913. angularSensibilityX: number;
  35914. /**
  35915. * Defines the pointer angular sensibility along the Y axis or how fast is
  35916. * the camera rotating.
  35917. */
  35918. angularSensibilityY: number;
  35919. /**
  35920. * Defines the pointer pinch precision or how fast is the camera zooming.
  35921. */
  35922. pinchPrecision: number;
  35923. /**
  35924. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35925. * from 0.
  35926. * It defines the percentage of current camera.radius to use as delta when
  35927. * pinch zoom is used.
  35928. */
  35929. pinchDeltaPercentage: number;
  35930. /**
  35931. * Defines the pointer panning sensibility or how fast is the camera moving.
  35932. */
  35933. panningSensibility: number;
  35934. /**
  35935. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35936. */
  35937. multiTouchPanning: boolean;
  35938. /**
  35939. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35940. * zoom (pinch) through multitouch.
  35941. */
  35942. multiTouchPanAndZoom: boolean;
  35943. /**
  35944. * Revers pinch action direction.
  35945. */
  35946. pinchInwards: boolean;
  35947. private _isPanClick;
  35948. private _twoFingerActivityCount;
  35949. private _isPinching;
  35950. /**
  35951. * Called on pointer POINTERMOVE event if only a single touch is active.
  35952. */
  35953. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35954. /**
  35955. * Called on pointer POINTERDOUBLETAP event.
  35956. */
  35957. protected onDoubleTap(type: string): void;
  35958. /**
  35959. * Called on pointer POINTERMOVE event if multiple touches are active.
  35960. */
  35961. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35962. /**
  35963. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35964. * press.
  35965. */
  35966. protected onButtonDown(evt: PointerEvent): void;
  35967. /**
  35968. * Called each time a new POINTERUP event occurs. Ie, for each button
  35969. * release.
  35970. */
  35971. protected onButtonUp(evt: PointerEvent): void;
  35972. /**
  35973. * Called when window becomes inactive.
  35974. */
  35975. protected onLostFocus(): void;
  35976. }
  35977. }
  35978. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35979. import { Nullable } from "babylonjs/types";
  35980. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35981. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35982. /**
  35983. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35984. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35985. */
  35986. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35987. /**
  35988. * Defines the camera the input is attached to.
  35989. */
  35990. camera: ArcRotateCamera;
  35991. /**
  35992. * Defines the list of key codes associated with the up action (increase alpha)
  35993. */
  35994. keysUp: number[];
  35995. /**
  35996. * Defines the list of key codes associated with the down action (decrease alpha)
  35997. */
  35998. keysDown: number[];
  35999. /**
  36000. * Defines the list of key codes associated with the left action (increase beta)
  36001. */
  36002. keysLeft: number[];
  36003. /**
  36004. * Defines the list of key codes associated with the right action (decrease beta)
  36005. */
  36006. keysRight: number[];
  36007. /**
  36008. * Defines the list of key codes associated with the reset action.
  36009. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  36010. */
  36011. keysReset: number[];
  36012. /**
  36013. * Defines the panning sensibility of the inputs.
  36014. * (How fast is the camera paning)
  36015. */
  36016. panningSensibility: number;
  36017. /**
  36018. * Defines the zooming sensibility of the inputs.
  36019. * (How fast is the camera zooming)
  36020. */
  36021. zoomingSensibility: number;
  36022. /**
  36023. * Defines wether maintaining the alt key down switch the movement mode from
  36024. * orientation to zoom.
  36025. */
  36026. useAltToZoom: boolean;
  36027. /**
  36028. * Rotation speed of the camera
  36029. */
  36030. angularSpeed: number;
  36031. private _keys;
  36032. private _ctrlPressed;
  36033. private _altPressed;
  36034. private _onCanvasBlurObserver;
  36035. private _onKeyboardObserver;
  36036. private _engine;
  36037. private _scene;
  36038. /**
  36039. * Attach the input controls to a specific dom element to get the input from.
  36040. * @param element Defines the element the controls should be listened from
  36041. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36042. */
  36043. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36044. /**
  36045. * Detach the current controls from the specified dom element.
  36046. * @param element Defines the element to stop listening the inputs from
  36047. */
  36048. detachControl(element: Nullable<HTMLElement>): void;
  36049. /**
  36050. * Update the current camera state depending on the inputs that have been used this frame.
  36051. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36052. */
  36053. checkInputs(): void;
  36054. /**
  36055. * Gets the class name of the current intput.
  36056. * @returns the class name
  36057. */
  36058. getClassName(): string;
  36059. /**
  36060. * Get the friendly name associated with the input class.
  36061. * @returns the input friendly name
  36062. */
  36063. getSimpleName(): string;
  36064. }
  36065. }
  36066. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  36067. import { Nullable } from "babylonjs/types";
  36068. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36069. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  36070. /**
  36071. * Manage the mouse wheel inputs to control an arc rotate camera.
  36072. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36073. */
  36074. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  36075. /**
  36076. * Defines the camera the input is attached to.
  36077. */
  36078. camera: ArcRotateCamera;
  36079. /**
  36080. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36081. */
  36082. wheelPrecision: number;
  36083. /**
  36084. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36085. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36086. */
  36087. wheelDeltaPercentage: number;
  36088. private _wheel;
  36089. private _observer;
  36090. private computeDeltaFromMouseWheelLegacyEvent;
  36091. /**
  36092. * Attach the input controls to a specific dom element to get the input from.
  36093. * @param element Defines the element the controls should be listened from
  36094. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36095. */
  36096. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36097. /**
  36098. * Detach the current controls from the specified dom element.
  36099. * @param element Defines the element to stop listening the inputs from
  36100. */
  36101. detachControl(element: Nullable<HTMLElement>): void;
  36102. /**
  36103. * Gets the class name of the current intput.
  36104. * @returns the class name
  36105. */
  36106. getClassName(): string;
  36107. /**
  36108. * Get the friendly name associated with the input class.
  36109. * @returns the input friendly name
  36110. */
  36111. getSimpleName(): string;
  36112. }
  36113. }
  36114. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  36115. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36116. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  36117. /**
  36118. * Default Inputs manager for the ArcRotateCamera.
  36119. * It groups all the default supported inputs for ease of use.
  36120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36121. */
  36122. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  36123. /**
  36124. * Instantiates a new ArcRotateCameraInputsManager.
  36125. * @param camera Defines the camera the inputs belong to
  36126. */
  36127. constructor(camera: ArcRotateCamera);
  36128. /**
  36129. * Add mouse wheel input support to the input manager.
  36130. * @returns the current input manager
  36131. */
  36132. addMouseWheel(): ArcRotateCameraInputsManager;
  36133. /**
  36134. * Add pointers input support to the input manager.
  36135. * @returns the current input manager
  36136. */
  36137. addPointers(): ArcRotateCameraInputsManager;
  36138. /**
  36139. * Add keyboard input support to the input manager.
  36140. * @returns the current input manager
  36141. */
  36142. addKeyboard(): ArcRotateCameraInputsManager;
  36143. }
  36144. }
  36145. declare module "babylonjs/Cameras/arcRotateCamera" {
  36146. import { Observable } from "babylonjs/Misc/observable";
  36147. import { Nullable } from "babylonjs/types";
  36148. import { Scene } from "babylonjs/scene";
  36149. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  36150. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36151. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36152. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36153. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  36154. import { Camera } from "babylonjs/Cameras/camera";
  36155. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  36156. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  36157. import { Collider } from "babylonjs/Collisions/collider";
  36158. /**
  36159. * This represents an orbital type of camera.
  36160. *
  36161. * 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.
  36162. * 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.
  36163. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  36164. */
  36165. export class ArcRotateCamera extends TargetCamera {
  36166. /**
  36167. * Defines the rotation angle of the camera along the longitudinal axis.
  36168. */
  36169. alpha: number;
  36170. /**
  36171. * Defines the rotation angle of the camera along the latitudinal axis.
  36172. */
  36173. beta: number;
  36174. /**
  36175. * Defines the radius of the camera from it s target point.
  36176. */
  36177. radius: number;
  36178. protected _target: Vector3;
  36179. protected _targetHost: Nullable<AbstractMesh>;
  36180. /**
  36181. * Defines the target point of the camera.
  36182. * The camera looks towards it form the radius distance.
  36183. */
  36184. target: Vector3;
  36185. /**
  36186. * Define the current local position of the camera in the scene
  36187. */
  36188. position: Vector3;
  36189. protected _upVector: Vector3;
  36190. protected _upToYMatrix: Matrix;
  36191. protected _YToUpMatrix: Matrix;
  36192. /**
  36193. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  36194. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  36195. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  36196. */
  36197. upVector: Vector3;
  36198. /**
  36199. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  36200. */
  36201. setMatUp(): void;
  36202. /**
  36203. * Current inertia value on the longitudinal axis.
  36204. * The bigger this number the longer it will take for the camera to stop.
  36205. */
  36206. inertialAlphaOffset: number;
  36207. /**
  36208. * Current inertia value on the latitudinal axis.
  36209. * The bigger this number the longer it will take for the camera to stop.
  36210. */
  36211. inertialBetaOffset: number;
  36212. /**
  36213. * Current inertia value on the radius axis.
  36214. * The bigger this number the longer it will take for the camera to stop.
  36215. */
  36216. inertialRadiusOffset: number;
  36217. /**
  36218. * Minimum allowed angle on the longitudinal axis.
  36219. * This can help limiting how the Camera is able to move in the scene.
  36220. */
  36221. lowerAlphaLimit: Nullable<number>;
  36222. /**
  36223. * Maximum allowed angle on the longitudinal axis.
  36224. * This can help limiting how the Camera is able to move in the scene.
  36225. */
  36226. upperAlphaLimit: Nullable<number>;
  36227. /**
  36228. * Minimum allowed angle on the latitudinal axis.
  36229. * This can help limiting how the Camera is able to move in the scene.
  36230. */
  36231. lowerBetaLimit: number;
  36232. /**
  36233. * Maximum allowed angle on the latitudinal axis.
  36234. * This can help limiting how the Camera is able to move in the scene.
  36235. */
  36236. upperBetaLimit: number;
  36237. /**
  36238. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  36239. * This can help limiting how the Camera is able to move in the scene.
  36240. */
  36241. lowerRadiusLimit: Nullable<number>;
  36242. /**
  36243. * Maximum allowed distance of the camera to the target (The camera can not get further).
  36244. * This can help limiting how the Camera is able to move in the scene.
  36245. */
  36246. upperRadiusLimit: Nullable<number>;
  36247. /**
  36248. * Defines the current inertia value used during panning of the camera along the X axis.
  36249. */
  36250. inertialPanningX: number;
  36251. /**
  36252. * Defines the current inertia value used during panning of the camera along the Y axis.
  36253. */
  36254. inertialPanningY: number;
  36255. /**
  36256. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36257. * Basically if your fingers moves away from more than this distance you will be considered
  36258. * in pinch mode.
  36259. */
  36260. pinchToPanMaxDistance: number;
  36261. /**
  36262. * Defines the maximum distance the camera can pan.
  36263. * This could help keeping the cammera always in your scene.
  36264. */
  36265. panningDistanceLimit: Nullable<number>;
  36266. /**
  36267. * Defines the target of the camera before paning.
  36268. */
  36269. panningOriginTarget: Vector3;
  36270. /**
  36271. * Defines the value of the inertia used during panning.
  36272. * 0 would mean stop inertia and one would mean no decelleration at all.
  36273. */
  36274. panningInertia: number;
  36275. /**
  36276. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36277. */
  36278. angularSensibilityX: number;
  36279. /**
  36280. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36281. */
  36282. angularSensibilityY: number;
  36283. /**
  36284. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36285. */
  36286. pinchPrecision: number;
  36287. /**
  36288. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36289. * It will be used instead of pinchDeltaPrecision if different from 0.
  36290. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36291. */
  36292. pinchDeltaPercentage: number;
  36293. /**
  36294. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36295. */
  36296. panningSensibility: number;
  36297. /**
  36298. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36299. */
  36300. keysUp: number[];
  36301. /**
  36302. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36303. */
  36304. keysDown: number[];
  36305. /**
  36306. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36307. */
  36308. keysLeft: number[];
  36309. /**
  36310. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36311. */
  36312. keysRight: number[];
  36313. /**
  36314. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36315. */
  36316. wheelPrecision: number;
  36317. /**
  36318. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36319. * It will be used instead of pinchDeltaPrecision if different from 0.
  36320. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36321. */
  36322. wheelDeltaPercentage: number;
  36323. /**
  36324. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36325. */
  36326. zoomOnFactor: number;
  36327. /**
  36328. * Defines a screen offset for the camera position.
  36329. */
  36330. targetScreenOffset: Vector2;
  36331. /**
  36332. * Allows the camera to be completely reversed.
  36333. * If false the camera can not arrive upside down.
  36334. */
  36335. allowUpsideDown: boolean;
  36336. /**
  36337. * Define if double tap/click is used to restore the previously saved state of the camera.
  36338. */
  36339. useInputToRestoreState: boolean;
  36340. /** @hidden */
  36341. _viewMatrix: Matrix;
  36342. /** @hidden */
  36343. _useCtrlForPanning: boolean;
  36344. /** @hidden */
  36345. _panningMouseButton: number;
  36346. /**
  36347. * Defines the input associated to the camera.
  36348. */
  36349. inputs: ArcRotateCameraInputsManager;
  36350. /** @hidden */
  36351. _reset: () => void;
  36352. /**
  36353. * Defines the allowed panning axis.
  36354. */
  36355. panningAxis: Vector3;
  36356. protected _localDirection: Vector3;
  36357. protected _transformedDirection: Vector3;
  36358. private _bouncingBehavior;
  36359. /**
  36360. * Gets the bouncing behavior of the camera if it has been enabled.
  36361. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36362. */
  36363. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36364. /**
  36365. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36366. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36367. */
  36368. useBouncingBehavior: boolean;
  36369. private _framingBehavior;
  36370. /**
  36371. * Gets the framing behavior of the camera if it has been enabled.
  36372. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36373. */
  36374. readonly framingBehavior: Nullable<FramingBehavior>;
  36375. /**
  36376. * Defines if the framing behavior of the camera is enabled on the camera.
  36377. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36378. */
  36379. useFramingBehavior: boolean;
  36380. private _autoRotationBehavior;
  36381. /**
  36382. * Gets the auto rotation behavior of the camera if it has been enabled.
  36383. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36384. */
  36385. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36386. /**
  36387. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36388. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36389. */
  36390. useAutoRotationBehavior: boolean;
  36391. /**
  36392. * Observable triggered when the mesh target has been changed on the camera.
  36393. */
  36394. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36395. /**
  36396. * Event raised when the camera is colliding with a mesh.
  36397. */
  36398. onCollide: (collidedMesh: AbstractMesh) => void;
  36399. /**
  36400. * Defines whether the camera should check collision with the objects oh the scene.
  36401. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36402. */
  36403. checkCollisions: boolean;
  36404. /**
  36405. * Defines the collision radius of the camera.
  36406. * This simulates a sphere around the camera.
  36407. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36408. */
  36409. collisionRadius: Vector3;
  36410. protected _collider: Collider;
  36411. protected _previousPosition: Vector3;
  36412. protected _collisionVelocity: Vector3;
  36413. protected _newPosition: Vector3;
  36414. protected _previousAlpha: number;
  36415. protected _previousBeta: number;
  36416. protected _previousRadius: number;
  36417. protected _collisionTriggered: boolean;
  36418. protected _targetBoundingCenter: Nullable<Vector3>;
  36419. private _computationVector;
  36420. /**
  36421. * Instantiates a new ArcRotateCamera in a given scene
  36422. * @param name Defines the name of the camera
  36423. * @param alpha Defines the camera rotation along the logitudinal axis
  36424. * @param beta Defines the camera rotation along the latitudinal axis
  36425. * @param radius Defines the camera distance from its target
  36426. * @param target Defines the camera target
  36427. * @param scene Defines the scene the camera belongs to
  36428. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36429. */
  36430. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36431. /** @hidden */
  36432. _initCache(): void;
  36433. /** @hidden */
  36434. _updateCache(ignoreParentClass?: boolean): void;
  36435. protected _getTargetPosition(): Vector3;
  36436. private _storedAlpha;
  36437. private _storedBeta;
  36438. private _storedRadius;
  36439. private _storedTarget;
  36440. /**
  36441. * Stores the current state of the camera (alpha, beta, radius and target)
  36442. * @returns the camera itself
  36443. */
  36444. storeState(): Camera;
  36445. /**
  36446. * @hidden
  36447. * Restored camera state. You must call storeState() first
  36448. */
  36449. _restoreStateValues(): boolean;
  36450. /** @hidden */
  36451. _isSynchronizedViewMatrix(): boolean;
  36452. /**
  36453. * Attached controls to the current camera.
  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. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36457. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36458. */
  36459. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36460. /**
  36461. * Detach the current controls from the camera.
  36462. * The camera will stop reacting to inputs.
  36463. * @param element Defines the element to stop listening the inputs from
  36464. */
  36465. detachControl(element: HTMLElement): void;
  36466. /** @hidden */
  36467. _checkInputs(): void;
  36468. protected _checkLimits(): void;
  36469. /**
  36470. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36471. */
  36472. rebuildAnglesAndRadius(): void;
  36473. /**
  36474. * Use a position to define the current camera related information like aplha, beta and radius
  36475. * @param position Defines the position to set the camera at
  36476. */
  36477. setPosition(position: Vector3): void;
  36478. /**
  36479. * Defines the target the camera should look at.
  36480. * This will automatically adapt alpha beta and radius to fit within the new target.
  36481. * @param target Defines the new target as a Vector or a mesh
  36482. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36483. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36484. */
  36485. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36486. /** @hidden */
  36487. _getViewMatrix(): Matrix;
  36488. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36489. /**
  36490. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36491. * @param meshes Defines the mesh to zoom on
  36492. * @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)
  36493. */
  36494. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36495. /**
  36496. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36497. * The target will be changed but the radius
  36498. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36499. * @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)
  36500. */
  36501. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36502. min: Vector3;
  36503. max: Vector3;
  36504. distance: number;
  36505. }, doNotUpdateMaxZ?: boolean): void;
  36506. /**
  36507. * @override
  36508. * Override Camera.createRigCamera
  36509. */
  36510. createRigCamera(name: string, cameraIndex: number): Camera;
  36511. /**
  36512. * @hidden
  36513. * @override
  36514. * Override Camera._updateRigCameras
  36515. */
  36516. _updateRigCameras(): void;
  36517. /**
  36518. * Destroy the camera and release the current resources hold by it.
  36519. */
  36520. dispose(): void;
  36521. /**
  36522. * Gets the current object class name.
  36523. * @return the class name
  36524. */
  36525. getClassName(): string;
  36526. }
  36527. }
  36528. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36529. import { Behavior } from "babylonjs/Behaviors/behavior";
  36530. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36531. /**
  36532. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36533. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36534. */
  36535. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36536. /**
  36537. * Gets the name of the behavior.
  36538. */
  36539. readonly name: string;
  36540. private _zoomStopsAnimation;
  36541. private _idleRotationSpeed;
  36542. private _idleRotationWaitTime;
  36543. private _idleRotationSpinupTime;
  36544. /**
  36545. * Sets the flag that indicates if user zooming should stop animation.
  36546. */
  36547. /**
  36548. * Gets the flag that indicates if user zooming should stop animation.
  36549. */
  36550. zoomStopsAnimation: boolean;
  36551. /**
  36552. * Sets the default speed at which the camera rotates around the model.
  36553. */
  36554. /**
  36555. * Gets the default speed at which the camera rotates around the model.
  36556. */
  36557. idleRotationSpeed: number;
  36558. /**
  36559. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36560. */
  36561. /**
  36562. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36563. */
  36564. idleRotationWaitTime: number;
  36565. /**
  36566. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36567. */
  36568. /**
  36569. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36570. */
  36571. idleRotationSpinupTime: number;
  36572. /**
  36573. * Gets a value indicating if the camera is currently rotating because of this behavior
  36574. */
  36575. readonly rotationInProgress: boolean;
  36576. private _onPrePointerObservableObserver;
  36577. private _onAfterCheckInputsObserver;
  36578. private _attachedCamera;
  36579. private _isPointerDown;
  36580. private _lastFrameTime;
  36581. private _lastInteractionTime;
  36582. private _cameraRotationSpeed;
  36583. /**
  36584. * Initializes the behavior.
  36585. */
  36586. init(): void;
  36587. /**
  36588. * Attaches the behavior to its arc rotate camera.
  36589. * @param camera Defines the camera to attach the behavior to
  36590. */
  36591. attach(camera: ArcRotateCamera): void;
  36592. /**
  36593. * Detaches the behavior from its current arc rotate camera.
  36594. */
  36595. detach(): void;
  36596. /**
  36597. * Returns true if user is scrolling.
  36598. * @return true if user is scrolling.
  36599. */
  36600. private _userIsZooming;
  36601. private _lastFrameRadius;
  36602. private _shouldAnimationStopForInteraction;
  36603. /**
  36604. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36605. */
  36606. private _applyUserInteraction;
  36607. private _userIsMoving;
  36608. }
  36609. }
  36610. declare module "babylonjs/Behaviors/Cameras/index" {
  36611. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36612. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36613. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36614. }
  36615. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36616. import { Mesh } from "babylonjs/Meshes/mesh";
  36617. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36618. import { Behavior } from "babylonjs/Behaviors/behavior";
  36619. /**
  36620. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36621. */
  36622. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36623. private ui;
  36624. /**
  36625. * The name of the behavior
  36626. */
  36627. name: string;
  36628. /**
  36629. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36630. */
  36631. distanceAwayFromFace: number;
  36632. /**
  36633. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36634. */
  36635. distanceAwayFromBottomOfFace: number;
  36636. private _faceVectors;
  36637. private _target;
  36638. private _scene;
  36639. private _onRenderObserver;
  36640. private _tmpMatrix;
  36641. private _tmpVector;
  36642. /**
  36643. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36644. * @param ui The transform node that should be attched to the mesh
  36645. */
  36646. constructor(ui: TransformNode);
  36647. /**
  36648. * Initializes the behavior
  36649. */
  36650. init(): void;
  36651. private _closestFace;
  36652. private _zeroVector;
  36653. private _lookAtTmpMatrix;
  36654. private _lookAtToRef;
  36655. /**
  36656. * Attaches the AttachToBoxBehavior to the passed in mesh
  36657. * @param target The mesh that the specified node will be attached to
  36658. */
  36659. attach(target: Mesh): void;
  36660. /**
  36661. * Detaches the behavior from the mesh
  36662. */
  36663. detach(): void;
  36664. }
  36665. }
  36666. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36667. import { Behavior } from "babylonjs/Behaviors/behavior";
  36668. import { Mesh } from "babylonjs/Meshes/mesh";
  36669. /**
  36670. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36671. */
  36672. export class FadeInOutBehavior implements Behavior<Mesh> {
  36673. /**
  36674. * Time in milliseconds to delay before fading in (Default: 0)
  36675. */
  36676. delay: number;
  36677. /**
  36678. * Time in milliseconds for the mesh to fade in (Default: 300)
  36679. */
  36680. fadeInTime: number;
  36681. private _millisecondsPerFrame;
  36682. private _hovered;
  36683. private _hoverValue;
  36684. private _ownerNode;
  36685. /**
  36686. * Instatiates the FadeInOutBehavior
  36687. */
  36688. constructor();
  36689. /**
  36690. * The name of the behavior
  36691. */
  36692. readonly name: string;
  36693. /**
  36694. * Initializes the behavior
  36695. */
  36696. init(): void;
  36697. /**
  36698. * Attaches the fade behavior on the passed in mesh
  36699. * @param ownerNode The mesh that will be faded in/out once attached
  36700. */
  36701. attach(ownerNode: Mesh): void;
  36702. /**
  36703. * Detaches the behavior from the mesh
  36704. */
  36705. detach(): void;
  36706. /**
  36707. * Triggers the mesh to begin fading in or out
  36708. * @param value if the object should fade in or out (true to fade in)
  36709. */
  36710. fadeIn(value: boolean): void;
  36711. private _update;
  36712. private _setAllVisibility;
  36713. }
  36714. }
  36715. declare module "babylonjs/Misc/pivotTools" {
  36716. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36717. /**
  36718. * Class containing a set of static utilities functions for managing Pivots
  36719. * @hidden
  36720. */
  36721. export class PivotTools {
  36722. private static _PivotCached;
  36723. private static _OldPivotPoint;
  36724. private static _PivotTranslation;
  36725. private static _PivotTmpVector;
  36726. /** @hidden */
  36727. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36728. /** @hidden */
  36729. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36730. }
  36731. }
  36732. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36733. import { Scene } from "babylonjs/scene";
  36734. import { Vector4, Plane } from "babylonjs/Maths/math";
  36735. import { Mesh } from "babylonjs/Meshes/mesh";
  36736. import { Nullable } from "babylonjs/types";
  36737. /**
  36738. * Class containing static functions to help procedurally build meshes
  36739. */
  36740. export class PlaneBuilder {
  36741. /**
  36742. * Creates a plane mesh
  36743. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36744. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36745. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36746. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36747. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36748. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36749. * @param name defines the name of the mesh
  36750. * @param options defines the options used to create the mesh
  36751. * @param scene defines the hosting scene
  36752. * @returns the plane mesh
  36753. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36754. */
  36755. static CreatePlane(name: string, options: {
  36756. size?: number;
  36757. width?: number;
  36758. height?: number;
  36759. sideOrientation?: number;
  36760. frontUVs?: Vector4;
  36761. backUVs?: Vector4;
  36762. updatable?: boolean;
  36763. sourcePlane?: Plane;
  36764. }, scene?: Nullable<Scene>): Mesh;
  36765. }
  36766. }
  36767. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36768. import { Behavior } from "babylonjs/Behaviors/behavior";
  36769. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36770. import { Observable } from "babylonjs/Misc/observable";
  36771. import { Vector3 } from "babylonjs/Maths/math";
  36772. import { Ray } from "babylonjs/Culling/ray";
  36773. import "babylonjs/Meshes/Builders/planeBuilder";
  36774. /**
  36775. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36776. */
  36777. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36778. private static _AnyMouseID;
  36779. /**
  36780. * Abstract mesh the behavior is set on
  36781. */
  36782. attachedNode: AbstractMesh;
  36783. private _dragPlane;
  36784. private _scene;
  36785. private _pointerObserver;
  36786. private _beforeRenderObserver;
  36787. private static _planeScene;
  36788. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36789. /**
  36790. * 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)
  36791. */
  36792. maxDragAngle: number;
  36793. /**
  36794. * @hidden
  36795. */
  36796. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36797. /**
  36798. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36799. */
  36800. currentDraggingPointerID: number;
  36801. /**
  36802. * The last position where the pointer hit the drag plane in world space
  36803. */
  36804. lastDragPosition: Vector3;
  36805. /**
  36806. * If the behavior is currently in a dragging state
  36807. */
  36808. dragging: boolean;
  36809. /**
  36810. * 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)
  36811. */
  36812. dragDeltaRatio: number;
  36813. /**
  36814. * If the drag plane orientation should be updated during the dragging (Default: true)
  36815. */
  36816. updateDragPlane: boolean;
  36817. private _debugMode;
  36818. private _moving;
  36819. /**
  36820. * Fires each time the attached mesh is dragged with the pointer
  36821. * * delta between last drag position and current drag position in world space
  36822. * * dragDistance along the drag axis
  36823. * * dragPlaneNormal normal of the current drag plane used during the drag
  36824. * * dragPlanePoint in world space where the drag intersects the drag plane
  36825. */
  36826. onDragObservable: Observable<{
  36827. delta: Vector3;
  36828. dragPlanePoint: Vector3;
  36829. dragPlaneNormal: Vector3;
  36830. dragDistance: number;
  36831. pointerId: number;
  36832. }>;
  36833. /**
  36834. * Fires each time a drag begins (eg. mouse down on mesh)
  36835. */
  36836. onDragStartObservable: Observable<{
  36837. dragPlanePoint: Vector3;
  36838. pointerId: number;
  36839. }>;
  36840. /**
  36841. * Fires each time a drag ends (eg. mouse release after drag)
  36842. */
  36843. onDragEndObservable: Observable<{
  36844. dragPlanePoint: Vector3;
  36845. pointerId: number;
  36846. }>;
  36847. /**
  36848. * If the attached mesh should be moved when dragged
  36849. */
  36850. moveAttached: boolean;
  36851. /**
  36852. * If the drag behavior will react to drag events (Default: true)
  36853. */
  36854. enabled: boolean;
  36855. /**
  36856. * If camera controls should be detached during the drag
  36857. */
  36858. detachCameraControls: boolean;
  36859. /**
  36860. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36861. */
  36862. useObjectOrienationForDragging: boolean;
  36863. private _options;
  36864. /**
  36865. * Creates a pointer drag behavior that can be attached to a mesh
  36866. * @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)
  36867. */
  36868. constructor(options?: {
  36869. dragAxis?: Vector3;
  36870. dragPlaneNormal?: Vector3;
  36871. });
  36872. /**
  36873. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36874. */
  36875. validateDrag: (targetPosition: Vector3) => boolean;
  36876. /**
  36877. * The name of the behavior
  36878. */
  36879. readonly name: string;
  36880. /**
  36881. * Initializes the behavior
  36882. */
  36883. init(): void;
  36884. private _tmpVector;
  36885. private _alternatePickedPoint;
  36886. private _worldDragAxis;
  36887. private _targetPosition;
  36888. private _attachedElement;
  36889. /**
  36890. * Attaches the drag behavior the passed in mesh
  36891. * @param ownerNode The mesh that will be dragged around once attached
  36892. */
  36893. attach(ownerNode: AbstractMesh): void;
  36894. /**
  36895. * Force relase the drag action by code.
  36896. */
  36897. releaseDrag(): void;
  36898. private _startDragRay;
  36899. private _lastPointerRay;
  36900. /**
  36901. * Simulates the start of a pointer drag event on the behavior
  36902. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36903. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36904. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36905. */
  36906. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36907. private _startDrag;
  36908. private _dragDelta;
  36909. private _moveDrag;
  36910. private _pickWithRayOnDragPlane;
  36911. private _pointA;
  36912. private _pointB;
  36913. private _pointC;
  36914. private _lineA;
  36915. private _lineB;
  36916. private _localAxis;
  36917. private _lookAt;
  36918. private _updateDragPlanePosition;
  36919. /**
  36920. * Detaches the behavior from the mesh
  36921. */
  36922. detach(): void;
  36923. }
  36924. }
  36925. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36926. import { Mesh } from "babylonjs/Meshes/mesh";
  36927. import { Behavior } from "babylonjs/Behaviors/behavior";
  36928. /**
  36929. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36930. */
  36931. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36932. private _dragBehaviorA;
  36933. private _dragBehaviorB;
  36934. private _startDistance;
  36935. private _initialScale;
  36936. private _targetScale;
  36937. private _ownerNode;
  36938. private _sceneRenderObserver;
  36939. /**
  36940. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36941. */
  36942. constructor();
  36943. /**
  36944. * The name of the behavior
  36945. */
  36946. readonly name: string;
  36947. /**
  36948. * Initializes the behavior
  36949. */
  36950. init(): void;
  36951. private _getCurrentDistance;
  36952. /**
  36953. * Attaches the scale behavior the passed in mesh
  36954. * @param ownerNode The mesh that will be scaled around once attached
  36955. */
  36956. attach(ownerNode: Mesh): void;
  36957. /**
  36958. * Detaches the behavior from the mesh
  36959. */
  36960. detach(): void;
  36961. }
  36962. }
  36963. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36964. import { Behavior } from "babylonjs/Behaviors/behavior";
  36965. import { Mesh } from "babylonjs/Meshes/mesh";
  36966. import { Observable } from "babylonjs/Misc/observable";
  36967. /**
  36968. * 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
  36969. */
  36970. export class SixDofDragBehavior implements Behavior<Mesh> {
  36971. private static _virtualScene;
  36972. private _ownerNode;
  36973. private _sceneRenderObserver;
  36974. private _scene;
  36975. private _targetPosition;
  36976. private _virtualOriginMesh;
  36977. private _virtualDragMesh;
  36978. private _pointerObserver;
  36979. private _moving;
  36980. private _startingOrientation;
  36981. /**
  36982. * 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)
  36983. */
  36984. private zDragFactor;
  36985. /**
  36986. * If the object should rotate to face the drag origin
  36987. */
  36988. rotateDraggedObject: boolean;
  36989. /**
  36990. * If the behavior is currently in a dragging state
  36991. */
  36992. dragging: boolean;
  36993. /**
  36994. * 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)
  36995. */
  36996. dragDeltaRatio: number;
  36997. /**
  36998. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36999. */
  37000. currentDraggingPointerID: number;
  37001. /**
  37002. * If camera controls should be detached during the drag
  37003. */
  37004. detachCameraControls: boolean;
  37005. /**
  37006. * Fires each time a drag starts
  37007. */
  37008. onDragStartObservable: Observable<{}>;
  37009. /**
  37010. * Fires each time a drag ends (eg. mouse release after drag)
  37011. */
  37012. onDragEndObservable: Observable<{}>;
  37013. /**
  37014. * 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
  37015. */
  37016. constructor();
  37017. /**
  37018. * The name of the behavior
  37019. */
  37020. readonly name: string;
  37021. /**
  37022. * Initializes the behavior
  37023. */
  37024. init(): void;
  37025. /**
  37026. * Attaches the scale behavior the passed in mesh
  37027. * @param ownerNode The mesh that will be scaled around once attached
  37028. */
  37029. attach(ownerNode: Mesh): void;
  37030. /**
  37031. * Detaches the behavior from the mesh
  37032. */
  37033. detach(): void;
  37034. }
  37035. }
  37036. declare module "babylonjs/Behaviors/Meshes/index" {
  37037. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  37038. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  37039. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  37040. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  37041. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  37042. }
  37043. declare module "babylonjs/Behaviors/index" {
  37044. export * from "babylonjs/Behaviors/behavior";
  37045. export * from "babylonjs/Behaviors/Cameras/index";
  37046. export * from "babylonjs/Behaviors/Meshes/index";
  37047. }
  37048. declare module "babylonjs/Bones/boneIKController" {
  37049. import { Bone } from "babylonjs/Bones/bone";
  37050. import { Vector3 } from "babylonjs/Maths/math";
  37051. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37052. import { Nullable } from "babylonjs/types";
  37053. /**
  37054. * Class used to apply inverse kinematics to bones
  37055. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  37056. */
  37057. export class BoneIKController {
  37058. private static _tmpVecs;
  37059. private static _tmpQuat;
  37060. private static _tmpMats;
  37061. /**
  37062. * Gets or sets the target mesh
  37063. */
  37064. targetMesh: AbstractMesh;
  37065. /** Gets or sets the mesh used as pole */
  37066. poleTargetMesh: AbstractMesh;
  37067. /**
  37068. * Gets or sets the bone used as pole
  37069. */
  37070. poleTargetBone: Nullable<Bone>;
  37071. /**
  37072. * Gets or sets the target position
  37073. */
  37074. targetPosition: Vector3;
  37075. /**
  37076. * Gets or sets the pole target position
  37077. */
  37078. poleTargetPosition: Vector3;
  37079. /**
  37080. * Gets or sets the pole target local offset
  37081. */
  37082. poleTargetLocalOffset: Vector3;
  37083. /**
  37084. * Gets or sets the pole angle
  37085. */
  37086. poleAngle: number;
  37087. /**
  37088. * Gets or sets the mesh associated with the controller
  37089. */
  37090. mesh: AbstractMesh;
  37091. /**
  37092. * 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)
  37093. */
  37094. slerpAmount: number;
  37095. private _bone1Quat;
  37096. private _bone1Mat;
  37097. private _bone2Ang;
  37098. private _bone1;
  37099. private _bone2;
  37100. private _bone1Length;
  37101. private _bone2Length;
  37102. private _maxAngle;
  37103. private _maxReach;
  37104. private _rightHandedSystem;
  37105. private _bendAxis;
  37106. private _slerping;
  37107. private _adjustRoll;
  37108. /**
  37109. * Gets or sets maximum allowed angle
  37110. */
  37111. maxAngle: number;
  37112. /**
  37113. * Creates a new BoneIKController
  37114. * @param mesh defines the mesh to control
  37115. * @param bone defines the bone to control
  37116. * @param options defines options to set up the controller
  37117. */
  37118. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  37119. targetMesh?: AbstractMesh;
  37120. poleTargetMesh?: AbstractMesh;
  37121. poleTargetBone?: Bone;
  37122. poleTargetLocalOffset?: Vector3;
  37123. poleAngle?: number;
  37124. bendAxis?: Vector3;
  37125. maxAngle?: number;
  37126. slerpAmount?: number;
  37127. });
  37128. private _setMaxAngle;
  37129. /**
  37130. * Force the controller to update the bones
  37131. */
  37132. update(): void;
  37133. }
  37134. }
  37135. declare module "babylonjs/Bones/boneLookController" {
  37136. import { Vector3, Space } from "babylonjs/Maths/math";
  37137. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37138. import { Bone } from "babylonjs/Bones/bone";
  37139. /**
  37140. * Class used to make a bone look toward a point in space
  37141. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  37142. */
  37143. export class BoneLookController {
  37144. private static _tmpVecs;
  37145. private static _tmpQuat;
  37146. private static _tmpMats;
  37147. /**
  37148. * The target Vector3 that the bone will look at
  37149. */
  37150. target: Vector3;
  37151. /**
  37152. * The mesh that the bone is attached to
  37153. */
  37154. mesh: AbstractMesh;
  37155. /**
  37156. * The bone that will be looking to the target
  37157. */
  37158. bone: Bone;
  37159. /**
  37160. * The up axis of the coordinate system that is used when the bone is rotated
  37161. */
  37162. upAxis: Vector3;
  37163. /**
  37164. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  37165. */
  37166. upAxisSpace: Space;
  37167. /**
  37168. * Used to make an adjustment to the yaw of the bone
  37169. */
  37170. adjustYaw: number;
  37171. /**
  37172. * Used to make an adjustment to the pitch of the bone
  37173. */
  37174. adjustPitch: number;
  37175. /**
  37176. * Used to make an adjustment to the roll of the bone
  37177. */
  37178. adjustRoll: number;
  37179. /**
  37180. * 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)
  37181. */
  37182. slerpAmount: number;
  37183. private _minYaw;
  37184. private _maxYaw;
  37185. private _minPitch;
  37186. private _maxPitch;
  37187. private _minYawSin;
  37188. private _minYawCos;
  37189. private _maxYawSin;
  37190. private _maxYawCos;
  37191. private _midYawConstraint;
  37192. private _minPitchTan;
  37193. private _maxPitchTan;
  37194. private _boneQuat;
  37195. private _slerping;
  37196. private _transformYawPitch;
  37197. private _transformYawPitchInv;
  37198. private _firstFrameSkipped;
  37199. private _yawRange;
  37200. private _fowardAxis;
  37201. /**
  37202. * Gets or sets the minimum yaw angle that the bone can look to
  37203. */
  37204. minYaw: number;
  37205. /**
  37206. * Gets or sets the maximum yaw angle that the bone can look to
  37207. */
  37208. maxYaw: number;
  37209. /**
  37210. * Gets or sets the minimum pitch angle that the bone can look to
  37211. */
  37212. minPitch: number;
  37213. /**
  37214. * Gets or sets the maximum pitch angle that the bone can look to
  37215. */
  37216. maxPitch: number;
  37217. /**
  37218. * Create a BoneLookController
  37219. * @param mesh the mesh that the bone belongs to
  37220. * @param bone the bone that will be looking to the target
  37221. * @param target the target Vector3 to look at
  37222. * @param options optional settings:
  37223. * * maxYaw: the maximum angle the bone will yaw to
  37224. * * minYaw: the minimum angle the bone will yaw to
  37225. * * maxPitch: the maximum angle the bone will pitch to
  37226. * * minPitch: the minimum angle the bone will yaw to
  37227. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  37228. * * upAxis: the up axis of the coordinate system
  37229. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  37230. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  37231. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  37232. * * adjustYaw: used to make an adjustment to the yaw of the bone
  37233. * * adjustPitch: used to make an adjustment to the pitch of the bone
  37234. * * adjustRoll: used to make an adjustment to the roll of the bone
  37235. **/
  37236. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  37237. maxYaw?: number;
  37238. minYaw?: number;
  37239. maxPitch?: number;
  37240. minPitch?: number;
  37241. slerpAmount?: number;
  37242. upAxis?: Vector3;
  37243. upAxisSpace?: Space;
  37244. yawAxis?: Vector3;
  37245. pitchAxis?: Vector3;
  37246. adjustYaw?: number;
  37247. adjustPitch?: number;
  37248. adjustRoll?: number;
  37249. });
  37250. /**
  37251. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  37252. */
  37253. update(): void;
  37254. private _getAngleDiff;
  37255. private _getAngleBetween;
  37256. private _isAngleBetween;
  37257. }
  37258. }
  37259. declare module "babylonjs/Bones/index" {
  37260. export * from "babylonjs/Bones/bone";
  37261. export * from "babylonjs/Bones/boneIKController";
  37262. export * from "babylonjs/Bones/boneLookController";
  37263. export * from "babylonjs/Bones/skeleton";
  37264. }
  37265. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37266. import { Nullable } from "babylonjs/types";
  37267. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37268. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37269. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37270. /**
  37271. * Manage the gamepad inputs to control an arc rotate camera.
  37272. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37273. */
  37274. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37275. /**
  37276. * Defines the camera the input is attached to.
  37277. */
  37278. camera: ArcRotateCamera;
  37279. /**
  37280. * Defines the gamepad the input is gathering event from.
  37281. */
  37282. gamepad: Nullable<Gamepad>;
  37283. /**
  37284. * Defines the gamepad rotation sensiblity.
  37285. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37286. */
  37287. gamepadRotationSensibility: number;
  37288. /**
  37289. * Defines the gamepad move sensiblity.
  37290. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37291. */
  37292. gamepadMoveSensibility: number;
  37293. private _onGamepadConnectedObserver;
  37294. private _onGamepadDisconnectedObserver;
  37295. /**
  37296. * Attach the input controls to a specific dom element to get the input from.
  37297. * @param element Defines the element the controls should be listened from
  37298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37299. */
  37300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37301. /**
  37302. * Detach the current controls from the specified dom element.
  37303. * @param element Defines the element to stop listening the inputs from
  37304. */
  37305. detachControl(element: Nullable<HTMLElement>): void;
  37306. /**
  37307. * Update the current camera state depending on the inputs that have been used this frame.
  37308. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37309. */
  37310. checkInputs(): void;
  37311. /**
  37312. * Gets the class name of the current intput.
  37313. * @returns the class name
  37314. */
  37315. getClassName(): string;
  37316. /**
  37317. * Get the friendly name associated with the input class.
  37318. * @returns the input friendly name
  37319. */
  37320. getSimpleName(): string;
  37321. }
  37322. }
  37323. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37324. import { Nullable } from "babylonjs/types";
  37325. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37326. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37327. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37328. interface ArcRotateCameraInputsManager {
  37329. /**
  37330. * Add orientation input support to the input manager.
  37331. * @returns the current input manager
  37332. */
  37333. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37334. }
  37335. }
  37336. /**
  37337. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37338. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37339. */
  37340. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37341. /**
  37342. * Defines the camera the input is attached to.
  37343. */
  37344. camera: ArcRotateCamera;
  37345. /**
  37346. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37347. */
  37348. alphaCorrection: number;
  37349. /**
  37350. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37351. */
  37352. gammaCorrection: number;
  37353. private _alpha;
  37354. private _gamma;
  37355. private _dirty;
  37356. private _deviceOrientationHandler;
  37357. /**
  37358. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37359. */
  37360. constructor();
  37361. /**
  37362. * Attach the input controls to a specific dom element to get the input from.
  37363. * @param element Defines the element the controls should be listened from
  37364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37365. */
  37366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37367. /** @hidden */
  37368. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37369. /**
  37370. * Update the current camera state depending on the inputs that have been used this frame.
  37371. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37372. */
  37373. checkInputs(): void;
  37374. /**
  37375. * Detach the current controls from the specified dom element.
  37376. * @param element Defines the element to stop listening the inputs from
  37377. */
  37378. detachControl(element: Nullable<HTMLElement>): void;
  37379. /**
  37380. * Gets the class name of the current intput.
  37381. * @returns the class name
  37382. */
  37383. getClassName(): string;
  37384. /**
  37385. * Get the friendly name associated with the input class.
  37386. * @returns the input friendly name
  37387. */
  37388. getSimpleName(): string;
  37389. }
  37390. }
  37391. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37392. import { Nullable } from "babylonjs/types";
  37393. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37394. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37395. /**
  37396. * Listen to mouse events to control the camera.
  37397. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37398. */
  37399. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37400. /**
  37401. * Defines the camera the input is attached to.
  37402. */
  37403. camera: FlyCamera;
  37404. /**
  37405. * Defines if touch is enabled. (Default is true.)
  37406. */
  37407. touchEnabled: boolean;
  37408. /**
  37409. * Defines the buttons associated with the input to handle camera rotation.
  37410. */
  37411. buttons: number[];
  37412. /**
  37413. * Assign buttons for Yaw control.
  37414. */
  37415. buttonsYaw: number[];
  37416. /**
  37417. * Assign buttons for Pitch control.
  37418. */
  37419. buttonsPitch: number[];
  37420. /**
  37421. * Assign buttons for Roll control.
  37422. */
  37423. buttonsRoll: number[];
  37424. /**
  37425. * Detect if any button is being pressed while mouse is moved.
  37426. * -1 = Mouse locked.
  37427. * 0 = Left button.
  37428. * 1 = Middle Button.
  37429. * 2 = Right Button.
  37430. */
  37431. activeButton: number;
  37432. /**
  37433. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37434. * Higher values reduce its sensitivity.
  37435. */
  37436. angularSensibility: number;
  37437. private _mousemoveCallback;
  37438. private _observer;
  37439. private _rollObserver;
  37440. private previousPosition;
  37441. private noPreventDefault;
  37442. private element;
  37443. /**
  37444. * Listen to mouse events to control the camera.
  37445. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37446. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37447. */
  37448. constructor(touchEnabled?: boolean);
  37449. /**
  37450. * Attach the mouse control to the HTML DOM element.
  37451. * @param element Defines the element that listens to the input events.
  37452. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37453. */
  37454. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37455. /**
  37456. * Detach the current controls from the specified dom element.
  37457. * @param element Defines the element to stop listening the inputs from
  37458. */
  37459. detachControl(element: Nullable<HTMLElement>): void;
  37460. /**
  37461. * Gets the class name of the current input.
  37462. * @returns the class name.
  37463. */
  37464. getClassName(): string;
  37465. /**
  37466. * Get the friendly name associated with the input class.
  37467. * @returns the input's friendly name.
  37468. */
  37469. getSimpleName(): string;
  37470. private _pointerInput;
  37471. private _onMouseMove;
  37472. /**
  37473. * Rotate camera by mouse offset.
  37474. */
  37475. private rotateCamera;
  37476. }
  37477. }
  37478. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37479. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37480. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37481. /**
  37482. * Default Inputs manager for the FlyCamera.
  37483. * It groups all the default supported inputs for ease of use.
  37484. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37485. */
  37486. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37487. /**
  37488. * Instantiates a new FlyCameraInputsManager.
  37489. * @param camera Defines the camera the inputs belong to.
  37490. */
  37491. constructor(camera: FlyCamera);
  37492. /**
  37493. * Add keyboard input support to the input manager.
  37494. * @returns the new FlyCameraKeyboardMoveInput().
  37495. */
  37496. addKeyboard(): FlyCameraInputsManager;
  37497. /**
  37498. * Add mouse input support to the input manager.
  37499. * @param touchEnabled Enable touch screen support.
  37500. * @returns the new FlyCameraMouseInput().
  37501. */
  37502. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37503. }
  37504. }
  37505. declare module "babylonjs/Cameras/flyCamera" {
  37506. import { Scene } from "babylonjs/scene";
  37507. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37508. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37509. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37510. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37511. /**
  37512. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37513. * such as in a 3D Space Shooter or a Flight Simulator.
  37514. */
  37515. export class FlyCamera extends TargetCamera {
  37516. /**
  37517. * Define the collision ellipsoid of the camera.
  37518. * This is helpful for simulating a camera body, like a player's body.
  37519. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37520. */
  37521. ellipsoid: Vector3;
  37522. /**
  37523. * Define an offset for the position of the ellipsoid around the camera.
  37524. * This can be helpful if the camera is attached away from the player's body center,
  37525. * such as at its head.
  37526. */
  37527. ellipsoidOffset: Vector3;
  37528. /**
  37529. * Enable or disable collisions of the camera with the rest of the scene objects.
  37530. */
  37531. checkCollisions: boolean;
  37532. /**
  37533. * Enable or disable gravity on the camera.
  37534. */
  37535. applyGravity: boolean;
  37536. /**
  37537. * Define the current direction the camera is moving to.
  37538. */
  37539. cameraDirection: Vector3;
  37540. /**
  37541. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37542. * This overrides and empties cameraRotation.
  37543. */
  37544. rotationQuaternion: Quaternion;
  37545. /**
  37546. * Track Roll to maintain the wanted Rolling when looking around.
  37547. */
  37548. _trackRoll: number;
  37549. /**
  37550. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37551. */
  37552. rollCorrect: number;
  37553. /**
  37554. * Mimic a banked turn, Rolling the camera when Yawing.
  37555. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37556. */
  37557. bankedTurn: boolean;
  37558. /**
  37559. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37560. */
  37561. bankedTurnLimit: number;
  37562. /**
  37563. * Value of 0 disables the banked Roll.
  37564. * Value of 1 is equal to the Yaw angle in radians.
  37565. */
  37566. bankedTurnMultiplier: number;
  37567. /**
  37568. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37569. */
  37570. inputs: FlyCameraInputsManager;
  37571. /**
  37572. * Gets the input sensibility for mouse input.
  37573. * Higher values reduce sensitivity.
  37574. */
  37575. /**
  37576. * Sets the input sensibility for a mouse input.
  37577. * Higher values reduce sensitivity.
  37578. */
  37579. angularSensibility: number;
  37580. /**
  37581. * Get the keys for camera movement forward.
  37582. */
  37583. /**
  37584. * Set the keys for camera movement forward.
  37585. */
  37586. keysForward: number[];
  37587. /**
  37588. * Get the keys for camera movement backward.
  37589. */
  37590. keysBackward: number[];
  37591. /**
  37592. * Get the keys for camera movement up.
  37593. */
  37594. /**
  37595. * Set the keys for camera movement up.
  37596. */
  37597. keysUp: number[];
  37598. /**
  37599. * Get the keys for camera movement down.
  37600. */
  37601. /**
  37602. * Set the keys for camera movement down.
  37603. */
  37604. keysDown: number[];
  37605. /**
  37606. * Get the keys for camera movement left.
  37607. */
  37608. /**
  37609. * Set the keys for camera movement left.
  37610. */
  37611. keysLeft: number[];
  37612. /**
  37613. * Set the keys for camera movement right.
  37614. */
  37615. /**
  37616. * Set the keys for camera movement right.
  37617. */
  37618. keysRight: number[];
  37619. /**
  37620. * Event raised when the camera collides with a mesh in the scene.
  37621. */
  37622. onCollide: (collidedMesh: AbstractMesh) => void;
  37623. private _collider;
  37624. private _needMoveForGravity;
  37625. private _oldPosition;
  37626. private _diffPosition;
  37627. private _newPosition;
  37628. /** @hidden */
  37629. _localDirection: Vector3;
  37630. /** @hidden */
  37631. _transformedDirection: Vector3;
  37632. /**
  37633. * Instantiates a FlyCamera.
  37634. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37635. * such as in a 3D Space Shooter or a Flight Simulator.
  37636. * @param name Define the name of the camera in the scene.
  37637. * @param position Define the starting position of the camera in the scene.
  37638. * @param scene Define the scene the camera belongs to.
  37639. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37640. */
  37641. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37642. /**
  37643. * Attach a control to the HTML DOM element.
  37644. * @param element Defines the element that listens to the input events.
  37645. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37646. */
  37647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37648. /**
  37649. * Detach a control from the HTML DOM element.
  37650. * The camera will stop reacting to that input.
  37651. * @param element Defines the element that listens to the input events.
  37652. */
  37653. detachControl(element: HTMLElement): void;
  37654. private _collisionMask;
  37655. /**
  37656. * Get the mask that the camera ignores in collision events.
  37657. */
  37658. /**
  37659. * Set the mask that the camera ignores in collision events.
  37660. */
  37661. collisionMask: number;
  37662. /** @hidden */
  37663. _collideWithWorld(displacement: Vector3): void;
  37664. /** @hidden */
  37665. private _onCollisionPositionChange;
  37666. /** @hidden */
  37667. _checkInputs(): void;
  37668. /** @hidden */
  37669. _decideIfNeedsToMove(): boolean;
  37670. /** @hidden */
  37671. _updatePosition(): void;
  37672. /**
  37673. * Restore the Roll to its target value at the rate specified.
  37674. * @param rate - Higher means slower restoring.
  37675. * @hidden
  37676. */
  37677. restoreRoll(rate: number): void;
  37678. /**
  37679. * Destroy the camera and release the current resources held by it.
  37680. */
  37681. dispose(): void;
  37682. /**
  37683. * Get the current object class name.
  37684. * @returns the class name.
  37685. */
  37686. getClassName(): string;
  37687. }
  37688. }
  37689. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37690. import { Nullable } from "babylonjs/types";
  37691. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37692. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37693. /**
  37694. * Listen to keyboard events to control the camera.
  37695. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37696. */
  37697. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37698. /**
  37699. * Defines the camera the input is attached to.
  37700. */
  37701. camera: FlyCamera;
  37702. /**
  37703. * The list of keyboard keys used to control the forward move of the camera.
  37704. */
  37705. keysForward: number[];
  37706. /**
  37707. * The list of keyboard keys used to control the backward move of the camera.
  37708. */
  37709. keysBackward: number[];
  37710. /**
  37711. * The list of keyboard keys used to control the forward move of the camera.
  37712. */
  37713. keysUp: number[];
  37714. /**
  37715. * The list of keyboard keys used to control the backward move of the camera.
  37716. */
  37717. keysDown: number[];
  37718. /**
  37719. * The list of keyboard keys used to control the right strafe move of the camera.
  37720. */
  37721. keysRight: number[];
  37722. /**
  37723. * The list of keyboard keys used to control the left strafe move of the camera.
  37724. */
  37725. keysLeft: number[];
  37726. private _keys;
  37727. private _onCanvasBlurObserver;
  37728. private _onKeyboardObserver;
  37729. private _engine;
  37730. private _scene;
  37731. /**
  37732. * Attach the input controls to a specific dom element to get the input from.
  37733. * @param element Defines the element the controls should be listened from
  37734. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37735. */
  37736. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37737. /**
  37738. * Detach the current controls from the specified dom element.
  37739. * @param element Defines the element to stop listening the inputs from
  37740. */
  37741. detachControl(element: Nullable<HTMLElement>): void;
  37742. /**
  37743. * Gets the class name of the current intput.
  37744. * @returns the class name
  37745. */
  37746. getClassName(): string;
  37747. /** @hidden */
  37748. _onLostFocus(e: FocusEvent): void;
  37749. /**
  37750. * Get the friendly name associated with the input class.
  37751. * @returns the input friendly name
  37752. */
  37753. getSimpleName(): string;
  37754. /**
  37755. * Update the current camera state depending on the inputs that have been used this frame.
  37756. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37757. */
  37758. checkInputs(): void;
  37759. }
  37760. }
  37761. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37762. import { Nullable } from "babylonjs/types";
  37763. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37764. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37765. /**
  37766. * Manage the mouse wheel inputs to control a follow camera.
  37767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37768. */
  37769. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37770. /**
  37771. * Defines the camera the input is attached to.
  37772. */
  37773. camera: FollowCamera;
  37774. /**
  37775. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37776. */
  37777. axisControlRadius: boolean;
  37778. /**
  37779. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37780. */
  37781. axisControlHeight: boolean;
  37782. /**
  37783. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37784. */
  37785. axisControlRotation: boolean;
  37786. /**
  37787. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37788. * relation to mouseWheel events.
  37789. */
  37790. wheelPrecision: number;
  37791. /**
  37792. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37793. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37794. */
  37795. wheelDeltaPercentage: number;
  37796. private _wheel;
  37797. private _observer;
  37798. /**
  37799. * Attach the input controls to a specific dom element to get the input from.
  37800. * @param element Defines the element the controls should be listened from
  37801. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37802. */
  37803. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37804. /**
  37805. * Detach the current controls from the specified dom element.
  37806. * @param element Defines the element to stop listening the inputs from
  37807. */
  37808. detachControl(element: Nullable<HTMLElement>): void;
  37809. /**
  37810. * Gets the class name of the current intput.
  37811. * @returns the class name
  37812. */
  37813. getClassName(): string;
  37814. /**
  37815. * Get the friendly name associated with the input class.
  37816. * @returns the input friendly name
  37817. */
  37818. getSimpleName(): string;
  37819. }
  37820. }
  37821. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37822. import { Nullable } from "babylonjs/types";
  37823. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37824. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37825. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37826. /**
  37827. * Manage the pointers inputs to control an follow camera.
  37828. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37829. */
  37830. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37831. /**
  37832. * Defines the camera the input is attached to.
  37833. */
  37834. camera: FollowCamera;
  37835. /**
  37836. * Gets the class name of the current input.
  37837. * @returns the class name
  37838. */
  37839. getClassName(): string;
  37840. /**
  37841. * Defines the pointer angular sensibility along the X axis or how fast is
  37842. * the camera rotating.
  37843. * A negative number will reverse the axis direction.
  37844. */
  37845. angularSensibilityX: number;
  37846. /**
  37847. * Defines the pointer angular sensibility along the Y axis or how fast is
  37848. * the camera rotating.
  37849. * A negative number will reverse the axis direction.
  37850. */
  37851. angularSensibilityY: number;
  37852. /**
  37853. * Defines the pointer pinch precision or how fast is the camera zooming.
  37854. * A negative number will reverse the axis direction.
  37855. */
  37856. pinchPrecision: number;
  37857. /**
  37858. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37859. * from 0.
  37860. * It defines the percentage of current camera.radius to use as delta when
  37861. * pinch zoom is used.
  37862. */
  37863. pinchDeltaPercentage: number;
  37864. /**
  37865. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37866. */
  37867. axisXControlRadius: boolean;
  37868. /**
  37869. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37870. */
  37871. axisXControlHeight: boolean;
  37872. /**
  37873. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37874. */
  37875. axisXControlRotation: boolean;
  37876. /**
  37877. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37878. */
  37879. axisYControlRadius: boolean;
  37880. /**
  37881. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37882. */
  37883. axisYControlHeight: boolean;
  37884. /**
  37885. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37886. */
  37887. axisYControlRotation: boolean;
  37888. /**
  37889. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37890. */
  37891. axisPinchControlRadius: boolean;
  37892. /**
  37893. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37894. */
  37895. axisPinchControlHeight: boolean;
  37896. /**
  37897. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37898. */
  37899. axisPinchControlRotation: boolean;
  37900. /**
  37901. * Log error messages if basic misconfiguration has occurred.
  37902. */
  37903. warningEnable: boolean;
  37904. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37905. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37906. private _warningCounter;
  37907. private _warning;
  37908. }
  37909. }
  37910. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37911. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37912. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37913. /**
  37914. * Default Inputs manager for the FollowCamera.
  37915. * It groups all the default supported inputs for ease of use.
  37916. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37917. */
  37918. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37919. /**
  37920. * Instantiates a new FollowCameraInputsManager.
  37921. * @param camera Defines the camera the inputs belong to
  37922. */
  37923. constructor(camera: FollowCamera);
  37924. /**
  37925. * Add keyboard input support to the input manager.
  37926. * @returns the current input manager
  37927. */
  37928. addKeyboard(): FollowCameraInputsManager;
  37929. /**
  37930. * Add mouse wheel input support to the input manager.
  37931. * @returns the current input manager
  37932. */
  37933. addMouseWheel(): FollowCameraInputsManager;
  37934. /**
  37935. * Add pointers input support to the input manager.
  37936. * @returns the current input manager
  37937. */
  37938. addPointers(): FollowCameraInputsManager;
  37939. /**
  37940. * Add orientation input support to the input manager.
  37941. * @returns the current input manager
  37942. */
  37943. addVRDeviceOrientation(): FollowCameraInputsManager;
  37944. }
  37945. }
  37946. declare module "babylonjs/Cameras/followCamera" {
  37947. import { Nullable } from "babylonjs/types";
  37948. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37949. import { Scene } from "babylonjs/scene";
  37950. import { Vector3 } from "babylonjs/Maths/math";
  37951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37952. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37953. /**
  37954. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37955. * an arc rotate version arcFollowCamera are available.
  37956. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37957. */
  37958. export class FollowCamera extends TargetCamera {
  37959. /**
  37960. * Distance the follow camera should follow an object at
  37961. */
  37962. radius: number;
  37963. /**
  37964. * Minimum allowed distance of the camera to the axis of rotation
  37965. * (The camera can not get closer).
  37966. * This can help limiting how the Camera is able to move in the scene.
  37967. */
  37968. lowerRadiusLimit: Nullable<number>;
  37969. /**
  37970. * Maximum allowed distance of the camera to the axis of rotation
  37971. * (The camera can not get further).
  37972. * This can help limiting how the Camera is able to move in the scene.
  37973. */
  37974. upperRadiusLimit: Nullable<number>;
  37975. /**
  37976. * Define a rotation offset between the camera and the object it follows
  37977. */
  37978. rotationOffset: number;
  37979. /**
  37980. * Minimum allowed angle to camera position relative to target object.
  37981. * This can help limiting how the Camera is able to move in the scene.
  37982. */
  37983. lowerRotationOffsetLimit: Nullable<number>;
  37984. /**
  37985. * Maximum allowed angle to camera position relative to target object.
  37986. * This can help limiting how the Camera is able to move in the scene.
  37987. */
  37988. upperRotationOffsetLimit: Nullable<number>;
  37989. /**
  37990. * Define a height offset between the camera and the object it follows.
  37991. * It can help following an object from the top (like a car chaing a plane)
  37992. */
  37993. heightOffset: number;
  37994. /**
  37995. * Minimum allowed height of camera position relative to target object.
  37996. * This can help limiting how the Camera is able to move in the scene.
  37997. */
  37998. lowerHeightOffsetLimit: Nullable<number>;
  37999. /**
  38000. * Maximum allowed height of camera position relative to target object.
  38001. * This can help limiting how the Camera is able to move in the scene.
  38002. */
  38003. upperHeightOffsetLimit: Nullable<number>;
  38004. /**
  38005. * Define how fast the camera can accelerate to follow it s target.
  38006. */
  38007. cameraAcceleration: number;
  38008. /**
  38009. * Define the speed limit of the camera following an object.
  38010. */
  38011. maxCameraSpeed: number;
  38012. /**
  38013. * Define the target of the camera.
  38014. */
  38015. lockedTarget: Nullable<AbstractMesh>;
  38016. /**
  38017. * Defines the input associated with the camera.
  38018. */
  38019. inputs: FollowCameraInputsManager;
  38020. /**
  38021. * Instantiates the follow camera.
  38022. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38023. * @param name Define the name of the camera in the scene
  38024. * @param position Define the position of the camera
  38025. * @param scene Define the scene the camera belong to
  38026. * @param lockedTarget Define the target of the camera
  38027. */
  38028. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  38029. private _follow;
  38030. /**
  38031. * Attached controls to the current camera.
  38032. * @param element Defines the element the controls should be listened from
  38033. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38034. */
  38035. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38036. /**
  38037. * Detach the current controls from the camera.
  38038. * The camera will stop reacting to inputs.
  38039. * @param element Defines the element to stop listening the inputs from
  38040. */
  38041. detachControl(element: HTMLElement): void;
  38042. /** @hidden */
  38043. _checkInputs(): void;
  38044. private _checkLimits;
  38045. /**
  38046. * Gets the camera class name.
  38047. * @returns the class name
  38048. */
  38049. getClassName(): string;
  38050. }
  38051. /**
  38052. * Arc Rotate version of the follow camera.
  38053. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  38054. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38055. */
  38056. export class ArcFollowCamera extends TargetCamera {
  38057. /** The longitudinal angle of the camera */
  38058. alpha: number;
  38059. /** The latitudinal angle of the camera */
  38060. beta: number;
  38061. /** The radius of the camera from its target */
  38062. radius: number;
  38063. /** Define the camera target (the messh it should follow) */
  38064. target: Nullable<AbstractMesh>;
  38065. private _cartesianCoordinates;
  38066. /**
  38067. * Instantiates a new ArcFollowCamera
  38068. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  38069. * @param name Define the name of the camera
  38070. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  38071. * @param beta Define the rotation angle of the camera around the elevation axis
  38072. * @param radius Define the radius of the camera from its target point
  38073. * @param target Define the target of the camera
  38074. * @param scene Define the scene the camera belongs to
  38075. */
  38076. constructor(name: string,
  38077. /** The longitudinal angle of the camera */
  38078. alpha: number,
  38079. /** The latitudinal angle of the camera */
  38080. beta: number,
  38081. /** The radius of the camera from its target */
  38082. radius: number,
  38083. /** Define the camera target (the messh it should follow) */
  38084. target: Nullable<AbstractMesh>, scene: Scene);
  38085. private _follow;
  38086. /** @hidden */
  38087. _checkInputs(): void;
  38088. /**
  38089. * Returns the class name of the object.
  38090. * It is mostly used internally for serialization purposes.
  38091. */
  38092. getClassName(): string;
  38093. }
  38094. }
  38095. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  38096. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38097. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  38098. import { Nullable } from "babylonjs/types";
  38099. /**
  38100. * Manage the keyboard inputs to control the movement of a follow camera.
  38101. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38102. */
  38103. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  38104. /**
  38105. * Defines the camera the input is attached to.
  38106. */
  38107. camera: FollowCamera;
  38108. /**
  38109. * Defines the list of key codes associated with the up action (increase heightOffset)
  38110. */
  38111. keysHeightOffsetIncr: number[];
  38112. /**
  38113. * Defines the list of key codes associated with the down action (decrease heightOffset)
  38114. */
  38115. keysHeightOffsetDecr: number[];
  38116. /**
  38117. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  38118. */
  38119. keysHeightOffsetModifierAlt: boolean;
  38120. /**
  38121. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  38122. */
  38123. keysHeightOffsetModifierCtrl: boolean;
  38124. /**
  38125. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  38126. */
  38127. keysHeightOffsetModifierShift: boolean;
  38128. /**
  38129. * Defines the list of key codes associated with the left action (increase rotationOffset)
  38130. */
  38131. keysRotationOffsetIncr: number[];
  38132. /**
  38133. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  38134. */
  38135. keysRotationOffsetDecr: number[];
  38136. /**
  38137. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  38138. */
  38139. keysRotationOffsetModifierAlt: boolean;
  38140. /**
  38141. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  38142. */
  38143. keysRotationOffsetModifierCtrl: boolean;
  38144. /**
  38145. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  38146. */
  38147. keysRotationOffsetModifierShift: boolean;
  38148. /**
  38149. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  38150. */
  38151. keysRadiusIncr: number[];
  38152. /**
  38153. * Defines the list of key codes associated with the zoom-out action (increase radius)
  38154. */
  38155. keysRadiusDecr: number[];
  38156. /**
  38157. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  38158. */
  38159. keysRadiusModifierAlt: boolean;
  38160. /**
  38161. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  38162. */
  38163. keysRadiusModifierCtrl: boolean;
  38164. /**
  38165. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  38166. */
  38167. keysRadiusModifierShift: boolean;
  38168. /**
  38169. * Defines the rate of change of heightOffset.
  38170. */
  38171. heightSensibility: number;
  38172. /**
  38173. * Defines the rate of change of rotationOffset.
  38174. */
  38175. rotationSensibility: number;
  38176. /**
  38177. * Defines the rate of change of radius.
  38178. */
  38179. radiusSensibility: number;
  38180. private _keys;
  38181. private _ctrlPressed;
  38182. private _altPressed;
  38183. private _shiftPressed;
  38184. private _onCanvasBlurObserver;
  38185. private _onKeyboardObserver;
  38186. private _engine;
  38187. private _scene;
  38188. /**
  38189. * Attach the input controls to a specific dom element to get the input from.
  38190. * @param element Defines the element the controls should be listened from
  38191. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38192. */
  38193. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38194. /**
  38195. * Detach the current controls from the specified dom element.
  38196. * @param element Defines the element to stop listening the inputs from
  38197. */
  38198. detachControl(element: Nullable<HTMLElement>): void;
  38199. /**
  38200. * Update the current camera state depending on the inputs that have been used this frame.
  38201. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38202. */
  38203. checkInputs(): void;
  38204. /**
  38205. * Gets the class name of the current input.
  38206. * @returns the class name
  38207. */
  38208. getClassName(): string;
  38209. /**
  38210. * Get the friendly name associated with the input class.
  38211. * @returns the input friendly name
  38212. */
  38213. getSimpleName(): string;
  38214. /**
  38215. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38216. * allow modification of the heightOffset value.
  38217. */
  38218. private _modifierHeightOffset;
  38219. /**
  38220. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38221. * allow modification of the rotationOffset value.
  38222. */
  38223. private _modifierRotationOffset;
  38224. /**
  38225. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  38226. * allow modification of the radius value.
  38227. */
  38228. private _modifierRadius;
  38229. }
  38230. }
  38231. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  38232. import { Nullable } from "babylonjs/types";
  38233. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38234. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38235. import { Observable } from "babylonjs/Misc/observable";
  38236. module "babylonjs/Cameras/freeCameraInputsManager" {
  38237. interface FreeCameraInputsManager {
  38238. /**
  38239. * @hidden
  38240. */
  38241. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  38242. /**
  38243. * Add orientation input support to the input manager.
  38244. * @returns the current input manager
  38245. */
  38246. addDeviceOrientation(): FreeCameraInputsManager;
  38247. }
  38248. }
  38249. /**
  38250. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  38251. * Screen rotation is taken into account.
  38252. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38253. */
  38254. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  38255. private _camera;
  38256. private _screenOrientationAngle;
  38257. private _constantTranform;
  38258. private _screenQuaternion;
  38259. private _alpha;
  38260. private _beta;
  38261. private _gamma;
  38262. /**
  38263. * @hidden
  38264. */
  38265. _onDeviceOrientationChangedObservable: Observable<void>;
  38266. /**
  38267. * Instantiates a new input
  38268. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38269. */
  38270. constructor();
  38271. /**
  38272. * Define the camera controlled by the input.
  38273. */
  38274. camera: FreeCamera;
  38275. /**
  38276. * Attach the input controls to a specific dom element to get the input from.
  38277. * @param element Defines the element the controls should be listened from
  38278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38279. */
  38280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38281. private _orientationChanged;
  38282. private _deviceOrientation;
  38283. /**
  38284. * Detach the current controls from the specified dom element.
  38285. * @param element Defines the element to stop listening the inputs from
  38286. */
  38287. detachControl(element: Nullable<HTMLElement>): void;
  38288. /**
  38289. * Update the current camera state depending on the inputs that have been used this frame.
  38290. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38291. */
  38292. checkInputs(): void;
  38293. /**
  38294. * Gets the class name of the current intput.
  38295. * @returns the class name
  38296. */
  38297. getClassName(): string;
  38298. /**
  38299. * Get the friendly name associated with the input class.
  38300. * @returns the input friendly name
  38301. */
  38302. getSimpleName(): string;
  38303. }
  38304. }
  38305. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38306. import { Nullable } from "babylonjs/types";
  38307. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38308. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38309. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38310. /**
  38311. * Manage the gamepad inputs to control a free camera.
  38312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38313. */
  38314. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38315. /**
  38316. * Define the camera the input is attached to.
  38317. */
  38318. camera: FreeCamera;
  38319. /**
  38320. * Define the Gamepad controlling the input
  38321. */
  38322. gamepad: Nullable<Gamepad>;
  38323. /**
  38324. * Defines the gamepad rotation sensiblity.
  38325. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38326. */
  38327. gamepadAngularSensibility: number;
  38328. /**
  38329. * Defines the gamepad move sensiblity.
  38330. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38331. */
  38332. gamepadMoveSensibility: number;
  38333. private _onGamepadConnectedObserver;
  38334. private _onGamepadDisconnectedObserver;
  38335. private _cameraTransform;
  38336. private _deltaTransform;
  38337. private _vector3;
  38338. private _vector2;
  38339. /**
  38340. * Attach the input controls to a specific dom element to get the input from.
  38341. * @param element Defines the element the controls should be listened from
  38342. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38343. */
  38344. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38345. /**
  38346. * Detach the current controls from the specified dom element.
  38347. * @param element Defines the element to stop listening the inputs from
  38348. */
  38349. detachControl(element: Nullable<HTMLElement>): void;
  38350. /**
  38351. * Update the current camera state depending on the inputs that have been used this frame.
  38352. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38353. */
  38354. checkInputs(): void;
  38355. /**
  38356. * Gets the class name of the current intput.
  38357. * @returns the class name
  38358. */
  38359. getClassName(): string;
  38360. /**
  38361. * Get the friendly name associated with the input class.
  38362. * @returns the input friendly name
  38363. */
  38364. getSimpleName(): string;
  38365. }
  38366. }
  38367. declare module "babylonjs/Misc/virtualJoystick" {
  38368. import { Nullable } from "babylonjs/types";
  38369. import { Vector3 } from "babylonjs/Maths/math";
  38370. /**
  38371. * Defines the potential axis of a Joystick
  38372. */
  38373. export enum JoystickAxis {
  38374. /** X axis */
  38375. X = 0,
  38376. /** Y axis */
  38377. Y = 1,
  38378. /** Z axis */
  38379. Z = 2
  38380. }
  38381. /**
  38382. * Class used to define virtual joystick (used in touch mode)
  38383. */
  38384. export class VirtualJoystick {
  38385. /**
  38386. * Gets or sets a boolean indicating that left and right values must be inverted
  38387. */
  38388. reverseLeftRight: boolean;
  38389. /**
  38390. * Gets or sets a boolean indicating that up and down values must be inverted
  38391. */
  38392. reverseUpDown: boolean;
  38393. /**
  38394. * Gets the offset value for the position (ie. the change of the position value)
  38395. */
  38396. deltaPosition: Vector3;
  38397. /**
  38398. * Gets a boolean indicating if the virtual joystick was pressed
  38399. */
  38400. pressed: boolean;
  38401. /**
  38402. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38403. */
  38404. static Canvas: Nullable<HTMLCanvasElement>;
  38405. private static _globalJoystickIndex;
  38406. private static vjCanvasContext;
  38407. private static vjCanvasWidth;
  38408. private static vjCanvasHeight;
  38409. private static halfWidth;
  38410. private _action;
  38411. private _axisTargetedByLeftAndRight;
  38412. private _axisTargetedByUpAndDown;
  38413. private _joystickSensibility;
  38414. private _inversedSensibility;
  38415. private _joystickPointerID;
  38416. private _joystickColor;
  38417. private _joystickPointerPos;
  38418. private _joystickPreviousPointerPos;
  38419. private _joystickPointerStartPos;
  38420. private _deltaJoystickVector;
  38421. private _leftJoystick;
  38422. private _touches;
  38423. private _onPointerDownHandlerRef;
  38424. private _onPointerMoveHandlerRef;
  38425. private _onPointerUpHandlerRef;
  38426. private _onResize;
  38427. /**
  38428. * Creates a new virtual joystick
  38429. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38430. */
  38431. constructor(leftJoystick?: boolean);
  38432. /**
  38433. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38434. * @param newJoystickSensibility defines the new sensibility
  38435. */
  38436. setJoystickSensibility(newJoystickSensibility: number): void;
  38437. private _onPointerDown;
  38438. private _onPointerMove;
  38439. private _onPointerUp;
  38440. /**
  38441. * Change the color of the virtual joystick
  38442. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38443. */
  38444. setJoystickColor(newColor: string): void;
  38445. /**
  38446. * Defines a callback to call when the joystick is touched
  38447. * @param action defines the callback
  38448. */
  38449. setActionOnTouch(action: () => any): void;
  38450. /**
  38451. * Defines which axis you'd like to control for left & right
  38452. * @param axis defines the axis to use
  38453. */
  38454. setAxisForLeftRight(axis: JoystickAxis): void;
  38455. /**
  38456. * Defines which axis you'd like to control for up & down
  38457. * @param axis defines the axis to use
  38458. */
  38459. setAxisForUpDown(axis: JoystickAxis): void;
  38460. private _drawVirtualJoystick;
  38461. /**
  38462. * Release internal HTML canvas
  38463. */
  38464. releaseCanvas(): void;
  38465. }
  38466. }
  38467. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38468. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38469. import { Nullable } from "babylonjs/types";
  38470. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38471. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38472. module "babylonjs/Cameras/freeCameraInputsManager" {
  38473. interface FreeCameraInputsManager {
  38474. /**
  38475. * Add virtual joystick input support to the input manager.
  38476. * @returns the current input manager
  38477. */
  38478. addVirtualJoystick(): FreeCameraInputsManager;
  38479. }
  38480. }
  38481. /**
  38482. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38484. */
  38485. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38486. /**
  38487. * Defines the camera the input is attached to.
  38488. */
  38489. camera: FreeCamera;
  38490. private _leftjoystick;
  38491. private _rightjoystick;
  38492. /**
  38493. * Gets the left stick of the virtual joystick.
  38494. * @returns The virtual Joystick
  38495. */
  38496. getLeftJoystick(): VirtualJoystick;
  38497. /**
  38498. * Gets the right stick of the virtual joystick.
  38499. * @returns The virtual Joystick
  38500. */
  38501. getRightJoystick(): VirtualJoystick;
  38502. /**
  38503. * Update the current camera state depending on the inputs that have been used this frame.
  38504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38505. */
  38506. checkInputs(): void;
  38507. /**
  38508. * Attach the input controls to a specific dom element to get the input from.
  38509. * @param element Defines the element the controls should be listened from
  38510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38511. */
  38512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38513. /**
  38514. * Detach the current controls from the specified dom element.
  38515. * @param element Defines the element to stop listening the inputs from
  38516. */
  38517. detachControl(element: Nullable<HTMLElement>): void;
  38518. /**
  38519. * Gets the class name of the current intput.
  38520. * @returns the class name
  38521. */
  38522. getClassName(): string;
  38523. /**
  38524. * Get the friendly name associated with the input class.
  38525. * @returns the input friendly name
  38526. */
  38527. getSimpleName(): string;
  38528. }
  38529. }
  38530. declare module "babylonjs/Cameras/Inputs/index" {
  38531. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38532. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38533. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38534. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38535. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38536. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38537. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38538. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38539. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38540. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38541. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38542. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38543. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38544. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38545. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38546. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38547. }
  38548. declare module "babylonjs/Cameras/touchCamera" {
  38549. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38550. import { Scene } from "babylonjs/scene";
  38551. import { Vector3 } from "babylonjs/Maths/math";
  38552. /**
  38553. * This represents a FPS type of camera controlled by touch.
  38554. * This is like a universal camera minus the Gamepad controls.
  38555. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38556. */
  38557. export class TouchCamera extends FreeCamera {
  38558. /**
  38559. * Defines the touch sensibility for rotation.
  38560. * The higher the faster.
  38561. */
  38562. touchAngularSensibility: number;
  38563. /**
  38564. * Defines the touch sensibility for move.
  38565. * The higher the faster.
  38566. */
  38567. touchMoveSensibility: number;
  38568. /**
  38569. * Instantiates a new touch camera.
  38570. * This represents a FPS type of camera controlled by touch.
  38571. * This is like a universal camera minus the Gamepad controls.
  38572. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38573. * @param name Define the name of the camera in the scene
  38574. * @param position Define the start position of the camera in the scene
  38575. * @param scene Define the scene the camera belongs to
  38576. */
  38577. constructor(name: string, position: Vector3, scene: Scene);
  38578. /**
  38579. * Gets the current object class name.
  38580. * @return the class name
  38581. */
  38582. getClassName(): string;
  38583. /** @hidden */
  38584. _setupInputs(): void;
  38585. }
  38586. }
  38587. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38588. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38589. import { Scene } from "babylonjs/scene";
  38590. import { Vector3, Axis } from "babylonjs/Maths/math";
  38591. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38592. /**
  38593. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38594. * being tilted forward or back and left or right.
  38595. */
  38596. export class DeviceOrientationCamera extends FreeCamera {
  38597. private _initialQuaternion;
  38598. private _quaternionCache;
  38599. private _tmpDragQuaternion;
  38600. /**
  38601. * Creates a new device orientation camera
  38602. * @param name The name of the camera
  38603. * @param position The start position camera
  38604. * @param scene The scene the camera belongs to
  38605. */
  38606. constructor(name: string, position: Vector3, scene: Scene);
  38607. /**
  38608. * @hidden
  38609. * Disabled pointer input on first orientation sensor update (Default: true)
  38610. */
  38611. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38612. private _dragFactor;
  38613. /**
  38614. * Enabled turning on the y axis when the orientation sensor is active
  38615. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38616. */
  38617. enableHorizontalDragging(dragFactor?: number): void;
  38618. /**
  38619. * Gets the current instance class name ("DeviceOrientationCamera").
  38620. * This helps avoiding instanceof at run time.
  38621. * @returns the class name
  38622. */
  38623. getClassName(): string;
  38624. /**
  38625. * @hidden
  38626. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38627. */
  38628. _checkInputs(): void;
  38629. /**
  38630. * Reset the camera to its default orientation on the specified axis only.
  38631. * @param axis The axis to reset
  38632. */
  38633. resetToCurrentRotation(axis?: Axis): void;
  38634. }
  38635. }
  38636. declare module "babylonjs/Gamepads/xboxGamepad" {
  38637. import { Observable } from "babylonjs/Misc/observable";
  38638. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38639. /**
  38640. * Defines supported buttons for XBox360 compatible gamepads
  38641. */
  38642. export enum Xbox360Button {
  38643. /** A */
  38644. A = 0,
  38645. /** B */
  38646. B = 1,
  38647. /** X */
  38648. X = 2,
  38649. /** Y */
  38650. Y = 3,
  38651. /** Start */
  38652. Start = 4,
  38653. /** Back */
  38654. Back = 5,
  38655. /** Left button */
  38656. LB = 6,
  38657. /** Right button */
  38658. RB = 7,
  38659. /** Left stick */
  38660. LeftStick = 8,
  38661. /** Right stick */
  38662. RightStick = 9
  38663. }
  38664. /** Defines values for XBox360 DPad */
  38665. export enum Xbox360Dpad {
  38666. /** Up */
  38667. Up = 0,
  38668. /** Down */
  38669. Down = 1,
  38670. /** Left */
  38671. Left = 2,
  38672. /** Right */
  38673. Right = 3
  38674. }
  38675. /**
  38676. * Defines a XBox360 gamepad
  38677. */
  38678. export class Xbox360Pad extends Gamepad {
  38679. private _leftTrigger;
  38680. private _rightTrigger;
  38681. private _onlefttriggerchanged;
  38682. private _onrighttriggerchanged;
  38683. private _onbuttondown;
  38684. private _onbuttonup;
  38685. private _ondpaddown;
  38686. private _ondpadup;
  38687. /** Observable raised when a button is pressed */
  38688. onButtonDownObservable: Observable<Xbox360Button>;
  38689. /** Observable raised when a button is released */
  38690. onButtonUpObservable: Observable<Xbox360Button>;
  38691. /** Observable raised when a pad is pressed */
  38692. onPadDownObservable: Observable<Xbox360Dpad>;
  38693. /** Observable raised when a pad is released */
  38694. onPadUpObservable: Observable<Xbox360Dpad>;
  38695. private _buttonA;
  38696. private _buttonB;
  38697. private _buttonX;
  38698. private _buttonY;
  38699. private _buttonBack;
  38700. private _buttonStart;
  38701. private _buttonLB;
  38702. private _buttonRB;
  38703. private _buttonLeftStick;
  38704. private _buttonRightStick;
  38705. private _dPadUp;
  38706. private _dPadDown;
  38707. private _dPadLeft;
  38708. private _dPadRight;
  38709. private _isXboxOnePad;
  38710. /**
  38711. * Creates a new XBox360 gamepad object
  38712. * @param id defines the id of this gamepad
  38713. * @param index defines its index
  38714. * @param gamepad defines the internal HTML gamepad object
  38715. * @param xboxOne defines if it is a XBox One gamepad
  38716. */
  38717. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  38718. /**
  38719. * Defines the callback to call when left trigger is pressed
  38720. * @param callback defines the callback to use
  38721. */
  38722. onlefttriggerchanged(callback: (value: number) => void): void;
  38723. /**
  38724. * Defines the callback to call when right trigger is pressed
  38725. * @param callback defines the callback to use
  38726. */
  38727. onrighttriggerchanged(callback: (value: number) => void): void;
  38728. /**
  38729. * Gets the left trigger value
  38730. */
  38731. /**
  38732. * Sets the left trigger value
  38733. */
  38734. leftTrigger: number;
  38735. /**
  38736. * Gets the right trigger value
  38737. */
  38738. /**
  38739. * Sets the right trigger value
  38740. */
  38741. rightTrigger: number;
  38742. /**
  38743. * Defines the callback to call when a button is pressed
  38744. * @param callback defines the callback to use
  38745. */
  38746. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  38747. /**
  38748. * Defines the callback to call when a button is released
  38749. * @param callback defines the callback to use
  38750. */
  38751. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  38752. /**
  38753. * Defines the callback to call when a pad is pressed
  38754. * @param callback defines the callback to use
  38755. */
  38756. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  38757. /**
  38758. * Defines the callback to call when a pad is released
  38759. * @param callback defines the callback to use
  38760. */
  38761. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  38762. private _setButtonValue;
  38763. private _setDPadValue;
  38764. /**
  38765. * Gets the value of the `A` button
  38766. */
  38767. /**
  38768. * Sets the value of the `A` button
  38769. */
  38770. buttonA: number;
  38771. /**
  38772. * Gets the value of the `B` button
  38773. */
  38774. /**
  38775. * Sets the value of the `B` button
  38776. */
  38777. buttonB: number;
  38778. /**
  38779. * Gets the value of the `X` button
  38780. */
  38781. /**
  38782. * Sets the value of the `X` button
  38783. */
  38784. buttonX: number;
  38785. /**
  38786. * Gets the value of the `Y` button
  38787. */
  38788. /**
  38789. * Sets the value of the `Y` button
  38790. */
  38791. buttonY: number;
  38792. /**
  38793. * Gets the value of the `Start` button
  38794. */
  38795. /**
  38796. * Sets the value of the `Start` button
  38797. */
  38798. buttonStart: number;
  38799. /**
  38800. * Gets the value of the `Back` button
  38801. */
  38802. /**
  38803. * Sets the value of the `Back` button
  38804. */
  38805. buttonBack: number;
  38806. /**
  38807. * Gets the value of the `Left` button
  38808. */
  38809. /**
  38810. * Sets the value of the `Left` button
  38811. */
  38812. buttonLB: number;
  38813. /**
  38814. * Gets the value of the `Right` button
  38815. */
  38816. /**
  38817. * Sets the value of the `Right` button
  38818. */
  38819. buttonRB: number;
  38820. /**
  38821. * Gets the value of the Left joystick
  38822. */
  38823. /**
  38824. * Sets the value of the Left joystick
  38825. */
  38826. buttonLeftStick: number;
  38827. /**
  38828. * Gets the value of the Right joystick
  38829. */
  38830. /**
  38831. * Sets the value of the Right joystick
  38832. */
  38833. buttonRightStick: number;
  38834. /**
  38835. * Gets the value of D-pad up
  38836. */
  38837. /**
  38838. * Sets the value of D-pad up
  38839. */
  38840. dPadUp: number;
  38841. /**
  38842. * Gets the value of D-pad down
  38843. */
  38844. /**
  38845. * Sets the value of D-pad down
  38846. */
  38847. dPadDown: number;
  38848. /**
  38849. * Gets the value of D-pad left
  38850. */
  38851. /**
  38852. * Sets the value of D-pad left
  38853. */
  38854. dPadLeft: number;
  38855. /**
  38856. * Gets the value of D-pad right
  38857. */
  38858. /**
  38859. * Sets the value of D-pad right
  38860. */
  38861. dPadRight: number;
  38862. /**
  38863. * Force the gamepad to synchronize with device values
  38864. */
  38865. update(): void;
  38866. /**
  38867. * Disposes the gamepad
  38868. */
  38869. dispose(): void;
  38870. }
  38871. }
  38872. declare module "babylonjs/Gamepads/gamepadManager" {
  38873. import { Observable } from "babylonjs/Misc/observable";
  38874. import { Nullable } from "babylonjs/types";
  38875. import { Scene } from "babylonjs/scene";
  38876. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38877. /**
  38878. * Manager for handling gamepads
  38879. */
  38880. export class GamepadManager {
  38881. private _scene?;
  38882. private _babylonGamepads;
  38883. private _oneGamepadConnected;
  38884. /** @hidden */
  38885. _isMonitoring: boolean;
  38886. private _gamepadEventSupported;
  38887. private _gamepadSupport;
  38888. /**
  38889. * observable to be triggered when the gamepad controller has been connected
  38890. */
  38891. onGamepadConnectedObservable: Observable<Gamepad>;
  38892. /**
  38893. * observable to be triggered when the gamepad controller has been disconnected
  38894. */
  38895. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38896. private _onGamepadConnectedEvent;
  38897. private _onGamepadDisconnectedEvent;
  38898. /**
  38899. * Initializes the gamepad manager
  38900. * @param _scene BabylonJS scene
  38901. */
  38902. constructor(_scene?: Scene | undefined);
  38903. /**
  38904. * The gamepads in the game pad manager
  38905. */
  38906. readonly gamepads: Gamepad[];
  38907. /**
  38908. * Get the gamepad controllers based on type
  38909. * @param type The type of gamepad controller
  38910. * @returns Nullable gamepad
  38911. */
  38912. getGamepadByType(type?: number): Nullable<Gamepad>;
  38913. /**
  38914. * Disposes the gamepad manager
  38915. */
  38916. dispose(): void;
  38917. private _addNewGamepad;
  38918. private _startMonitoringGamepads;
  38919. private _stopMonitoringGamepads;
  38920. /** @hidden */
  38921. _checkGamepadsStatus(): void;
  38922. private _updateGamepadObjects;
  38923. }
  38924. }
  38925. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  38926. import { Nullable } from "babylonjs/types";
  38927. import { Scene } from "babylonjs/scene";
  38928. import { ISceneComponent } from "babylonjs/sceneComponent";
  38929. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  38930. module "babylonjs/scene" {
  38931. interface Scene {
  38932. /** @hidden */
  38933. _gamepadManager: Nullable<GamepadManager>;
  38934. /**
  38935. * Gets the gamepad manager associated with the scene
  38936. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38937. */
  38938. gamepadManager: GamepadManager;
  38939. }
  38940. }
  38941. module "babylonjs/Cameras/freeCameraInputsManager" {
  38942. /**
  38943. * Interface representing a free camera inputs manager
  38944. */
  38945. interface FreeCameraInputsManager {
  38946. /**
  38947. * Adds gamepad input support to the FreeCameraInputsManager.
  38948. * @returns the FreeCameraInputsManager
  38949. */
  38950. addGamepad(): FreeCameraInputsManager;
  38951. }
  38952. }
  38953. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38954. /**
  38955. * Interface representing an arc rotate camera inputs manager
  38956. */
  38957. interface ArcRotateCameraInputsManager {
  38958. /**
  38959. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38960. * @returns the camera inputs manager
  38961. */
  38962. addGamepad(): ArcRotateCameraInputsManager;
  38963. }
  38964. }
  38965. /**
  38966. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38967. */
  38968. export class GamepadSystemSceneComponent implements ISceneComponent {
  38969. /**
  38970. * The component name helpfull to identify the component in the list of scene components.
  38971. */
  38972. readonly name: string;
  38973. /**
  38974. * The scene the component belongs to.
  38975. */
  38976. scene: Scene;
  38977. /**
  38978. * Creates a new instance of the component for the given scene
  38979. * @param scene Defines the scene to register the component in
  38980. */
  38981. constructor(scene: Scene);
  38982. /**
  38983. * Registers the component in a given scene
  38984. */
  38985. register(): void;
  38986. /**
  38987. * Rebuilds the elements related to this component in case of
  38988. * context lost for instance.
  38989. */
  38990. rebuild(): void;
  38991. /**
  38992. * Disposes the component and the associated ressources
  38993. */
  38994. dispose(): void;
  38995. private _beforeCameraUpdate;
  38996. }
  38997. }
  38998. declare module "babylonjs/Cameras/universalCamera" {
  38999. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  39000. import { Scene } from "babylonjs/scene";
  39001. import { Vector3 } from "babylonjs/Maths/math";
  39002. import "babylonjs/Gamepads/gamepadSceneComponent";
  39003. /**
  39004. * 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,
  39005. * which still works and will still be found in many Playgrounds.
  39006. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39007. */
  39008. export class UniversalCamera extends TouchCamera {
  39009. /**
  39010. * Defines the gamepad rotation sensiblity.
  39011. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39012. */
  39013. gamepadAngularSensibility: number;
  39014. /**
  39015. * Defines the gamepad move sensiblity.
  39016. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39017. */
  39018. gamepadMoveSensibility: number;
  39019. /**
  39020. * 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,
  39021. * which still works and will still be found in many Playgrounds.
  39022. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39023. * @param name Define the name of the camera in the scene
  39024. * @param position Define the start position of the camera in the scene
  39025. * @param scene Define the scene the camera belongs to
  39026. */
  39027. constructor(name: string, position: Vector3, scene: Scene);
  39028. /**
  39029. * Gets the current object class name.
  39030. * @return the class name
  39031. */
  39032. getClassName(): string;
  39033. }
  39034. }
  39035. declare module "babylonjs/Cameras/gamepadCamera" {
  39036. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39037. import { Scene } from "babylonjs/scene";
  39038. import { Vector3 } from "babylonjs/Maths/math";
  39039. /**
  39040. * This represents a FPS type of camera. This is only here for back compat purpose.
  39041. * Please use the UniversalCamera instead as both are identical.
  39042. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39043. */
  39044. export class GamepadCamera extends UniversalCamera {
  39045. /**
  39046. * Instantiates a new Gamepad Camera
  39047. * This represents a FPS type of camera. This is only here for back compat purpose.
  39048. * Please use the UniversalCamera instead as both are identical.
  39049. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39050. * @param name Define the name of the camera in the scene
  39051. * @param position Define the start position of the camera in the scene
  39052. * @param scene Define the scene the camera belongs to
  39053. */
  39054. constructor(name: string, position: Vector3, scene: Scene);
  39055. /**
  39056. * Gets the current object class name.
  39057. * @return the class name
  39058. */
  39059. getClassName(): string;
  39060. }
  39061. }
  39062. declare module "babylonjs/Shaders/pass.fragment" {
  39063. /** @hidden */
  39064. export var passPixelShader: {
  39065. name: string;
  39066. shader: string;
  39067. };
  39068. }
  39069. declare module "babylonjs/Shaders/passCube.fragment" {
  39070. /** @hidden */
  39071. export var passCubePixelShader: {
  39072. name: string;
  39073. shader: string;
  39074. };
  39075. }
  39076. declare module "babylonjs/PostProcesses/passPostProcess" {
  39077. import { Nullable } from "babylonjs/types";
  39078. import { Camera } from "babylonjs/Cameras/camera";
  39079. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39080. import { Engine } from "babylonjs/Engines/engine";
  39081. import "babylonjs/Shaders/pass.fragment";
  39082. import "babylonjs/Shaders/passCube.fragment";
  39083. /**
  39084. * PassPostProcess which produces an output the same as it's input
  39085. */
  39086. export class PassPostProcess extends PostProcess {
  39087. /**
  39088. * Creates the PassPostProcess
  39089. * @param name The name of the effect.
  39090. * @param options The required width/height ratio to downsize to before computing the render pass.
  39091. * @param camera The camera to apply the render pass to.
  39092. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39093. * @param engine The engine which the post process will be applied. (default: current engine)
  39094. * @param reusable If the post process can be reused on the same frame. (default: false)
  39095. * @param textureType The type of texture to be used when performing the post processing.
  39096. * @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)
  39097. */
  39098. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39099. }
  39100. /**
  39101. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  39102. */
  39103. export class PassCubePostProcess extends PostProcess {
  39104. private _face;
  39105. /**
  39106. * Gets or sets the cube face to display.
  39107. * * 0 is +X
  39108. * * 1 is -X
  39109. * * 2 is +Y
  39110. * * 3 is -Y
  39111. * * 4 is +Z
  39112. * * 5 is -Z
  39113. */
  39114. face: number;
  39115. /**
  39116. * Creates the PassCubePostProcess
  39117. * @param name The name of the effect.
  39118. * @param options The required width/height ratio to downsize to before computing the render pass.
  39119. * @param camera The camera to apply the render pass to.
  39120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39121. * @param engine The engine which the post process will be applied. (default: current engine)
  39122. * @param reusable If the post process can be reused on the same frame. (default: false)
  39123. * @param textureType The type of texture to be used when performing the post processing.
  39124. * @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)
  39125. */
  39126. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  39127. }
  39128. }
  39129. declare module "babylonjs/Shaders/anaglyph.fragment" {
  39130. /** @hidden */
  39131. export var anaglyphPixelShader: {
  39132. name: string;
  39133. shader: string;
  39134. };
  39135. }
  39136. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  39137. import { Engine } from "babylonjs/Engines/engine";
  39138. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  39139. import { Camera } from "babylonjs/Cameras/camera";
  39140. import "babylonjs/Shaders/anaglyph.fragment";
  39141. /**
  39142. * Postprocess used to generate anaglyphic rendering
  39143. */
  39144. export class AnaglyphPostProcess extends PostProcess {
  39145. private _passedProcess;
  39146. /**
  39147. * Creates a new AnaglyphPostProcess
  39148. * @param name defines postprocess name
  39149. * @param options defines creation options or target ratio scale
  39150. * @param rigCameras defines cameras using this postprocess
  39151. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  39152. * @param engine defines hosting engine
  39153. * @param reusable defines if the postprocess will be reused multiple times per frame
  39154. */
  39155. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  39156. }
  39157. }
  39158. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  39159. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  39160. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39161. import { Scene } from "babylonjs/scene";
  39162. import { Vector3 } from "babylonjs/Maths/math";
  39163. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39164. /**
  39165. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  39166. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39167. */
  39168. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  39169. /**
  39170. * Creates a new AnaglyphArcRotateCamera
  39171. * @param name defines camera name
  39172. * @param alpha defines alpha angle (in radians)
  39173. * @param beta defines beta angle (in radians)
  39174. * @param radius defines radius
  39175. * @param target defines camera target
  39176. * @param interaxialDistance defines distance between each color axis
  39177. * @param scene defines the hosting scene
  39178. */
  39179. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  39180. /**
  39181. * Gets camera class name
  39182. * @returns AnaglyphArcRotateCamera
  39183. */
  39184. getClassName(): string;
  39185. }
  39186. }
  39187. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  39188. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39189. import { Scene } from "babylonjs/scene";
  39190. import { Vector3 } from "babylonjs/Maths/math";
  39191. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39192. /**
  39193. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  39194. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39195. */
  39196. export class AnaglyphFreeCamera extends FreeCamera {
  39197. /**
  39198. * Creates a new AnaglyphFreeCamera
  39199. * @param name defines camera name
  39200. * @param position defines initial position
  39201. * @param interaxialDistance defines distance between each color axis
  39202. * @param scene defines the hosting scene
  39203. */
  39204. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39205. /**
  39206. * Gets camera class name
  39207. * @returns AnaglyphFreeCamera
  39208. */
  39209. getClassName(): string;
  39210. }
  39211. }
  39212. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  39213. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39214. import { Scene } from "babylonjs/scene";
  39215. import { Vector3 } from "babylonjs/Maths/math";
  39216. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39217. /**
  39218. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  39219. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39220. */
  39221. export class AnaglyphGamepadCamera extends GamepadCamera {
  39222. /**
  39223. * Creates a new AnaglyphGamepadCamera
  39224. * @param name defines camera name
  39225. * @param position defines initial position
  39226. * @param interaxialDistance defines distance between each color axis
  39227. * @param scene defines the hosting scene
  39228. */
  39229. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39230. /**
  39231. * Gets camera class name
  39232. * @returns AnaglyphGamepadCamera
  39233. */
  39234. getClassName(): string;
  39235. }
  39236. }
  39237. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  39238. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39239. import { Scene } from "babylonjs/scene";
  39240. import { Vector3 } from "babylonjs/Maths/math";
  39241. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  39242. /**
  39243. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  39244. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  39245. */
  39246. export class AnaglyphUniversalCamera extends UniversalCamera {
  39247. /**
  39248. * Creates a new AnaglyphUniversalCamera
  39249. * @param name defines camera name
  39250. * @param position defines initial position
  39251. * @param interaxialDistance defines distance between each color axis
  39252. * @param scene defines the hosting scene
  39253. */
  39254. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  39255. /**
  39256. * Gets camera class name
  39257. * @returns AnaglyphUniversalCamera
  39258. */
  39259. getClassName(): string;
  39260. }
  39261. }
  39262. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  39263. /** @hidden */
  39264. export var stereoscopicInterlacePixelShader: {
  39265. name: string;
  39266. shader: string;
  39267. };
  39268. }
  39269. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  39270. import { Camera } from "babylonjs/Cameras/camera";
  39271. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39272. import { Engine } from "babylonjs/Engines/engine";
  39273. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  39274. /**
  39275. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  39276. */
  39277. export class StereoscopicInterlacePostProcess extends PostProcess {
  39278. private _stepSize;
  39279. private _passedProcess;
  39280. /**
  39281. * Initializes a StereoscopicInterlacePostProcess
  39282. * @param name The name of the effect.
  39283. * @param rigCameras The rig cameras to be appled to the post process
  39284. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  39285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  39286. * @param engine The engine which the post process will be applied. (default: current engine)
  39287. * @param reusable If the post process can be reused on the same frame. (default: false)
  39288. */
  39289. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  39290. }
  39291. }
  39292. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  39293. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  39294. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39295. import { Scene } from "babylonjs/scene";
  39296. import { Vector3 } from "babylonjs/Maths/math";
  39297. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39298. /**
  39299. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  39300. * @see http://doc.babylonjs.com/features/cameras
  39301. */
  39302. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  39303. /**
  39304. * Creates a new StereoscopicArcRotateCamera
  39305. * @param name defines camera name
  39306. * @param alpha defines alpha angle (in radians)
  39307. * @param beta defines beta angle (in radians)
  39308. * @param radius defines radius
  39309. * @param target defines camera target
  39310. * @param interaxialDistance defines distance between each color axis
  39311. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39312. * @param scene defines the hosting scene
  39313. */
  39314. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39315. /**
  39316. * Gets camera class name
  39317. * @returns StereoscopicArcRotateCamera
  39318. */
  39319. getClassName(): string;
  39320. }
  39321. }
  39322. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  39323. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39324. import { Scene } from "babylonjs/scene";
  39325. import { Vector3 } from "babylonjs/Maths/math";
  39326. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39327. /**
  39328. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  39329. * @see http://doc.babylonjs.com/features/cameras
  39330. */
  39331. export class StereoscopicFreeCamera extends FreeCamera {
  39332. /**
  39333. * Creates a new StereoscopicFreeCamera
  39334. * @param name defines camera name
  39335. * @param position defines initial position
  39336. * @param interaxialDistance defines distance between each color axis
  39337. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39338. * @param scene defines the hosting scene
  39339. */
  39340. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39341. /**
  39342. * Gets camera class name
  39343. * @returns StereoscopicFreeCamera
  39344. */
  39345. getClassName(): string;
  39346. }
  39347. }
  39348. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  39349. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  39350. import { Scene } from "babylonjs/scene";
  39351. import { Vector3 } from "babylonjs/Maths/math";
  39352. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39353. /**
  39354. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  39355. * @see http://doc.babylonjs.com/features/cameras
  39356. */
  39357. export class StereoscopicGamepadCamera extends GamepadCamera {
  39358. /**
  39359. * Creates a new StereoscopicGamepadCamera
  39360. * @param name defines camera name
  39361. * @param position defines initial position
  39362. * @param interaxialDistance defines distance between each color axis
  39363. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39364. * @param scene defines the hosting scene
  39365. */
  39366. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39367. /**
  39368. * Gets camera class name
  39369. * @returns StereoscopicGamepadCamera
  39370. */
  39371. getClassName(): string;
  39372. }
  39373. }
  39374. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  39375. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  39376. import { Scene } from "babylonjs/scene";
  39377. import { Vector3 } from "babylonjs/Maths/math";
  39378. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  39379. /**
  39380. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  39381. * @see http://doc.babylonjs.com/features/cameras
  39382. */
  39383. export class StereoscopicUniversalCamera extends UniversalCamera {
  39384. /**
  39385. * Creates a new StereoscopicUniversalCamera
  39386. * @param name defines camera name
  39387. * @param position defines initial position
  39388. * @param interaxialDistance defines distance between each color axis
  39389. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  39390. * @param scene defines the hosting scene
  39391. */
  39392. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  39393. /**
  39394. * Gets camera class name
  39395. * @returns StereoscopicUniversalCamera
  39396. */
  39397. getClassName(): string;
  39398. }
  39399. }
  39400. declare module "babylonjs/Cameras/Stereoscopic/index" {
  39401. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  39402. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  39403. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  39404. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  39405. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  39406. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  39407. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  39408. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  39409. }
  39410. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  39411. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39412. import { Scene } from "babylonjs/scene";
  39413. import { Vector3 } from "babylonjs/Maths/math";
  39414. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39415. /**
  39416. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  39417. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39418. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39419. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39420. */
  39421. export class VirtualJoysticksCamera extends FreeCamera {
  39422. /**
  39423. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  39424. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  39425. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  39426. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  39427. * @param name Define the name of the camera in the scene
  39428. * @param position Define the start position of the camera in the scene
  39429. * @param scene Define the scene the camera belongs to
  39430. */
  39431. constructor(name: string, position: Vector3, scene: Scene);
  39432. /**
  39433. * Gets the current object class name.
  39434. * @return the class name
  39435. */
  39436. getClassName(): string;
  39437. }
  39438. }
  39439. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  39440. import { Matrix } from "babylonjs/Maths/math";
  39441. /**
  39442. * This represents all the required metrics to create a VR camera.
  39443. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  39444. */
  39445. export class VRCameraMetrics {
  39446. /**
  39447. * Define the horizontal resolution off the screen.
  39448. */
  39449. hResolution: number;
  39450. /**
  39451. * Define the vertical resolution off the screen.
  39452. */
  39453. vResolution: number;
  39454. /**
  39455. * Define the horizontal screen size.
  39456. */
  39457. hScreenSize: number;
  39458. /**
  39459. * Define the vertical screen size.
  39460. */
  39461. vScreenSize: number;
  39462. /**
  39463. * Define the vertical screen center position.
  39464. */
  39465. vScreenCenter: number;
  39466. /**
  39467. * Define the distance of the eyes to the screen.
  39468. */
  39469. eyeToScreenDistance: number;
  39470. /**
  39471. * Define the distance between both lenses
  39472. */
  39473. lensSeparationDistance: number;
  39474. /**
  39475. * Define the distance between both viewer's eyes.
  39476. */
  39477. interpupillaryDistance: number;
  39478. /**
  39479. * Define the distortion factor of the VR postprocess.
  39480. * Please, touch with care.
  39481. */
  39482. distortionK: number[];
  39483. /**
  39484. * Define the chromatic aberration correction factors for the VR post process.
  39485. */
  39486. chromaAbCorrection: number[];
  39487. /**
  39488. * Define the scale factor of the post process.
  39489. * The smaller the better but the slower.
  39490. */
  39491. postProcessScaleFactor: number;
  39492. /**
  39493. * Define an offset for the lens center.
  39494. */
  39495. lensCenterOffset: number;
  39496. /**
  39497. * Define if the current vr camera should compensate the distortion of the lense or not.
  39498. */
  39499. compensateDistortion: boolean;
  39500. /**
  39501. * Defines if multiview should be enabled when rendering (Default: false)
  39502. */
  39503. multiviewEnabled: boolean;
  39504. /**
  39505. * Gets the rendering aspect ratio based on the provided resolutions.
  39506. */
  39507. readonly aspectRatio: number;
  39508. /**
  39509. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  39510. */
  39511. readonly aspectRatioFov: number;
  39512. /**
  39513. * @hidden
  39514. */
  39515. readonly leftHMatrix: Matrix;
  39516. /**
  39517. * @hidden
  39518. */
  39519. readonly rightHMatrix: Matrix;
  39520. /**
  39521. * @hidden
  39522. */
  39523. readonly leftPreViewMatrix: Matrix;
  39524. /**
  39525. * @hidden
  39526. */
  39527. readonly rightPreViewMatrix: Matrix;
  39528. /**
  39529. * Get the default VRMetrics based on the most generic setup.
  39530. * @returns the default vr metrics
  39531. */
  39532. static GetDefault(): VRCameraMetrics;
  39533. }
  39534. }
  39535. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  39536. /** @hidden */
  39537. export var vrDistortionCorrectionPixelShader: {
  39538. name: string;
  39539. shader: string;
  39540. };
  39541. }
  39542. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  39543. import { Camera } from "babylonjs/Cameras/camera";
  39544. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39545. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  39546. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  39547. /**
  39548. * VRDistortionCorrectionPostProcess used for mobile VR
  39549. */
  39550. export class VRDistortionCorrectionPostProcess extends PostProcess {
  39551. private _isRightEye;
  39552. private _distortionFactors;
  39553. private _postProcessScaleFactor;
  39554. private _lensCenterOffset;
  39555. private _scaleIn;
  39556. private _scaleFactor;
  39557. private _lensCenter;
  39558. /**
  39559. * Initializes the VRDistortionCorrectionPostProcess
  39560. * @param name The name of the effect.
  39561. * @param camera The camera to apply the render pass to.
  39562. * @param isRightEye If this is for the right eye distortion
  39563. * @param vrMetrics All the required metrics for the VR camera
  39564. */
  39565. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  39566. }
  39567. }
  39568. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  39569. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  39570. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39571. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39572. import { Scene } from "babylonjs/scene";
  39573. import { Vector3 } from "babylonjs/Maths/math";
  39574. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39575. import "babylonjs/Cameras/RigModes/vrRigMode";
  39576. /**
  39577. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  39578. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39579. */
  39580. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  39581. /**
  39582. * Creates a new VRDeviceOrientationArcRotateCamera
  39583. * @param name defines camera name
  39584. * @param alpha defines the camera rotation along the logitudinal axis
  39585. * @param beta defines the camera rotation along the latitudinal axis
  39586. * @param radius defines the camera distance from its target
  39587. * @param target defines the camera target
  39588. * @param scene defines the scene the camera belongs to
  39589. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39590. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39591. */
  39592. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39593. /**
  39594. * Gets camera class name
  39595. * @returns VRDeviceOrientationArcRotateCamera
  39596. */
  39597. getClassName(): string;
  39598. }
  39599. }
  39600. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  39601. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  39602. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39603. import { Scene } from "babylonjs/scene";
  39604. import { Vector3 } from "babylonjs/Maths/math";
  39605. import "babylonjs/Cameras/RigModes/vrRigMode";
  39606. /**
  39607. * Camera used to simulate VR rendering (based on FreeCamera)
  39608. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39609. */
  39610. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  39611. /**
  39612. * Creates a new VRDeviceOrientationFreeCamera
  39613. * @param name defines camera name
  39614. * @param position defines the start position of the camera
  39615. * @param scene defines the scene the camera belongs to
  39616. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39617. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39618. */
  39619. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39620. /**
  39621. * Gets camera class name
  39622. * @returns VRDeviceOrientationFreeCamera
  39623. */
  39624. getClassName(): string;
  39625. }
  39626. }
  39627. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39628. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39629. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39630. import { Scene } from "babylonjs/scene";
  39631. import { Vector3 } from "babylonjs/Maths/math";
  39632. import "babylonjs/Gamepads/gamepadSceneComponent";
  39633. /**
  39634. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39635. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39636. */
  39637. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39638. /**
  39639. * Creates a new VRDeviceOrientationGamepadCamera
  39640. * @param name defines camera name
  39641. * @param position defines the start position of the camera
  39642. * @param scene defines the scene the camera belongs to
  39643. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39644. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39645. */
  39646. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39647. /**
  39648. * Gets camera class name
  39649. * @returns VRDeviceOrientationGamepadCamera
  39650. */
  39651. getClassName(): string;
  39652. }
  39653. }
  39654. declare module "babylonjs/Materials/pushMaterial" {
  39655. import { Nullable } from "babylonjs/types";
  39656. import { Scene } from "babylonjs/scene";
  39657. import { Matrix } from "babylonjs/Maths/math";
  39658. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39659. import { Mesh } from "babylonjs/Meshes/mesh";
  39660. import { Material } from "babylonjs/Materials/material";
  39661. import { Effect } from "babylonjs/Materials/effect";
  39662. /**
  39663. * Base class of materials working in push mode in babylon JS
  39664. * @hidden
  39665. */
  39666. export class PushMaterial extends Material {
  39667. protected _activeEffect: Effect;
  39668. protected _normalMatrix: Matrix;
  39669. /**
  39670. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39671. * This means that the material can keep using a previous shader while a new one is being compiled.
  39672. * This is mostly used when shader parallel compilation is supported (true by default)
  39673. */
  39674. allowShaderHotSwapping: boolean;
  39675. constructor(name: string, scene: Scene);
  39676. getEffect(): Effect;
  39677. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39678. /**
  39679. * Binds the given world matrix to the active effect
  39680. *
  39681. * @param world the matrix to bind
  39682. */
  39683. bindOnlyWorldMatrix(world: Matrix): void;
  39684. /**
  39685. * Binds the given normal matrix to the active effect
  39686. *
  39687. * @param normalMatrix the matrix to bind
  39688. */
  39689. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39690. bind(world: Matrix, mesh?: Mesh): void;
  39691. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39692. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39693. }
  39694. }
  39695. declare module "babylonjs/Materials/materialFlags" {
  39696. /**
  39697. * This groups all the flags used to control the materials channel.
  39698. */
  39699. export class MaterialFlags {
  39700. private static _DiffuseTextureEnabled;
  39701. /**
  39702. * Are diffuse textures enabled in the application.
  39703. */
  39704. static DiffuseTextureEnabled: boolean;
  39705. private static _AmbientTextureEnabled;
  39706. /**
  39707. * Are ambient textures enabled in the application.
  39708. */
  39709. static AmbientTextureEnabled: boolean;
  39710. private static _OpacityTextureEnabled;
  39711. /**
  39712. * Are opacity textures enabled in the application.
  39713. */
  39714. static OpacityTextureEnabled: boolean;
  39715. private static _ReflectionTextureEnabled;
  39716. /**
  39717. * Are reflection textures enabled in the application.
  39718. */
  39719. static ReflectionTextureEnabled: boolean;
  39720. private static _EmissiveTextureEnabled;
  39721. /**
  39722. * Are emissive textures enabled in the application.
  39723. */
  39724. static EmissiveTextureEnabled: boolean;
  39725. private static _SpecularTextureEnabled;
  39726. /**
  39727. * Are specular textures enabled in the application.
  39728. */
  39729. static SpecularTextureEnabled: boolean;
  39730. private static _BumpTextureEnabled;
  39731. /**
  39732. * Are bump textures enabled in the application.
  39733. */
  39734. static BumpTextureEnabled: boolean;
  39735. private static _LightmapTextureEnabled;
  39736. /**
  39737. * Are lightmap textures enabled in the application.
  39738. */
  39739. static LightmapTextureEnabled: boolean;
  39740. private static _RefractionTextureEnabled;
  39741. /**
  39742. * Are refraction textures enabled in the application.
  39743. */
  39744. static RefractionTextureEnabled: boolean;
  39745. private static _ColorGradingTextureEnabled;
  39746. /**
  39747. * Are color grading textures enabled in the application.
  39748. */
  39749. static ColorGradingTextureEnabled: boolean;
  39750. private static _FresnelEnabled;
  39751. /**
  39752. * Are fresnels enabled in the application.
  39753. */
  39754. static FresnelEnabled: boolean;
  39755. private static _ClearCoatTextureEnabled;
  39756. /**
  39757. * Are clear coat textures enabled in the application.
  39758. */
  39759. static ClearCoatTextureEnabled: boolean;
  39760. private static _ClearCoatBumpTextureEnabled;
  39761. /**
  39762. * Are clear coat bump textures enabled in the application.
  39763. */
  39764. static ClearCoatBumpTextureEnabled: boolean;
  39765. private static _ClearCoatTintTextureEnabled;
  39766. /**
  39767. * Are clear coat tint textures enabled in the application.
  39768. */
  39769. static ClearCoatTintTextureEnabled: boolean;
  39770. private static _SheenTextureEnabled;
  39771. /**
  39772. * Are sheen textures enabled in the application.
  39773. */
  39774. static SheenTextureEnabled: boolean;
  39775. private static _AnisotropicTextureEnabled;
  39776. /**
  39777. * Are anisotropic textures enabled in the application.
  39778. */
  39779. static AnisotropicTextureEnabled: boolean;
  39780. private static _ThicknessTextureEnabled;
  39781. /**
  39782. * Are thickness textures enabled in the application.
  39783. */
  39784. static ThicknessTextureEnabled: boolean;
  39785. }
  39786. }
  39787. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39788. /** @hidden */
  39789. export var defaultFragmentDeclaration: {
  39790. name: string;
  39791. shader: string;
  39792. };
  39793. }
  39794. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39795. /** @hidden */
  39796. export var defaultUboDeclaration: {
  39797. name: string;
  39798. shader: string;
  39799. };
  39800. }
  39801. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39802. /** @hidden */
  39803. export var lightFragmentDeclaration: {
  39804. name: string;
  39805. shader: string;
  39806. };
  39807. }
  39808. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39809. /** @hidden */
  39810. export var lightUboDeclaration: {
  39811. name: string;
  39812. shader: string;
  39813. };
  39814. }
  39815. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39816. /** @hidden */
  39817. export var lightsFragmentFunctions: {
  39818. name: string;
  39819. shader: string;
  39820. };
  39821. }
  39822. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39823. /** @hidden */
  39824. export var shadowsFragmentFunctions: {
  39825. name: string;
  39826. shader: string;
  39827. };
  39828. }
  39829. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39830. /** @hidden */
  39831. export var fresnelFunction: {
  39832. name: string;
  39833. shader: string;
  39834. };
  39835. }
  39836. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39837. /** @hidden */
  39838. export var reflectionFunction: {
  39839. name: string;
  39840. shader: string;
  39841. };
  39842. }
  39843. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39844. /** @hidden */
  39845. export var bumpFragmentFunctions: {
  39846. name: string;
  39847. shader: string;
  39848. };
  39849. }
  39850. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39851. /** @hidden */
  39852. export var logDepthDeclaration: {
  39853. name: string;
  39854. shader: string;
  39855. };
  39856. }
  39857. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39858. /** @hidden */
  39859. export var bumpFragment: {
  39860. name: string;
  39861. shader: string;
  39862. };
  39863. }
  39864. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39865. /** @hidden */
  39866. export var depthPrePass: {
  39867. name: string;
  39868. shader: string;
  39869. };
  39870. }
  39871. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39872. /** @hidden */
  39873. export var lightFragment: {
  39874. name: string;
  39875. shader: string;
  39876. };
  39877. }
  39878. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39879. /** @hidden */
  39880. export var logDepthFragment: {
  39881. name: string;
  39882. shader: string;
  39883. };
  39884. }
  39885. declare module "babylonjs/Shaders/default.fragment" {
  39886. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39887. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39888. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39889. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39890. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39891. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39892. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39893. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39894. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39895. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39896. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39897. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39898. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39899. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39900. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39901. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39902. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39903. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39904. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39905. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39906. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39907. /** @hidden */
  39908. export var defaultPixelShader: {
  39909. name: string;
  39910. shader: string;
  39911. };
  39912. }
  39913. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39914. /** @hidden */
  39915. export var defaultVertexDeclaration: {
  39916. name: string;
  39917. shader: string;
  39918. };
  39919. }
  39920. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39921. /** @hidden */
  39922. export var bumpVertexDeclaration: {
  39923. name: string;
  39924. shader: string;
  39925. };
  39926. }
  39927. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39928. /** @hidden */
  39929. export var bumpVertex: {
  39930. name: string;
  39931. shader: string;
  39932. };
  39933. }
  39934. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39935. /** @hidden */
  39936. export var fogVertex: {
  39937. name: string;
  39938. shader: string;
  39939. };
  39940. }
  39941. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39942. /** @hidden */
  39943. export var shadowsVertex: {
  39944. name: string;
  39945. shader: string;
  39946. };
  39947. }
  39948. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39949. /** @hidden */
  39950. export var pointCloudVertex: {
  39951. name: string;
  39952. shader: string;
  39953. };
  39954. }
  39955. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39956. /** @hidden */
  39957. export var logDepthVertex: {
  39958. name: string;
  39959. shader: string;
  39960. };
  39961. }
  39962. declare module "babylonjs/Shaders/default.vertex" {
  39963. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39964. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39965. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39966. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39967. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39968. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39969. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39970. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39971. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39972. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39973. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39974. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39975. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39976. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39977. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39978. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39979. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39980. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39981. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39982. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39983. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39984. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39985. /** @hidden */
  39986. export var defaultVertexShader: {
  39987. name: string;
  39988. shader: string;
  39989. };
  39990. }
  39991. declare module "babylonjs/Materials/standardMaterial" {
  39992. import { SmartArray } from "babylonjs/Misc/smartArray";
  39993. import { IAnimatable } from "babylonjs/Misc/tools";
  39994. import { Nullable } from "babylonjs/types";
  39995. import { Scene } from "babylonjs/scene";
  39996. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39997. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39999. import { Mesh } from "babylonjs/Meshes/mesh";
  40000. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  40001. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40002. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  40003. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  40004. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  40005. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40006. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40007. import "babylonjs/Shaders/default.fragment";
  40008. import "babylonjs/Shaders/default.vertex";
  40009. /** @hidden */
  40010. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  40011. MAINUV1: boolean;
  40012. MAINUV2: boolean;
  40013. DIFFUSE: boolean;
  40014. DIFFUSEDIRECTUV: number;
  40015. AMBIENT: boolean;
  40016. AMBIENTDIRECTUV: number;
  40017. OPACITY: boolean;
  40018. OPACITYDIRECTUV: number;
  40019. OPACITYRGB: boolean;
  40020. REFLECTION: boolean;
  40021. EMISSIVE: boolean;
  40022. EMISSIVEDIRECTUV: number;
  40023. SPECULAR: boolean;
  40024. SPECULARDIRECTUV: number;
  40025. BUMP: boolean;
  40026. BUMPDIRECTUV: number;
  40027. PARALLAX: boolean;
  40028. PARALLAXOCCLUSION: boolean;
  40029. SPECULAROVERALPHA: boolean;
  40030. CLIPPLANE: boolean;
  40031. CLIPPLANE2: boolean;
  40032. CLIPPLANE3: boolean;
  40033. CLIPPLANE4: boolean;
  40034. ALPHATEST: boolean;
  40035. DEPTHPREPASS: boolean;
  40036. ALPHAFROMDIFFUSE: boolean;
  40037. POINTSIZE: boolean;
  40038. FOG: boolean;
  40039. SPECULARTERM: boolean;
  40040. DIFFUSEFRESNEL: boolean;
  40041. OPACITYFRESNEL: boolean;
  40042. REFLECTIONFRESNEL: boolean;
  40043. REFRACTIONFRESNEL: boolean;
  40044. EMISSIVEFRESNEL: boolean;
  40045. FRESNEL: boolean;
  40046. NORMAL: boolean;
  40047. UV1: boolean;
  40048. UV2: boolean;
  40049. VERTEXCOLOR: boolean;
  40050. VERTEXALPHA: boolean;
  40051. NUM_BONE_INFLUENCERS: number;
  40052. BonesPerMesh: number;
  40053. BONETEXTURE: boolean;
  40054. INSTANCES: boolean;
  40055. GLOSSINESS: boolean;
  40056. ROUGHNESS: boolean;
  40057. EMISSIVEASILLUMINATION: boolean;
  40058. LINKEMISSIVEWITHDIFFUSE: boolean;
  40059. REFLECTIONFRESNELFROMSPECULAR: boolean;
  40060. LIGHTMAP: boolean;
  40061. LIGHTMAPDIRECTUV: number;
  40062. OBJECTSPACE_NORMALMAP: boolean;
  40063. USELIGHTMAPASSHADOWMAP: boolean;
  40064. REFLECTIONMAP_3D: boolean;
  40065. REFLECTIONMAP_SPHERICAL: boolean;
  40066. REFLECTIONMAP_PLANAR: boolean;
  40067. REFLECTIONMAP_CUBIC: boolean;
  40068. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  40069. REFLECTIONMAP_PROJECTION: boolean;
  40070. REFLECTIONMAP_SKYBOX: boolean;
  40071. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  40072. REFLECTIONMAP_EXPLICIT: boolean;
  40073. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  40074. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  40075. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  40076. INVERTCUBICMAP: boolean;
  40077. LOGARITHMICDEPTH: boolean;
  40078. REFRACTION: boolean;
  40079. REFRACTIONMAP_3D: boolean;
  40080. REFLECTIONOVERALPHA: boolean;
  40081. TWOSIDEDLIGHTING: boolean;
  40082. SHADOWFLOAT: boolean;
  40083. MORPHTARGETS: boolean;
  40084. MORPHTARGETS_NORMAL: boolean;
  40085. MORPHTARGETS_TANGENT: boolean;
  40086. NUM_MORPH_INFLUENCERS: number;
  40087. NONUNIFORMSCALING: boolean;
  40088. PREMULTIPLYALPHA: boolean;
  40089. IMAGEPROCESSING: boolean;
  40090. VIGNETTE: boolean;
  40091. VIGNETTEBLENDMODEMULTIPLY: boolean;
  40092. VIGNETTEBLENDMODEOPAQUE: boolean;
  40093. TONEMAPPING: boolean;
  40094. TONEMAPPING_ACES: boolean;
  40095. CONTRAST: boolean;
  40096. COLORCURVES: boolean;
  40097. COLORGRADING: boolean;
  40098. COLORGRADING3D: boolean;
  40099. SAMPLER3DGREENDEPTH: boolean;
  40100. SAMPLER3DBGRMAP: boolean;
  40101. IMAGEPROCESSINGPOSTPROCESS: boolean;
  40102. MULTIVIEW: boolean;
  40103. /**
  40104. * If the reflection texture on this material is in linear color space
  40105. * @hidden
  40106. */
  40107. IS_REFLECTION_LINEAR: boolean;
  40108. /**
  40109. * If the refraction texture on this material is in linear color space
  40110. * @hidden
  40111. */
  40112. IS_REFRACTION_LINEAR: boolean;
  40113. EXPOSURE: boolean;
  40114. constructor();
  40115. setReflectionMode(modeToEnable: string): void;
  40116. }
  40117. /**
  40118. * This is the default material used in Babylon. It is the best trade off between quality
  40119. * and performances.
  40120. * @see http://doc.babylonjs.com/babylon101/materials
  40121. */
  40122. export class StandardMaterial extends PushMaterial {
  40123. private _diffuseTexture;
  40124. /**
  40125. * The basic texture of the material as viewed under a light.
  40126. */
  40127. diffuseTexture: Nullable<BaseTexture>;
  40128. private _ambientTexture;
  40129. /**
  40130. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  40131. */
  40132. ambientTexture: Nullable<BaseTexture>;
  40133. private _opacityTexture;
  40134. /**
  40135. * Define the transparency of the material from a texture.
  40136. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  40137. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  40138. */
  40139. opacityTexture: Nullable<BaseTexture>;
  40140. private _reflectionTexture;
  40141. /**
  40142. * Define the texture used to display the reflection.
  40143. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40144. */
  40145. reflectionTexture: Nullable<BaseTexture>;
  40146. private _emissiveTexture;
  40147. /**
  40148. * Define texture of the material as if self lit.
  40149. * This will be mixed in the final result even in the absence of light.
  40150. */
  40151. emissiveTexture: Nullable<BaseTexture>;
  40152. private _specularTexture;
  40153. /**
  40154. * Define how the color and intensity of the highlight given by the light in the material.
  40155. */
  40156. specularTexture: Nullable<BaseTexture>;
  40157. private _bumpTexture;
  40158. /**
  40159. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  40160. * 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.
  40161. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  40162. */
  40163. bumpTexture: Nullable<BaseTexture>;
  40164. private _lightmapTexture;
  40165. /**
  40166. * Complex lighting can be computationally expensive to compute at runtime.
  40167. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  40168. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  40169. */
  40170. lightmapTexture: Nullable<BaseTexture>;
  40171. private _refractionTexture;
  40172. /**
  40173. * Define the texture used to display the refraction.
  40174. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40175. */
  40176. refractionTexture: Nullable<BaseTexture>;
  40177. /**
  40178. * The color of the material lit by the environmental background lighting.
  40179. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  40180. */
  40181. ambientColor: Color3;
  40182. /**
  40183. * The basic color of the material as viewed under a light.
  40184. */
  40185. diffuseColor: Color3;
  40186. /**
  40187. * Define how the color and intensity of the highlight given by the light in the material.
  40188. */
  40189. specularColor: Color3;
  40190. /**
  40191. * Define the color of the material as if self lit.
  40192. * This will be mixed in the final result even in the absence of light.
  40193. */
  40194. emissiveColor: Color3;
  40195. /**
  40196. * Defines how sharp are the highlights in the material.
  40197. * The bigger the value the sharper giving a more glossy feeling to the result.
  40198. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  40199. */
  40200. specularPower: number;
  40201. private _useAlphaFromDiffuseTexture;
  40202. /**
  40203. * Does the transparency come from the diffuse texture alpha channel.
  40204. */
  40205. useAlphaFromDiffuseTexture: boolean;
  40206. private _useEmissiveAsIllumination;
  40207. /**
  40208. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  40209. */
  40210. useEmissiveAsIllumination: boolean;
  40211. private _linkEmissiveWithDiffuse;
  40212. /**
  40213. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  40214. * the emissive level when the final color is close to one.
  40215. */
  40216. linkEmissiveWithDiffuse: boolean;
  40217. private _useSpecularOverAlpha;
  40218. /**
  40219. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  40220. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  40221. */
  40222. useSpecularOverAlpha: boolean;
  40223. private _useReflectionOverAlpha;
  40224. /**
  40225. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  40226. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  40227. */
  40228. useReflectionOverAlpha: boolean;
  40229. private _disableLighting;
  40230. /**
  40231. * Does lights from the scene impacts this material.
  40232. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  40233. */
  40234. disableLighting: boolean;
  40235. private _useObjectSpaceNormalMap;
  40236. /**
  40237. * Allows using an object space normal map (instead of tangent space).
  40238. */
  40239. useObjectSpaceNormalMap: boolean;
  40240. private _useParallax;
  40241. /**
  40242. * Is parallax enabled or not.
  40243. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40244. */
  40245. useParallax: boolean;
  40246. private _useParallaxOcclusion;
  40247. /**
  40248. * Is parallax occlusion enabled or not.
  40249. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  40250. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  40251. */
  40252. useParallaxOcclusion: boolean;
  40253. /**
  40254. * 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.
  40255. */
  40256. parallaxScaleBias: number;
  40257. private _roughness;
  40258. /**
  40259. * Helps to define how blurry the reflections should appears in the material.
  40260. */
  40261. roughness: number;
  40262. /**
  40263. * In case of refraction, define the value of the indice of refraction.
  40264. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40265. */
  40266. indexOfRefraction: number;
  40267. /**
  40268. * Invert the refraction texture alongside the y axis.
  40269. * It can be useful with procedural textures or probe for instance.
  40270. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  40271. */
  40272. invertRefractionY: boolean;
  40273. /**
  40274. * Defines the alpha limits in alpha test mode.
  40275. */
  40276. alphaCutOff: number;
  40277. private _useLightmapAsShadowmap;
  40278. /**
  40279. * In case of light mapping, define whether the map contains light or shadow informations.
  40280. */
  40281. useLightmapAsShadowmap: boolean;
  40282. private _diffuseFresnelParameters;
  40283. /**
  40284. * Define the diffuse fresnel parameters of the material.
  40285. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40286. */
  40287. diffuseFresnelParameters: FresnelParameters;
  40288. private _opacityFresnelParameters;
  40289. /**
  40290. * Define the opacity fresnel parameters of the material.
  40291. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40292. */
  40293. opacityFresnelParameters: FresnelParameters;
  40294. private _reflectionFresnelParameters;
  40295. /**
  40296. * Define the reflection fresnel parameters of the material.
  40297. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40298. */
  40299. reflectionFresnelParameters: FresnelParameters;
  40300. private _refractionFresnelParameters;
  40301. /**
  40302. * Define the refraction fresnel parameters of the material.
  40303. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40304. */
  40305. refractionFresnelParameters: FresnelParameters;
  40306. private _emissiveFresnelParameters;
  40307. /**
  40308. * Define the emissive fresnel parameters of the material.
  40309. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40310. */
  40311. emissiveFresnelParameters: FresnelParameters;
  40312. private _useReflectionFresnelFromSpecular;
  40313. /**
  40314. * If true automatically deducts the fresnels values from the material specularity.
  40315. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  40316. */
  40317. useReflectionFresnelFromSpecular: boolean;
  40318. private _useGlossinessFromSpecularMapAlpha;
  40319. /**
  40320. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  40321. */
  40322. useGlossinessFromSpecularMapAlpha: boolean;
  40323. private _maxSimultaneousLights;
  40324. /**
  40325. * Defines the maximum number of lights that can be used in the material
  40326. */
  40327. maxSimultaneousLights: number;
  40328. private _invertNormalMapX;
  40329. /**
  40330. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  40331. */
  40332. invertNormalMapX: boolean;
  40333. private _invertNormalMapY;
  40334. /**
  40335. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  40336. */
  40337. invertNormalMapY: boolean;
  40338. private _twoSidedLighting;
  40339. /**
  40340. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  40341. */
  40342. twoSidedLighting: boolean;
  40343. /**
  40344. * Default configuration related to image processing available in the standard Material.
  40345. */
  40346. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40347. /**
  40348. * Gets the image processing configuration used either in this material.
  40349. */
  40350. /**
  40351. * Sets the Default image processing configuration used either in the this material.
  40352. *
  40353. * If sets to null, the scene one is in use.
  40354. */
  40355. imageProcessingConfiguration: ImageProcessingConfiguration;
  40356. /**
  40357. * Keep track of the image processing observer to allow dispose and replace.
  40358. */
  40359. private _imageProcessingObserver;
  40360. /**
  40361. * Attaches a new image processing configuration to the Standard Material.
  40362. * @param configuration
  40363. */
  40364. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  40365. /**
  40366. * Gets wether the color curves effect is enabled.
  40367. */
  40368. /**
  40369. * Sets wether the color curves effect is enabled.
  40370. */
  40371. cameraColorCurvesEnabled: boolean;
  40372. /**
  40373. * Gets wether the color grading effect is enabled.
  40374. */
  40375. /**
  40376. * Gets wether the color grading effect is enabled.
  40377. */
  40378. cameraColorGradingEnabled: boolean;
  40379. /**
  40380. * Gets wether tonemapping is enabled or not.
  40381. */
  40382. /**
  40383. * Sets wether tonemapping is enabled or not
  40384. */
  40385. cameraToneMappingEnabled: boolean;
  40386. /**
  40387. * The camera exposure used on this material.
  40388. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40389. * This corresponds to a photographic exposure.
  40390. */
  40391. /**
  40392. * The camera exposure used on this material.
  40393. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40394. * This corresponds to a photographic exposure.
  40395. */
  40396. cameraExposure: number;
  40397. /**
  40398. * Gets The camera contrast used on this material.
  40399. */
  40400. /**
  40401. * Sets The camera contrast used on this material.
  40402. */
  40403. cameraContrast: number;
  40404. /**
  40405. * Gets the Color Grading 2D Lookup Texture.
  40406. */
  40407. /**
  40408. * Sets the Color Grading 2D Lookup Texture.
  40409. */
  40410. cameraColorGradingTexture: Nullable<BaseTexture>;
  40411. /**
  40412. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40413. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40414. * 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;
  40415. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40416. */
  40417. /**
  40418. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40419. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40420. * 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;
  40421. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40422. */
  40423. cameraColorCurves: Nullable<ColorCurves>;
  40424. /**
  40425. * Custom callback helping to override the default shader used in the material.
  40426. */
  40427. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40428. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40429. protected _worldViewProjectionMatrix: Matrix;
  40430. protected _globalAmbientColor: Color3;
  40431. protected _useLogarithmicDepth: boolean;
  40432. /**
  40433. * Instantiates a new standard material.
  40434. * This is the default material used in Babylon. It is the best trade off between quality
  40435. * and performances.
  40436. * @see http://doc.babylonjs.com/babylon101/materials
  40437. * @param name Define the name of the material in the scene
  40438. * @param scene Define the scene the material belong to
  40439. */
  40440. constructor(name: string, scene: Scene);
  40441. /**
  40442. * Gets a boolean indicating that current material needs to register RTT
  40443. */
  40444. readonly hasRenderTargetTextures: boolean;
  40445. /**
  40446. * Gets the current class name of the material e.g. "StandardMaterial"
  40447. * Mainly use in serialization.
  40448. * @returns the class name
  40449. */
  40450. getClassName(): string;
  40451. /**
  40452. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40453. * You can try switching to logarithmic depth.
  40454. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40455. */
  40456. useLogarithmicDepth: boolean;
  40457. /**
  40458. * Specifies if the material will require alpha blending
  40459. * @returns a boolean specifying if alpha blending is needed
  40460. */
  40461. needAlphaBlending(): boolean;
  40462. /**
  40463. * Specifies if this material should be rendered in alpha test mode
  40464. * @returns a boolean specifying if an alpha test is needed.
  40465. */
  40466. needAlphaTesting(): boolean;
  40467. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40468. /**
  40469. * Get the texture used for alpha test purpose.
  40470. * @returns the diffuse texture in case of the standard material.
  40471. */
  40472. getAlphaTestTexture(): Nullable<BaseTexture>;
  40473. /**
  40474. * Get if the submesh is ready to be used and all its information available.
  40475. * Child classes can use it to update shaders
  40476. * @param mesh defines the mesh to check
  40477. * @param subMesh defines which submesh to check
  40478. * @param useInstances specifies that instances should be used
  40479. * @returns a boolean indicating that the submesh is ready or not
  40480. */
  40481. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40482. /**
  40483. * Builds the material UBO layouts.
  40484. * Used internally during the effect preparation.
  40485. */
  40486. buildUniformLayout(): void;
  40487. /**
  40488. * Unbinds the material from the mesh
  40489. */
  40490. unbind(): void;
  40491. /**
  40492. * Binds the submesh to this material by preparing the effect and shader to draw
  40493. * @param world defines the world transformation matrix
  40494. * @param mesh defines the mesh containing the submesh
  40495. * @param subMesh defines the submesh to bind the material to
  40496. */
  40497. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40498. /**
  40499. * Get the list of animatables in the material.
  40500. * @returns the list of animatables object used in the material
  40501. */
  40502. getAnimatables(): IAnimatable[];
  40503. /**
  40504. * Gets the active textures from the material
  40505. * @returns an array of textures
  40506. */
  40507. getActiveTextures(): BaseTexture[];
  40508. /**
  40509. * Specifies if the material uses a texture
  40510. * @param texture defines the texture to check against the material
  40511. * @returns a boolean specifying if the material uses the texture
  40512. */
  40513. hasTexture(texture: BaseTexture): boolean;
  40514. /**
  40515. * Disposes the material
  40516. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40517. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40518. */
  40519. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40520. /**
  40521. * Makes a duplicate of the material, and gives it a new name
  40522. * @param name defines the new name for the duplicated material
  40523. * @returns the cloned material
  40524. */
  40525. clone(name: string): StandardMaterial;
  40526. /**
  40527. * Serializes this material in a JSON representation
  40528. * @returns the serialized material object
  40529. */
  40530. serialize(): any;
  40531. /**
  40532. * Creates a standard material from parsed material data
  40533. * @param source defines the JSON representation of the material
  40534. * @param scene defines the hosting scene
  40535. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40536. * @returns a new standard material
  40537. */
  40538. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40539. /**
  40540. * Are diffuse textures enabled in the application.
  40541. */
  40542. static DiffuseTextureEnabled: boolean;
  40543. /**
  40544. * Are ambient textures enabled in the application.
  40545. */
  40546. static AmbientTextureEnabled: boolean;
  40547. /**
  40548. * Are opacity textures enabled in the application.
  40549. */
  40550. static OpacityTextureEnabled: boolean;
  40551. /**
  40552. * Are reflection textures enabled in the application.
  40553. */
  40554. static ReflectionTextureEnabled: boolean;
  40555. /**
  40556. * Are emissive textures enabled in the application.
  40557. */
  40558. static EmissiveTextureEnabled: boolean;
  40559. /**
  40560. * Are specular textures enabled in the application.
  40561. */
  40562. static SpecularTextureEnabled: boolean;
  40563. /**
  40564. * Are bump textures enabled in the application.
  40565. */
  40566. static BumpTextureEnabled: boolean;
  40567. /**
  40568. * Are lightmap textures enabled in the application.
  40569. */
  40570. static LightmapTextureEnabled: boolean;
  40571. /**
  40572. * Are refraction textures enabled in the application.
  40573. */
  40574. static RefractionTextureEnabled: boolean;
  40575. /**
  40576. * Are color grading textures enabled in the application.
  40577. */
  40578. static ColorGradingTextureEnabled: boolean;
  40579. /**
  40580. * Are fresnels enabled in the application.
  40581. */
  40582. static FresnelEnabled: boolean;
  40583. }
  40584. }
  40585. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40586. import { Scene } from "babylonjs/scene";
  40587. import { Texture } from "babylonjs/Materials/Textures/texture";
  40588. /**
  40589. * A class extending Texture allowing drawing on a texture
  40590. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40591. */
  40592. export class DynamicTexture extends Texture {
  40593. private _generateMipMaps;
  40594. private _canvas;
  40595. private _context;
  40596. private _engine;
  40597. /**
  40598. * Creates a DynamicTexture
  40599. * @param name defines the name of the texture
  40600. * @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
  40601. * @param scene defines the scene where you want the texture
  40602. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40603. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40604. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40605. */
  40606. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40607. /**
  40608. * Get the current class name of the texture useful for serialization or dynamic coding.
  40609. * @returns "DynamicTexture"
  40610. */
  40611. getClassName(): string;
  40612. /**
  40613. * Gets the current state of canRescale
  40614. */
  40615. readonly canRescale: boolean;
  40616. private _recreate;
  40617. /**
  40618. * Scales the texture
  40619. * @param ratio the scale factor to apply to both width and height
  40620. */
  40621. scale(ratio: number): void;
  40622. /**
  40623. * Resizes the texture
  40624. * @param width the new width
  40625. * @param height the new height
  40626. */
  40627. scaleTo(width: number, height: number): void;
  40628. /**
  40629. * Gets the context of the canvas used by the texture
  40630. * @returns the canvas context of the dynamic texture
  40631. */
  40632. getContext(): CanvasRenderingContext2D;
  40633. /**
  40634. * Clears the texture
  40635. */
  40636. clear(): void;
  40637. /**
  40638. * Updates the texture
  40639. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40640. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40641. */
  40642. update(invertY?: boolean, premulAlpha?: boolean): void;
  40643. /**
  40644. * Draws text onto the texture
  40645. * @param text defines the text to be drawn
  40646. * @param x defines the placement of the text from the left
  40647. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40648. * @param font defines the font to be used with font-style, font-size, font-name
  40649. * @param color defines the color used for the text
  40650. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40651. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40652. * @param update defines whether texture is immediately update (default is true)
  40653. */
  40654. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40655. /**
  40656. * Clones the texture
  40657. * @returns the clone of the texture.
  40658. */
  40659. clone(): DynamicTexture;
  40660. /**
  40661. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40662. * @returns a serialized dynamic texture object
  40663. */
  40664. serialize(): any;
  40665. /** @hidden */
  40666. _rebuild(): void;
  40667. }
  40668. }
  40669. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40670. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40671. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40672. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40673. /** @hidden */
  40674. export var imageProcessingPixelShader: {
  40675. name: string;
  40676. shader: string;
  40677. };
  40678. }
  40679. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40680. import { Nullable } from "babylonjs/types";
  40681. import { Color4 } from "babylonjs/Maths/math";
  40682. import { Camera } from "babylonjs/Cameras/camera";
  40683. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40684. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40685. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40686. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40687. import { Engine } from "babylonjs/Engines/engine";
  40688. import "babylonjs/Shaders/imageProcessing.fragment";
  40689. import "babylonjs/Shaders/postprocess.vertex";
  40690. /**
  40691. * ImageProcessingPostProcess
  40692. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40693. */
  40694. export class ImageProcessingPostProcess extends PostProcess {
  40695. /**
  40696. * Default configuration related to image processing available in the PBR Material.
  40697. */
  40698. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40699. /**
  40700. * Gets the image processing configuration used either in this material.
  40701. */
  40702. /**
  40703. * Sets the Default image processing configuration used either in the this material.
  40704. *
  40705. * If sets to null, the scene one is in use.
  40706. */
  40707. imageProcessingConfiguration: ImageProcessingConfiguration;
  40708. /**
  40709. * Keep track of the image processing observer to allow dispose and replace.
  40710. */
  40711. private _imageProcessingObserver;
  40712. /**
  40713. * Attaches a new image processing configuration to the PBR Material.
  40714. * @param configuration
  40715. */
  40716. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40717. /**
  40718. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40719. */
  40720. /**
  40721. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40722. */
  40723. colorCurves: Nullable<ColorCurves>;
  40724. /**
  40725. * Gets wether the color curves effect is enabled.
  40726. */
  40727. /**
  40728. * Sets wether the color curves effect is enabled.
  40729. */
  40730. colorCurvesEnabled: boolean;
  40731. /**
  40732. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40733. */
  40734. /**
  40735. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40736. */
  40737. colorGradingTexture: Nullable<BaseTexture>;
  40738. /**
  40739. * Gets wether the color grading effect is enabled.
  40740. */
  40741. /**
  40742. * Gets wether the color grading effect is enabled.
  40743. */
  40744. colorGradingEnabled: boolean;
  40745. /**
  40746. * Gets exposure used in the effect.
  40747. */
  40748. /**
  40749. * Sets exposure used in the effect.
  40750. */
  40751. exposure: number;
  40752. /**
  40753. * Gets wether tonemapping is enabled or not.
  40754. */
  40755. /**
  40756. * Sets wether tonemapping is enabled or not
  40757. */
  40758. toneMappingEnabled: boolean;
  40759. /**
  40760. * Gets the type of tone mapping effect.
  40761. */
  40762. /**
  40763. * Sets the type of tone mapping effect.
  40764. */
  40765. toneMappingType: number;
  40766. /**
  40767. * Gets contrast used in the effect.
  40768. */
  40769. /**
  40770. * Sets contrast used in the effect.
  40771. */
  40772. contrast: number;
  40773. /**
  40774. * Gets Vignette stretch size.
  40775. */
  40776. /**
  40777. * Sets Vignette stretch size.
  40778. */
  40779. vignetteStretch: number;
  40780. /**
  40781. * Gets Vignette centre X Offset.
  40782. */
  40783. /**
  40784. * Sets Vignette centre X Offset.
  40785. */
  40786. vignetteCentreX: number;
  40787. /**
  40788. * Gets Vignette centre Y Offset.
  40789. */
  40790. /**
  40791. * Sets Vignette centre Y Offset.
  40792. */
  40793. vignetteCentreY: number;
  40794. /**
  40795. * Gets Vignette weight or intensity of the vignette effect.
  40796. */
  40797. /**
  40798. * Sets Vignette weight or intensity of the vignette effect.
  40799. */
  40800. vignetteWeight: number;
  40801. /**
  40802. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40803. * if vignetteEnabled is set to true.
  40804. */
  40805. /**
  40806. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40807. * if vignetteEnabled is set to true.
  40808. */
  40809. vignetteColor: Color4;
  40810. /**
  40811. * Gets Camera field of view used by the Vignette effect.
  40812. */
  40813. /**
  40814. * Sets Camera field of view used by the Vignette effect.
  40815. */
  40816. vignetteCameraFov: number;
  40817. /**
  40818. * Gets the vignette blend mode allowing different kind of effect.
  40819. */
  40820. /**
  40821. * Sets the vignette blend mode allowing different kind of effect.
  40822. */
  40823. vignetteBlendMode: number;
  40824. /**
  40825. * Gets wether the vignette effect is enabled.
  40826. */
  40827. /**
  40828. * Sets wether the vignette effect is enabled.
  40829. */
  40830. vignetteEnabled: boolean;
  40831. private _fromLinearSpace;
  40832. /**
  40833. * Gets wether the input of the processing is in Gamma or Linear Space.
  40834. */
  40835. /**
  40836. * Sets wether the input of the processing is in Gamma or Linear Space.
  40837. */
  40838. fromLinearSpace: boolean;
  40839. /**
  40840. * Defines cache preventing GC.
  40841. */
  40842. private _defines;
  40843. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40844. /**
  40845. * "ImageProcessingPostProcess"
  40846. * @returns "ImageProcessingPostProcess"
  40847. */
  40848. getClassName(): string;
  40849. protected _updateParameters(): void;
  40850. dispose(camera?: Camera): void;
  40851. }
  40852. }
  40853. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40854. import { Scene } from "babylonjs/scene";
  40855. import { Color3 } from "babylonjs/Maths/math";
  40856. import { Mesh } from "babylonjs/Meshes/mesh";
  40857. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40858. import { Nullable } from "babylonjs/types";
  40859. /**
  40860. * Class containing static functions to help procedurally build meshes
  40861. */
  40862. export class GroundBuilder {
  40863. /**
  40864. * Creates a ground mesh
  40865. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40866. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40867. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40868. * @param name defines the name of the mesh
  40869. * @param options defines the options used to create the mesh
  40870. * @param scene defines the hosting scene
  40871. * @returns the ground mesh
  40872. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40873. */
  40874. static CreateGround(name: string, options: {
  40875. width?: number;
  40876. height?: number;
  40877. subdivisions?: number;
  40878. subdivisionsX?: number;
  40879. subdivisionsY?: number;
  40880. updatable?: boolean;
  40881. }, scene: any): Mesh;
  40882. /**
  40883. * Creates a tiled ground mesh
  40884. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40885. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40886. * * 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
  40887. * * 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
  40888. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40889. * @param name defines the name of the mesh
  40890. * @param options defines the options used to create the mesh
  40891. * @param scene defines the hosting scene
  40892. * @returns the tiled ground mesh
  40893. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40894. */
  40895. static CreateTiledGround(name: string, options: {
  40896. xmin: number;
  40897. zmin: number;
  40898. xmax: number;
  40899. zmax: number;
  40900. subdivisions?: {
  40901. w: number;
  40902. h: number;
  40903. };
  40904. precision?: {
  40905. w: number;
  40906. h: number;
  40907. };
  40908. updatable?: boolean;
  40909. }, scene?: Nullable<Scene>): Mesh;
  40910. /**
  40911. * Creates a ground mesh from a height map
  40912. * * The parameter `url` sets the URL of the height map image resource.
  40913. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40914. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40915. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40916. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40917. * * 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.
  40918. * * 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).
  40919. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40920. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40921. * @param name defines the name of the mesh
  40922. * @param url defines the url to the height map
  40923. * @param options defines the options used to create the mesh
  40924. * @param scene defines the hosting scene
  40925. * @returns the ground mesh
  40926. * @see https://doc.babylonjs.com/babylon101/height_map
  40927. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40928. */
  40929. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40930. width?: number;
  40931. height?: number;
  40932. subdivisions?: number;
  40933. minHeight?: number;
  40934. maxHeight?: number;
  40935. colorFilter?: Color3;
  40936. alphaFilter?: number;
  40937. updatable?: boolean;
  40938. onReady?: (mesh: GroundMesh) => void;
  40939. }, scene?: Nullable<Scene>): GroundMesh;
  40940. }
  40941. }
  40942. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40943. import { Vector4 } from "babylonjs/Maths/math";
  40944. import { Mesh } from "babylonjs/Meshes/mesh";
  40945. /**
  40946. * Class containing static functions to help procedurally build meshes
  40947. */
  40948. export class TorusBuilder {
  40949. /**
  40950. * Creates a torus mesh
  40951. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40952. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40953. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40954. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40955. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40956. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40957. * @param name defines the name of the mesh
  40958. * @param options defines the options used to create the mesh
  40959. * @param scene defines the hosting scene
  40960. * @returns the torus mesh
  40961. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40962. */
  40963. static CreateTorus(name: string, options: {
  40964. diameter?: number;
  40965. thickness?: number;
  40966. tessellation?: number;
  40967. updatable?: boolean;
  40968. sideOrientation?: number;
  40969. frontUVs?: Vector4;
  40970. backUVs?: Vector4;
  40971. }, scene: any): Mesh;
  40972. }
  40973. }
  40974. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40975. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40976. import { Mesh } from "babylonjs/Meshes/mesh";
  40977. /**
  40978. * Class containing static functions to help procedurally build meshes
  40979. */
  40980. export class CylinderBuilder {
  40981. /**
  40982. * Creates a cylinder or a cone mesh
  40983. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40984. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40985. * * 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.
  40986. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40987. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40988. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40989. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40990. * * 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).
  40991. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40992. * * 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).
  40993. * * 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
  40994. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40995. * * 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
  40996. * * 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.
  40997. * * If `enclose` is false, a ring surface is one element.
  40998. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40999. * * 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
  41000. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  41001. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  41002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  41003. * @param name defines the name of the mesh
  41004. * @param options defines the options used to create the mesh
  41005. * @param scene defines the hosting scene
  41006. * @returns the cylinder mesh
  41007. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  41008. */
  41009. static CreateCylinder(name: string, options: {
  41010. height?: number;
  41011. diameterTop?: number;
  41012. diameterBottom?: number;
  41013. diameter?: number;
  41014. tessellation?: number;
  41015. subdivisions?: number;
  41016. arc?: number;
  41017. faceColors?: Color4[];
  41018. faceUV?: Vector4[];
  41019. updatable?: boolean;
  41020. hasRings?: boolean;
  41021. enclose?: boolean;
  41022. cap?: number;
  41023. sideOrientation?: number;
  41024. frontUVs?: Vector4;
  41025. backUVs?: Vector4;
  41026. }, scene: any): Mesh;
  41027. }
  41028. }
  41029. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  41030. import { Observable } from "babylonjs/Misc/observable";
  41031. import { Nullable } from "babylonjs/types";
  41032. import { Camera } from "babylonjs/Cameras/camera";
  41033. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41034. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41035. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  41036. import { Scene } from "babylonjs/scene";
  41037. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41038. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  41039. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41040. import { Mesh } from "babylonjs/Meshes/mesh";
  41041. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  41042. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41043. import "babylonjs/Meshes/Builders/groundBuilder";
  41044. import "babylonjs/Meshes/Builders/torusBuilder";
  41045. import "babylonjs/Meshes/Builders/cylinderBuilder";
  41046. import "babylonjs/Gamepads/gamepadSceneComponent";
  41047. import "babylonjs/Animations/animatable";
  41048. /**
  41049. * Options to modify the vr teleportation behavior.
  41050. */
  41051. export interface VRTeleportationOptions {
  41052. /**
  41053. * The name of the mesh which should be used as the teleportation floor. (default: null)
  41054. */
  41055. floorMeshName?: string;
  41056. /**
  41057. * A list of meshes to be used as the teleportation floor. (default: empty)
  41058. */
  41059. floorMeshes?: Mesh[];
  41060. }
  41061. /**
  41062. * Options to modify the vr experience helper's behavior.
  41063. */
  41064. export interface VRExperienceHelperOptions extends WebVROptions {
  41065. /**
  41066. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  41067. */
  41068. createDeviceOrientationCamera?: boolean;
  41069. /**
  41070. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  41071. */
  41072. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  41073. /**
  41074. * Uses the main button on the controller to toggle the laser casted. (default: true)
  41075. */
  41076. laserToggle?: boolean;
  41077. /**
  41078. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  41079. */
  41080. floorMeshes?: Mesh[];
  41081. /**
  41082. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  41083. */
  41084. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  41085. }
  41086. /**
  41087. * Event containing information after VR has been entered
  41088. */
  41089. export class OnAfterEnteringVRObservableEvent {
  41090. /**
  41091. * If entering vr was successful
  41092. */
  41093. success: boolean;
  41094. }
  41095. /**
  41096. * Helps to quickly add VR support to an existing scene.
  41097. * See http://doc.babylonjs.com/how_to/webvr_helper
  41098. */
  41099. export class VRExperienceHelper {
  41100. /** Options to modify the vr experience helper's behavior. */
  41101. webVROptions: VRExperienceHelperOptions;
  41102. private _scene;
  41103. private _position;
  41104. private _btnVR;
  41105. private _btnVRDisplayed;
  41106. private _webVRsupported;
  41107. private _webVRready;
  41108. private _webVRrequesting;
  41109. private _webVRpresenting;
  41110. private _hasEnteredVR;
  41111. private _fullscreenVRpresenting;
  41112. private _canvas;
  41113. private _webVRCamera;
  41114. private _vrDeviceOrientationCamera;
  41115. private _deviceOrientationCamera;
  41116. private _existingCamera;
  41117. private _onKeyDown;
  41118. private _onVrDisplayPresentChange;
  41119. private _onVRDisplayChanged;
  41120. private _onVRRequestPresentStart;
  41121. private _onVRRequestPresentComplete;
  41122. /**
  41123. * Observable raised right before entering VR.
  41124. */
  41125. onEnteringVRObservable: Observable<VRExperienceHelper>;
  41126. /**
  41127. * Observable raised when entering VR has completed.
  41128. */
  41129. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  41130. /**
  41131. * Observable raised when exiting VR.
  41132. */
  41133. onExitingVRObservable: Observable<VRExperienceHelper>;
  41134. /**
  41135. * Observable raised when controller mesh is loaded.
  41136. */
  41137. onControllerMeshLoadedObservable: Observable<WebVRController>;
  41138. /** Return this.onEnteringVRObservable
  41139. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  41140. */
  41141. readonly onEnteringVR: Observable<VRExperienceHelper>;
  41142. /** Return this.onExitingVRObservable
  41143. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  41144. */
  41145. readonly onExitingVR: Observable<VRExperienceHelper>;
  41146. /** Return this.onControllerMeshLoadedObservable
  41147. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  41148. */
  41149. readonly onControllerMeshLoaded: Observable<WebVRController>;
  41150. private _rayLength;
  41151. private _useCustomVRButton;
  41152. private _teleportationRequested;
  41153. private _teleportActive;
  41154. private _floorMeshName;
  41155. private _floorMeshesCollection;
  41156. private _rotationAllowed;
  41157. private _teleportBackwardsVector;
  41158. private _teleportationTarget;
  41159. private _isDefaultTeleportationTarget;
  41160. private _postProcessMove;
  41161. private _teleportationFillColor;
  41162. private _teleportationBorderColor;
  41163. private _rotationAngle;
  41164. private _haloCenter;
  41165. private _cameraGazer;
  41166. private _padSensibilityUp;
  41167. private _padSensibilityDown;
  41168. private _leftController;
  41169. private _rightController;
  41170. /**
  41171. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  41172. */
  41173. onNewMeshSelected: Observable<AbstractMesh>;
  41174. /**
  41175. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  41176. */
  41177. onNewMeshPicked: Observable<PickingInfo>;
  41178. private _circleEase;
  41179. /**
  41180. * Observable raised before camera teleportation
  41181. */
  41182. onBeforeCameraTeleport: Observable<Vector3>;
  41183. /**
  41184. * Observable raised after camera teleportation
  41185. */
  41186. onAfterCameraTeleport: Observable<Vector3>;
  41187. /**
  41188. * Observable raised when current selected mesh gets unselected
  41189. */
  41190. onSelectedMeshUnselected: Observable<AbstractMesh>;
  41191. private _raySelectionPredicate;
  41192. /**
  41193. * To be optionaly changed by user to define custom ray selection
  41194. */
  41195. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  41196. /**
  41197. * To be optionaly changed by user to define custom selection logic (after ray selection)
  41198. */
  41199. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  41200. /**
  41201. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  41202. */
  41203. teleportationEnabled: boolean;
  41204. private _defaultHeight;
  41205. private _teleportationInitialized;
  41206. private _interactionsEnabled;
  41207. private _interactionsRequested;
  41208. private _displayGaze;
  41209. private _displayLaserPointer;
  41210. /**
  41211. * The mesh used to display where the user is going to teleport.
  41212. */
  41213. /**
  41214. * Sets the mesh to be used to display where the user is going to teleport.
  41215. */
  41216. teleportationTarget: Mesh;
  41217. /**
  41218. * 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
  41219. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  41220. * See http://doc.babylonjs.com/resources/baking_transformations
  41221. */
  41222. gazeTrackerMesh: Mesh;
  41223. /**
  41224. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  41225. */
  41226. updateGazeTrackerScale: boolean;
  41227. /**
  41228. * If the gaze trackers color should be updated when selecting meshes
  41229. */
  41230. updateGazeTrackerColor: boolean;
  41231. /**
  41232. * The gaze tracking mesh corresponding to the left controller
  41233. */
  41234. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  41235. /**
  41236. * The gaze tracking mesh corresponding to the right controller
  41237. */
  41238. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  41239. /**
  41240. * If the ray of the gaze should be displayed.
  41241. */
  41242. /**
  41243. * Sets if the ray of the gaze should be displayed.
  41244. */
  41245. displayGaze: boolean;
  41246. /**
  41247. * If the ray of the LaserPointer should be displayed.
  41248. */
  41249. /**
  41250. * Sets if the ray of the LaserPointer should be displayed.
  41251. */
  41252. displayLaserPointer: boolean;
  41253. /**
  41254. * The deviceOrientationCamera used as the camera when not in VR.
  41255. */
  41256. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  41257. /**
  41258. * Based on the current WebVR support, returns the current VR camera used.
  41259. */
  41260. readonly currentVRCamera: Nullable<Camera>;
  41261. /**
  41262. * The webVRCamera which is used when in VR.
  41263. */
  41264. readonly webVRCamera: WebVRFreeCamera;
  41265. /**
  41266. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41267. */
  41268. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41269. private readonly _teleportationRequestInitiated;
  41270. /**
  41271. * Defines wether or not Pointer lock should be requested when switching to
  41272. * full screen.
  41273. */
  41274. requestPointerLockOnFullScreen: boolean;
  41275. /**
  41276. * Instantiates a VRExperienceHelper.
  41277. * Helps to quickly add VR support to an existing scene.
  41278. * @param scene The scene the VRExperienceHelper belongs to.
  41279. * @param webVROptions Options to modify the vr experience helper's behavior.
  41280. */
  41281. constructor(scene: Scene,
  41282. /** Options to modify the vr experience helper's behavior. */
  41283. webVROptions?: VRExperienceHelperOptions);
  41284. private _onDefaultMeshLoaded;
  41285. private _onResize;
  41286. private _onFullscreenChange;
  41287. /**
  41288. * Gets a value indicating if we are currently in VR mode.
  41289. */
  41290. readonly isInVRMode: boolean;
  41291. private onVrDisplayPresentChange;
  41292. private onVRDisplayChanged;
  41293. private moveButtonToBottomRight;
  41294. private displayVRButton;
  41295. private updateButtonVisibility;
  41296. private _cachedAngularSensibility;
  41297. /**
  41298. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41299. * Otherwise, will use the fullscreen API.
  41300. */
  41301. enterVR(): void;
  41302. /**
  41303. * Attempt to exit VR, or fullscreen.
  41304. */
  41305. exitVR(): void;
  41306. /**
  41307. * The position of the vr experience helper.
  41308. */
  41309. /**
  41310. * Sets the position of the vr experience helper.
  41311. */
  41312. position: Vector3;
  41313. /**
  41314. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41315. */
  41316. enableInteractions(): void;
  41317. private readonly _noControllerIsActive;
  41318. private beforeRender;
  41319. private _isTeleportationFloor;
  41320. /**
  41321. * Adds a floor mesh to be used for teleportation.
  41322. * @param floorMesh the mesh to be used for teleportation.
  41323. */
  41324. addFloorMesh(floorMesh: Mesh): void;
  41325. /**
  41326. * Removes a floor mesh from being used for teleportation.
  41327. * @param floorMesh the mesh to be removed.
  41328. */
  41329. removeFloorMesh(floorMesh: Mesh): void;
  41330. /**
  41331. * Enables interactions and teleportation using the VR controllers and gaze.
  41332. * @param vrTeleportationOptions options to modify teleportation behavior.
  41333. */
  41334. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41335. private _onNewGamepadConnected;
  41336. private _tryEnableInteractionOnController;
  41337. private _onNewGamepadDisconnected;
  41338. private _enableInteractionOnController;
  41339. private _checkTeleportWithRay;
  41340. private _checkRotate;
  41341. private _checkTeleportBackwards;
  41342. private _enableTeleportationOnController;
  41343. private _createTeleportationCircles;
  41344. private _displayTeleportationTarget;
  41345. private _hideTeleportationTarget;
  41346. private _rotateCamera;
  41347. private _moveTeleportationSelectorTo;
  41348. private _workingVector;
  41349. private _workingQuaternion;
  41350. private _workingMatrix;
  41351. /**
  41352. * Teleports the users feet to the desired location
  41353. * @param location The location where the user's feet should be placed
  41354. */
  41355. teleportCamera(location: Vector3): void;
  41356. private _convertNormalToDirectionOfRay;
  41357. private _castRayAndSelectObject;
  41358. private _notifySelectedMeshUnselected;
  41359. /**
  41360. * Sets the color of the laser ray from the vr controllers.
  41361. * @param color new color for the ray.
  41362. */
  41363. changeLaserColor(color: Color3): void;
  41364. /**
  41365. * Sets the color of the ray from the vr headsets gaze.
  41366. * @param color new color for the ray.
  41367. */
  41368. changeGazeColor(color: Color3): void;
  41369. /**
  41370. * Exits VR and disposes of the vr experience helper
  41371. */
  41372. dispose(): void;
  41373. /**
  41374. * Gets the name of the VRExperienceHelper class
  41375. * @returns "VRExperienceHelper"
  41376. */
  41377. getClassName(): string;
  41378. }
  41379. }
  41380. declare module "babylonjs/Cameras/VR/index" {
  41381. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41382. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41383. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41384. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41385. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41386. export * from "babylonjs/Cameras/VR/webVRCamera";
  41387. }
  41388. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41389. import { Observable } from "babylonjs/Misc/observable";
  41390. import { Nullable } from "babylonjs/types";
  41391. import { IDisposable, Scene } from "babylonjs/scene";
  41392. import { Vector3 } from "babylonjs/Maths/math";
  41393. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41394. import { Ray } from "babylonjs/Culling/ray";
  41395. /**
  41396. * Manages an XRSession
  41397. * @see https://doc.babylonjs.com/how_to/webxr
  41398. */
  41399. export class WebXRSessionManager implements IDisposable {
  41400. private scene;
  41401. /**
  41402. * Fires every time a new xrFrame arrives which can be used to update the camera
  41403. */
  41404. onXRFrameObservable: Observable<any>;
  41405. /**
  41406. * Fires when the xr session is ended either by the device or manually done
  41407. */
  41408. onXRSessionEnded: Observable<any>;
  41409. /** @hidden */
  41410. _xrSession: XRSession;
  41411. /** @hidden */
  41412. _frameOfReference: XRFrameOfReference;
  41413. /** @hidden */
  41414. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41415. /** @hidden */
  41416. _currentXRFrame: Nullable<XRFrame>;
  41417. private _xrNavigator;
  41418. private _xrDevice;
  41419. private _tmpMatrix;
  41420. /**
  41421. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41422. * @param scene The scene which the session should be created for
  41423. */
  41424. constructor(scene: Scene);
  41425. /**
  41426. * Initializes the manager
  41427. * After initialization enterXR can be called to start an XR session
  41428. * @returns Promise which resolves after it is initialized
  41429. */
  41430. initializeAsync(): Promise<void>;
  41431. /**
  41432. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41433. * @param sessionCreationOptions xr options to create the session with
  41434. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41435. * @returns Promise which resolves after it enters XR
  41436. */
  41437. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41438. /**
  41439. * Stops the xrSession and restores the renderloop
  41440. * @returns Promise which resolves after it exits XR
  41441. */
  41442. exitXRAsync(): Promise<void>;
  41443. /**
  41444. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41445. * @param ray ray to cast into the environment
  41446. * @returns Promise which resolves with a collision point in the environment if it exists
  41447. */
  41448. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41449. /**
  41450. * Checks if a session would be supported for the creation options specified
  41451. * @param options creation options to check if they are supported
  41452. * @returns true if supported
  41453. */
  41454. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41455. /**
  41456. * @hidden
  41457. * Converts the render layer of xrSession to a render target
  41458. * @param session session to create render target for
  41459. * @param scene scene the new render target should be created for
  41460. */
  41461. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41462. /**
  41463. * Disposes of the session manager
  41464. */
  41465. dispose(): void;
  41466. }
  41467. }
  41468. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41469. import { Scene } from "babylonjs/scene";
  41470. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41471. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41472. /**
  41473. * WebXR Camera which holds the views for the xrSession
  41474. * @see https://doc.babylonjs.com/how_to/webxr
  41475. */
  41476. export class WebXRCamera extends FreeCamera {
  41477. private static _TmpMatrix;
  41478. /**
  41479. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41480. * @param name the name of the camera
  41481. * @param scene the scene to add the camera to
  41482. */
  41483. constructor(name: string, scene: Scene);
  41484. private _updateNumberOfRigCameras;
  41485. /** @hidden */
  41486. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41487. /**
  41488. * Updates the cameras position from the current pose information of the XR session
  41489. * @param xrSessionManager the session containing pose information
  41490. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41491. */
  41492. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41493. }
  41494. }
  41495. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41496. import { Nullable } from "babylonjs/types";
  41497. import { Observable } from "babylonjs/Misc/observable";
  41498. import { IDisposable, Scene } from "babylonjs/scene";
  41499. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41500. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41501. import { Ray } from "babylonjs/Culling/ray";
  41502. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41503. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41504. /**
  41505. * States of the webXR experience
  41506. */
  41507. export enum WebXRState {
  41508. /**
  41509. * Transitioning to being in XR mode
  41510. */
  41511. ENTERING_XR = 0,
  41512. /**
  41513. * Transitioning to non XR mode
  41514. */
  41515. EXITING_XR = 1,
  41516. /**
  41517. * In XR mode and presenting
  41518. */
  41519. IN_XR = 2,
  41520. /**
  41521. * Not entered XR mode
  41522. */
  41523. NOT_IN_XR = 3
  41524. }
  41525. /**
  41526. * Helper class used to enable XR
  41527. * @see https://doc.babylonjs.com/how_to/webxr
  41528. */
  41529. export class WebXRExperienceHelper implements IDisposable {
  41530. private scene;
  41531. /**
  41532. * 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
  41533. */
  41534. container: AbstractMesh;
  41535. /**
  41536. * Camera used to render xr content
  41537. */
  41538. camera: WebXRCamera;
  41539. /**
  41540. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41541. */
  41542. state: WebXRState;
  41543. private _setState;
  41544. private static _TmpVector;
  41545. /**
  41546. * Fires when the state of the experience helper has changed
  41547. */
  41548. onStateChangedObservable: Observable<WebXRState>;
  41549. /** @hidden */
  41550. _sessionManager: WebXRSessionManager;
  41551. private _nonVRCamera;
  41552. private _originalSceneAutoClear;
  41553. private _supported;
  41554. /**
  41555. * Creates the experience helper
  41556. * @param scene the scene to attach the experience helper to
  41557. * @returns a promise for the experience helper
  41558. */
  41559. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41560. /**
  41561. * Creates a WebXRExperienceHelper
  41562. * @param scene The scene the helper should be created in
  41563. */
  41564. private constructor();
  41565. /**
  41566. * Exits XR mode and returns the scene to its original state
  41567. * @returns promise that resolves after xr mode has exited
  41568. */
  41569. exitXRAsync(): Promise<void>;
  41570. /**
  41571. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41572. * @param sessionCreationOptions options for the XR session
  41573. * @param frameOfReference frame of reference of the XR session
  41574. * @returns promise that resolves after xr mode has entered
  41575. */
  41576. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41577. /**
  41578. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41579. * @param ray ray to cast into the environment
  41580. * @returns Promise which resolves with a collision point in the environment if it exists
  41581. */
  41582. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41583. /**
  41584. * Updates the global position of the camera by moving the camera's container
  41585. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41586. * @param position The desired global position of the camera
  41587. */
  41588. setPositionOfCameraUsingContainer(position: Vector3): void;
  41589. /**
  41590. * Rotates the xr camera by rotating the camera's container around the camera's position
  41591. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41592. * @param rotation the desired quaternion rotation to apply to the camera
  41593. */
  41594. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41595. /**
  41596. * Checks if the creation options are supported by the xr session
  41597. * @param options creation options
  41598. * @returns true if supported
  41599. */
  41600. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41601. /**
  41602. * Disposes of the experience helper
  41603. */
  41604. dispose(): void;
  41605. }
  41606. }
  41607. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41608. import { Nullable } from "babylonjs/types";
  41609. import { Observable } from "babylonjs/Misc/observable";
  41610. import { IDisposable, Scene } from "babylonjs/scene";
  41611. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41612. /**
  41613. * Button which can be used to enter a different mode of XR
  41614. */
  41615. export class WebXREnterExitUIButton {
  41616. /** button element */
  41617. element: HTMLElement;
  41618. /** XR initialization options for the button */
  41619. initializationOptions: XRSessionCreationOptions;
  41620. /**
  41621. * Creates a WebXREnterExitUIButton
  41622. * @param element button element
  41623. * @param initializationOptions XR initialization options for the button
  41624. */
  41625. constructor(
  41626. /** button element */
  41627. element: HTMLElement,
  41628. /** XR initialization options for the button */
  41629. initializationOptions: XRSessionCreationOptions);
  41630. /**
  41631. * Overwritable function which can be used to update the button's visuals when the state changes
  41632. * @param activeButton the current active button in the UI
  41633. */
  41634. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41635. }
  41636. /**
  41637. * Options to create the webXR UI
  41638. */
  41639. export class WebXREnterExitUIOptions {
  41640. /**
  41641. * Context to enter xr with
  41642. */
  41643. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41644. /**
  41645. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41646. */
  41647. customButtons?: Array<WebXREnterExitUIButton>;
  41648. }
  41649. /**
  41650. * UI to allow the user to enter/exit XR mode
  41651. */
  41652. export class WebXREnterExitUI implements IDisposable {
  41653. private scene;
  41654. private _overlay;
  41655. private _buttons;
  41656. private _activeButton;
  41657. /**
  41658. * Fired every time the active button is changed.
  41659. *
  41660. * When xr is entered via a button that launches xr that button will be the callback parameter
  41661. *
  41662. * When exiting xr the callback parameter will be null)
  41663. */
  41664. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41665. /**
  41666. * Creates UI to allow the user to enter/exit XR mode
  41667. * @param scene the scene to add the ui to
  41668. * @param helper the xr experience helper to enter/exit xr with
  41669. * @param options options to configure the UI
  41670. * @returns the created ui
  41671. */
  41672. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41673. private constructor();
  41674. private _updateButtons;
  41675. /**
  41676. * Disposes of the object
  41677. */
  41678. dispose(): void;
  41679. }
  41680. }
  41681. declare module "babylonjs/Cameras/XR/webXRInput" {
  41682. import { IDisposable, Scene } from "babylonjs/scene";
  41683. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41684. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41685. /**
  41686. * Represents an XR input
  41687. */
  41688. export class WebXRController {
  41689. /**
  41690. * 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
  41691. */
  41692. grip?: AbstractMesh;
  41693. /**
  41694. * Pointer which can be used to select objects or attach a visible laser to
  41695. */
  41696. pointer: AbstractMesh;
  41697. /**
  41698. * Creates the controller
  41699. * @see https://doc.babylonjs.com/how_to/webxr
  41700. * @param scene the scene which the controller should be associated to
  41701. */
  41702. constructor(scene: Scene);
  41703. /**
  41704. * Disposes of the object
  41705. */
  41706. dispose(): void;
  41707. }
  41708. /**
  41709. * XR input used to track XR inputs such as controllers/rays
  41710. */
  41711. export class WebXRInput implements IDisposable {
  41712. private helper;
  41713. /**
  41714. * XR controllers being tracked
  41715. */
  41716. controllers: Array<WebXRController>;
  41717. private _tmpMatrix;
  41718. private _frameObserver;
  41719. /**
  41720. * Initializes the WebXRInput
  41721. * @param helper experience helper which the input should be created for
  41722. */
  41723. constructor(helper: WebXRExperienceHelper);
  41724. /**
  41725. * Disposes of the object
  41726. */
  41727. dispose(): void;
  41728. }
  41729. }
  41730. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41731. import { Nullable } from "babylonjs/types";
  41732. import { IDisposable } from "babylonjs/scene";
  41733. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41734. /**
  41735. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41736. */
  41737. export class WebXRManagedOutputCanvas implements IDisposable {
  41738. private _canvas;
  41739. /**
  41740. * xrpresent context of the canvas which can be used to display/mirror xr content
  41741. */
  41742. canvasContext: Nullable<WebGLRenderingContext>;
  41743. /**
  41744. * Initializes the canvas to be added/removed upon entering/exiting xr
  41745. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41746. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41747. */
  41748. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41749. /**
  41750. * Disposes of the object
  41751. */
  41752. dispose(): void;
  41753. private _setManagedOutputCanvas;
  41754. private _addCanvas;
  41755. private _removeCanvas;
  41756. }
  41757. }
  41758. declare module "babylonjs/Cameras/XR/index" {
  41759. export * from "babylonjs/Cameras/XR/webXRCamera";
  41760. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41761. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41762. export * from "babylonjs/Cameras/XR/webXRInput";
  41763. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41764. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41765. }
  41766. declare module "babylonjs/Cameras/RigModes/index" {
  41767. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41768. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41769. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41770. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41771. }
  41772. declare module "babylonjs/Cameras/index" {
  41773. export * from "babylonjs/Cameras/Inputs/index";
  41774. export * from "babylonjs/Cameras/cameraInputsManager";
  41775. export * from "babylonjs/Cameras/camera";
  41776. export * from "babylonjs/Cameras/targetCamera";
  41777. export * from "babylonjs/Cameras/freeCamera";
  41778. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41779. export * from "babylonjs/Cameras/touchCamera";
  41780. export * from "babylonjs/Cameras/arcRotateCamera";
  41781. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41782. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41783. export * from "babylonjs/Cameras/flyCamera";
  41784. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41785. export * from "babylonjs/Cameras/followCamera";
  41786. export * from "babylonjs/Cameras/gamepadCamera";
  41787. export * from "babylonjs/Cameras/Stereoscopic/index";
  41788. export * from "babylonjs/Cameras/universalCamera";
  41789. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41790. export * from "babylonjs/Cameras/VR/index";
  41791. export * from "babylonjs/Cameras/XR/index";
  41792. export * from "babylonjs/Cameras/RigModes/index";
  41793. }
  41794. declare module "babylonjs/Collisions/index" {
  41795. export * from "babylonjs/Collisions/collider";
  41796. export * from "babylonjs/Collisions/collisionCoordinator";
  41797. export * from "babylonjs/Collisions/pickingInfo";
  41798. export * from "babylonjs/Collisions/intersectionInfo";
  41799. export * from "babylonjs/Collisions/meshCollisionData";
  41800. }
  41801. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41802. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41803. import { Vector3, Plane } from "babylonjs/Maths/math";
  41804. import { Ray } from "babylonjs/Culling/ray";
  41805. /**
  41806. * Contains an array of blocks representing the octree
  41807. */
  41808. export interface IOctreeContainer<T> {
  41809. /**
  41810. * Blocks within the octree
  41811. */
  41812. blocks: Array<OctreeBlock<T>>;
  41813. }
  41814. /**
  41815. * Class used to store a cell in an octree
  41816. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41817. */
  41818. export class OctreeBlock<T> {
  41819. /**
  41820. * Gets the content of the current block
  41821. */
  41822. entries: T[];
  41823. /**
  41824. * Gets the list of block children
  41825. */
  41826. blocks: Array<OctreeBlock<T>>;
  41827. private _depth;
  41828. private _maxDepth;
  41829. private _capacity;
  41830. private _minPoint;
  41831. private _maxPoint;
  41832. private _boundingVectors;
  41833. private _creationFunc;
  41834. /**
  41835. * Creates a new block
  41836. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41837. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41838. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41839. * @param depth defines the current depth of this block in the octree
  41840. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41841. * @param creationFunc defines a callback to call when an element is added to the block
  41842. */
  41843. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41844. /**
  41845. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41846. */
  41847. readonly capacity: number;
  41848. /**
  41849. * Gets the minimum vector (in world space) of the block's bounding box
  41850. */
  41851. readonly minPoint: Vector3;
  41852. /**
  41853. * Gets the maximum vector (in world space) of the block's bounding box
  41854. */
  41855. readonly maxPoint: Vector3;
  41856. /**
  41857. * Add a new element to this block
  41858. * @param entry defines the element to add
  41859. */
  41860. addEntry(entry: T): void;
  41861. /**
  41862. * Remove an element from this block
  41863. * @param entry defines the element to remove
  41864. */
  41865. removeEntry(entry: T): void;
  41866. /**
  41867. * Add an array of elements to this block
  41868. * @param entries defines the array of elements to add
  41869. */
  41870. addEntries(entries: T[]): void;
  41871. /**
  41872. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41873. * @param frustumPlanes defines the frustum planes to test
  41874. * @param selection defines the array to store current content if selection is positive
  41875. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41876. */
  41877. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41878. /**
  41879. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41880. * @param sphereCenter defines the bounding sphere center
  41881. * @param sphereRadius defines the bounding sphere radius
  41882. * @param selection defines the array to store current content if selection is positive
  41883. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41884. */
  41885. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41886. /**
  41887. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41888. * @param ray defines the ray to test with
  41889. * @param selection defines the array to store current content if selection is positive
  41890. */
  41891. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41892. /**
  41893. * Subdivide the content into child blocks (this block will then be empty)
  41894. */
  41895. createInnerBlocks(): void;
  41896. /**
  41897. * @hidden
  41898. */
  41899. 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;
  41900. }
  41901. }
  41902. declare module "babylonjs/Culling/Octrees/octree" {
  41903. import { SmartArray } from "babylonjs/Misc/smartArray";
  41904. import { Vector3, Plane } from "babylonjs/Maths/math";
  41905. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41907. import { Ray } from "babylonjs/Culling/ray";
  41908. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41909. /**
  41910. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41911. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41912. */
  41913. export class Octree<T> {
  41914. /** 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.) */
  41915. maxDepth: number;
  41916. /**
  41917. * Blocks within the octree containing objects
  41918. */
  41919. blocks: Array<OctreeBlock<T>>;
  41920. /**
  41921. * Content stored in the octree
  41922. */
  41923. dynamicContent: T[];
  41924. private _maxBlockCapacity;
  41925. private _selectionContent;
  41926. private _creationFunc;
  41927. /**
  41928. * Creates a octree
  41929. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41930. * @param creationFunc function to be used to instatiate the octree
  41931. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41932. * @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.)
  41933. */
  41934. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41935. /** 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.) */
  41936. maxDepth?: number);
  41937. /**
  41938. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41939. * @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);
  41940. * @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);
  41941. * @param entries meshes to be added to the octree blocks
  41942. */
  41943. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41944. /**
  41945. * Adds a mesh to the octree
  41946. * @param entry Mesh to add to the octree
  41947. */
  41948. addMesh(entry: T): void;
  41949. /**
  41950. * Remove an element from the octree
  41951. * @param entry defines the element to remove
  41952. */
  41953. removeMesh(entry: T): void;
  41954. /**
  41955. * Selects an array of meshes within the frustum
  41956. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41957. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41958. * @returns array of meshes within the frustum
  41959. */
  41960. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41961. /**
  41962. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41963. * @param sphereCenter defines the bounding sphere center
  41964. * @param sphereRadius defines the bounding sphere radius
  41965. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41966. * @returns an array of objects that intersect the sphere
  41967. */
  41968. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41969. /**
  41970. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41971. * @param ray defines the ray to test with
  41972. * @returns array of intersected objects
  41973. */
  41974. intersectsRay(ray: Ray): SmartArray<T>;
  41975. /**
  41976. * Adds a mesh into the octree block if it intersects the block
  41977. */
  41978. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41979. /**
  41980. * Adds a submesh into the octree block if it intersects the block
  41981. */
  41982. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41983. }
  41984. }
  41985. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41986. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41987. import { Scene } from "babylonjs/scene";
  41988. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41990. import { Ray } from "babylonjs/Culling/ray";
  41991. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41992. import { Collider } from "babylonjs/Collisions/collider";
  41993. module "babylonjs/scene" {
  41994. interface Scene {
  41995. /**
  41996. * @hidden
  41997. * Backing Filed
  41998. */
  41999. _selectionOctree: Octree<AbstractMesh>;
  42000. /**
  42001. * Gets the octree used to boost mesh selection (picking)
  42002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42003. */
  42004. selectionOctree: Octree<AbstractMesh>;
  42005. /**
  42006. * Creates or updates the octree used to boost selection (picking)
  42007. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42008. * @param maxCapacity defines the maximum capacity per leaf
  42009. * @param maxDepth defines the maximum depth of the octree
  42010. * @returns an octree of AbstractMesh
  42011. */
  42012. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  42013. }
  42014. }
  42015. module "babylonjs/Meshes/abstractMesh" {
  42016. interface AbstractMesh {
  42017. /**
  42018. * @hidden
  42019. * Backing Field
  42020. */
  42021. _submeshesOctree: Octree<SubMesh>;
  42022. /**
  42023. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  42024. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  42025. * @param maxCapacity defines the maximum size of each block (64 by default)
  42026. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  42027. * @returns the new octree
  42028. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  42029. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  42030. */
  42031. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  42032. }
  42033. }
  42034. /**
  42035. * Defines the octree scene component responsible to manage any octrees
  42036. * in a given scene.
  42037. */
  42038. export class OctreeSceneComponent {
  42039. /**
  42040. * The component name help to identify the component in the list of scene components.
  42041. */
  42042. readonly name: string;
  42043. /**
  42044. * The scene the component belongs to.
  42045. */
  42046. scene: Scene;
  42047. /**
  42048. * Indicates if the meshes have been checked to make sure they are isEnabled()
  42049. */
  42050. readonly checksIsEnabled: boolean;
  42051. /**
  42052. * Creates a new instance of the component for the given scene
  42053. * @param scene Defines the scene to register the component in
  42054. */
  42055. constructor(scene: Scene);
  42056. /**
  42057. * Registers the component in a given scene
  42058. */
  42059. register(): void;
  42060. /**
  42061. * Return the list of active meshes
  42062. * @returns the list of active meshes
  42063. */
  42064. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  42065. /**
  42066. * Return the list of active sub meshes
  42067. * @param mesh The mesh to get the candidates sub meshes from
  42068. * @returns the list of active sub meshes
  42069. */
  42070. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  42071. private _tempRay;
  42072. /**
  42073. * Return the list of sub meshes intersecting with a given local ray
  42074. * @param mesh defines the mesh to find the submesh for
  42075. * @param localRay defines the ray in local space
  42076. * @returns the list of intersecting sub meshes
  42077. */
  42078. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  42079. /**
  42080. * Return the list of sub meshes colliding with a collider
  42081. * @param mesh defines the mesh to find the submesh for
  42082. * @param collider defines the collider to evaluate the collision against
  42083. * @returns the list of colliding sub meshes
  42084. */
  42085. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  42086. /**
  42087. * Rebuilds the elements related to this component in case of
  42088. * context lost for instance.
  42089. */
  42090. rebuild(): void;
  42091. /**
  42092. * Disposes the component and the associated ressources.
  42093. */
  42094. dispose(): void;
  42095. }
  42096. }
  42097. declare module "babylonjs/Culling/Octrees/index" {
  42098. export * from "babylonjs/Culling/Octrees/octree";
  42099. export * from "babylonjs/Culling/Octrees/octreeBlock";
  42100. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  42101. }
  42102. declare module "babylonjs/Culling/index" {
  42103. export * from "babylonjs/Culling/boundingBox";
  42104. export * from "babylonjs/Culling/boundingInfo";
  42105. export * from "babylonjs/Culling/boundingSphere";
  42106. export * from "babylonjs/Culling/Octrees/index";
  42107. export * from "babylonjs/Culling/ray";
  42108. }
  42109. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  42110. import { IDisposable, Scene } from "babylonjs/scene";
  42111. import { Nullable } from "babylonjs/types";
  42112. import { Observable } from "babylonjs/Misc/observable";
  42113. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42114. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  42115. /**
  42116. * Renders a layer on top of an existing scene
  42117. */
  42118. export class UtilityLayerRenderer implements IDisposable {
  42119. /** the original scene that will be rendered on top of */
  42120. originalScene: Scene;
  42121. private _pointerCaptures;
  42122. private _lastPointerEvents;
  42123. private static _DefaultUtilityLayer;
  42124. private static _DefaultKeepDepthUtilityLayer;
  42125. private _sharedGizmoLight;
  42126. /**
  42127. * @hidden
  42128. * Light which used by gizmos to get light shading
  42129. */
  42130. _getSharedGizmoLight(): HemisphericLight;
  42131. /**
  42132. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  42133. */
  42134. pickUtilitySceneFirst: boolean;
  42135. /**
  42136. * 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)
  42137. */
  42138. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  42139. /**
  42140. * 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)
  42141. */
  42142. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  42143. /**
  42144. * The scene that is rendered on top of the original scene
  42145. */
  42146. utilityLayerScene: Scene;
  42147. /**
  42148. * If the utility layer should automatically be rendered on top of existing scene
  42149. */
  42150. shouldRender: boolean;
  42151. /**
  42152. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  42153. */
  42154. onlyCheckPointerDownEvents: boolean;
  42155. /**
  42156. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  42157. */
  42158. processAllEvents: boolean;
  42159. /**
  42160. * Observable raised when the pointer move from the utility layer scene to the main scene
  42161. */
  42162. onPointerOutObservable: Observable<number>;
  42163. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  42164. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  42165. private _afterRenderObserver;
  42166. private _sceneDisposeObserver;
  42167. private _originalPointerObserver;
  42168. /**
  42169. * Instantiates a UtilityLayerRenderer
  42170. * @param originalScene the original scene that will be rendered on top of
  42171. * @param handleEvents boolean indicating if the utility layer should handle events
  42172. */
  42173. constructor(
  42174. /** the original scene that will be rendered on top of */
  42175. originalScene: Scene, handleEvents?: boolean);
  42176. private _notifyObservers;
  42177. /**
  42178. * Renders the utility layers scene on top of the original scene
  42179. */
  42180. render(): void;
  42181. /**
  42182. * Disposes of the renderer
  42183. */
  42184. dispose(): void;
  42185. private _updateCamera;
  42186. }
  42187. }
  42188. declare module "babylonjs/Gizmos/gizmo" {
  42189. import { Nullable } from "babylonjs/types";
  42190. import { IDisposable } from "babylonjs/scene";
  42191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42192. import { Mesh } from "babylonjs/Meshes/mesh";
  42193. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42194. /**
  42195. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  42196. */
  42197. export class Gizmo implements IDisposable {
  42198. /** The utility layer the gizmo will be added to */
  42199. gizmoLayer: UtilityLayerRenderer;
  42200. /**
  42201. * The root mesh of the gizmo
  42202. */
  42203. _rootMesh: Mesh;
  42204. private _attachedMesh;
  42205. /**
  42206. * Ratio for the scale of the gizmo (Default: 1)
  42207. */
  42208. scaleRatio: number;
  42209. /**
  42210. * If a custom mesh has been set (Default: false)
  42211. */
  42212. protected _customMeshSet: boolean;
  42213. /**
  42214. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  42215. * * When set, interactions will be enabled
  42216. */
  42217. attachedMesh: Nullable<AbstractMesh>;
  42218. /**
  42219. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  42220. * @param mesh The mesh to replace the default mesh of the gizmo
  42221. */
  42222. setCustomMesh(mesh: Mesh): void;
  42223. /**
  42224. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  42225. */
  42226. updateGizmoRotationToMatchAttachedMesh: boolean;
  42227. /**
  42228. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  42229. */
  42230. updateGizmoPositionToMatchAttachedMesh: boolean;
  42231. /**
  42232. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  42233. */
  42234. protected _updateScale: boolean;
  42235. protected _interactionsEnabled: boolean;
  42236. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42237. private _beforeRenderObserver;
  42238. private _tempVector;
  42239. /**
  42240. * Creates a gizmo
  42241. * @param gizmoLayer The utility layer the gizmo will be added to
  42242. */
  42243. constructor(
  42244. /** The utility layer the gizmo will be added to */
  42245. gizmoLayer?: UtilityLayerRenderer);
  42246. /**
  42247. * Updates the gizmo to match the attached mesh's position/rotation
  42248. */
  42249. protected _update(): void;
  42250. /**
  42251. * Disposes of the gizmo
  42252. */
  42253. dispose(): void;
  42254. }
  42255. }
  42256. declare module "babylonjs/Gizmos/planeDragGizmo" {
  42257. import { Observable } from "babylonjs/Misc/observable";
  42258. import { Nullable } from "babylonjs/types";
  42259. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42260. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42261. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42262. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42263. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42264. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42265. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42266. import { Scene } from "babylonjs/scene";
  42267. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42268. /**
  42269. * Single plane drag gizmo
  42270. */
  42271. export class PlaneDragGizmo extends Gizmo {
  42272. /**
  42273. * Drag behavior responsible for the gizmos dragging interactions
  42274. */
  42275. dragBehavior: PointerDragBehavior;
  42276. private _pointerObserver;
  42277. /**
  42278. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42279. */
  42280. snapDistance: number;
  42281. /**
  42282. * Event that fires each time the gizmo snaps to a new location.
  42283. * * snapDistance is the the change in distance
  42284. */
  42285. onSnapObservable: Observable<{
  42286. snapDistance: number;
  42287. }>;
  42288. private _plane;
  42289. private _coloredMaterial;
  42290. private _hoverMaterial;
  42291. private _isEnabled;
  42292. private _parent;
  42293. /** @hidden */
  42294. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  42295. /** @hidden */
  42296. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42297. /**
  42298. * Creates a PlaneDragGizmo
  42299. * @param gizmoLayer The utility layer the gizmo will be added to
  42300. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  42301. * @param color The color of the gizmo
  42302. */
  42303. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42304. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42305. /**
  42306. * If the gizmo is enabled
  42307. */
  42308. isEnabled: boolean;
  42309. /**
  42310. * Disposes of the gizmo
  42311. */
  42312. dispose(): void;
  42313. }
  42314. }
  42315. declare module "babylonjs/Gizmos/positionGizmo" {
  42316. import { Observable } from "babylonjs/Misc/observable";
  42317. import { Nullable } from "babylonjs/types";
  42318. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42319. import { Mesh } from "babylonjs/Meshes/mesh";
  42320. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42321. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  42322. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  42323. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42324. /**
  42325. * Gizmo that enables dragging a mesh along 3 axis
  42326. */
  42327. export class PositionGizmo extends Gizmo {
  42328. /**
  42329. * Internal gizmo used for interactions on the x axis
  42330. */
  42331. xGizmo: AxisDragGizmo;
  42332. /**
  42333. * Internal gizmo used for interactions on the y axis
  42334. */
  42335. yGizmo: AxisDragGizmo;
  42336. /**
  42337. * Internal gizmo used for interactions on the z axis
  42338. */
  42339. zGizmo: AxisDragGizmo;
  42340. /**
  42341. * Internal gizmo used for interactions on the yz plane
  42342. */
  42343. xPlaneGizmo: PlaneDragGizmo;
  42344. /**
  42345. * Internal gizmo used for interactions on the xz plane
  42346. */
  42347. yPlaneGizmo: PlaneDragGizmo;
  42348. /**
  42349. * Internal gizmo used for interactions on the xy plane
  42350. */
  42351. zPlaneGizmo: PlaneDragGizmo;
  42352. /**
  42353. * private variables
  42354. */
  42355. private _meshAttached;
  42356. private _updateGizmoRotationToMatchAttachedMesh;
  42357. private _snapDistance;
  42358. private _scaleRatio;
  42359. /** Fires an event when any of it's sub gizmos are dragged */
  42360. onDragStartObservable: Observable<{}>;
  42361. /** Fires an event when any of it's sub gizmos are released from dragging */
  42362. onDragEndObservable: Observable<{}>;
  42363. /**
  42364. * If set to true, planar drag is enabled
  42365. */
  42366. private _planarGizmoEnabled;
  42367. attachedMesh: Nullable<AbstractMesh>;
  42368. /**
  42369. * Creates a PositionGizmo
  42370. * @param gizmoLayer The utility layer the gizmo will be added to
  42371. */
  42372. constructor(gizmoLayer?: UtilityLayerRenderer);
  42373. /**
  42374. * If the planar drag gizmo is enabled
  42375. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  42376. */
  42377. planarGizmoEnabled: boolean;
  42378. updateGizmoRotationToMatchAttachedMesh: boolean;
  42379. /**
  42380. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42381. */
  42382. snapDistance: number;
  42383. /**
  42384. * Ratio for the scale of the gizmo (Default: 1)
  42385. */
  42386. scaleRatio: number;
  42387. /**
  42388. * Disposes of the gizmo
  42389. */
  42390. dispose(): void;
  42391. /**
  42392. * CustomMeshes are not supported by this gizmo
  42393. * @param mesh The mesh to replace the default mesh of the gizmo
  42394. */
  42395. setCustomMesh(mesh: Mesh): void;
  42396. }
  42397. }
  42398. declare module "babylonjs/Gizmos/axisDragGizmo" {
  42399. import { Observable } from "babylonjs/Misc/observable";
  42400. import { Nullable } from "babylonjs/types";
  42401. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42402. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42403. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42404. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42405. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42406. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42407. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42408. import { Scene } from "babylonjs/scene";
  42409. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  42410. /**
  42411. * Single axis drag gizmo
  42412. */
  42413. export class AxisDragGizmo extends Gizmo {
  42414. /**
  42415. * Drag behavior responsible for the gizmos dragging interactions
  42416. */
  42417. dragBehavior: PointerDragBehavior;
  42418. private _pointerObserver;
  42419. /**
  42420. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42421. */
  42422. snapDistance: number;
  42423. /**
  42424. * Event that fires each time the gizmo snaps to a new location.
  42425. * * snapDistance is the the change in distance
  42426. */
  42427. onSnapObservable: Observable<{
  42428. snapDistance: number;
  42429. }>;
  42430. private _isEnabled;
  42431. private _parent;
  42432. private _arrow;
  42433. private _coloredMaterial;
  42434. private _hoverMaterial;
  42435. /** @hidden */
  42436. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42437. /** @hidden */
  42438. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42439. /**
  42440. * Creates an AxisDragGizmo
  42441. * @param gizmoLayer The utility layer the gizmo will be added to
  42442. * @param dragAxis The axis which the gizmo will be able to drag on
  42443. * @param color The color of the gizmo
  42444. */
  42445. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42446. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42447. /**
  42448. * If the gizmo is enabled
  42449. */
  42450. isEnabled: boolean;
  42451. /**
  42452. * Disposes of the gizmo
  42453. */
  42454. dispose(): void;
  42455. }
  42456. }
  42457. declare module "babylonjs/Debug/axesViewer" {
  42458. import { Vector3 } from "babylonjs/Maths/math";
  42459. import { Nullable } from "babylonjs/types";
  42460. import { Scene } from "babylonjs/scene";
  42461. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42462. /**
  42463. * The Axes viewer will show 3 axes in a specific point in space
  42464. */
  42465. export class AxesViewer {
  42466. private _xAxis;
  42467. private _yAxis;
  42468. private _zAxis;
  42469. private _scaleLinesFactor;
  42470. private _instanced;
  42471. /**
  42472. * Gets the hosting scene
  42473. */
  42474. scene: Scene;
  42475. /**
  42476. * Gets or sets a number used to scale line length
  42477. */
  42478. scaleLines: number;
  42479. /** Gets the node hierarchy used to render x-axis */
  42480. readonly xAxis: TransformNode;
  42481. /** Gets the node hierarchy used to render y-axis */
  42482. readonly yAxis: TransformNode;
  42483. /** Gets the node hierarchy used to render z-axis */
  42484. readonly zAxis: TransformNode;
  42485. /**
  42486. * Creates a new AxesViewer
  42487. * @param scene defines the hosting scene
  42488. * @param scaleLines defines a number used to scale line length (1 by default)
  42489. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42490. * @param xAxis defines the node hierarchy used to render the x-axis
  42491. * @param yAxis defines the node hierarchy used to render the y-axis
  42492. * @param zAxis defines the node hierarchy used to render the z-axis
  42493. */
  42494. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42495. /**
  42496. * Force the viewer to update
  42497. * @param position defines the position of the viewer
  42498. * @param xaxis defines the x axis of the viewer
  42499. * @param yaxis defines the y axis of the viewer
  42500. * @param zaxis defines the z axis of the viewer
  42501. */
  42502. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42503. /**
  42504. * Creates an instance of this axes viewer.
  42505. * @returns a new axes viewer with instanced meshes
  42506. */
  42507. createInstance(): AxesViewer;
  42508. /** Releases resources */
  42509. dispose(): void;
  42510. private static _SetRenderingGroupId;
  42511. }
  42512. }
  42513. declare module "babylonjs/Debug/boneAxesViewer" {
  42514. import { Nullable } from "babylonjs/types";
  42515. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42516. import { Vector3 } from "babylonjs/Maths/math";
  42517. import { Mesh } from "babylonjs/Meshes/mesh";
  42518. import { Bone } from "babylonjs/Bones/bone";
  42519. import { Scene } from "babylonjs/scene";
  42520. /**
  42521. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42522. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42523. */
  42524. export class BoneAxesViewer extends AxesViewer {
  42525. /**
  42526. * Gets or sets the target mesh where to display the axes viewer
  42527. */
  42528. mesh: Nullable<Mesh>;
  42529. /**
  42530. * Gets or sets the target bone where to display the axes viewer
  42531. */
  42532. bone: Nullable<Bone>;
  42533. /** Gets current position */
  42534. pos: Vector3;
  42535. /** Gets direction of X axis */
  42536. xaxis: Vector3;
  42537. /** Gets direction of Y axis */
  42538. yaxis: Vector3;
  42539. /** Gets direction of Z axis */
  42540. zaxis: Vector3;
  42541. /**
  42542. * Creates a new BoneAxesViewer
  42543. * @param scene defines the hosting scene
  42544. * @param bone defines the target bone
  42545. * @param mesh defines the target mesh
  42546. * @param scaleLines defines a scaling factor for line length (1 by default)
  42547. */
  42548. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42549. /**
  42550. * Force the viewer to update
  42551. */
  42552. update(): void;
  42553. /** Releases resources */
  42554. dispose(): void;
  42555. }
  42556. }
  42557. declare module "babylonjs/Debug/debugLayer" {
  42558. import { Observable } from "babylonjs/Misc/observable";
  42559. import { Scene } from "babylonjs/scene";
  42560. /**
  42561. * Interface used to define scene explorer extensibility option
  42562. */
  42563. export interface IExplorerExtensibilityOption {
  42564. /**
  42565. * Define the option label
  42566. */
  42567. label: string;
  42568. /**
  42569. * Defines the action to execute on click
  42570. */
  42571. action: (entity: any) => void;
  42572. }
  42573. /**
  42574. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42575. */
  42576. export interface IExplorerExtensibilityGroup {
  42577. /**
  42578. * Defines a predicate to test if a given type mut be extended
  42579. */
  42580. predicate: (entity: any) => boolean;
  42581. /**
  42582. * Gets the list of options added to a type
  42583. */
  42584. entries: IExplorerExtensibilityOption[];
  42585. }
  42586. /**
  42587. * Interface used to define the options to use to create the Inspector
  42588. */
  42589. export interface IInspectorOptions {
  42590. /**
  42591. * Display in overlay mode (default: false)
  42592. */
  42593. overlay?: boolean;
  42594. /**
  42595. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42596. */
  42597. globalRoot?: HTMLElement;
  42598. /**
  42599. * Display the Scene explorer
  42600. */
  42601. showExplorer?: boolean;
  42602. /**
  42603. * Display the property inspector
  42604. */
  42605. showInspector?: boolean;
  42606. /**
  42607. * Display in embed mode (both panes on the right)
  42608. */
  42609. embedMode?: boolean;
  42610. /**
  42611. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42612. */
  42613. handleResize?: boolean;
  42614. /**
  42615. * Allow the panes to popup (default: true)
  42616. */
  42617. enablePopup?: boolean;
  42618. /**
  42619. * Allow the panes to be closed by users (default: true)
  42620. */
  42621. enableClose?: boolean;
  42622. /**
  42623. * Optional list of extensibility entries
  42624. */
  42625. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42626. /**
  42627. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42628. */
  42629. inspectorURL?: string;
  42630. }
  42631. module "babylonjs/scene" {
  42632. interface Scene {
  42633. /**
  42634. * @hidden
  42635. * Backing field
  42636. */
  42637. _debugLayer: DebugLayer;
  42638. /**
  42639. * Gets the debug layer (aka Inspector) associated with the scene
  42640. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42641. */
  42642. debugLayer: DebugLayer;
  42643. }
  42644. }
  42645. /**
  42646. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42647. * what is happening in your scene
  42648. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42649. */
  42650. export class DebugLayer {
  42651. /**
  42652. * Define the url to get the inspector script from.
  42653. * By default it uses the babylonjs CDN.
  42654. * @ignoreNaming
  42655. */
  42656. static InspectorURL: string;
  42657. private _scene;
  42658. private BJSINSPECTOR;
  42659. /**
  42660. * Observable triggered when a property is changed through the inspector.
  42661. */
  42662. onPropertyChangedObservable: Observable<{
  42663. object: any;
  42664. property: string;
  42665. value: any;
  42666. initialValue: any;
  42667. }>;
  42668. /**
  42669. * Instantiates a new debug layer.
  42670. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42671. * what is happening in your scene
  42672. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42673. * @param scene Defines the scene to inspect
  42674. */
  42675. constructor(scene: Scene);
  42676. /** Creates the inspector window. */
  42677. private _createInspector;
  42678. /**
  42679. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42680. * @param entity defines the entity to select
  42681. * @param lineContainerTitle defines the specific block to highlight
  42682. */
  42683. select(entity: any, lineContainerTitle?: string): void;
  42684. /** Get the inspector from bundle or global */
  42685. private _getGlobalInspector;
  42686. /**
  42687. * Get if the inspector is visible or not.
  42688. * @returns true if visible otherwise, false
  42689. */
  42690. isVisible(): boolean;
  42691. /**
  42692. * Hide the inspector and close its window.
  42693. */
  42694. hide(): void;
  42695. /**
  42696. * Launch the debugLayer.
  42697. * @param config Define the configuration of the inspector
  42698. * @return a promise fulfilled when the debug layer is visible
  42699. */
  42700. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42701. }
  42702. }
  42703. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42704. import { Nullable } from "babylonjs/types";
  42705. import { Scene } from "babylonjs/scene";
  42706. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42707. import { Mesh } from "babylonjs/Meshes/mesh";
  42708. /**
  42709. * Class containing static functions to help procedurally build meshes
  42710. */
  42711. export class BoxBuilder {
  42712. /**
  42713. * Creates a box mesh
  42714. * * The parameter `size` sets the size (float) of each box side (default 1)
  42715. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42716. * * 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)
  42717. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42718. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42719. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42720. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42721. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42722. * @param name defines the name of the mesh
  42723. * @param options defines the options used to create the mesh
  42724. * @param scene defines the hosting scene
  42725. * @returns the box mesh
  42726. */
  42727. static CreateBox(name: string, options: {
  42728. size?: number;
  42729. width?: number;
  42730. height?: number;
  42731. depth?: number;
  42732. faceUV?: Vector4[];
  42733. faceColors?: Color4[];
  42734. sideOrientation?: number;
  42735. frontUVs?: Vector4;
  42736. backUVs?: Vector4;
  42737. wrap?: boolean;
  42738. topBaseAt?: number;
  42739. bottomBaseAt?: number;
  42740. updatable?: boolean;
  42741. }, scene?: Nullable<Scene>): Mesh;
  42742. }
  42743. }
  42744. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42745. import { Vector4 } from "babylonjs/Maths/math";
  42746. import { Mesh } from "babylonjs/Meshes/mesh";
  42747. /**
  42748. * Class containing static functions to help procedurally build meshes
  42749. */
  42750. export class SphereBuilder {
  42751. /**
  42752. * Creates a sphere mesh
  42753. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42754. * * 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`)
  42755. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42756. * * 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
  42757. * * 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)
  42758. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42759. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42761. * @param name defines the name of the mesh
  42762. * @param options defines the options used to create the mesh
  42763. * @param scene defines the hosting scene
  42764. * @returns the sphere mesh
  42765. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42766. */
  42767. static CreateSphere(name: string, options: {
  42768. segments?: number;
  42769. diameter?: number;
  42770. diameterX?: number;
  42771. diameterY?: number;
  42772. diameterZ?: number;
  42773. arc?: number;
  42774. slice?: number;
  42775. sideOrientation?: number;
  42776. frontUVs?: Vector4;
  42777. backUVs?: Vector4;
  42778. updatable?: boolean;
  42779. }, scene: any): Mesh;
  42780. }
  42781. }
  42782. declare module "babylonjs/Debug/physicsViewer" {
  42783. import { Nullable } from "babylonjs/types";
  42784. import { Scene } from "babylonjs/scene";
  42785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42786. import { Mesh } from "babylonjs/Meshes/mesh";
  42787. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42788. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42789. /**
  42790. * Used to show the physics impostor around the specific mesh
  42791. */
  42792. export class PhysicsViewer {
  42793. /** @hidden */
  42794. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42795. /** @hidden */
  42796. protected _meshes: Array<Nullable<AbstractMesh>>;
  42797. /** @hidden */
  42798. protected _scene: Nullable<Scene>;
  42799. /** @hidden */
  42800. protected _numMeshes: number;
  42801. /** @hidden */
  42802. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42803. private _renderFunction;
  42804. private _utilityLayer;
  42805. private _debugBoxMesh;
  42806. private _debugSphereMesh;
  42807. private _debugCylinderMesh;
  42808. private _debugMaterial;
  42809. private _debugMeshMeshes;
  42810. /**
  42811. * Creates a new PhysicsViewer
  42812. * @param scene defines the hosting scene
  42813. */
  42814. constructor(scene: Scene);
  42815. /** @hidden */
  42816. protected _updateDebugMeshes(): void;
  42817. /**
  42818. * Renders a specified physic impostor
  42819. * @param impostor defines the impostor to render
  42820. * @param targetMesh defines the mesh represented by the impostor
  42821. * @returns the new debug mesh used to render the impostor
  42822. */
  42823. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42824. /**
  42825. * Hides a specified physic impostor
  42826. * @param impostor defines the impostor to hide
  42827. */
  42828. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42829. private _getDebugMaterial;
  42830. private _getDebugBoxMesh;
  42831. private _getDebugSphereMesh;
  42832. private _getDebugCylinderMesh;
  42833. private _getDebugMeshMesh;
  42834. private _getDebugMesh;
  42835. /** Releases all resources */
  42836. dispose(): void;
  42837. }
  42838. }
  42839. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42840. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42841. import { Nullable } from "babylonjs/types";
  42842. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42843. import { Scene } from "babylonjs/scene";
  42844. /**
  42845. * Class containing static functions to help procedurally build meshes
  42846. */
  42847. export class LinesBuilder {
  42848. /**
  42849. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42850. * * 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
  42851. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42852. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42853. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42854. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42855. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42856. * * 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
  42857. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42859. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42860. * @param name defines the name of the new line system
  42861. * @param options defines the options used to create the line system
  42862. * @param scene defines the hosting scene
  42863. * @returns a new line system mesh
  42864. */
  42865. static CreateLineSystem(name: string, options: {
  42866. lines: Vector3[][];
  42867. updatable?: boolean;
  42868. instance?: Nullable<LinesMesh>;
  42869. colors?: Nullable<Color4[][]>;
  42870. useVertexAlpha?: boolean;
  42871. }, scene: Nullable<Scene>): LinesMesh;
  42872. /**
  42873. * Creates a line mesh
  42874. * 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
  42875. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42876. * * The parameter `points` is an array successive Vector3
  42877. * * 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
  42878. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42879. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42880. * * When updating an instance, remember that only point positions can change, not the number of points
  42881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42883. * @param name defines the name of the new line system
  42884. * @param options defines the options used to create the line system
  42885. * @param scene defines the hosting scene
  42886. * @returns a new line mesh
  42887. */
  42888. static CreateLines(name: string, options: {
  42889. points: Vector3[];
  42890. updatable?: boolean;
  42891. instance?: Nullable<LinesMesh>;
  42892. colors?: Color4[];
  42893. useVertexAlpha?: boolean;
  42894. }, scene?: Nullable<Scene>): LinesMesh;
  42895. /**
  42896. * Creates a dashed line mesh
  42897. * * 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
  42898. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42899. * * The parameter `points` is an array successive Vector3
  42900. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42901. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42902. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42903. * * 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
  42904. * * When updating an instance, remember that only point positions can change, not the number of points
  42905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42906. * @param name defines the name of the mesh
  42907. * @param options defines the options used to create the mesh
  42908. * @param scene defines the hosting scene
  42909. * @returns the dashed line mesh
  42910. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42911. */
  42912. static CreateDashedLines(name: string, options: {
  42913. points: Vector3[];
  42914. dashSize?: number;
  42915. gapSize?: number;
  42916. dashNb?: number;
  42917. updatable?: boolean;
  42918. instance?: LinesMesh;
  42919. }, scene?: Nullable<Scene>): LinesMesh;
  42920. }
  42921. }
  42922. declare module "babylonjs/Debug/rayHelper" {
  42923. import { Nullable } from "babylonjs/types";
  42924. import { Ray } from "babylonjs/Culling/ray";
  42925. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42926. import { Scene } from "babylonjs/scene";
  42927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42928. import "babylonjs/Meshes/Builders/linesBuilder";
  42929. /**
  42930. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42931. * in order to better appreciate the issue one might have.
  42932. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42933. */
  42934. export class RayHelper {
  42935. /**
  42936. * Defines the ray we are currently tryin to visualize.
  42937. */
  42938. ray: Nullable<Ray>;
  42939. private _renderPoints;
  42940. private _renderLine;
  42941. private _renderFunction;
  42942. private _scene;
  42943. private _updateToMeshFunction;
  42944. private _attachedToMesh;
  42945. private _meshSpaceDirection;
  42946. private _meshSpaceOrigin;
  42947. /**
  42948. * Helper function to create a colored helper in a scene in one line.
  42949. * @param ray Defines the ray we are currently tryin to visualize
  42950. * @param scene Defines the scene the ray is used in
  42951. * @param color Defines the color we want to see the ray in
  42952. * @returns The newly created ray helper.
  42953. */
  42954. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42955. /**
  42956. * Instantiate a new ray helper.
  42957. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42958. * in order to better appreciate the issue one might have.
  42959. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42960. * @param ray Defines the ray we are currently tryin to visualize
  42961. */
  42962. constructor(ray: Ray);
  42963. /**
  42964. * Shows the ray we are willing to debug.
  42965. * @param scene Defines the scene the ray needs to be rendered in
  42966. * @param color Defines the color the ray needs to be rendered in
  42967. */
  42968. show(scene: Scene, color?: Color3): void;
  42969. /**
  42970. * Hides the ray we are debugging.
  42971. */
  42972. hide(): void;
  42973. private _render;
  42974. /**
  42975. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42976. * @param mesh Defines the mesh we want the helper attached to
  42977. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42978. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42979. * @param length Defines the length of the ray
  42980. */
  42981. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42982. /**
  42983. * Detach the ray helper from the mesh it has previously been attached to.
  42984. */
  42985. detachFromMesh(): void;
  42986. private _updateToMesh;
  42987. /**
  42988. * Dispose the helper and release its associated resources.
  42989. */
  42990. dispose(): void;
  42991. }
  42992. }
  42993. declare module "babylonjs/Debug/skeletonViewer" {
  42994. import { Color3 } from "babylonjs/Maths/math";
  42995. import { Scene } from "babylonjs/scene";
  42996. import { Nullable } from "babylonjs/types";
  42997. import { Skeleton } from "babylonjs/Bones/skeleton";
  42998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42999. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  43000. /**
  43001. * Class used to render a debug view of a given skeleton
  43002. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  43003. */
  43004. export class SkeletonViewer {
  43005. /** defines the skeleton to render */
  43006. skeleton: Skeleton;
  43007. /** defines the mesh attached to the skeleton */
  43008. mesh: AbstractMesh;
  43009. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43010. autoUpdateBonesMatrices: boolean;
  43011. /** defines the rendering group id to use with the viewer */
  43012. renderingGroupId: number;
  43013. /** Gets or sets the color used to render the skeleton */
  43014. color: Color3;
  43015. private _scene;
  43016. private _debugLines;
  43017. private _debugMesh;
  43018. private _isEnabled;
  43019. private _renderFunction;
  43020. private _utilityLayer;
  43021. /**
  43022. * Returns the mesh used to render the bones
  43023. */
  43024. readonly debugMesh: Nullable<LinesMesh>;
  43025. /**
  43026. * Creates a new SkeletonViewer
  43027. * @param skeleton defines the skeleton to render
  43028. * @param mesh defines the mesh attached to the skeleton
  43029. * @param scene defines the hosting scene
  43030. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  43031. * @param renderingGroupId defines the rendering group id to use with the viewer
  43032. */
  43033. constructor(
  43034. /** defines the skeleton to render */
  43035. skeleton: Skeleton,
  43036. /** defines the mesh attached to the skeleton */
  43037. mesh: AbstractMesh, scene: Scene,
  43038. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  43039. autoUpdateBonesMatrices?: boolean,
  43040. /** defines the rendering group id to use with the viewer */
  43041. renderingGroupId?: number);
  43042. /** Gets or sets a boolean indicating if the viewer is enabled */
  43043. isEnabled: boolean;
  43044. private _getBonePosition;
  43045. private _getLinesForBonesWithLength;
  43046. private _getLinesForBonesNoLength;
  43047. /** Update the viewer to sync with current skeleton state */
  43048. update(): void;
  43049. /** Release associated resources */
  43050. dispose(): void;
  43051. }
  43052. }
  43053. declare module "babylonjs/Debug/index" {
  43054. export * from "babylonjs/Debug/axesViewer";
  43055. export * from "babylonjs/Debug/boneAxesViewer";
  43056. export * from "babylonjs/Debug/debugLayer";
  43057. export * from "babylonjs/Debug/physicsViewer";
  43058. export * from "babylonjs/Debug/rayHelper";
  43059. export * from "babylonjs/Debug/skeletonViewer";
  43060. }
  43061. declare module "babylonjs/Engines/nullEngine" {
  43062. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  43063. import { Scene } from "babylonjs/scene";
  43064. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  43065. import { Engine } from "babylonjs/Engines/engine";
  43066. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  43067. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  43068. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43069. import { Effect } from "babylonjs/Materials/effect";
  43070. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  43071. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43072. /**
  43073. * Options to create the null engine
  43074. */
  43075. export class NullEngineOptions {
  43076. /**
  43077. * Render width (Default: 512)
  43078. */
  43079. renderWidth: number;
  43080. /**
  43081. * Render height (Default: 256)
  43082. */
  43083. renderHeight: number;
  43084. /**
  43085. * Texture size (Default: 512)
  43086. */
  43087. textureSize: number;
  43088. /**
  43089. * If delta time between frames should be constant
  43090. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43091. */
  43092. deterministicLockstep: boolean;
  43093. /**
  43094. * Maximum about of steps between frames (Default: 4)
  43095. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43096. */
  43097. lockstepMaxSteps: number;
  43098. }
  43099. /**
  43100. * The null engine class provides support for headless version of babylon.js.
  43101. * This can be used in server side scenario or for testing purposes
  43102. */
  43103. export class NullEngine extends Engine {
  43104. private _options;
  43105. /**
  43106. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  43107. */
  43108. isDeterministicLockStep(): boolean;
  43109. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  43110. getLockstepMaxSteps(): number;
  43111. /**
  43112. * Sets hardware scaling, used to save performance if needed
  43113. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  43114. */
  43115. getHardwareScalingLevel(): number;
  43116. constructor(options?: NullEngineOptions);
  43117. createVertexBuffer(vertices: FloatArray): DataBuffer;
  43118. createIndexBuffer(indices: IndicesArray): DataBuffer;
  43119. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  43120. getRenderWidth(useScreen?: boolean): number;
  43121. getRenderHeight(useScreen?: boolean): number;
  43122. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  43123. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  43124. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  43125. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  43126. bindSamplers(effect: Effect): void;
  43127. enableEffect(effect: Effect): void;
  43128. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  43129. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  43130. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  43131. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  43132. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  43133. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  43134. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  43135. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  43136. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  43137. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  43138. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  43139. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  43140. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  43141. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  43142. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  43143. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43144. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  43145. setFloat(uniform: WebGLUniformLocation, value: number): void;
  43146. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  43147. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  43148. setBool(uniform: WebGLUniformLocation, bool: number): void;
  43149. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  43150. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  43151. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  43152. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  43153. bindBuffers(vertexBuffers: {
  43154. [key: string]: VertexBuffer;
  43155. }, indexBuffer: DataBuffer, effect: Effect): void;
  43156. wipeCaches(bruteForce?: boolean): void;
  43157. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  43158. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  43159. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  43160. /** @hidden */
  43161. _createTexture(): WebGLTexture;
  43162. /** @hidden */
  43163. _releaseTexture(texture: InternalTexture): void;
  43164. 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;
  43165. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  43166. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  43167. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  43168. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  43169. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  43170. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  43171. areAllEffectsReady(): boolean;
  43172. /**
  43173. * @hidden
  43174. * Get the current error code of the webGL context
  43175. * @returns the error code
  43176. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  43177. */
  43178. getError(): number;
  43179. /** @hidden */
  43180. _getUnpackAlignement(): number;
  43181. /** @hidden */
  43182. _unpackFlipY(value: boolean): void;
  43183. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  43184. /**
  43185. * Updates a dynamic vertex buffer.
  43186. * @param vertexBuffer the vertex buffer to update
  43187. * @param data the data used to update the vertex buffer
  43188. * @param byteOffset the byte offset of the data (optional)
  43189. * @param byteLength the byte length of the data (optional)
  43190. */
  43191. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  43192. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  43193. /** @hidden */
  43194. _bindTexture(channel: number, texture: InternalTexture): void;
  43195. /** @hidden */
  43196. _releaseBuffer(buffer: DataBuffer): boolean;
  43197. releaseEffects(): void;
  43198. displayLoadingUI(): void;
  43199. hideLoadingUI(): void;
  43200. /** @hidden */
  43201. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43202. /** @hidden */
  43203. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43204. /** @hidden */
  43205. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  43206. /** @hidden */
  43207. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  43208. }
  43209. }
  43210. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  43211. import { Nullable, int } from "babylonjs/types";
  43212. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  43213. /** @hidden */
  43214. export class _OcclusionDataStorage {
  43215. /** @hidden */
  43216. occlusionInternalRetryCounter: number;
  43217. /** @hidden */
  43218. isOcclusionQueryInProgress: boolean;
  43219. /** @hidden */
  43220. isOccluded: boolean;
  43221. /** @hidden */
  43222. occlusionRetryCount: number;
  43223. /** @hidden */
  43224. occlusionType: number;
  43225. /** @hidden */
  43226. occlusionQueryAlgorithmType: number;
  43227. }
  43228. module "babylonjs/Engines/engine" {
  43229. interface Engine {
  43230. /**
  43231. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  43232. * @return the new query
  43233. */
  43234. createQuery(): WebGLQuery;
  43235. /**
  43236. * Delete and release a webGL query
  43237. * @param query defines the query to delete
  43238. * @return the current engine
  43239. */
  43240. deleteQuery(query: WebGLQuery): Engine;
  43241. /**
  43242. * Check if a given query has resolved and got its value
  43243. * @param query defines the query to check
  43244. * @returns true if the query got its value
  43245. */
  43246. isQueryResultAvailable(query: WebGLQuery): boolean;
  43247. /**
  43248. * Gets the value of a given query
  43249. * @param query defines the query to check
  43250. * @returns the value of the query
  43251. */
  43252. getQueryResult(query: WebGLQuery): number;
  43253. /**
  43254. * Initiates an occlusion query
  43255. * @param algorithmType defines the algorithm to use
  43256. * @param query defines the query to use
  43257. * @returns the current engine
  43258. * @see http://doc.babylonjs.com/features/occlusionquery
  43259. */
  43260. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  43261. /**
  43262. * Ends an occlusion query
  43263. * @see http://doc.babylonjs.com/features/occlusionquery
  43264. * @param algorithmType defines the algorithm to use
  43265. * @returns the current engine
  43266. */
  43267. endOcclusionQuery(algorithmType: number): Engine;
  43268. /**
  43269. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  43270. * Please note that only one query can be issued at a time
  43271. * @returns a time token used to track the time span
  43272. */
  43273. startTimeQuery(): Nullable<_TimeToken>;
  43274. /**
  43275. * Ends a time query
  43276. * @param token defines the token used to measure the time span
  43277. * @returns the time spent (in ns)
  43278. */
  43279. endTimeQuery(token: _TimeToken): int;
  43280. /** @hidden */
  43281. _currentNonTimestampToken: Nullable<_TimeToken>;
  43282. /** @hidden */
  43283. _createTimeQuery(): WebGLQuery;
  43284. /** @hidden */
  43285. _deleteTimeQuery(query: WebGLQuery): void;
  43286. /** @hidden */
  43287. _getGlAlgorithmType(algorithmType: number): number;
  43288. /** @hidden */
  43289. _getTimeQueryResult(query: WebGLQuery): any;
  43290. /** @hidden */
  43291. _getTimeQueryAvailability(query: WebGLQuery): any;
  43292. }
  43293. }
  43294. module "babylonjs/Meshes/abstractMesh" {
  43295. interface AbstractMesh {
  43296. /**
  43297. * Backing filed
  43298. * @hidden
  43299. */
  43300. __occlusionDataStorage: _OcclusionDataStorage;
  43301. /**
  43302. * Access property
  43303. * @hidden
  43304. */
  43305. _occlusionDataStorage: _OcclusionDataStorage;
  43306. /**
  43307. * 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.
  43308. * The default value is -1 which means don't break the query and wait till the result
  43309. * @see http://doc.babylonjs.com/features/occlusionquery
  43310. */
  43311. occlusionRetryCount: number;
  43312. /**
  43313. * 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:
  43314. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  43315. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  43316. * * 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.
  43317. * @see http://doc.babylonjs.com/features/occlusionquery
  43318. */
  43319. occlusionType: number;
  43320. /**
  43321. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  43322. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  43323. * * 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.
  43324. * @see http://doc.babylonjs.com/features/occlusionquery
  43325. */
  43326. occlusionQueryAlgorithmType: number;
  43327. /**
  43328. * 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
  43329. * @see http://doc.babylonjs.com/features/occlusionquery
  43330. */
  43331. isOccluded: boolean;
  43332. /**
  43333. * Flag to check the progress status of the query
  43334. * @see http://doc.babylonjs.com/features/occlusionquery
  43335. */
  43336. isOcclusionQueryInProgress: boolean;
  43337. }
  43338. }
  43339. }
  43340. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  43341. import { Nullable } from "babylonjs/types";
  43342. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  43343. /** @hidden */
  43344. export var _forceTransformFeedbackToBundle: boolean;
  43345. module "babylonjs/Engines/engine" {
  43346. interface Engine {
  43347. /**
  43348. * Creates a webGL transform feedback object
  43349. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  43350. * @returns the webGL transform feedback object
  43351. */
  43352. createTransformFeedback(): WebGLTransformFeedback;
  43353. /**
  43354. * Delete a webGL transform feedback object
  43355. * @param value defines the webGL transform feedback object to delete
  43356. */
  43357. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  43358. /**
  43359. * Bind a webGL transform feedback object to the webgl context
  43360. * @param value defines the webGL transform feedback object to bind
  43361. */
  43362. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  43363. /**
  43364. * Begins a transform feedback operation
  43365. * @param usePoints defines if points or triangles must be used
  43366. */
  43367. beginTransformFeedback(usePoints: boolean): void;
  43368. /**
  43369. * Ends a transform feedback operation
  43370. */
  43371. endTransformFeedback(): void;
  43372. /**
  43373. * Specify the varyings to use with transform feedback
  43374. * @param program defines the associated webGL program
  43375. * @param value defines the list of strings representing the varying names
  43376. */
  43377. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  43378. /**
  43379. * Bind a webGL buffer for a transform feedback operation
  43380. * @param value defines the webGL buffer to bind
  43381. */
  43382. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  43383. }
  43384. }
  43385. }
  43386. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  43387. import { Scene } from "babylonjs/scene";
  43388. import { Engine } from "babylonjs/Engines/engine";
  43389. import { Texture } from "babylonjs/Materials/Textures/texture";
  43390. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  43391. import "babylonjs/Engines/Extensions/engine.multiRender";
  43392. /**
  43393. * Creation options of the multi render target texture.
  43394. */
  43395. export interface IMultiRenderTargetOptions {
  43396. /**
  43397. * Define if the texture needs to create mip maps after render.
  43398. */
  43399. generateMipMaps?: boolean;
  43400. /**
  43401. * Define the types of all the draw buffers we want to create
  43402. */
  43403. types?: number[];
  43404. /**
  43405. * Define the sampling modes of all the draw buffers we want to create
  43406. */
  43407. samplingModes?: number[];
  43408. /**
  43409. * Define if a depth buffer is required
  43410. */
  43411. generateDepthBuffer?: boolean;
  43412. /**
  43413. * Define if a stencil buffer is required
  43414. */
  43415. generateStencilBuffer?: boolean;
  43416. /**
  43417. * Define if a depth texture is required instead of a depth buffer
  43418. */
  43419. generateDepthTexture?: boolean;
  43420. /**
  43421. * Define the number of desired draw buffers
  43422. */
  43423. textureCount?: number;
  43424. /**
  43425. * Define if aspect ratio should be adapted to the texture or stay the scene one
  43426. */
  43427. doNotChangeAspectRatio?: boolean;
  43428. /**
  43429. * Define the default type of the buffers we are creating
  43430. */
  43431. defaultType?: number;
  43432. }
  43433. /**
  43434. * A multi render target, like a render target provides the ability to render to a texture.
  43435. * Unlike the render target, it can render to several draw buffers in one draw.
  43436. * This is specially interesting in deferred rendering or for any effects requiring more than
  43437. * just one color from a single pass.
  43438. */
  43439. export class MultiRenderTarget extends RenderTargetTexture {
  43440. private _internalTextures;
  43441. private _textures;
  43442. private _multiRenderTargetOptions;
  43443. /**
  43444. * Get if draw buffers are currently supported by the used hardware and browser.
  43445. */
  43446. readonly isSupported: boolean;
  43447. /**
  43448. * Get the list of textures generated by the multi render target.
  43449. */
  43450. readonly textures: Texture[];
  43451. /**
  43452. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  43453. */
  43454. readonly depthTexture: Texture;
  43455. /**
  43456. * Set the wrapping mode on U of all the textures we are rendering to.
  43457. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43458. */
  43459. wrapU: number;
  43460. /**
  43461. * Set the wrapping mode on V of all the textures we are rendering to.
  43462. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  43463. */
  43464. wrapV: number;
  43465. /**
  43466. * Instantiate a new multi render target texture.
  43467. * A multi render target, like a render target provides the ability to render to a texture.
  43468. * Unlike the render target, it can render to several draw buffers in one draw.
  43469. * This is specially interesting in deferred rendering or for any effects requiring more than
  43470. * just one color from a single pass.
  43471. * @param name Define the name of the texture
  43472. * @param size Define the size of the buffers to render to
  43473. * @param count Define the number of target we are rendering into
  43474. * @param scene Define the scene the texture belongs to
  43475. * @param options Define the options used to create the multi render target
  43476. */
  43477. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  43478. /** @hidden */
  43479. _rebuild(): void;
  43480. private _createInternalTextures;
  43481. private _createTextures;
  43482. /**
  43483. * Define the number of samples used if MSAA is enabled.
  43484. */
  43485. samples: number;
  43486. /**
  43487. * Resize all the textures in the multi render target.
  43488. * Be carrefull as it will recreate all the data in the new texture.
  43489. * @param size Define the new size
  43490. */
  43491. resize(size: any): void;
  43492. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  43493. /**
  43494. * Dispose the render targets and their associated resources
  43495. */
  43496. dispose(): void;
  43497. /**
  43498. * Release all the underlying texture used as draw buffers.
  43499. */
  43500. releaseInternalTextures(): void;
  43501. }
  43502. }
  43503. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  43504. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  43505. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  43506. import { Nullable } from "babylonjs/types";
  43507. module "babylonjs/Engines/engine" {
  43508. interface Engine {
  43509. /**
  43510. * Unbind a list of render target textures from the webGL context
  43511. * This is used only when drawBuffer extension or webGL2 are active
  43512. * @param textures defines the render target textures to unbind
  43513. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  43514. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  43515. */
  43516. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  43517. /**
  43518. * Create a multi render target texture
  43519. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  43520. * @param size defines the size of the texture
  43521. * @param options defines the creation options
  43522. * @returns the cube texture as an InternalTexture
  43523. */
  43524. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  43525. /**
  43526. * Update the sample count for a given multiple render target texture
  43527. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  43528. * @param textures defines the textures to update
  43529. * @param samples defines the sample count to set
  43530. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  43531. */
  43532. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  43533. }
  43534. }
  43535. }
  43536. declare module "babylonjs/Engines/Extensions/index" {
  43537. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  43538. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  43539. export * from "babylonjs/Engines/Extensions/engine.multiview";
  43540. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  43541. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  43542. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  43543. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  43544. export * from "babylonjs/Engines/Extensions/engine.webVR";
  43545. }
  43546. declare module "babylonjs/Engines/index" {
  43547. export * from "babylonjs/Engines/constants";
  43548. export * from "babylonjs/Engines/engine";
  43549. export * from "babylonjs/Engines/engineStore";
  43550. export * from "babylonjs/Engines/nullEngine";
  43551. export * from "babylonjs/Engines/Extensions/index";
  43552. export * from "babylonjs/Engines/IPipelineContext";
  43553. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  43554. }
  43555. declare module "babylonjs/Events/clipboardEvents" {
  43556. /**
  43557. * Gather the list of clipboard event types as constants.
  43558. */
  43559. export class ClipboardEventTypes {
  43560. /**
  43561. * The clipboard event is fired when a copy command is active (pressed).
  43562. */
  43563. static readonly COPY: number;
  43564. /**
  43565. * The clipboard event is fired when a cut command is active (pressed).
  43566. */
  43567. static readonly CUT: number;
  43568. /**
  43569. * The clipboard event is fired when a paste command is active (pressed).
  43570. */
  43571. static readonly PASTE: number;
  43572. }
  43573. /**
  43574. * This class is used to store clipboard related info for the onClipboardObservable event.
  43575. */
  43576. export class ClipboardInfo {
  43577. /**
  43578. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43579. */
  43580. type: number;
  43581. /**
  43582. * Defines the related dom event
  43583. */
  43584. event: ClipboardEvent;
  43585. /**
  43586. *Creates an instance of ClipboardInfo.
  43587. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43588. * @param event Defines the related dom event
  43589. */
  43590. constructor(
  43591. /**
  43592. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43593. */
  43594. type: number,
  43595. /**
  43596. * Defines the related dom event
  43597. */
  43598. event: ClipboardEvent);
  43599. /**
  43600. * Get the clipboard event's type from the keycode.
  43601. * @param keyCode Defines the keyCode for the current keyboard event.
  43602. * @return {number}
  43603. */
  43604. static GetTypeFromCharacter(keyCode: number): number;
  43605. }
  43606. }
  43607. declare module "babylonjs/Events/index" {
  43608. export * from "babylonjs/Events/keyboardEvents";
  43609. export * from "babylonjs/Events/pointerEvents";
  43610. export * from "babylonjs/Events/clipboardEvents";
  43611. }
  43612. declare module "babylonjs/Loading/sceneLoader" {
  43613. import { Observable } from "babylonjs/Misc/observable";
  43614. import { Nullable } from "babylonjs/types";
  43615. import { Scene } from "babylonjs/scene";
  43616. import { Engine } from "babylonjs/Engines/engine";
  43617. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43618. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43619. import { AssetContainer } from "babylonjs/assetContainer";
  43620. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43621. import { Skeleton } from "babylonjs/Bones/skeleton";
  43622. /**
  43623. * Class used to represent data loading progression
  43624. */
  43625. export class SceneLoaderProgressEvent {
  43626. /** defines if data length to load can be evaluated */
  43627. readonly lengthComputable: boolean;
  43628. /** defines the loaded data length */
  43629. readonly loaded: number;
  43630. /** defines the data length to load */
  43631. readonly total: number;
  43632. /**
  43633. * Create a new progress event
  43634. * @param lengthComputable defines if data length to load can be evaluated
  43635. * @param loaded defines the loaded data length
  43636. * @param total defines the data length to load
  43637. */
  43638. constructor(
  43639. /** defines if data length to load can be evaluated */
  43640. lengthComputable: boolean,
  43641. /** defines the loaded data length */
  43642. loaded: number,
  43643. /** defines the data length to load */
  43644. total: number);
  43645. /**
  43646. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43647. * @param event defines the source event
  43648. * @returns a new SceneLoaderProgressEvent
  43649. */
  43650. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43651. }
  43652. /**
  43653. * Interface used by SceneLoader plugins to define supported file extensions
  43654. */
  43655. export interface ISceneLoaderPluginExtensions {
  43656. /**
  43657. * Defines the list of supported extensions
  43658. */
  43659. [extension: string]: {
  43660. isBinary: boolean;
  43661. };
  43662. }
  43663. /**
  43664. * Interface used by SceneLoader plugin factory
  43665. */
  43666. export interface ISceneLoaderPluginFactory {
  43667. /**
  43668. * Defines the name of the factory
  43669. */
  43670. name: string;
  43671. /**
  43672. * Function called to create a new plugin
  43673. * @return the new plugin
  43674. */
  43675. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43676. /**
  43677. * Boolean indicating if the plugin can direct load specific data
  43678. */
  43679. canDirectLoad?: (data: string) => boolean;
  43680. }
  43681. /**
  43682. * Interface used to define a SceneLoader plugin
  43683. */
  43684. export interface ISceneLoaderPlugin {
  43685. /**
  43686. * The friendly name of this plugin.
  43687. */
  43688. name: string;
  43689. /**
  43690. * The file extensions supported by this plugin.
  43691. */
  43692. extensions: string | ISceneLoaderPluginExtensions;
  43693. /**
  43694. * Import meshes into a scene.
  43695. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43696. * @param scene The scene to import into
  43697. * @param data The data to import
  43698. * @param rootUrl The root url for scene and resources
  43699. * @param meshes The meshes array to import into
  43700. * @param particleSystems The particle systems array to import into
  43701. * @param skeletons The skeletons array to import into
  43702. * @param onError The callback when import fails
  43703. * @returns True if successful or false otherwise
  43704. */
  43705. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43706. /**
  43707. * Load into a scene.
  43708. * @param scene The scene to load into
  43709. * @param data The data to import
  43710. * @param rootUrl The root url for scene and resources
  43711. * @param onError The callback when import fails
  43712. * @returns true if successful or false otherwise
  43713. */
  43714. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43715. /**
  43716. * The callback that returns true if the data can be directly loaded.
  43717. */
  43718. canDirectLoad?: (data: string) => boolean;
  43719. /**
  43720. * The callback that allows custom handling of the root url based on the response url.
  43721. */
  43722. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43723. /**
  43724. * Load into an asset container.
  43725. * @param scene The scene to load into
  43726. * @param data The data to import
  43727. * @param rootUrl The root url for scene and resources
  43728. * @param onError The callback when import fails
  43729. * @returns The loaded asset container
  43730. */
  43731. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43732. }
  43733. /**
  43734. * Interface used to define an async SceneLoader plugin
  43735. */
  43736. export interface ISceneLoaderPluginAsync {
  43737. /**
  43738. * The friendly name of this plugin.
  43739. */
  43740. name: string;
  43741. /**
  43742. * The file extensions supported by this plugin.
  43743. */
  43744. extensions: string | ISceneLoaderPluginExtensions;
  43745. /**
  43746. * Import meshes into a scene.
  43747. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43748. * @param scene The scene to import into
  43749. * @param data The data to import
  43750. * @param rootUrl The root url for scene and resources
  43751. * @param onProgress The callback when the load progresses
  43752. * @param fileName Defines the name of the file to load
  43753. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43754. */
  43755. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43756. meshes: AbstractMesh[];
  43757. particleSystems: IParticleSystem[];
  43758. skeletons: Skeleton[];
  43759. animationGroups: AnimationGroup[];
  43760. }>;
  43761. /**
  43762. * Load into a scene.
  43763. * @param scene The scene to load into
  43764. * @param data The data to import
  43765. * @param rootUrl The root url for scene and resources
  43766. * @param onProgress The callback when the load progresses
  43767. * @param fileName Defines the name of the file to load
  43768. * @returns Nothing
  43769. */
  43770. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43771. /**
  43772. * The callback that returns true if the data can be directly loaded.
  43773. */
  43774. canDirectLoad?: (data: string) => boolean;
  43775. /**
  43776. * The callback that allows custom handling of the root url based on the response url.
  43777. */
  43778. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43779. /**
  43780. * Load into an asset container.
  43781. * @param scene The scene to load into
  43782. * @param data The data to import
  43783. * @param rootUrl The root url for scene and resources
  43784. * @param onProgress The callback when the load progresses
  43785. * @param fileName Defines the name of the file to load
  43786. * @returns The loaded asset container
  43787. */
  43788. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43789. }
  43790. /**
  43791. * Class used to load scene from various file formats using registered plugins
  43792. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43793. */
  43794. export class SceneLoader {
  43795. /**
  43796. * No logging while loading
  43797. */
  43798. static readonly NO_LOGGING: number;
  43799. /**
  43800. * Minimal logging while loading
  43801. */
  43802. static readonly MINIMAL_LOGGING: number;
  43803. /**
  43804. * Summary logging while loading
  43805. */
  43806. static readonly SUMMARY_LOGGING: number;
  43807. /**
  43808. * Detailled logging while loading
  43809. */
  43810. static readonly DETAILED_LOGGING: number;
  43811. /**
  43812. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43813. */
  43814. static ForceFullSceneLoadingForIncremental: boolean;
  43815. /**
  43816. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43817. */
  43818. static ShowLoadingScreen: boolean;
  43819. /**
  43820. * Defines the current logging level (while loading the scene)
  43821. * @ignorenaming
  43822. */
  43823. static loggingLevel: number;
  43824. /**
  43825. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43826. */
  43827. static CleanBoneMatrixWeights: boolean;
  43828. /**
  43829. * Event raised when a plugin is used to load a scene
  43830. */
  43831. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43832. private static _registeredPlugins;
  43833. private static _getDefaultPlugin;
  43834. private static _getPluginForExtension;
  43835. private static _getPluginForDirectLoad;
  43836. private static _getPluginForFilename;
  43837. private static _getDirectLoad;
  43838. private static _loadData;
  43839. private static _getFileInfo;
  43840. /**
  43841. * Gets a plugin that can load the given extension
  43842. * @param extension defines the extension to load
  43843. * @returns a plugin or null if none works
  43844. */
  43845. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43846. /**
  43847. * Gets a boolean indicating that the given extension can be loaded
  43848. * @param extension defines the extension to load
  43849. * @returns true if the extension is supported
  43850. */
  43851. static IsPluginForExtensionAvailable(extension: string): boolean;
  43852. /**
  43853. * Adds a new plugin to the list of registered plugins
  43854. * @param plugin defines the plugin to add
  43855. */
  43856. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43857. /**
  43858. * Import meshes into a scene
  43859. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43860. * @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)
  43861. * @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)
  43862. * @param scene the instance of BABYLON.Scene to append to
  43863. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43864. * @param onProgress a callback with a progress event for each file being loaded
  43865. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43866. * @param pluginExtension the extension used to determine the plugin
  43867. * @returns The loaded plugin
  43868. */
  43869. 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>;
  43870. /**
  43871. * Import meshes into a scene
  43872. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43873. * @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)
  43874. * @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)
  43875. * @param scene the instance of BABYLON.Scene to append to
  43876. * @param onProgress a callback with a progress event for each file being loaded
  43877. * @param pluginExtension the extension used to determine the plugin
  43878. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43879. */
  43880. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43881. meshes: AbstractMesh[];
  43882. particleSystems: IParticleSystem[];
  43883. skeletons: Skeleton[];
  43884. animationGroups: AnimationGroup[];
  43885. }>;
  43886. /**
  43887. * Load a scene
  43888. * @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)
  43889. * @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)
  43890. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43891. * @param onSuccess a callback with the scene when import succeeds
  43892. * @param onProgress a callback with a progress event for each file being loaded
  43893. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43894. * @param pluginExtension the extension used to determine the plugin
  43895. * @returns The loaded plugin
  43896. */
  43897. 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>;
  43898. /**
  43899. * Load a scene
  43900. * @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)
  43901. * @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)
  43902. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43903. * @param onProgress a callback with a progress event for each file being loaded
  43904. * @param pluginExtension the extension used to determine the plugin
  43905. * @returns The loaded scene
  43906. */
  43907. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43908. /**
  43909. * Append a scene
  43910. * @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)
  43911. * @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)
  43912. * @param scene is the instance of BABYLON.Scene to append to
  43913. * @param onSuccess a callback with the scene when import succeeds
  43914. * @param onProgress a callback with a progress event for each file being loaded
  43915. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43916. * @param pluginExtension the extension used to determine the plugin
  43917. * @returns The loaded plugin
  43918. */
  43919. 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>;
  43920. /**
  43921. * Append a scene
  43922. * @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)
  43923. * @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)
  43924. * @param scene is the instance of BABYLON.Scene to append to
  43925. * @param onProgress a callback with a progress event for each file being loaded
  43926. * @param pluginExtension the extension used to determine the plugin
  43927. * @returns The given scene
  43928. */
  43929. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43930. /**
  43931. * Load a scene into an asset container
  43932. * @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)
  43933. * @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)
  43934. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43935. * @param onSuccess a callback with the scene when import succeeds
  43936. * @param onProgress a callback with a progress event for each file being loaded
  43937. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43938. * @param pluginExtension the extension used to determine the plugin
  43939. * @returns The loaded plugin
  43940. */
  43941. 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>;
  43942. /**
  43943. * Load a scene into an asset container
  43944. * @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)
  43945. * @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)
  43946. * @param scene is the instance of Scene to append to
  43947. * @param onProgress a callback with a progress event for each file being loaded
  43948. * @param pluginExtension the extension used to determine the plugin
  43949. * @returns The loaded asset container
  43950. */
  43951. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43952. }
  43953. }
  43954. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43955. import { Scene } from "babylonjs/scene";
  43956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43957. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43958. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43959. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43960. /**
  43961. * Google Daydream controller
  43962. */
  43963. export class DaydreamController extends WebVRController {
  43964. /**
  43965. * Base Url for the controller model.
  43966. */
  43967. static MODEL_BASE_URL: string;
  43968. /**
  43969. * File name for the controller model.
  43970. */
  43971. static MODEL_FILENAME: string;
  43972. /**
  43973. * Gamepad Id prefix used to identify Daydream Controller.
  43974. */
  43975. static readonly GAMEPAD_ID_PREFIX: string;
  43976. /**
  43977. * Creates a new DaydreamController from a gamepad
  43978. * @param vrGamepad the gamepad that the controller should be created from
  43979. */
  43980. constructor(vrGamepad: any);
  43981. /**
  43982. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43983. * @param scene scene in which to add meshes
  43984. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43985. */
  43986. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43987. /**
  43988. * Called once for each button that changed state since the last frame
  43989. * @param buttonIdx Which button index changed
  43990. * @param state New state of the button
  43991. * @param changes Which properties on the state changed since last frame
  43992. */
  43993. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43994. }
  43995. }
  43996. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43997. import { Scene } from "babylonjs/scene";
  43998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43999. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44000. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44001. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44002. /**
  44003. * Gear VR Controller
  44004. */
  44005. export class GearVRController extends WebVRController {
  44006. /**
  44007. * Base Url for the controller model.
  44008. */
  44009. static MODEL_BASE_URL: string;
  44010. /**
  44011. * File name for the controller model.
  44012. */
  44013. static MODEL_FILENAME: string;
  44014. /**
  44015. * Gamepad Id prefix used to identify this controller.
  44016. */
  44017. static readonly GAMEPAD_ID_PREFIX: string;
  44018. private readonly _buttonIndexToObservableNameMap;
  44019. /**
  44020. * Creates a new GearVRController from a gamepad
  44021. * @param vrGamepad the gamepad that the controller should be created from
  44022. */
  44023. constructor(vrGamepad: any);
  44024. /**
  44025. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44026. * @param scene scene in which to add meshes
  44027. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44028. */
  44029. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44030. /**
  44031. * Called once for each button that changed state since the last frame
  44032. * @param buttonIdx Which button index changed
  44033. * @param state New state of the button
  44034. * @param changes Which properties on the state changed since last frame
  44035. */
  44036. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44037. }
  44038. }
  44039. declare module "babylonjs/Gamepads/Controllers/genericController" {
  44040. import { Scene } from "babylonjs/scene";
  44041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44042. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44043. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44044. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44045. /**
  44046. * Generic Controller
  44047. */
  44048. export class GenericController extends WebVRController {
  44049. /**
  44050. * Base Url for the controller model.
  44051. */
  44052. static readonly MODEL_BASE_URL: string;
  44053. /**
  44054. * File name for the controller model.
  44055. */
  44056. static readonly MODEL_FILENAME: string;
  44057. /**
  44058. * Creates a new GenericController from a gamepad
  44059. * @param vrGamepad the gamepad that the controller should be created from
  44060. */
  44061. constructor(vrGamepad: any);
  44062. /**
  44063. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44064. * @param scene scene in which to add meshes
  44065. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44066. */
  44067. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44068. /**
  44069. * Called once for each button that changed state since the last frame
  44070. * @param buttonIdx Which button index changed
  44071. * @param state New state of the button
  44072. * @param changes Which properties on the state changed since last frame
  44073. */
  44074. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44075. }
  44076. }
  44077. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  44078. import { Observable } from "babylonjs/Misc/observable";
  44079. import { Scene } from "babylonjs/scene";
  44080. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44081. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44082. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44083. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44084. /**
  44085. * Oculus Touch Controller
  44086. */
  44087. export class OculusTouchController extends WebVRController {
  44088. /**
  44089. * Base Url for the controller model.
  44090. */
  44091. static MODEL_BASE_URL: string;
  44092. /**
  44093. * File name for the left controller model.
  44094. */
  44095. static MODEL_LEFT_FILENAME: string;
  44096. /**
  44097. * File name for the right controller model.
  44098. */
  44099. static MODEL_RIGHT_FILENAME: string;
  44100. /**
  44101. * Fired when the secondary trigger on this controller is modified
  44102. */
  44103. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  44104. /**
  44105. * Fired when the thumb rest on this controller is modified
  44106. */
  44107. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  44108. /**
  44109. * Creates a new OculusTouchController from a gamepad
  44110. * @param vrGamepad the gamepad that the controller should be created from
  44111. */
  44112. constructor(vrGamepad: any);
  44113. /**
  44114. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44115. * @param scene scene in which to add meshes
  44116. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44117. */
  44118. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44119. /**
  44120. * Fired when the A button on this controller is modified
  44121. */
  44122. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44123. /**
  44124. * Fired when the B button on this controller is modified
  44125. */
  44126. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44127. /**
  44128. * Fired when the X button on this controller is modified
  44129. */
  44130. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44131. /**
  44132. * Fired when the Y button on this controller is modified
  44133. */
  44134. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44135. /**
  44136. * Called once for each button that changed state since the last frame
  44137. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  44138. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  44139. * 2) secondary trigger (same)
  44140. * 3) A (right) X (left), touch, pressed = value
  44141. * 4) B / Y
  44142. * 5) thumb rest
  44143. * @param buttonIdx Which button index changed
  44144. * @param state New state of the button
  44145. * @param changes Which properties on the state changed since last frame
  44146. */
  44147. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44148. }
  44149. }
  44150. declare module "babylonjs/Gamepads/Controllers/viveController" {
  44151. import { Scene } from "babylonjs/scene";
  44152. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44153. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44154. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44155. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44156. import { Observable } from "babylonjs/Misc/observable";
  44157. /**
  44158. * Vive Controller
  44159. */
  44160. export class ViveController extends WebVRController {
  44161. /**
  44162. * Base Url for the controller model.
  44163. */
  44164. static MODEL_BASE_URL: string;
  44165. /**
  44166. * File name for the controller model.
  44167. */
  44168. static MODEL_FILENAME: string;
  44169. /**
  44170. * Creates a new ViveController from a gamepad
  44171. * @param vrGamepad the gamepad that the controller should be created from
  44172. */
  44173. constructor(vrGamepad: any);
  44174. /**
  44175. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44176. * @param scene scene in which to add meshes
  44177. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44178. */
  44179. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  44180. /**
  44181. * Fired when the left button on this controller is modified
  44182. */
  44183. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44184. /**
  44185. * Fired when the right button on this controller is modified
  44186. */
  44187. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44188. /**
  44189. * Fired when the menu button on this controller is modified
  44190. */
  44191. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44192. /**
  44193. * Called once for each button that changed state since the last frame
  44194. * Vive mapping:
  44195. * 0: touchpad
  44196. * 1: trigger
  44197. * 2: left AND right buttons
  44198. * 3: menu button
  44199. * @param buttonIdx Which button index changed
  44200. * @param state New state of the button
  44201. * @param changes Which properties on the state changed since last frame
  44202. */
  44203. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44204. }
  44205. }
  44206. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  44207. import { Observable } from "babylonjs/Misc/observable";
  44208. import { Scene } from "babylonjs/scene";
  44209. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44210. import { Ray } from "babylonjs/Culling/ray";
  44211. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  44212. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44213. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  44214. /**
  44215. * Defines the WindowsMotionController object that the state of the windows motion controller
  44216. */
  44217. export class WindowsMotionController extends WebVRController {
  44218. /**
  44219. * The base url used to load the left and right controller models
  44220. */
  44221. static MODEL_BASE_URL: string;
  44222. /**
  44223. * The name of the left controller model file
  44224. */
  44225. static MODEL_LEFT_FILENAME: string;
  44226. /**
  44227. * The name of the right controller model file
  44228. */
  44229. static MODEL_RIGHT_FILENAME: string;
  44230. /**
  44231. * The controller name prefix for this controller type
  44232. */
  44233. static readonly GAMEPAD_ID_PREFIX: string;
  44234. /**
  44235. * The controller id pattern for this controller type
  44236. */
  44237. private static readonly GAMEPAD_ID_PATTERN;
  44238. private _loadedMeshInfo;
  44239. private readonly _mapping;
  44240. /**
  44241. * Fired when the trackpad on this controller is clicked
  44242. */
  44243. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  44244. /**
  44245. * Fired when the trackpad on this controller is modified
  44246. */
  44247. onTrackpadValuesChangedObservable: Observable<StickValues>;
  44248. /**
  44249. * The current x and y values of this controller's trackpad
  44250. */
  44251. trackpad: StickValues;
  44252. /**
  44253. * Creates a new WindowsMotionController from a gamepad
  44254. * @param vrGamepad the gamepad that the controller should be created from
  44255. */
  44256. constructor(vrGamepad: any);
  44257. /**
  44258. * Fired when the trigger on this controller is modified
  44259. */
  44260. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44261. /**
  44262. * Fired when the menu button on this controller is modified
  44263. */
  44264. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44265. /**
  44266. * Fired when the grip button on this controller is modified
  44267. */
  44268. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44269. /**
  44270. * Fired when the thumbstick button on this controller is modified
  44271. */
  44272. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44273. /**
  44274. * Fired when the touchpad button on this controller is modified
  44275. */
  44276. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  44277. /**
  44278. * Fired when the touchpad values on this controller are modified
  44279. */
  44280. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  44281. private _updateTrackpad;
  44282. /**
  44283. * Called once per frame by the engine.
  44284. */
  44285. update(): void;
  44286. /**
  44287. * Called once for each button that changed state since the last frame
  44288. * @param buttonIdx Which button index changed
  44289. * @param state New state of the button
  44290. * @param changes Which properties on the state changed since last frame
  44291. */
  44292. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44293. /**
  44294. * Moves the buttons on the controller mesh based on their current state
  44295. * @param buttonName the name of the button to move
  44296. * @param buttonValue the value of the button which determines the buttons new position
  44297. */
  44298. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  44299. /**
  44300. * Moves the axis on the controller mesh based on its current state
  44301. * @param axis the index of the axis
  44302. * @param axisValue the value of the axis which determines the meshes new position
  44303. * @hidden
  44304. */
  44305. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  44306. /**
  44307. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  44308. * @param scene scene in which to add meshes
  44309. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  44310. */
  44311. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  44312. /**
  44313. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  44314. * can be transformed by button presses and axes values, based on this._mapping.
  44315. *
  44316. * @param scene scene in which the meshes exist
  44317. * @param meshes list of meshes that make up the controller model to process
  44318. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  44319. */
  44320. private processModel;
  44321. private createMeshInfo;
  44322. /**
  44323. * Gets the ray of the controller in the direction the controller is pointing
  44324. * @param length the length the resulting ray should be
  44325. * @returns a ray in the direction the controller is pointing
  44326. */
  44327. getForwardRay(length?: number): Ray;
  44328. /**
  44329. * Disposes of the controller
  44330. */
  44331. dispose(): void;
  44332. }
  44333. }
  44334. declare module "babylonjs/Gamepads/Controllers/index" {
  44335. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  44336. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  44337. export * from "babylonjs/Gamepads/Controllers/genericController";
  44338. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  44339. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  44340. export * from "babylonjs/Gamepads/Controllers/viveController";
  44341. export * from "babylonjs/Gamepads/Controllers/webVRController";
  44342. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  44343. }
  44344. declare module "babylonjs/Gamepads/index" {
  44345. export * from "babylonjs/Gamepads/Controllers/index";
  44346. export * from "babylonjs/Gamepads/gamepad";
  44347. export * from "babylonjs/Gamepads/gamepadManager";
  44348. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  44349. export * from "babylonjs/Gamepads/xboxGamepad";
  44350. }
  44351. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44352. import { Scene } from "babylonjs/scene";
  44353. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44354. import { Mesh } from "babylonjs/Meshes/mesh";
  44355. import { Nullable } from "babylonjs/types";
  44356. /**
  44357. * Class containing static functions to help procedurally build meshes
  44358. */
  44359. export class PolyhedronBuilder {
  44360. /**
  44361. * Creates a polyhedron mesh
  44362. * * 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
  44363. * * The parameter `size` (positive float, default 1) sets the polygon size
  44364. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44365. * * 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`
  44366. * * 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
  44367. * * 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)`)
  44368. * * 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
  44369. * * 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
  44370. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44371. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44372. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44373. * @param name defines the name of the mesh
  44374. * @param options defines the options used to create the mesh
  44375. * @param scene defines the hosting scene
  44376. * @returns the polyhedron mesh
  44377. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44378. */
  44379. static CreatePolyhedron(name: string, options: {
  44380. type?: number;
  44381. size?: number;
  44382. sizeX?: number;
  44383. sizeY?: number;
  44384. sizeZ?: number;
  44385. custom?: any;
  44386. faceUV?: Vector4[];
  44387. faceColors?: Color4[];
  44388. flat?: boolean;
  44389. updatable?: boolean;
  44390. sideOrientation?: number;
  44391. frontUVs?: Vector4;
  44392. backUVs?: Vector4;
  44393. }, scene?: Nullable<Scene>): Mesh;
  44394. }
  44395. }
  44396. declare module "babylonjs/Gizmos/scaleGizmo" {
  44397. import { Observable } from "babylonjs/Misc/observable";
  44398. import { Nullable } from "babylonjs/types";
  44399. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44400. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44401. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44402. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44403. /**
  44404. * Gizmo that enables scaling a mesh along 3 axis
  44405. */
  44406. export class ScaleGizmo extends Gizmo {
  44407. /**
  44408. * Internal gizmo used for interactions on the x axis
  44409. */
  44410. xGizmo: AxisScaleGizmo;
  44411. /**
  44412. * Internal gizmo used for interactions on the y axis
  44413. */
  44414. yGizmo: AxisScaleGizmo;
  44415. /**
  44416. * Internal gizmo used for interactions on the z axis
  44417. */
  44418. zGizmo: AxisScaleGizmo;
  44419. /**
  44420. * Internal gizmo used to scale all axis equally
  44421. */
  44422. uniformScaleGizmo: AxisScaleGizmo;
  44423. private _meshAttached;
  44424. private _updateGizmoRotationToMatchAttachedMesh;
  44425. private _snapDistance;
  44426. private _scaleRatio;
  44427. private _uniformScalingMesh;
  44428. private _octahedron;
  44429. /** Fires an event when any of it's sub gizmos are dragged */
  44430. onDragStartObservable: Observable<{}>;
  44431. /** Fires an event when any of it's sub gizmos are released from dragging */
  44432. onDragEndObservable: Observable<{}>;
  44433. attachedMesh: Nullable<AbstractMesh>;
  44434. /**
  44435. * Creates a ScaleGizmo
  44436. * @param gizmoLayer The utility layer the gizmo will be added to
  44437. */
  44438. constructor(gizmoLayer?: UtilityLayerRenderer);
  44439. updateGizmoRotationToMatchAttachedMesh: boolean;
  44440. /**
  44441. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44442. */
  44443. snapDistance: number;
  44444. /**
  44445. * Ratio for the scale of the gizmo (Default: 1)
  44446. */
  44447. scaleRatio: number;
  44448. /**
  44449. * Disposes of the gizmo
  44450. */
  44451. dispose(): void;
  44452. }
  44453. }
  44454. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  44455. import { Observable } from "babylonjs/Misc/observable";
  44456. import { Nullable } from "babylonjs/types";
  44457. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44459. import { Mesh } from "babylonjs/Meshes/mesh";
  44460. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44461. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44462. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44463. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44464. /**
  44465. * Single axis scale gizmo
  44466. */
  44467. export class AxisScaleGizmo extends Gizmo {
  44468. /**
  44469. * Drag behavior responsible for the gizmos dragging interactions
  44470. */
  44471. dragBehavior: PointerDragBehavior;
  44472. private _pointerObserver;
  44473. /**
  44474. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44475. */
  44476. snapDistance: number;
  44477. /**
  44478. * Event that fires each time the gizmo snaps to a new location.
  44479. * * snapDistance is the the change in distance
  44480. */
  44481. onSnapObservable: Observable<{
  44482. snapDistance: number;
  44483. }>;
  44484. /**
  44485. * If the scaling operation should be done on all axis (default: false)
  44486. */
  44487. uniformScaling: boolean;
  44488. private _isEnabled;
  44489. private _parent;
  44490. private _arrow;
  44491. private _coloredMaterial;
  44492. private _hoverMaterial;
  44493. /**
  44494. * Creates an AxisScaleGizmo
  44495. * @param gizmoLayer The utility layer the gizmo will be added to
  44496. * @param dragAxis The axis which the gizmo will be able to scale on
  44497. * @param color The color of the gizmo
  44498. */
  44499. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  44500. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44501. /**
  44502. * If the gizmo is enabled
  44503. */
  44504. isEnabled: boolean;
  44505. /**
  44506. * Disposes of the gizmo
  44507. */
  44508. dispose(): void;
  44509. /**
  44510. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44511. * @param mesh The mesh to replace the default mesh of the gizmo
  44512. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  44513. */
  44514. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  44515. }
  44516. }
  44517. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  44518. import { Observable } from "babylonjs/Misc/observable";
  44519. import { Nullable } from "babylonjs/types";
  44520. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44521. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44522. import { Mesh } from "babylonjs/Meshes/mesh";
  44523. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44524. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44525. import "babylonjs/Meshes/Builders/boxBuilder";
  44526. /**
  44527. * Bounding box gizmo
  44528. */
  44529. export class BoundingBoxGizmo extends Gizmo {
  44530. private _lineBoundingBox;
  44531. private _rotateSpheresParent;
  44532. private _scaleBoxesParent;
  44533. private _boundingDimensions;
  44534. private _renderObserver;
  44535. private _pointerObserver;
  44536. private _scaleDragSpeed;
  44537. private _tmpQuaternion;
  44538. private _tmpVector;
  44539. private _tmpRotationMatrix;
  44540. /**
  44541. * 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)
  44542. */
  44543. ignoreChildren: boolean;
  44544. /**
  44545. * 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)
  44546. */
  44547. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  44548. /**
  44549. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  44550. */
  44551. rotationSphereSize: number;
  44552. /**
  44553. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  44554. */
  44555. scaleBoxSize: number;
  44556. /**
  44557. * 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)
  44558. */
  44559. fixedDragMeshScreenSize: boolean;
  44560. /**
  44561. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  44562. */
  44563. fixedDragMeshScreenSizeDistanceFactor: number;
  44564. /**
  44565. * Fired when a rotation sphere or scale box is dragged
  44566. */
  44567. onDragStartObservable: Observable<{}>;
  44568. /**
  44569. * Fired when a scale box is dragged
  44570. */
  44571. onScaleBoxDragObservable: Observable<{}>;
  44572. /**
  44573. * Fired when a scale box drag is ended
  44574. */
  44575. onScaleBoxDragEndObservable: Observable<{}>;
  44576. /**
  44577. * Fired when a rotation sphere is dragged
  44578. */
  44579. onRotationSphereDragObservable: Observable<{}>;
  44580. /**
  44581. * Fired when a rotation sphere drag is ended
  44582. */
  44583. onRotationSphereDragEndObservable: Observable<{}>;
  44584. /**
  44585. * 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)
  44586. */
  44587. scalePivot: Nullable<Vector3>;
  44588. /**
  44589. * Mesh used as a pivot to rotate the attached mesh
  44590. */
  44591. private _anchorMesh;
  44592. private _existingMeshScale;
  44593. private _dragMesh;
  44594. private pointerDragBehavior;
  44595. private coloredMaterial;
  44596. private hoverColoredMaterial;
  44597. /**
  44598. * Sets the color of the bounding box gizmo
  44599. * @param color the color to set
  44600. */
  44601. setColor(color: Color3): void;
  44602. /**
  44603. * Creates an BoundingBoxGizmo
  44604. * @param gizmoLayer The utility layer the gizmo will be added to
  44605. * @param color The color of the gizmo
  44606. */
  44607. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  44608. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44609. private _selectNode;
  44610. /**
  44611. * Updates the bounding box information for the Gizmo
  44612. */
  44613. updateBoundingBox(): void;
  44614. private _updateRotationSpheres;
  44615. private _updateScaleBoxes;
  44616. /**
  44617. * Enables rotation on the specified axis and disables rotation on the others
  44618. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  44619. */
  44620. setEnabledRotationAxis(axis: string): void;
  44621. /**
  44622. * Enables/disables scaling
  44623. * @param enable if scaling should be enabled
  44624. */
  44625. setEnabledScaling(enable: boolean): void;
  44626. private _updateDummy;
  44627. /**
  44628. * Enables a pointer drag behavior on the bounding box of the gizmo
  44629. */
  44630. enableDragBehavior(): void;
  44631. /**
  44632. * Disposes of the gizmo
  44633. */
  44634. dispose(): void;
  44635. /**
  44636. * 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)
  44637. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  44638. * @returns the bounding box mesh with the passed in mesh as a child
  44639. */
  44640. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  44641. /**
  44642. * CustomMeshes are not supported by this gizmo
  44643. * @param mesh The mesh to replace the default mesh of the gizmo
  44644. */
  44645. setCustomMesh(mesh: Mesh): void;
  44646. }
  44647. }
  44648. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  44649. import { Observable } from "babylonjs/Misc/observable";
  44650. import { Nullable } from "babylonjs/types";
  44651. import { Vector3, Color3 } from "babylonjs/Maths/math";
  44652. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44653. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44654. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44655. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44656. import "babylonjs/Meshes/Builders/linesBuilder";
  44657. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44658. /**
  44659. * Single plane rotation gizmo
  44660. */
  44661. export class PlaneRotationGizmo extends Gizmo {
  44662. /**
  44663. * Drag behavior responsible for the gizmos dragging interactions
  44664. */
  44665. dragBehavior: PointerDragBehavior;
  44666. private _pointerObserver;
  44667. /**
  44668. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  44669. */
  44670. snapDistance: number;
  44671. /**
  44672. * Event that fires each time the gizmo snaps to a new location.
  44673. * * snapDistance is the the change in distance
  44674. */
  44675. onSnapObservable: Observable<{
  44676. snapDistance: number;
  44677. }>;
  44678. private _isEnabled;
  44679. private _parent;
  44680. /**
  44681. * Creates a PlaneRotationGizmo
  44682. * @param gizmoLayer The utility layer the gizmo will be added to
  44683. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  44684. * @param color The color of the gizmo
  44685. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44686. */
  44687. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  44688. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44689. /**
  44690. * If the gizmo is enabled
  44691. */
  44692. isEnabled: boolean;
  44693. /**
  44694. * Disposes of the gizmo
  44695. */
  44696. dispose(): void;
  44697. }
  44698. }
  44699. declare module "babylonjs/Gizmos/rotationGizmo" {
  44700. import { Observable } from "babylonjs/Misc/observable";
  44701. import { Nullable } from "babylonjs/types";
  44702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44703. import { Mesh } from "babylonjs/Meshes/mesh";
  44704. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44705. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44706. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44707. /**
  44708. * Gizmo that enables rotating a mesh along 3 axis
  44709. */
  44710. export class RotationGizmo extends Gizmo {
  44711. /**
  44712. * Internal gizmo used for interactions on the x axis
  44713. */
  44714. xGizmo: PlaneRotationGizmo;
  44715. /**
  44716. * Internal gizmo used for interactions on the y axis
  44717. */
  44718. yGizmo: PlaneRotationGizmo;
  44719. /**
  44720. * Internal gizmo used for interactions on the z axis
  44721. */
  44722. zGizmo: PlaneRotationGizmo;
  44723. /** Fires an event when any of it's sub gizmos are dragged */
  44724. onDragStartObservable: Observable<{}>;
  44725. /** Fires an event when any of it's sub gizmos are released from dragging */
  44726. onDragEndObservable: Observable<{}>;
  44727. private _meshAttached;
  44728. attachedMesh: Nullable<AbstractMesh>;
  44729. /**
  44730. * Creates a RotationGizmo
  44731. * @param gizmoLayer The utility layer the gizmo will be added to
  44732. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44733. */
  44734. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44735. updateGizmoRotationToMatchAttachedMesh: boolean;
  44736. /**
  44737. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44738. */
  44739. snapDistance: number;
  44740. /**
  44741. * Ratio for the scale of the gizmo (Default: 1)
  44742. */
  44743. scaleRatio: number;
  44744. /**
  44745. * Disposes of the gizmo
  44746. */
  44747. dispose(): void;
  44748. /**
  44749. * CustomMeshes are not supported by this gizmo
  44750. * @param mesh The mesh to replace the default mesh of the gizmo
  44751. */
  44752. setCustomMesh(mesh: Mesh): void;
  44753. }
  44754. }
  44755. declare module "babylonjs/Gizmos/gizmoManager" {
  44756. import { Observable } from "babylonjs/Misc/observable";
  44757. import { Nullable } from "babylonjs/types";
  44758. import { Scene, IDisposable } from "babylonjs/scene";
  44759. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44760. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44761. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44762. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44763. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44764. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44765. /**
  44766. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44767. */
  44768. export class GizmoManager implements IDisposable {
  44769. private scene;
  44770. /**
  44771. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44772. */
  44773. gizmos: {
  44774. positionGizmo: Nullable<PositionGizmo>;
  44775. rotationGizmo: Nullable<RotationGizmo>;
  44776. scaleGizmo: Nullable<ScaleGizmo>;
  44777. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44778. };
  44779. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44780. clearGizmoOnEmptyPointerEvent: boolean;
  44781. /** Fires an event when the manager is attached to a mesh */
  44782. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44783. private _gizmosEnabled;
  44784. private _pointerObserver;
  44785. private _attachedMesh;
  44786. private _boundingBoxColor;
  44787. private _defaultUtilityLayer;
  44788. private _defaultKeepDepthUtilityLayer;
  44789. /**
  44790. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44791. */
  44792. boundingBoxDragBehavior: SixDofDragBehavior;
  44793. /**
  44794. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44795. */
  44796. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44797. /**
  44798. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44799. */
  44800. usePointerToAttachGizmos: boolean;
  44801. /**
  44802. * Instatiates a gizmo manager
  44803. * @param scene the scene to overlay the gizmos on top of
  44804. */
  44805. constructor(scene: Scene);
  44806. /**
  44807. * Attaches a set of gizmos to the specified mesh
  44808. * @param mesh The mesh the gizmo's should be attached to
  44809. */
  44810. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44811. /**
  44812. * If the position gizmo is enabled
  44813. */
  44814. positionGizmoEnabled: boolean;
  44815. /**
  44816. * If the rotation gizmo is enabled
  44817. */
  44818. rotationGizmoEnabled: boolean;
  44819. /**
  44820. * If the scale gizmo is enabled
  44821. */
  44822. scaleGizmoEnabled: boolean;
  44823. /**
  44824. * If the boundingBox gizmo is enabled
  44825. */
  44826. boundingBoxGizmoEnabled: boolean;
  44827. /**
  44828. * Disposes of the gizmo manager
  44829. */
  44830. dispose(): void;
  44831. }
  44832. }
  44833. declare module "babylonjs/Lights/directionalLight" {
  44834. import { Camera } from "babylonjs/Cameras/camera";
  44835. import { Scene } from "babylonjs/scene";
  44836. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44837. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44838. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44839. import { Effect } from "babylonjs/Materials/effect";
  44840. /**
  44841. * A directional light is defined by a direction (what a surprise!).
  44842. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44843. * 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.
  44844. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44845. */
  44846. export class DirectionalLight extends ShadowLight {
  44847. private _shadowFrustumSize;
  44848. /**
  44849. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44850. */
  44851. /**
  44852. * Specifies a fix frustum size for the shadow generation.
  44853. */
  44854. shadowFrustumSize: number;
  44855. private _shadowOrthoScale;
  44856. /**
  44857. * Gets the shadow projection scale against the optimal computed one.
  44858. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44859. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44860. */
  44861. /**
  44862. * Sets the shadow projection scale against the optimal computed one.
  44863. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44864. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44865. */
  44866. shadowOrthoScale: number;
  44867. /**
  44868. * Automatically compute the projection matrix to best fit (including all the casters)
  44869. * on each frame.
  44870. */
  44871. autoUpdateExtends: boolean;
  44872. private _orthoLeft;
  44873. private _orthoRight;
  44874. private _orthoTop;
  44875. private _orthoBottom;
  44876. /**
  44877. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44878. * The directional light is emitted from everywhere in the given direction.
  44879. * It can cast shadows.
  44880. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44881. * @param name The friendly name of the light
  44882. * @param direction The direction of the light
  44883. * @param scene The scene the light belongs to
  44884. */
  44885. constructor(name: string, direction: Vector3, scene: Scene);
  44886. /**
  44887. * Returns the string "DirectionalLight".
  44888. * @return The class name
  44889. */
  44890. getClassName(): string;
  44891. /**
  44892. * Returns the integer 1.
  44893. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44894. */
  44895. getTypeID(): number;
  44896. /**
  44897. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44898. * Returns the DirectionalLight Shadow projection matrix.
  44899. */
  44900. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44901. /**
  44902. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44903. * Returns the DirectionalLight Shadow projection matrix.
  44904. */
  44905. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44906. /**
  44907. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44908. * Returns the DirectionalLight Shadow projection matrix.
  44909. */
  44910. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44911. protected _buildUniformLayout(): void;
  44912. /**
  44913. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44914. * @param effect The effect to update
  44915. * @param lightIndex The index of the light in the effect to update
  44916. * @returns The directional light
  44917. */
  44918. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44919. /**
  44920. * Gets the minZ used for shadow according to both the scene and the light.
  44921. *
  44922. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44923. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44924. * @param activeCamera The camera we are returning the min for
  44925. * @returns the depth min z
  44926. */
  44927. getDepthMinZ(activeCamera: Camera): number;
  44928. /**
  44929. * Gets the maxZ used for shadow according to both the scene and the light.
  44930. *
  44931. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44932. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44933. * @param activeCamera The camera we are returning the max for
  44934. * @returns the depth max z
  44935. */
  44936. getDepthMaxZ(activeCamera: Camera): number;
  44937. /**
  44938. * Prepares the list of defines specific to the light type.
  44939. * @param defines the list of defines
  44940. * @param lightIndex defines the index of the light for the effect
  44941. */
  44942. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44943. }
  44944. }
  44945. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44946. import { Mesh } from "babylonjs/Meshes/mesh";
  44947. /**
  44948. * Class containing static functions to help procedurally build meshes
  44949. */
  44950. export class HemisphereBuilder {
  44951. /**
  44952. * Creates a hemisphere mesh
  44953. * @param name defines the name of the mesh
  44954. * @param options defines the options used to create the mesh
  44955. * @param scene defines the hosting scene
  44956. * @returns the hemisphere mesh
  44957. */
  44958. static CreateHemisphere(name: string, options: {
  44959. segments?: number;
  44960. diameter?: number;
  44961. sideOrientation?: number;
  44962. }, scene: any): Mesh;
  44963. }
  44964. }
  44965. declare module "babylonjs/Lights/spotLight" {
  44966. import { Nullable } from "babylonjs/types";
  44967. import { Scene } from "babylonjs/scene";
  44968. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44969. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44970. import { Effect } from "babylonjs/Materials/effect";
  44971. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44972. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44973. /**
  44974. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44975. * These values define a cone of light starting from the position, emitting toward the direction.
  44976. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44977. * and the exponent defines the speed of the decay of the light with distance (reach).
  44978. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44979. */
  44980. export class SpotLight extends ShadowLight {
  44981. private _angle;
  44982. private _innerAngle;
  44983. private _cosHalfAngle;
  44984. private _lightAngleScale;
  44985. private _lightAngleOffset;
  44986. /**
  44987. * Gets the cone angle of the spot light in Radians.
  44988. */
  44989. /**
  44990. * Sets the cone angle of the spot light in Radians.
  44991. */
  44992. angle: number;
  44993. /**
  44994. * Only used in gltf falloff mode, this defines the angle where
  44995. * the directional falloff will start before cutting at angle which could be seen
  44996. * as outer angle.
  44997. */
  44998. /**
  44999. * Only used in gltf falloff mode, this defines the angle where
  45000. * the directional falloff will start before cutting at angle which could be seen
  45001. * as outer angle.
  45002. */
  45003. innerAngle: number;
  45004. private _shadowAngleScale;
  45005. /**
  45006. * Allows scaling the angle of the light for shadow generation only.
  45007. */
  45008. /**
  45009. * Allows scaling the angle of the light for shadow generation only.
  45010. */
  45011. shadowAngleScale: number;
  45012. /**
  45013. * The light decay speed with the distance from the emission spot.
  45014. */
  45015. exponent: number;
  45016. private _projectionTextureMatrix;
  45017. /**
  45018. * Allows reading the projecton texture
  45019. */
  45020. readonly projectionTextureMatrix: Matrix;
  45021. protected _projectionTextureLightNear: number;
  45022. /**
  45023. * Gets the near clip of the Spotlight for texture projection.
  45024. */
  45025. /**
  45026. * Sets the near clip of the Spotlight for texture projection.
  45027. */
  45028. projectionTextureLightNear: number;
  45029. protected _projectionTextureLightFar: number;
  45030. /**
  45031. * Gets the far clip of the Spotlight for texture projection.
  45032. */
  45033. /**
  45034. * Sets the far clip of the Spotlight for texture projection.
  45035. */
  45036. projectionTextureLightFar: number;
  45037. protected _projectionTextureUpDirection: Vector3;
  45038. /**
  45039. * Gets the Up vector of the Spotlight for texture projection.
  45040. */
  45041. /**
  45042. * Sets the Up vector of the Spotlight for texture projection.
  45043. */
  45044. projectionTextureUpDirection: Vector3;
  45045. private _projectionTexture;
  45046. /**
  45047. * Gets the projection texture of the light.
  45048. */
  45049. /**
  45050. * Sets the projection texture of the light.
  45051. */
  45052. projectionTexture: Nullable<BaseTexture>;
  45053. private _projectionTextureViewLightDirty;
  45054. private _projectionTextureProjectionLightDirty;
  45055. private _projectionTextureDirty;
  45056. private _projectionTextureViewTargetVector;
  45057. private _projectionTextureViewLightMatrix;
  45058. private _projectionTextureProjectionLightMatrix;
  45059. private _projectionTextureScalingMatrix;
  45060. /**
  45061. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  45062. * It can cast shadows.
  45063. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45064. * @param name The light friendly name
  45065. * @param position The position of the spot light in the scene
  45066. * @param direction The direction of the light in the scene
  45067. * @param angle The cone angle of the light in Radians
  45068. * @param exponent The light decay speed with the distance from the emission spot
  45069. * @param scene The scene the lights belongs to
  45070. */
  45071. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  45072. /**
  45073. * Returns the string "SpotLight".
  45074. * @returns the class name
  45075. */
  45076. getClassName(): string;
  45077. /**
  45078. * Returns the integer 2.
  45079. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45080. */
  45081. getTypeID(): number;
  45082. /**
  45083. * Overrides the direction setter to recompute the projection texture view light Matrix.
  45084. */
  45085. protected _setDirection(value: Vector3): void;
  45086. /**
  45087. * Overrides the position setter to recompute the projection texture view light Matrix.
  45088. */
  45089. protected _setPosition(value: Vector3): void;
  45090. /**
  45091. * 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.
  45092. * Returns the SpotLight.
  45093. */
  45094. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  45095. protected _computeProjectionTextureViewLightMatrix(): void;
  45096. protected _computeProjectionTextureProjectionLightMatrix(): void;
  45097. /**
  45098. * Main function for light texture projection matrix computing.
  45099. */
  45100. protected _computeProjectionTextureMatrix(): void;
  45101. protected _buildUniformLayout(): void;
  45102. private _computeAngleValues;
  45103. /**
  45104. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  45105. * @param effect The effect to update
  45106. * @param lightIndex The index of the light in the effect to update
  45107. * @returns The spot light
  45108. */
  45109. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  45110. /**
  45111. * Disposes the light and the associated resources.
  45112. */
  45113. dispose(): void;
  45114. /**
  45115. * Prepares the list of defines specific to the light type.
  45116. * @param defines the list of defines
  45117. * @param lightIndex defines the index of the light for the effect
  45118. */
  45119. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  45120. }
  45121. }
  45122. declare module "babylonjs/Gizmos/lightGizmo" {
  45123. import { Nullable } from "babylonjs/types";
  45124. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  45125. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  45126. import { Light } from "babylonjs/Lights/light";
  45127. /**
  45128. * Gizmo that enables viewing a light
  45129. */
  45130. export class LightGizmo extends Gizmo {
  45131. private _lightMesh;
  45132. private _material;
  45133. private cachedPosition;
  45134. private cachedForward;
  45135. /**
  45136. * Creates a LightGizmo
  45137. * @param gizmoLayer The utility layer the gizmo will be added to
  45138. */
  45139. constructor(gizmoLayer?: UtilityLayerRenderer);
  45140. private _light;
  45141. /**
  45142. * The light that the gizmo is attached to
  45143. */
  45144. light: Nullable<Light>;
  45145. /**
  45146. * @hidden
  45147. * Updates the gizmo to match the attached mesh's position/rotation
  45148. */
  45149. protected _update(): void;
  45150. private static _Scale;
  45151. /**
  45152. * Creates the lines for a light mesh
  45153. */
  45154. private static _createLightLines;
  45155. /**
  45156. * Disposes of the light gizmo
  45157. */
  45158. dispose(): void;
  45159. private static _CreateHemisphericLightMesh;
  45160. private static _CreatePointLightMesh;
  45161. private static _CreateSpotLightMesh;
  45162. private static _CreateDirectionalLightMesh;
  45163. }
  45164. }
  45165. declare module "babylonjs/Gizmos/index" {
  45166. export * from "babylonjs/Gizmos/axisDragGizmo";
  45167. export * from "babylonjs/Gizmos/axisScaleGizmo";
  45168. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  45169. export * from "babylonjs/Gizmos/gizmo";
  45170. export * from "babylonjs/Gizmos/gizmoManager";
  45171. export * from "babylonjs/Gizmos/planeRotationGizmo";
  45172. export * from "babylonjs/Gizmos/positionGizmo";
  45173. export * from "babylonjs/Gizmos/rotationGizmo";
  45174. export * from "babylonjs/Gizmos/scaleGizmo";
  45175. export * from "babylonjs/Gizmos/lightGizmo";
  45176. }
  45177. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  45178. /** @hidden */
  45179. export var backgroundFragmentDeclaration: {
  45180. name: string;
  45181. shader: string;
  45182. };
  45183. }
  45184. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  45185. /** @hidden */
  45186. export var backgroundUboDeclaration: {
  45187. name: string;
  45188. shader: string;
  45189. };
  45190. }
  45191. declare module "babylonjs/Shaders/background.fragment" {
  45192. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  45193. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45194. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  45195. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  45196. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45197. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45198. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45199. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  45200. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  45201. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  45202. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  45203. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  45204. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  45205. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  45206. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  45207. /** @hidden */
  45208. export var backgroundPixelShader: {
  45209. name: string;
  45210. shader: string;
  45211. };
  45212. }
  45213. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  45214. /** @hidden */
  45215. export var backgroundVertexDeclaration: {
  45216. name: string;
  45217. shader: string;
  45218. };
  45219. }
  45220. declare module "babylonjs/Shaders/background.vertex" {
  45221. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  45222. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  45223. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45224. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  45225. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  45226. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  45227. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  45228. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  45229. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  45230. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  45231. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  45232. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  45233. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  45234. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  45235. /** @hidden */
  45236. export var backgroundVertexShader: {
  45237. name: string;
  45238. shader: string;
  45239. };
  45240. }
  45241. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  45242. import { Nullable, int, float } from "babylonjs/types";
  45243. import { Scene } from "babylonjs/scene";
  45244. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  45245. import { SubMesh } from "babylonjs/Meshes/subMesh";
  45246. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45247. import { Mesh } from "babylonjs/Meshes/mesh";
  45248. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  45249. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  45250. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  45251. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45252. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  45253. import "babylonjs/Shaders/background.fragment";
  45254. import "babylonjs/Shaders/background.vertex";
  45255. /**
  45256. * Background material used to create an efficient environement around your scene.
  45257. */
  45258. export class BackgroundMaterial extends PushMaterial {
  45259. /**
  45260. * Standard reflectance value at parallel view angle.
  45261. */
  45262. static StandardReflectance0: number;
  45263. /**
  45264. * Standard reflectance value at grazing angle.
  45265. */
  45266. static StandardReflectance90: number;
  45267. protected _primaryColor: Color3;
  45268. /**
  45269. * Key light Color (multiply against the environement texture)
  45270. */
  45271. primaryColor: Color3;
  45272. protected __perceptualColor: Nullable<Color3>;
  45273. /**
  45274. * Experimental Internal Use Only.
  45275. *
  45276. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  45277. * This acts as a helper to set the primary color to a more "human friendly" value.
  45278. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  45279. * output color as close as possible from the chosen value.
  45280. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  45281. * part of lighting setup.)
  45282. */
  45283. _perceptualColor: Nullable<Color3>;
  45284. protected _primaryColorShadowLevel: float;
  45285. /**
  45286. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  45287. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  45288. */
  45289. primaryColorShadowLevel: float;
  45290. protected _primaryColorHighlightLevel: float;
  45291. /**
  45292. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  45293. * The primary color is used at the level chosen to define what the white area would look.
  45294. */
  45295. primaryColorHighlightLevel: float;
  45296. protected _reflectionTexture: Nullable<BaseTexture>;
  45297. /**
  45298. * Reflection Texture used in the material.
  45299. * Should be author in a specific way for the best result (refer to the documentation).
  45300. */
  45301. reflectionTexture: Nullable<BaseTexture>;
  45302. protected _reflectionBlur: float;
  45303. /**
  45304. * Reflection Texture level of blur.
  45305. *
  45306. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  45307. * texture twice.
  45308. */
  45309. reflectionBlur: float;
  45310. protected _diffuseTexture: Nullable<BaseTexture>;
  45311. /**
  45312. * Diffuse Texture used in the material.
  45313. * Should be author in a specific way for the best result (refer to the documentation).
  45314. */
  45315. diffuseTexture: Nullable<BaseTexture>;
  45316. protected _shadowLights: Nullable<IShadowLight[]>;
  45317. /**
  45318. * Specify the list of lights casting shadow on the material.
  45319. * All scene shadow lights will be included if null.
  45320. */
  45321. shadowLights: Nullable<IShadowLight[]>;
  45322. protected _shadowLevel: float;
  45323. /**
  45324. * Helps adjusting the shadow to a softer level if required.
  45325. * 0 means black shadows and 1 means no shadows.
  45326. */
  45327. shadowLevel: float;
  45328. protected _sceneCenter: Vector3;
  45329. /**
  45330. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  45331. * It is usually zero but might be interesting to modify according to your setup.
  45332. */
  45333. sceneCenter: Vector3;
  45334. protected _opacityFresnel: boolean;
  45335. /**
  45336. * This helps specifying that the material is falling off to the sky box at grazing angle.
  45337. * This helps ensuring a nice transition when the camera goes under the ground.
  45338. */
  45339. opacityFresnel: boolean;
  45340. protected _reflectionFresnel: boolean;
  45341. /**
  45342. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  45343. * This helps adding a mirror texture on the ground.
  45344. */
  45345. reflectionFresnel: boolean;
  45346. protected _reflectionFalloffDistance: number;
  45347. /**
  45348. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  45349. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  45350. */
  45351. reflectionFalloffDistance: number;
  45352. protected _reflectionAmount: number;
  45353. /**
  45354. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  45355. */
  45356. reflectionAmount: number;
  45357. protected _reflectionReflectance0: number;
  45358. /**
  45359. * This specifies the weight of the reflection at grazing angle.
  45360. */
  45361. reflectionReflectance0: number;
  45362. protected _reflectionReflectance90: number;
  45363. /**
  45364. * This specifies the weight of the reflection at a perpendicular point of view.
  45365. */
  45366. reflectionReflectance90: number;
  45367. /**
  45368. * Sets the reflection reflectance fresnel values according to the default standard
  45369. * empirically know to work well :-)
  45370. */
  45371. reflectionStandardFresnelWeight: number;
  45372. protected _useRGBColor: boolean;
  45373. /**
  45374. * Helps to directly use the maps channels instead of their level.
  45375. */
  45376. useRGBColor: boolean;
  45377. protected _enableNoise: boolean;
  45378. /**
  45379. * This helps reducing the banding effect that could occur on the background.
  45380. */
  45381. enableNoise: boolean;
  45382. /**
  45383. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45384. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  45385. * Recommended to be keep at 1.0 except for special cases.
  45386. */
  45387. fovMultiplier: number;
  45388. private _fovMultiplier;
  45389. /**
  45390. * Enable the FOV adjustment feature controlled by fovMultiplier.
  45391. */
  45392. useEquirectangularFOV: boolean;
  45393. private _maxSimultaneousLights;
  45394. /**
  45395. * Number of Simultaneous lights allowed on the material.
  45396. */
  45397. maxSimultaneousLights: int;
  45398. /**
  45399. * Default configuration related to image processing available in the Background Material.
  45400. */
  45401. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  45402. /**
  45403. * Keep track of the image processing observer to allow dispose and replace.
  45404. */
  45405. private _imageProcessingObserver;
  45406. /**
  45407. * Attaches a new image processing configuration to the PBR Material.
  45408. * @param configuration (if null the scene configuration will be use)
  45409. */
  45410. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  45411. /**
  45412. * Gets the image processing configuration used either in this material.
  45413. */
  45414. /**
  45415. * Sets the Default image processing configuration used either in the this material.
  45416. *
  45417. * If sets to null, the scene one is in use.
  45418. */
  45419. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  45420. /**
  45421. * Gets wether the color curves effect is enabled.
  45422. */
  45423. /**
  45424. * Sets wether the color curves effect is enabled.
  45425. */
  45426. cameraColorCurvesEnabled: boolean;
  45427. /**
  45428. * Gets wether the color grading effect is enabled.
  45429. */
  45430. /**
  45431. * Gets wether the color grading effect is enabled.
  45432. */
  45433. cameraColorGradingEnabled: boolean;
  45434. /**
  45435. * Gets wether tonemapping is enabled or not.
  45436. */
  45437. /**
  45438. * Sets wether tonemapping is enabled or not
  45439. */
  45440. cameraToneMappingEnabled: boolean;
  45441. /**
  45442. * The camera exposure used on this material.
  45443. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45444. * This corresponds to a photographic exposure.
  45445. */
  45446. /**
  45447. * The camera exposure used on this material.
  45448. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  45449. * This corresponds to a photographic exposure.
  45450. */
  45451. cameraExposure: float;
  45452. /**
  45453. * Gets The camera contrast used on this material.
  45454. */
  45455. /**
  45456. * Sets The camera contrast used on this material.
  45457. */
  45458. cameraContrast: float;
  45459. /**
  45460. * Gets the Color Grading 2D Lookup Texture.
  45461. */
  45462. /**
  45463. * Sets the Color Grading 2D Lookup Texture.
  45464. */
  45465. cameraColorGradingTexture: Nullable<BaseTexture>;
  45466. /**
  45467. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45468. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45469. * 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;
  45470. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45471. */
  45472. /**
  45473. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  45474. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  45475. * 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;
  45476. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  45477. */
  45478. cameraColorCurves: Nullable<ColorCurves>;
  45479. /**
  45480. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  45481. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  45482. */
  45483. switchToBGR: boolean;
  45484. private _renderTargets;
  45485. private _reflectionControls;
  45486. private _white;
  45487. private _primaryShadowColor;
  45488. private _primaryHighlightColor;
  45489. /**
  45490. * Instantiates a Background Material in the given scene
  45491. * @param name The friendly name of the material
  45492. * @param scene The scene to add the material to
  45493. */
  45494. constructor(name: string, scene: Scene);
  45495. /**
  45496. * Gets a boolean indicating that current material needs to register RTT
  45497. */
  45498. readonly hasRenderTargetTextures: boolean;
  45499. /**
  45500. * The entire material has been created in order to prevent overdraw.
  45501. * @returns false
  45502. */
  45503. needAlphaTesting(): boolean;
  45504. /**
  45505. * The entire material has been created in order to prevent overdraw.
  45506. * @returns true if blending is enable
  45507. */
  45508. needAlphaBlending(): boolean;
  45509. /**
  45510. * Checks wether the material is ready to be rendered for a given mesh.
  45511. * @param mesh The mesh to render
  45512. * @param subMesh The submesh to check against
  45513. * @param useInstances Specify wether or not the material is used with instances
  45514. * @returns true if all the dependencies are ready (Textures, Effects...)
  45515. */
  45516. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  45517. /**
  45518. * Compute the primary color according to the chosen perceptual color.
  45519. */
  45520. private _computePrimaryColorFromPerceptualColor;
  45521. /**
  45522. * Compute the highlights and shadow colors according to their chosen levels.
  45523. */
  45524. private _computePrimaryColors;
  45525. /**
  45526. * Build the uniform buffer used in the material.
  45527. */
  45528. buildUniformLayout(): void;
  45529. /**
  45530. * Unbind the material.
  45531. */
  45532. unbind(): void;
  45533. /**
  45534. * Bind only the world matrix to the material.
  45535. * @param world The world matrix to bind.
  45536. */
  45537. bindOnlyWorldMatrix(world: Matrix): void;
  45538. /**
  45539. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  45540. * @param world The world matrix to bind.
  45541. * @param subMesh The submesh to bind for.
  45542. */
  45543. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  45544. /**
  45545. * Dispose the material.
  45546. * @param forceDisposeEffect Force disposal of the associated effect.
  45547. * @param forceDisposeTextures Force disposal of the associated textures.
  45548. */
  45549. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45550. /**
  45551. * Clones the material.
  45552. * @param name The cloned name.
  45553. * @returns The cloned material.
  45554. */
  45555. clone(name: string): BackgroundMaterial;
  45556. /**
  45557. * Serializes the current material to its JSON representation.
  45558. * @returns The JSON representation.
  45559. */
  45560. serialize(): any;
  45561. /**
  45562. * Gets the class name of the material
  45563. * @returns "BackgroundMaterial"
  45564. */
  45565. getClassName(): string;
  45566. /**
  45567. * Parse a JSON input to create back a background material.
  45568. * @param source The JSON data to parse
  45569. * @param scene The scene to create the parsed material in
  45570. * @param rootUrl The root url of the assets the material depends upon
  45571. * @returns the instantiated BackgroundMaterial.
  45572. */
  45573. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45574. }
  45575. }
  45576. declare module "babylonjs/Helpers/environmentHelper" {
  45577. import { Observable } from "babylonjs/Misc/observable";
  45578. import { Nullable } from "babylonjs/types";
  45579. import { Scene } from "babylonjs/scene";
  45580. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45581. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45582. import { Mesh } from "babylonjs/Meshes/mesh";
  45583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45584. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45585. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45586. import "babylonjs/Meshes/Builders/planeBuilder";
  45587. import "babylonjs/Meshes/Builders/boxBuilder";
  45588. /**
  45589. * Represents the different options available during the creation of
  45590. * a Environment helper.
  45591. *
  45592. * This can control the default ground, skybox and image processing setup of your scene.
  45593. */
  45594. export interface IEnvironmentHelperOptions {
  45595. /**
  45596. * Specifies wether or not to create a ground.
  45597. * True by default.
  45598. */
  45599. createGround: boolean;
  45600. /**
  45601. * Specifies the ground size.
  45602. * 15 by default.
  45603. */
  45604. groundSize: number;
  45605. /**
  45606. * The texture used on the ground for the main color.
  45607. * Comes from the BabylonJS CDN by default.
  45608. *
  45609. * Remarks: Can be either a texture or a url.
  45610. */
  45611. groundTexture: string | BaseTexture;
  45612. /**
  45613. * The color mixed in the ground texture by default.
  45614. * BabylonJS clearColor by default.
  45615. */
  45616. groundColor: Color3;
  45617. /**
  45618. * Specifies the ground opacity.
  45619. * 1 by default.
  45620. */
  45621. groundOpacity: number;
  45622. /**
  45623. * Enables the ground to receive shadows.
  45624. * True by default.
  45625. */
  45626. enableGroundShadow: boolean;
  45627. /**
  45628. * Helps preventing the shadow to be fully black on the ground.
  45629. * 0.5 by default.
  45630. */
  45631. groundShadowLevel: number;
  45632. /**
  45633. * Creates a mirror texture attach to the ground.
  45634. * false by default.
  45635. */
  45636. enableGroundMirror: boolean;
  45637. /**
  45638. * Specifies the ground mirror size ratio.
  45639. * 0.3 by default as the default kernel is 64.
  45640. */
  45641. groundMirrorSizeRatio: number;
  45642. /**
  45643. * Specifies the ground mirror blur kernel size.
  45644. * 64 by default.
  45645. */
  45646. groundMirrorBlurKernel: number;
  45647. /**
  45648. * Specifies the ground mirror visibility amount.
  45649. * 1 by default
  45650. */
  45651. groundMirrorAmount: number;
  45652. /**
  45653. * Specifies the ground mirror reflectance weight.
  45654. * This uses the standard weight of the background material to setup the fresnel effect
  45655. * of the mirror.
  45656. * 1 by default.
  45657. */
  45658. groundMirrorFresnelWeight: number;
  45659. /**
  45660. * Specifies the ground mirror Falloff distance.
  45661. * This can helps reducing the size of the reflection.
  45662. * 0 by Default.
  45663. */
  45664. groundMirrorFallOffDistance: number;
  45665. /**
  45666. * Specifies the ground mirror texture type.
  45667. * Unsigned Int by Default.
  45668. */
  45669. groundMirrorTextureType: number;
  45670. /**
  45671. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45672. * the shown objects.
  45673. */
  45674. groundYBias: number;
  45675. /**
  45676. * Specifies wether or not to create a skybox.
  45677. * True by default.
  45678. */
  45679. createSkybox: boolean;
  45680. /**
  45681. * Specifies the skybox size.
  45682. * 20 by default.
  45683. */
  45684. skyboxSize: number;
  45685. /**
  45686. * The texture used on the skybox for the main color.
  45687. * Comes from the BabylonJS CDN by default.
  45688. *
  45689. * Remarks: Can be either a texture or a url.
  45690. */
  45691. skyboxTexture: string | BaseTexture;
  45692. /**
  45693. * The color mixed in the skybox texture by default.
  45694. * BabylonJS clearColor by default.
  45695. */
  45696. skyboxColor: Color3;
  45697. /**
  45698. * The background rotation around the Y axis of the scene.
  45699. * This helps aligning the key lights of your scene with the background.
  45700. * 0 by default.
  45701. */
  45702. backgroundYRotation: number;
  45703. /**
  45704. * Compute automatically the size of the elements to best fit with the scene.
  45705. */
  45706. sizeAuto: boolean;
  45707. /**
  45708. * Default position of the rootMesh if autoSize is not true.
  45709. */
  45710. rootPosition: Vector3;
  45711. /**
  45712. * Sets up the image processing in the scene.
  45713. * true by default.
  45714. */
  45715. setupImageProcessing: boolean;
  45716. /**
  45717. * The texture used as your environment texture in the scene.
  45718. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45719. *
  45720. * Remarks: Can be either a texture or a url.
  45721. */
  45722. environmentTexture: string | BaseTexture;
  45723. /**
  45724. * The value of the exposure to apply to the scene.
  45725. * 0.6 by default if setupImageProcessing is true.
  45726. */
  45727. cameraExposure: number;
  45728. /**
  45729. * The value of the contrast to apply to the scene.
  45730. * 1.6 by default if setupImageProcessing is true.
  45731. */
  45732. cameraContrast: number;
  45733. /**
  45734. * Specifies wether or not tonemapping should be enabled in the scene.
  45735. * true by default if setupImageProcessing is true.
  45736. */
  45737. toneMappingEnabled: boolean;
  45738. }
  45739. /**
  45740. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45741. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45742. * It also helps with the default setup of your imageProcessing configuration.
  45743. */
  45744. export class EnvironmentHelper {
  45745. /**
  45746. * Default ground texture URL.
  45747. */
  45748. private static _groundTextureCDNUrl;
  45749. /**
  45750. * Default skybox texture URL.
  45751. */
  45752. private static _skyboxTextureCDNUrl;
  45753. /**
  45754. * Default environment texture URL.
  45755. */
  45756. private static _environmentTextureCDNUrl;
  45757. /**
  45758. * Creates the default options for the helper.
  45759. */
  45760. private static _getDefaultOptions;
  45761. private _rootMesh;
  45762. /**
  45763. * Gets the root mesh created by the helper.
  45764. */
  45765. readonly rootMesh: Mesh;
  45766. private _skybox;
  45767. /**
  45768. * Gets the skybox created by the helper.
  45769. */
  45770. readonly skybox: Nullable<Mesh>;
  45771. private _skyboxTexture;
  45772. /**
  45773. * Gets the skybox texture created by the helper.
  45774. */
  45775. readonly skyboxTexture: Nullable<BaseTexture>;
  45776. private _skyboxMaterial;
  45777. /**
  45778. * Gets the skybox material created by the helper.
  45779. */
  45780. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45781. private _ground;
  45782. /**
  45783. * Gets the ground mesh created by the helper.
  45784. */
  45785. readonly ground: Nullable<Mesh>;
  45786. private _groundTexture;
  45787. /**
  45788. * Gets the ground texture created by the helper.
  45789. */
  45790. readonly groundTexture: Nullable<BaseTexture>;
  45791. private _groundMirror;
  45792. /**
  45793. * Gets the ground mirror created by the helper.
  45794. */
  45795. readonly groundMirror: Nullable<MirrorTexture>;
  45796. /**
  45797. * Gets the ground mirror render list to helps pushing the meshes
  45798. * you wish in the ground reflection.
  45799. */
  45800. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45801. private _groundMaterial;
  45802. /**
  45803. * Gets the ground material created by the helper.
  45804. */
  45805. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45806. /**
  45807. * Stores the creation options.
  45808. */
  45809. private readonly _scene;
  45810. private _options;
  45811. /**
  45812. * This observable will be notified with any error during the creation of the environment,
  45813. * mainly texture creation errors.
  45814. */
  45815. onErrorObservable: Observable<{
  45816. message?: string;
  45817. exception?: any;
  45818. }>;
  45819. /**
  45820. * constructor
  45821. * @param options Defines the options we want to customize the helper
  45822. * @param scene The scene to add the material to
  45823. */
  45824. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45825. /**
  45826. * Updates the background according to the new options
  45827. * @param options
  45828. */
  45829. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45830. /**
  45831. * Sets the primary color of all the available elements.
  45832. * @param color the main color to affect to the ground and the background
  45833. */
  45834. setMainColor(color: Color3): void;
  45835. /**
  45836. * Setup the image processing according to the specified options.
  45837. */
  45838. private _setupImageProcessing;
  45839. /**
  45840. * Setup the environment texture according to the specified options.
  45841. */
  45842. private _setupEnvironmentTexture;
  45843. /**
  45844. * Setup the background according to the specified options.
  45845. */
  45846. private _setupBackground;
  45847. /**
  45848. * Get the scene sizes according to the setup.
  45849. */
  45850. private _getSceneSize;
  45851. /**
  45852. * Setup the ground according to the specified options.
  45853. */
  45854. private _setupGround;
  45855. /**
  45856. * Setup the ground material according to the specified options.
  45857. */
  45858. private _setupGroundMaterial;
  45859. /**
  45860. * Setup the ground diffuse texture according to the specified options.
  45861. */
  45862. private _setupGroundDiffuseTexture;
  45863. /**
  45864. * Setup the ground mirror texture according to the specified options.
  45865. */
  45866. private _setupGroundMirrorTexture;
  45867. /**
  45868. * Setup the ground to receive the mirror texture.
  45869. */
  45870. private _setupMirrorInGroundMaterial;
  45871. /**
  45872. * Setup the skybox according to the specified options.
  45873. */
  45874. private _setupSkybox;
  45875. /**
  45876. * Setup the skybox material according to the specified options.
  45877. */
  45878. private _setupSkyboxMaterial;
  45879. /**
  45880. * Setup the skybox reflection texture according to the specified options.
  45881. */
  45882. private _setupSkyboxReflectionTexture;
  45883. private _errorHandler;
  45884. /**
  45885. * Dispose all the elements created by the Helper.
  45886. */
  45887. dispose(): void;
  45888. }
  45889. }
  45890. declare module "babylonjs/Helpers/photoDome" {
  45891. import { Observable } from "babylonjs/Misc/observable";
  45892. import { Nullable } from "babylonjs/types";
  45893. import { Scene } from "babylonjs/scene";
  45894. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45895. import { Mesh } from "babylonjs/Meshes/mesh";
  45896. import { Texture } from "babylonjs/Materials/Textures/texture";
  45897. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45898. import "babylonjs/Meshes/Builders/sphereBuilder";
  45899. /**
  45900. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45901. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45902. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45903. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45904. */
  45905. export class PhotoDome extends TransformNode {
  45906. private _useDirectMapping;
  45907. /**
  45908. * The texture being displayed on the sphere
  45909. */
  45910. protected _photoTexture: Texture;
  45911. /**
  45912. * Gets or sets the texture being displayed on the sphere
  45913. */
  45914. photoTexture: Texture;
  45915. /**
  45916. * Observable raised when an error occured while loading the 360 image
  45917. */
  45918. onLoadErrorObservable: Observable<string>;
  45919. /**
  45920. * The skybox material
  45921. */
  45922. protected _material: BackgroundMaterial;
  45923. /**
  45924. * The surface used for the skybox
  45925. */
  45926. protected _mesh: Mesh;
  45927. /**
  45928. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45929. * Also see the options.resolution property.
  45930. */
  45931. fovMultiplier: number;
  45932. /**
  45933. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45934. * @param name Element's name, child elements will append suffixes for their own names.
  45935. * @param urlsOfPhoto defines the url of the photo to display
  45936. * @param options defines an object containing optional or exposed sub element properties
  45937. * @param onError defines a callback called when an error occured while loading the texture
  45938. */
  45939. constructor(name: string, urlOfPhoto: string, options: {
  45940. resolution?: number;
  45941. size?: number;
  45942. useDirectMapping?: boolean;
  45943. faceForward?: boolean;
  45944. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45945. /**
  45946. * Releases resources associated with this node.
  45947. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45948. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45949. */
  45950. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45951. }
  45952. }
  45953. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45954. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45955. /** @hidden */
  45956. export var rgbdDecodePixelShader: {
  45957. name: string;
  45958. shader: string;
  45959. };
  45960. }
  45961. declare module "babylonjs/Misc/brdfTextureTools" {
  45962. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45963. import { Scene } from "babylonjs/scene";
  45964. import "babylonjs/Shaders/rgbdDecode.fragment";
  45965. /**
  45966. * Class used to host texture specific utilities
  45967. */
  45968. export class BRDFTextureTools {
  45969. /**
  45970. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45971. * @param texture the texture to expand.
  45972. */
  45973. private static _ExpandDefaultBRDFTexture;
  45974. /**
  45975. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45976. * @param scene defines the hosting scene
  45977. * @returns the environment BRDF texture
  45978. */
  45979. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45980. private static _environmentBRDFBase64Texture;
  45981. }
  45982. }
  45983. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45984. import { Nullable } from "babylonjs/types";
  45985. import { IAnimatable } from "babylonjs/Misc/tools";
  45986. import { Color3 } from "babylonjs/Maths/math";
  45987. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45988. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45989. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45990. import { Engine } from "babylonjs/Engines/engine";
  45991. import { Scene } from "babylonjs/scene";
  45992. /**
  45993. * @hidden
  45994. */
  45995. export interface IMaterialClearCoatDefines {
  45996. CLEARCOAT: boolean;
  45997. CLEARCOAT_DEFAULTIOR: boolean;
  45998. CLEARCOAT_TEXTURE: boolean;
  45999. CLEARCOAT_TEXTUREDIRECTUV: number;
  46000. CLEARCOAT_BUMP: boolean;
  46001. CLEARCOAT_BUMPDIRECTUV: number;
  46002. CLEARCOAT_TINT: boolean;
  46003. CLEARCOAT_TINT_TEXTURE: boolean;
  46004. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46005. /** @hidden */
  46006. _areTexturesDirty: boolean;
  46007. }
  46008. /**
  46009. * Define the code related to the clear coat parameters of the pbr material.
  46010. */
  46011. export class PBRClearCoatConfiguration {
  46012. /**
  46013. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46014. * The default fits with a polyurethane material.
  46015. */
  46016. private static readonly _DefaultIndiceOfRefraction;
  46017. private _isEnabled;
  46018. /**
  46019. * Defines if the clear coat is enabled in the material.
  46020. */
  46021. isEnabled: boolean;
  46022. /**
  46023. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  46024. */
  46025. intensity: number;
  46026. /**
  46027. * Defines the clear coat layer roughness.
  46028. */
  46029. roughness: number;
  46030. private _indiceOfRefraction;
  46031. /**
  46032. * Defines the indice of refraction of the clear coat.
  46033. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  46034. * The default fits with a polyurethane material.
  46035. * Changing the default value is more performance intensive.
  46036. */
  46037. indiceOfRefraction: number;
  46038. private _texture;
  46039. /**
  46040. * Stores the clear coat values in a texture.
  46041. */
  46042. texture: Nullable<BaseTexture>;
  46043. private _bumpTexture;
  46044. /**
  46045. * Define the clear coat specific bump texture.
  46046. */
  46047. bumpTexture: Nullable<BaseTexture>;
  46048. private _isTintEnabled;
  46049. /**
  46050. * Defines if the clear coat tint is enabled in the material.
  46051. */
  46052. isTintEnabled: boolean;
  46053. /**
  46054. * Defines the clear coat tint of the material.
  46055. * This is only use if tint is enabled
  46056. */
  46057. tintColor: Color3;
  46058. /**
  46059. * Defines the distance at which the tint color should be found in the
  46060. * clear coat media.
  46061. * This is only use if tint is enabled
  46062. */
  46063. tintColorAtDistance: number;
  46064. /**
  46065. * Defines the clear coat layer thickness.
  46066. * This is only use if tint is enabled
  46067. */
  46068. tintThickness: number;
  46069. private _tintTexture;
  46070. /**
  46071. * Stores the clear tint values in a texture.
  46072. * rgb is tint
  46073. * a is a thickness factor
  46074. */
  46075. tintTexture: Nullable<BaseTexture>;
  46076. /** @hidden */
  46077. private _internalMarkAllSubMeshesAsTexturesDirty;
  46078. /** @hidden */
  46079. _markAllSubMeshesAsTexturesDirty(): void;
  46080. /**
  46081. * Instantiate a new istance of clear coat configuration.
  46082. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46083. */
  46084. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46085. /**
  46086. * Gets wehter the submesh is ready to be used or not.
  46087. * @param defines the list of "defines" to update.
  46088. * @param scene defines the scene the material belongs to.
  46089. * @param engine defines the engine the material belongs to.
  46090. * @param disableBumpMap defines wether the material disables bump or not.
  46091. * @returns - boolean indicating that the submesh is ready or not.
  46092. */
  46093. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  46094. /**
  46095. * Checks to see if a texture is used in the material.
  46096. * @param defines the list of "defines" to update.
  46097. * @param scene defines the scene to the material belongs to.
  46098. */
  46099. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  46100. /**
  46101. * Binds the material data.
  46102. * @param uniformBuffer defines the Uniform buffer to fill in.
  46103. * @param scene defines the scene the material belongs to.
  46104. * @param engine defines the engine the material belongs to.
  46105. * @param disableBumpMap defines wether the material disables bump or not.
  46106. * @param isFrozen defines wether the material is frozen or not.
  46107. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46108. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46109. */
  46110. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  46111. /**
  46112. * Checks to see if a texture is used in the material.
  46113. * @param texture - Base texture to use.
  46114. * @returns - Boolean specifying if a texture is used in the material.
  46115. */
  46116. hasTexture(texture: BaseTexture): boolean;
  46117. /**
  46118. * Returns an array of the actively used textures.
  46119. * @param activeTextures Array of BaseTextures
  46120. */
  46121. getActiveTextures(activeTextures: BaseTexture[]): void;
  46122. /**
  46123. * Returns the animatable textures.
  46124. * @param animatables Array of animatable textures.
  46125. */
  46126. getAnimatables(animatables: IAnimatable[]): void;
  46127. /**
  46128. * Disposes the resources of the material.
  46129. * @param forceDisposeTextures - Forces the disposal of all textures.
  46130. */
  46131. dispose(forceDisposeTextures?: boolean): void;
  46132. /**
  46133. * Get the current class name of the texture useful for serialization or dynamic coding.
  46134. * @returns "PBRClearCoatConfiguration"
  46135. */
  46136. getClassName(): string;
  46137. /**
  46138. * Add fallbacks to the effect fallbacks list.
  46139. * @param defines defines the Base texture to use.
  46140. * @param fallbacks defines the current fallback list.
  46141. * @param currentRank defines the current fallback rank.
  46142. * @returns the new fallback rank.
  46143. */
  46144. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46145. /**
  46146. * Add the required uniforms to the current list.
  46147. * @param uniforms defines the current uniform list.
  46148. */
  46149. static AddUniforms(uniforms: string[]): void;
  46150. /**
  46151. * Add the required samplers to the current list.
  46152. * @param samplers defines the current sampler list.
  46153. */
  46154. static AddSamplers(samplers: string[]): void;
  46155. /**
  46156. * Add the required uniforms to the current buffer.
  46157. * @param uniformBuffer defines the current uniform buffer.
  46158. */
  46159. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46160. /**
  46161. * Makes a duplicate of the current configuration into another one.
  46162. * @param clearCoatConfiguration define the config where to copy the info
  46163. */
  46164. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  46165. /**
  46166. * Serializes this clear coat configuration.
  46167. * @returns - An object with the serialized config.
  46168. */
  46169. serialize(): any;
  46170. /**
  46171. * Parses a Clear Coat Configuration from a serialized object.
  46172. * @param source - Serialized object.
  46173. */
  46174. parse(source: any): void;
  46175. }
  46176. }
  46177. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  46178. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46179. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46181. import { Vector2 } from "babylonjs/Maths/math";
  46182. import { Scene } from "babylonjs/scene";
  46183. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46184. import { IAnimatable } from "babylonjs/Misc/tools";
  46185. import { Nullable } from "babylonjs/types";
  46186. /**
  46187. * @hidden
  46188. */
  46189. export interface IMaterialAnisotropicDefines {
  46190. ANISOTROPIC: boolean;
  46191. ANISOTROPIC_TEXTURE: boolean;
  46192. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46193. MAINUV1: boolean;
  46194. _areTexturesDirty: boolean;
  46195. _needUVs: boolean;
  46196. }
  46197. /**
  46198. * Define the code related to the anisotropic parameters of the pbr material.
  46199. */
  46200. export class PBRAnisotropicConfiguration {
  46201. private _isEnabled;
  46202. /**
  46203. * Defines if the anisotropy is enabled in the material.
  46204. */
  46205. isEnabled: boolean;
  46206. /**
  46207. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  46208. */
  46209. intensity: number;
  46210. /**
  46211. * Defines if the effect is along the tangents, bitangents or in between.
  46212. * By default, the effect is "strectching" the highlights along the tangents.
  46213. */
  46214. direction: Vector2;
  46215. private _texture;
  46216. /**
  46217. * Stores the anisotropy values in a texture.
  46218. * rg is direction (like normal from -1 to 1)
  46219. * b is a intensity
  46220. */
  46221. texture: Nullable<BaseTexture>;
  46222. /** @hidden */
  46223. private _internalMarkAllSubMeshesAsTexturesDirty;
  46224. /** @hidden */
  46225. _markAllSubMeshesAsTexturesDirty(): void;
  46226. /**
  46227. * Instantiate a new istance of anisotropy configuration.
  46228. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46229. */
  46230. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46231. /**
  46232. * Specifies that the submesh is ready to be used.
  46233. * @param defines the list of "defines" to update.
  46234. * @param scene defines the scene the material belongs to.
  46235. * @returns - boolean indicating that the submesh is ready or not.
  46236. */
  46237. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  46238. /**
  46239. * Checks to see if a texture is used in the material.
  46240. * @param defines the list of "defines" to update.
  46241. * @param mesh the mesh we are preparing the defines for.
  46242. * @param scene defines the scene the material belongs to.
  46243. */
  46244. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  46245. /**
  46246. * Binds the material data.
  46247. * @param uniformBuffer defines the Uniform buffer to fill in.
  46248. * @param scene defines the scene the material belongs to.
  46249. * @param isFrozen defines wether the material is frozen or not.
  46250. */
  46251. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46252. /**
  46253. * Checks to see if a texture is used in the material.
  46254. * @param texture - Base texture to use.
  46255. * @returns - Boolean specifying if a texture is used in the material.
  46256. */
  46257. hasTexture(texture: BaseTexture): boolean;
  46258. /**
  46259. * Returns an array of the actively used textures.
  46260. * @param activeTextures Array of BaseTextures
  46261. */
  46262. getActiveTextures(activeTextures: BaseTexture[]): void;
  46263. /**
  46264. * Returns the animatable textures.
  46265. * @param animatables Array of animatable textures.
  46266. */
  46267. getAnimatables(animatables: IAnimatable[]): void;
  46268. /**
  46269. * Disposes the resources of the material.
  46270. * @param forceDisposeTextures - Forces the disposal of all textures.
  46271. */
  46272. dispose(forceDisposeTextures?: boolean): void;
  46273. /**
  46274. * Get the current class name of the texture useful for serialization or dynamic coding.
  46275. * @returns "PBRAnisotropicConfiguration"
  46276. */
  46277. getClassName(): string;
  46278. /**
  46279. * Add fallbacks to the effect fallbacks list.
  46280. * @param defines defines the Base texture to use.
  46281. * @param fallbacks defines the current fallback list.
  46282. * @param currentRank defines the current fallback rank.
  46283. * @returns the new fallback rank.
  46284. */
  46285. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46286. /**
  46287. * Add the required uniforms to the current list.
  46288. * @param uniforms defines the current uniform list.
  46289. */
  46290. static AddUniforms(uniforms: string[]): void;
  46291. /**
  46292. * Add the required uniforms to the current buffer.
  46293. * @param uniformBuffer defines the current uniform buffer.
  46294. */
  46295. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46296. /**
  46297. * Add the required samplers to the current list.
  46298. * @param samplers defines the current sampler list.
  46299. */
  46300. static AddSamplers(samplers: string[]): void;
  46301. /**
  46302. * Makes a duplicate of the current configuration into another one.
  46303. * @param anisotropicConfiguration define the config where to copy the info
  46304. */
  46305. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  46306. /**
  46307. * Serializes this anisotropy configuration.
  46308. * @returns - An object with the serialized config.
  46309. */
  46310. serialize(): any;
  46311. /**
  46312. * Parses a anisotropy Configuration from a serialized object.
  46313. * @param source - Serialized object.
  46314. */
  46315. parse(source: any): void;
  46316. }
  46317. }
  46318. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  46319. /**
  46320. * @hidden
  46321. */
  46322. export interface IMaterialBRDFDefines {
  46323. BRDF_V_HEIGHT_CORRELATED: boolean;
  46324. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46325. SPHERICAL_HARMONICS: boolean;
  46326. /** @hidden */
  46327. _areMiscDirty: boolean;
  46328. }
  46329. /**
  46330. * Define the code related to the BRDF parameters of the pbr material.
  46331. */
  46332. export class PBRBRDFConfiguration {
  46333. /**
  46334. * Default value used for the energy conservation.
  46335. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46336. */
  46337. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  46338. /**
  46339. * Default value used for the Smith Visibility Height Correlated mode.
  46340. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  46341. */
  46342. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  46343. /**
  46344. * Default value used for the IBL diffuse part.
  46345. * This can help switching back to the polynomials mode globally which is a tiny bit
  46346. * less GPU intensive at the drawback of a lower quality.
  46347. */
  46348. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  46349. private _useEnergyConservation;
  46350. /**
  46351. * Defines if the material uses energy conservation.
  46352. */
  46353. useEnergyConservation: boolean;
  46354. private _useSmithVisibilityHeightCorrelated;
  46355. /**
  46356. * LEGACY Mode set to false
  46357. * Defines if the material uses height smith correlated visibility term.
  46358. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  46359. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  46360. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  46361. * Not relying on height correlated will also disable energy conservation.
  46362. */
  46363. useSmithVisibilityHeightCorrelated: boolean;
  46364. private _useSphericalHarmonics;
  46365. /**
  46366. * LEGACY Mode set to false
  46367. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  46368. * diffuse part of the IBL.
  46369. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  46370. * to the ground truth.
  46371. */
  46372. useSphericalHarmonics: boolean;
  46373. /** @hidden */
  46374. private _internalMarkAllSubMeshesAsMiscDirty;
  46375. /** @hidden */
  46376. _markAllSubMeshesAsMiscDirty(): void;
  46377. /**
  46378. * Instantiate a new istance of clear coat configuration.
  46379. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  46380. */
  46381. constructor(markAllSubMeshesAsMiscDirty: () => void);
  46382. /**
  46383. * Checks to see if a texture is used in the material.
  46384. * @param defines the list of "defines" to update.
  46385. */
  46386. prepareDefines(defines: IMaterialBRDFDefines): void;
  46387. /**
  46388. * Get the current class name of the texture useful for serialization or dynamic coding.
  46389. * @returns "PBRClearCoatConfiguration"
  46390. */
  46391. getClassName(): string;
  46392. /**
  46393. * Makes a duplicate of the current configuration into another one.
  46394. * @param brdfConfiguration define the config where to copy the info
  46395. */
  46396. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  46397. /**
  46398. * Serializes this BRDF configuration.
  46399. * @returns - An object with the serialized config.
  46400. */
  46401. serialize(): any;
  46402. /**
  46403. * Parses a BRDF Configuration from a serialized object.
  46404. * @param source - Serialized object.
  46405. */
  46406. parse(source: any): void;
  46407. }
  46408. }
  46409. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  46410. import { EffectFallbacks } from "babylonjs/Materials/effect";
  46411. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46412. import { Color3 } from "babylonjs/Maths/math";
  46413. import { Scene } from "babylonjs/scene";
  46414. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46415. import { IAnimatable } from "babylonjs/Misc/tools";
  46416. import { Nullable } from "babylonjs/types";
  46417. /**
  46418. * @hidden
  46419. */
  46420. export interface IMaterialSheenDefines {
  46421. SHEEN: boolean;
  46422. SHEEN_TEXTURE: boolean;
  46423. SHEEN_TEXTUREDIRECTUV: number;
  46424. SHEEN_LINKWITHALBEDO: boolean;
  46425. /** @hidden */
  46426. _areTexturesDirty: boolean;
  46427. }
  46428. /**
  46429. * Define the code related to the Sheen parameters of the pbr material.
  46430. */
  46431. export class PBRSheenConfiguration {
  46432. private _isEnabled;
  46433. /**
  46434. * Defines if the material uses sheen.
  46435. */
  46436. isEnabled: boolean;
  46437. private _linkSheenWithAlbedo;
  46438. /**
  46439. * Defines if the sheen is linked to the sheen color.
  46440. */
  46441. linkSheenWithAlbedo: boolean;
  46442. /**
  46443. * Defines the sheen intensity.
  46444. */
  46445. intensity: number;
  46446. /**
  46447. * Defines the sheen color.
  46448. */
  46449. color: Color3;
  46450. private _texture;
  46451. /**
  46452. * Stores the sheen tint values in a texture.
  46453. * rgb is tint
  46454. * a is a intensity
  46455. */
  46456. texture: Nullable<BaseTexture>;
  46457. /** @hidden */
  46458. private _internalMarkAllSubMeshesAsTexturesDirty;
  46459. /** @hidden */
  46460. _markAllSubMeshesAsTexturesDirty(): void;
  46461. /**
  46462. * Instantiate a new istance of clear coat configuration.
  46463. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46464. */
  46465. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46466. /**
  46467. * Specifies that the submesh is ready to be used.
  46468. * @param defines the list of "defines" to update.
  46469. * @param scene defines the scene the material belongs to.
  46470. * @returns - boolean indicating that the submesh is ready or not.
  46471. */
  46472. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  46473. /**
  46474. * Checks to see if a texture is used in the material.
  46475. * @param defines the list of "defines" to update.
  46476. * @param scene defines the scene the material belongs to.
  46477. */
  46478. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  46479. /**
  46480. * Binds the material data.
  46481. * @param uniformBuffer defines the Uniform buffer to fill in.
  46482. * @param scene defines the scene the material belongs to.
  46483. * @param isFrozen defines wether the material is frozen or not.
  46484. */
  46485. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  46486. /**
  46487. * Checks to see if a texture is used in the material.
  46488. * @param texture - Base texture to use.
  46489. * @returns - Boolean specifying if a texture is used in the material.
  46490. */
  46491. hasTexture(texture: BaseTexture): boolean;
  46492. /**
  46493. * Returns an array of the actively used textures.
  46494. * @param activeTextures Array of BaseTextures
  46495. */
  46496. getActiveTextures(activeTextures: BaseTexture[]): void;
  46497. /**
  46498. * Returns the animatable textures.
  46499. * @param animatables Array of animatable textures.
  46500. */
  46501. getAnimatables(animatables: IAnimatable[]): void;
  46502. /**
  46503. * Disposes the resources of the material.
  46504. * @param forceDisposeTextures - Forces the disposal of all textures.
  46505. */
  46506. dispose(forceDisposeTextures?: boolean): void;
  46507. /**
  46508. * Get the current class name of the texture useful for serialization or dynamic coding.
  46509. * @returns "PBRSheenConfiguration"
  46510. */
  46511. getClassName(): string;
  46512. /**
  46513. * Add fallbacks to the effect fallbacks list.
  46514. * @param defines defines the Base texture to use.
  46515. * @param fallbacks defines the current fallback list.
  46516. * @param currentRank defines the current fallback rank.
  46517. * @returns the new fallback rank.
  46518. */
  46519. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46520. /**
  46521. * Add the required uniforms to the current list.
  46522. * @param uniforms defines the current uniform list.
  46523. */
  46524. static AddUniforms(uniforms: string[]): void;
  46525. /**
  46526. * Add the required uniforms to the current buffer.
  46527. * @param uniformBuffer defines the current uniform buffer.
  46528. */
  46529. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46530. /**
  46531. * Add the required samplers to the current list.
  46532. * @param samplers defines the current sampler list.
  46533. */
  46534. static AddSamplers(samplers: string[]): void;
  46535. /**
  46536. * Makes a duplicate of the current configuration into another one.
  46537. * @param sheenConfiguration define the config where to copy the info
  46538. */
  46539. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  46540. /**
  46541. * Serializes this BRDF configuration.
  46542. * @returns - An object with the serialized config.
  46543. */
  46544. serialize(): any;
  46545. /**
  46546. * Parses a Sheen Configuration from a serialized object.
  46547. * @param source - Serialized object.
  46548. */
  46549. parse(source: any): void;
  46550. }
  46551. }
  46552. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  46553. import { Nullable } from "babylonjs/types";
  46554. import { IAnimatable } from "babylonjs/Misc/tools";
  46555. import { Color3 } from "babylonjs/Maths/math";
  46556. import { SmartArray } from "babylonjs/Misc/smartArray";
  46557. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  46559. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  46560. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  46561. import { Engine } from "babylonjs/Engines/engine";
  46562. import { Scene } from "babylonjs/scene";
  46563. /**
  46564. * @hidden
  46565. */
  46566. export interface IMaterialSubSurfaceDefines {
  46567. SUBSURFACE: boolean;
  46568. SS_REFRACTION: boolean;
  46569. SS_TRANSLUCENCY: boolean;
  46570. SS_SCATERRING: boolean;
  46571. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46572. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46573. SS_REFRACTIONMAP_3D: boolean;
  46574. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46575. SS_LODINREFRACTIONALPHA: boolean;
  46576. SS_GAMMAREFRACTION: boolean;
  46577. SS_RGBDREFRACTION: boolean;
  46578. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46579. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46580. /** @hidden */
  46581. _areTexturesDirty: boolean;
  46582. }
  46583. /**
  46584. * Define the code related to the sub surface parameters of the pbr material.
  46585. */
  46586. export class PBRSubSurfaceConfiguration {
  46587. private _isRefractionEnabled;
  46588. /**
  46589. * Defines if the refraction is enabled in the material.
  46590. */
  46591. isRefractionEnabled: boolean;
  46592. private _isTranslucencyEnabled;
  46593. /**
  46594. * Defines if the translucency is enabled in the material.
  46595. */
  46596. isTranslucencyEnabled: boolean;
  46597. private _isScatteringEnabled;
  46598. /**
  46599. * Defines the refraction intensity of the material.
  46600. * The refraction when enabled replaces the Diffuse part of the material.
  46601. * The intensity helps transitionning between diffuse and refraction.
  46602. */
  46603. refractionIntensity: number;
  46604. /**
  46605. * Defines the translucency intensity of the material.
  46606. * When translucency has been enabled, this defines how much of the "translucency"
  46607. * is addded to the diffuse part of the material.
  46608. */
  46609. translucencyIntensity: number;
  46610. /**
  46611. * Defines the scattering intensity of the material.
  46612. * When scattering has been enabled, this defines how much of the "scattered light"
  46613. * is addded to the diffuse part of the material.
  46614. */
  46615. scatteringIntensity: number;
  46616. private _thicknessTexture;
  46617. /**
  46618. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46619. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46620. * 0 would mean minimumThickness
  46621. * 1 would mean maximumThickness
  46622. * The other channels might be use as a mask to vary the different effects intensity.
  46623. */
  46624. thicknessTexture: Nullable<BaseTexture>;
  46625. private _refractionTexture;
  46626. /**
  46627. * Defines the texture to use for refraction.
  46628. */
  46629. refractionTexture: Nullable<BaseTexture>;
  46630. private _indexOfRefraction;
  46631. /**
  46632. * Defines the indice of refraction used in the material.
  46633. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46634. */
  46635. indexOfRefraction: number;
  46636. private _invertRefractionY;
  46637. /**
  46638. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46639. */
  46640. invertRefractionY: boolean;
  46641. private _linkRefractionWithTransparency;
  46642. /**
  46643. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46644. * Materials half opaque for instance using refraction could benefit from this control.
  46645. */
  46646. linkRefractionWithTransparency: boolean;
  46647. /**
  46648. * Defines the minimum thickness stored in the thickness map.
  46649. * If no thickness map is defined, this value will be used to simulate thickness.
  46650. */
  46651. minimumThickness: number;
  46652. /**
  46653. * Defines the maximum thickness stored in the thickness map.
  46654. */
  46655. maximumThickness: number;
  46656. /**
  46657. * Defines the volume tint of the material.
  46658. * This is used for both translucency and scattering.
  46659. */
  46660. tintColor: Color3;
  46661. /**
  46662. * Defines the distance at which the tint color should be found in the media.
  46663. * This is used for refraction only.
  46664. */
  46665. tintColorAtDistance: number;
  46666. /**
  46667. * Defines how far each channel transmit through the media.
  46668. * It is defined as a color to simplify it selection.
  46669. */
  46670. diffusionDistance: Color3;
  46671. private _useMaskFromThicknessTexture;
  46672. /**
  46673. * Stores the intensity of the different subsurface effects in the thickness texture.
  46674. * * the green channel is the translucency intensity.
  46675. * * the blue channel is the scattering intensity.
  46676. * * the alpha channel is the refraction intensity.
  46677. */
  46678. useMaskFromThicknessTexture: boolean;
  46679. /** @hidden */
  46680. private _internalMarkAllSubMeshesAsTexturesDirty;
  46681. /** @hidden */
  46682. _markAllSubMeshesAsTexturesDirty(): void;
  46683. /**
  46684. * Instantiate a new istance of sub surface configuration.
  46685. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46686. */
  46687. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46688. /**
  46689. * Gets wehter the submesh is ready to be used or not.
  46690. * @param defines the list of "defines" to update.
  46691. * @param scene defines the scene the material belongs to.
  46692. * @returns - boolean indicating that the submesh is ready or not.
  46693. */
  46694. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46695. /**
  46696. * Checks to see if a texture is used in the material.
  46697. * @param defines the list of "defines" to update.
  46698. * @param scene defines the scene to the material belongs to.
  46699. */
  46700. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46701. /**
  46702. * Binds the material data.
  46703. * @param uniformBuffer defines the Uniform buffer to fill in.
  46704. * @param scene defines the scene the material belongs to.
  46705. * @param engine defines the engine the material belongs to.
  46706. * @param isFrozen defines wether the material is frozen or not.
  46707. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46708. */
  46709. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46710. /**
  46711. * Unbinds the material from the mesh.
  46712. * @param activeEffect defines the effect that should be unbound from.
  46713. * @returns true if unbound, otherwise false
  46714. */
  46715. unbind(activeEffect: Effect): boolean;
  46716. /**
  46717. * Returns the texture used for refraction or null if none is used.
  46718. * @param scene defines the scene the material belongs to.
  46719. * @returns - Refraction texture if present. If no refraction texture and refraction
  46720. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46721. */
  46722. private _getRefractionTexture;
  46723. /**
  46724. * Returns true if alpha blending should be disabled.
  46725. */
  46726. readonly disableAlphaBlending: boolean;
  46727. /**
  46728. * Fills the list of render target textures.
  46729. * @param renderTargets the list of render targets to update
  46730. */
  46731. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46732. /**
  46733. * Checks to see if a texture is used in the material.
  46734. * @param texture - Base texture to use.
  46735. * @returns - Boolean specifying if a texture is used in the material.
  46736. */
  46737. hasTexture(texture: BaseTexture): boolean;
  46738. /**
  46739. * Gets a boolean indicating that current material needs to register RTT
  46740. * @returns true if this uses a render target otherwise false.
  46741. */
  46742. hasRenderTargetTextures(): boolean;
  46743. /**
  46744. * Returns an array of the actively used textures.
  46745. * @param activeTextures Array of BaseTextures
  46746. */
  46747. getActiveTextures(activeTextures: BaseTexture[]): void;
  46748. /**
  46749. * Returns the animatable textures.
  46750. * @param animatables Array of animatable textures.
  46751. */
  46752. getAnimatables(animatables: IAnimatable[]): void;
  46753. /**
  46754. * Disposes the resources of the material.
  46755. * @param forceDisposeTextures - Forces the disposal of all textures.
  46756. */
  46757. dispose(forceDisposeTextures?: boolean): void;
  46758. /**
  46759. * Get the current class name of the texture useful for serialization or dynamic coding.
  46760. * @returns "PBRSubSurfaceConfiguration"
  46761. */
  46762. getClassName(): string;
  46763. /**
  46764. * Add fallbacks to the effect fallbacks list.
  46765. * @param defines defines the Base texture to use.
  46766. * @param fallbacks defines the current fallback list.
  46767. * @param currentRank defines the current fallback rank.
  46768. * @returns the new fallback rank.
  46769. */
  46770. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46771. /**
  46772. * Add the required uniforms to the current list.
  46773. * @param uniforms defines the current uniform list.
  46774. */
  46775. static AddUniforms(uniforms: string[]): void;
  46776. /**
  46777. * Add the required samplers to the current list.
  46778. * @param samplers defines the current sampler list.
  46779. */
  46780. static AddSamplers(samplers: string[]): void;
  46781. /**
  46782. * Add the required uniforms to the current buffer.
  46783. * @param uniformBuffer defines the current uniform buffer.
  46784. */
  46785. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46786. /**
  46787. * Makes a duplicate of the current configuration into another one.
  46788. * @param configuration define the config where to copy the info
  46789. */
  46790. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46791. /**
  46792. * Serializes this Sub Surface configuration.
  46793. * @returns - An object with the serialized config.
  46794. */
  46795. serialize(): any;
  46796. /**
  46797. * Parses a Sub Surface Configuration from a serialized object.
  46798. * @param source - Serialized object.
  46799. */
  46800. parse(source: any): void;
  46801. }
  46802. }
  46803. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46804. /** @hidden */
  46805. export var pbrFragmentDeclaration: {
  46806. name: string;
  46807. shader: string;
  46808. };
  46809. }
  46810. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46811. /** @hidden */
  46812. export var pbrUboDeclaration: {
  46813. name: string;
  46814. shader: string;
  46815. };
  46816. }
  46817. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46818. /** @hidden */
  46819. export var pbrFragmentExtraDeclaration: {
  46820. name: string;
  46821. shader: string;
  46822. };
  46823. }
  46824. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46825. /** @hidden */
  46826. export var pbrFragmentSamplersDeclaration: {
  46827. name: string;
  46828. shader: string;
  46829. };
  46830. }
  46831. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46832. /** @hidden */
  46833. export var pbrHelperFunctions: {
  46834. name: string;
  46835. shader: string;
  46836. };
  46837. }
  46838. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46839. /** @hidden */
  46840. export var harmonicsFunctions: {
  46841. name: string;
  46842. shader: string;
  46843. };
  46844. }
  46845. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46846. /** @hidden */
  46847. export var pbrDirectLightingSetupFunctions: {
  46848. name: string;
  46849. shader: string;
  46850. };
  46851. }
  46852. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46853. /** @hidden */
  46854. export var pbrDirectLightingFalloffFunctions: {
  46855. name: string;
  46856. shader: string;
  46857. };
  46858. }
  46859. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46860. /** @hidden */
  46861. export var pbrBRDFFunctions: {
  46862. name: string;
  46863. shader: string;
  46864. };
  46865. }
  46866. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46867. /** @hidden */
  46868. export var pbrDirectLightingFunctions: {
  46869. name: string;
  46870. shader: string;
  46871. };
  46872. }
  46873. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46874. /** @hidden */
  46875. export var pbrIBLFunctions: {
  46876. name: string;
  46877. shader: string;
  46878. };
  46879. }
  46880. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46881. /** @hidden */
  46882. export var pbrDebug: {
  46883. name: string;
  46884. shader: string;
  46885. };
  46886. }
  46887. declare module "babylonjs/Shaders/pbr.fragment" {
  46888. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46889. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46890. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46891. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46892. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46893. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46894. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46895. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46896. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46897. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46898. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46899. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46900. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46901. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46902. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46903. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46904. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46905. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46906. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46907. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46908. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46909. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46910. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46911. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46912. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46913. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46914. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46915. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46916. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46917. /** @hidden */
  46918. export var pbrPixelShader: {
  46919. name: string;
  46920. shader: string;
  46921. };
  46922. }
  46923. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46924. /** @hidden */
  46925. export var pbrVertexDeclaration: {
  46926. name: string;
  46927. shader: string;
  46928. };
  46929. }
  46930. declare module "babylonjs/Shaders/pbr.vertex" {
  46931. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46932. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46933. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46934. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46935. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46936. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46937. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46938. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46939. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46940. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46941. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46942. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46943. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46944. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46945. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46946. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46947. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46948. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46949. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46950. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46951. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46952. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46953. /** @hidden */
  46954. export var pbrVertexShader: {
  46955. name: string;
  46956. shader: string;
  46957. };
  46958. }
  46959. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46960. import { IAnimatable } from "babylonjs/Misc/tools";
  46961. import { Nullable } from "babylonjs/types";
  46962. import { Scene } from "babylonjs/scene";
  46963. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46964. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46965. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46966. import { Mesh } from "babylonjs/Meshes/mesh";
  46967. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46968. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46969. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46970. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46971. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46972. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46973. import { Material } from "babylonjs/Materials/material";
  46974. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46975. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46977. import "babylonjs/Shaders/pbr.fragment";
  46978. import "babylonjs/Shaders/pbr.vertex";
  46979. /**
  46980. * Manages the defines for the PBR Material.
  46981. * @hidden
  46982. */
  46983. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46984. PBR: boolean;
  46985. MAINUV1: boolean;
  46986. MAINUV2: boolean;
  46987. UV1: boolean;
  46988. UV2: boolean;
  46989. ALBEDO: boolean;
  46990. ALBEDODIRECTUV: number;
  46991. VERTEXCOLOR: boolean;
  46992. AMBIENT: boolean;
  46993. AMBIENTDIRECTUV: number;
  46994. AMBIENTINGRAYSCALE: boolean;
  46995. OPACITY: boolean;
  46996. VERTEXALPHA: boolean;
  46997. OPACITYDIRECTUV: number;
  46998. OPACITYRGB: boolean;
  46999. ALPHATEST: boolean;
  47000. DEPTHPREPASS: boolean;
  47001. ALPHABLEND: boolean;
  47002. ALPHAFROMALBEDO: boolean;
  47003. ALPHATESTVALUE: string;
  47004. SPECULAROVERALPHA: boolean;
  47005. RADIANCEOVERALPHA: boolean;
  47006. ALPHAFRESNEL: boolean;
  47007. LINEARALPHAFRESNEL: boolean;
  47008. PREMULTIPLYALPHA: boolean;
  47009. EMISSIVE: boolean;
  47010. EMISSIVEDIRECTUV: number;
  47011. REFLECTIVITY: boolean;
  47012. REFLECTIVITYDIRECTUV: number;
  47013. SPECULARTERM: boolean;
  47014. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  47015. MICROSURFACEAUTOMATIC: boolean;
  47016. LODBASEDMICROSFURACE: boolean;
  47017. MICROSURFACEMAP: boolean;
  47018. MICROSURFACEMAPDIRECTUV: number;
  47019. METALLICWORKFLOW: boolean;
  47020. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  47021. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  47022. METALLNESSSTOREINMETALMAPBLUE: boolean;
  47023. AOSTOREINMETALMAPRED: boolean;
  47024. ENVIRONMENTBRDF: boolean;
  47025. ENVIRONMENTBRDF_RGBD: boolean;
  47026. NORMAL: boolean;
  47027. TANGENT: boolean;
  47028. BUMP: boolean;
  47029. BUMPDIRECTUV: number;
  47030. OBJECTSPACE_NORMALMAP: boolean;
  47031. PARALLAX: boolean;
  47032. PARALLAXOCCLUSION: boolean;
  47033. NORMALXYSCALE: boolean;
  47034. LIGHTMAP: boolean;
  47035. LIGHTMAPDIRECTUV: number;
  47036. USELIGHTMAPASSHADOWMAP: boolean;
  47037. GAMMALIGHTMAP: boolean;
  47038. REFLECTION: boolean;
  47039. REFLECTIONMAP_3D: boolean;
  47040. REFLECTIONMAP_SPHERICAL: boolean;
  47041. REFLECTIONMAP_PLANAR: boolean;
  47042. REFLECTIONMAP_CUBIC: boolean;
  47043. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  47044. REFLECTIONMAP_PROJECTION: boolean;
  47045. REFLECTIONMAP_SKYBOX: boolean;
  47046. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  47047. REFLECTIONMAP_EXPLICIT: boolean;
  47048. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  47049. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  47050. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  47051. INVERTCUBICMAP: boolean;
  47052. USESPHERICALFROMREFLECTIONMAP: boolean;
  47053. SPHERICAL_HARMONICS: boolean;
  47054. USESPHERICALINVERTEX: boolean;
  47055. REFLECTIONMAP_OPPOSITEZ: boolean;
  47056. LODINREFLECTIONALPHA: boolean;
  47057. GAMMAREFLECTION: boolean;
  47058. RGBDREFLECTION: boolean;
  47059. RADIANCEOCCLUSION: boolean;
  47060. HORIZONOCCLUSION: boolean;
  47061. INSTANCES: boolean;
  47062. NUM_BONE_INFLUENCERS: number;
  47063. BonesPerMesh: number;
  47064. BONETEXTURE: boolean;
  47065. NONUNIFORMSCALING: boolean;
  47066. MORPHTARGETS: boolean;
  47067. MORPHTARGETS_NORMAL: boolean;
  47068. MORPHTARGETS_TANGENT: boolean;
  47069. NUM_MORPH_INFLUENCERS: number;
  47070. IMAGEPROCESSING: boolean;
  47071. VIGNETTE: boolean;
  47072. VIGNETTEBLENDMODEMULTIPLY: boolean;
  47073. VIGNETTEBLENDMODEOPAQUE: boolean;
  47074. TONEMAPPING: boolean;
  47075. TONEMAPPING_ACES: boolean;
  47076. CONTRAST: boolean;
  47077. COLORCURVES: boolean;
  47078. COLORGRADING: boolean;
  47079. COLORGRADING3D: boolean;
  47080. SAMPLER3DGREENDEPTH: boolean;
  47081. SAMPLER3DBGRMAP: boolean;
  47082. IMAGEPROCESSINGPOSTPROCESS: boolean;
  47083. EXPOSURE: boolean;
  47084. MULTIVIEW: boolean;
  47085. USEPHYSICALLIGHTFALLOFF: boolean;
  47086. USEGLTFLIGHTFALLOFF: boolean;
  47087. TWOSIDEDLIGHTING: boolean;
  47088. SHADOWFLOAT: boolean;
  47089. CLIPPLANE: boolean;
  47090. CLIPPLANE2: boolean;
  47091. CLIPPLANE3: boolean;
  47092. CLIPPLANE4: boolean;
  47093. POINTSIZE: boolean;
  47094. FOG: boolean;
  47095. LOGARITHMICDEPTH: boolean;
  47096. FORCENORMALFORWARD: boolean;
  47097. SPECULARAA: boolean;
  47098. CLEARCOAT: boolean;
  47099. CLEARCOAT_DEFAULTIOR: boolean;
  47100. CLEARCOAT_TEXTURE: boolean;
  47101. CLEARCOAT_TEXTUREDIRECTUV: number;
  47102. CLEARCOAT_BUMP: boolean;
  47103. CLEARCOAT_BUMPDIRECTUV: number;
  47104. CLEARCOAT_TINT: boolean;
  47105. CLEARCOAT_TINT_TEXTURE: boolean;
  47106. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  47107. ANISOTROPIC: boolean;
  47108. ANISOTROPIC_TEXTURE: boolean;
  47109. ANISOTROPIC_TEXTUREDIRECTUV: number;
  47110. BRDF_V_HEIGHT_CORRELATED: boolean;
  47111. MS_BRDF_ENERGY_CONSERVATION: boolean;
  47112. SHEEN: boolean;
  47113. SHEEN_TEXTURE: boolean;
  47114. SHEEN_TEXTUREDIRECTUV: number;
  47115. SHEEN_LINKWITHALBEDO: boolean;
  47116. SUBSURFACE: boolean;
  47117. SS_REFRACTION: boolean;
  47118. SS_TRANSLUCENCY: boolean;
  47119. SS_SCATERRING: boolean;
  47120. SS_THICKNESSANDMASK_TEXTURE: boolean;
  47121. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  47122. SS_REFRACTIONMAP_3D: boolean;
  47123. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  47124. SS_LODINREFRACTIONALPHA: boolean;
  47125. SS_GAMMAREFRACTION: boolean;
  47126. SS_RGBDREFRACTION: boolean;
  47127. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  47128. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  47129. UNLIT: boolean;
  47130. DEBUGMODE: number;
  47131. /**
  47132. * Initializes the PBR Material defines.
  47133. */
  47134. constructor();
  47135. /**
  47136. * Resets the PBR Material defines.
  47137. */
  47138. reset(): void;
  47139. }
  47140. /**
  47141. * The Physically based material base class of BJS.
  47142. *
  47143. * This offers the main features of a standard PBR material.
  47144. * For more information, please refer to the documentation :
  47145. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47146. */
  47147. export abstract class PBRBaseMaterial extends PushMaterial {
  47148. /**
  47149. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47150. */
  47151. static readonly PBRMATERIAL_OPAQUE: number;
  47152. /**
  47153. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47154. */
  47155. static readonly PBRMATERIAL_ALPHATEST: number;
  47156. /**
  47157. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47158. */
  47159. static readonly PBRMATERIAL_ALPHABLEND: number;
  47160. /**
  47161. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47162. * They are also discarded below the alpha cutoff threshold to improve performances.
  47163. */
  47164. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47165. /**
  47166. * Defines the default value of how much AO map is occluding the analytical lights
  47167. * (point spot...).
  47168. */
  47169. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47170. /**
  47171. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  47172. */
  47173. static readonly LIGHTFALLOFF_PHYSICAL: number;
  47174. /**
  47175. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  47176. * to enhance interoperability with other engines.
  47177. */
  47178. static readonly LIGHTFALLOFF_GLTF: number;
  47179. /**
  47180. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  47181. * to enhance interoperability with other materials.
  47182. */
  47183. static readonly LIGHTFALLOFF_STANDARD: number;
  47184. /**
  47185. * Intensity of the direct lights e.g. the four lights available in your scene.
  47186. * This impacts both the direct diffuse and specular highlights.
  47187. */
  47188. protected _directIntensity: number;
  47189. /**
  47190. * Intensity of the emissive part of the material.
  47191. * This helps controlling the emissive effect without modifying the emissive color.
  47192. */
  47193. protected _emissiveIntensity: number;
  47194. /**
  47195. * Intensity of the environment e.g. how much the environment will light the object
  47196. * either through harmonics for rough material or through the refelction for shiny ones.
  47197. */
  47198. protected _environmentIntensity: number;
  47199. /**
  47200. * This is a special control allowing the reduction of the specular highlights coming from the
  47201. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47202. */
  47203. protected _specularIntensity: number;
  47204. /**
  47205. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  47206. */
  47207. private _lightingInfos;
  47208. /**
  47209. * Debug Control allowing disabling the bump map on this material.
  47210. */
  47211. protected _disableBumpMap: boolean;
  47212. /**
  47213. * AKA Diffuse Texture in standard nomenclature.
  47214. */
  47215. protected _albedoTexture: Nullable<BaseTexture>;
  47216. /**
  47217. * AKA Occlusion Texture in other nomenclature.
  47218. */
  47219. protected _ambientTexture: Nullable<BaseTexture>;
  47220. /**
  47221. * AKA Occlusion Texture Intensity in other nomenclature.
  47222. */
  47223. protected _ambientTextureStrength: number;
  47224. /**
  47225. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47226. * 1 means it completely occludes it
  47227. * 0 mean it has no impact
  47228. */
  47229. protected _ambientTextureImpactOnAnalyticalLights: number;
  47230. /**
  47231. * Stores the alpha values in a texture.
  47232. */
  47233. protected _opacityTexture: Nullable<BaseTexture>;
  47234. /**
  47235. * Stores the reflection values in a texture.
  47236. */
  47237. protected _reflectionTexture: Nullable<BaseTexture>;
  47238. /**
  47239. * Stores the emissive values in a texture.
  47240. */
  47241. protected _emissiveTexture: Nullable<BaseTexture>;
  47242. /**
  47243. * AKA Specular texture in other nomenclature.
  47244. */
  47245. protected _reflectivityTexture: Nullable<BaseTexture>;
  47246. /**
  47247. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47248. */
  47249. protected _metallicTexture: Nullable<BaseTexture>;
  47250. /**
  47251. * Specifies the metallic scalar of the metallic/roughness workflow.
  47252. * Can also be used to scale the metalness values of the metallic texture.
  47253. */
  47254. protected _metallic: Nullable<number>;
  47255. /**
  47256. * Specifies the roughness scalar of the metallic/roughness workflow.
  47257. * Can also be used to scale the roughness values of the metallic texture.
  47258. */
  47259. protected _roughness: Nullable<number>;
  47260. /**
  47261. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47262. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47263. */
  47264. protected _microSurfaceTexture: Nullable<BaseTexture>;
  47265. /**
  47266. * Stores surface normal data used to displace a mesh in a texture.
  47267. */
  47268. protected _bumpTexture: Nullable<BaseTexture>;
  47269. /**
  47270. * Stores the pre-calculated light information of a mesh in a texture.
  47271. */
  47272. protected _lightmapTexture: Nullable<BaseTexture>;
  47273. /**
  47274. * The color of a material in ambient lighting.
  47275. */
  47276. protected _ambientColor: Color3;
  47277. /**
  47278. * AKA Diffuse Color in other nomenclature.
  47279. */
  47280. protected _albedoColor: Color3;
  47281. /**
  47282. * AKA Specular Color in other nomenclature.
  47283. */
  47284. protected _reflectivityColor: Color3;
  47285. /**
  47286. * The color applied when light is reflected from a material.
  47287. */
  47288. protected _reflectionColor: Color3;
  47289. /**
  47290. * The color applied when light is emitted from a material.
  47291. */
  47292. protected _emissiveColor: Color3;
  47293. /**
  47294. * AKA Glossiness in other nomenclature.
  47295. */
  47296. protected _microSurface: number;
  47297. /**
  47298. * Specifies that the material will use the light map as a show map.
  47299. */
  47300. protected _useLightmapAsShadowmap: boolean;
  47301. /**
  47302. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47303. * makes the reflect vector face the model (under horizon).
  47304. */
  47305. protected _useHorizonOcclusion: boolean;
  47306. /**
  47307. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47308. * too much the area relying on ambient texture to define their ambient occlusion.
  47309. */
  47310. protected _useRadianceOcclusion: boolean;
  47311. /**
  47312. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47313. */
  47314. protected _useAlphaFromAlbedoTexture: boolean;
  47315. /**
  47316. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  47317. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47318. */
  47319. protected _useSpecularOverAlpha: boolean;
  47320. /**
  47321. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47322. */
  47323. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47324. /**
  47325. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47326. */
  47327. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  47328. /**
  47329. * Specifies if the metallic texture contains the roughness information in its green channel.
  47330. */
  47331. protected _useRoughnessFromMetallicTextureGreen: boolean;
  47332. /**
  47333. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47334. */
  47335. protected _useMetallnessFromMetallicTextureBlue: boolean;
  47336. /**
  47337. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47338. */
  47339. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  47340. /**
  47341. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47342. */
  47343. protected _useAmbientInGrayScale: boolean;
  47344. /**
  47345. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47346. * The material will try to infer what glossiness each pixel should be.
  47347. */
  47348. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  47349. /**
  47350. * Defines the falloff type used in this material.
  47351. * It by default is Physical.
  47352. */
  47353. protected _lightFalloff: number;
  47354. /**
  47355. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47356. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47357. */
  47358. protected _useRadianceOverAlpha: boolean;
  47359. /**
  47360. * Allows using an object space normal map (instead of tangent space).
  47361. */
  47362. protected _useObjectSpaceNormalMap: boolean;
  47363. /**
  47364. * Allows using the bump map in parallax mode.
  47365. */
  47366. protected _useParallax: boolean;
  47367. /**
  47368. * Allows using the bump map in parallax occlusion mode.
  47369. */
  47370. protected _useParallaxOcclusion: boolean;
  47371. /**
  47372. * Controls the scale bias of the parallax mode.
  47373. */
  47374. protected _parallaxScaleBias: number;
  47375. /**
  47376. * If sets to true, disables all the lights affecting the material.
  47377. */
  47378. protected _disableLighting: boolean;
  47379. /**
  47380. * Number of Simultaneous lights allowed on the material.
  47381. */
  47382. protected _maxSimultaneousLights: number;
  47383. /**
  47384. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  47385. */
  47386. protected _invertNormalMapX: boolean;
  47387. /**
  47388. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  47389. */
  47390. protected _invertNormalMapY: boolean;
  47391. /**
  47392. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47393. */
  47394. protected _twoSidedLighting: boolean;
  47395. /**
  47396. * Defines the alpha limits in alpha test mode.
  47397. */
  47398. protected _alphaCutOff: number;
  47399. /**
  47400. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47401. */
  47402. protected _forceAlphaTest: boolean;
  47403. /**
  47404. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47405. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47406. */
  47407. protected _useAlphaFresnel: boolean;
  47408. /**
  47409. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47410. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47411. */
  47412. protected _useLinearAlphaFresnel: boolean;
  47413. /**
  47414. * The transparency mode of the material.
  47415. */
  47416. protected _transparencyMode: Nullable<number>;
  47417. /**
  47418. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  47419. * from cos thetav and roughness:
  47420. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  47421. */
  47422. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  47423. /**
  47424. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47425. */
  47426. protected _forceIrradianceInFragment: boolean;
  47427. /**
  47428. * Force normal to face away from face.
  47429. */
  47430. protected _forceNormalForward: boolean;
  47431. /**
  47432. * Enables specular anti aliasing in the PBR shader.
  47433. * It will both interacts on the Geometry for analytical and IBL lighting.
  47434. * It also prefilter the roughness map based on the bump values.
  47435. */
  47436. protected _enableSpecularAntiAliasing: boolean;
  47437. /**
  47438. * Default configuration related to image processing available in the PBR Material.
  47439. */
  47440. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47441. /**
  47442. * Keep track of the image processing observer to allow dispose and replace.
  47443. */
  47444. private _imageProcessingObserver;
  47445. /**
  47446. * Attaches a new image processing configuration to the PBR Material.
  47447. * @param configuration
  47448. */
  47449. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47450. /**
  47451. * Stores the available render targets.
  47452. */
  47453. private _renderTargets;
  47454. /**
  47455. * Sets the global ambient color for the material used in lighting calculations.
  47456. */
  47457. private _globalAmbientColor;
  47458. /**
  47459. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  47460. */
  47461. private _useLogarithmicDepth;
  47462. /**
  47463. * If set to true, no lighting calculations will be applied.
  47464. */
  47465. private _unlit;
  47466. private _debugMode;
  47467. /**
  47468. * @hidden
  47469. * This is reserved for the inspector.
  47470. * Defines the material debug mode.
  47471. * It helps seeing only some components of the material while troubleshooting.
  47472. */
  47473. debugMode: number;
  47474. /**
  47475. * @hidden
  47476. * This is reserved for the inspector.
  47477. * Specify from where on screen the debug mode should start.
  47478. * The value goes from -1 (full screen) to 1 (not visible)
  47479. * It helps with side by side comparison against the final render
  47480. * This defaults to -1
  47481. */
  47482. private debugLimit;
  47483. /**
  47484. * @hidden
  47485. * This is reserved for the inspector.
  47486. * As the default viewing range might not be enough (if the ambient is really small for instance)
  47487. * You can use the factor to better multiply the final value.
  47488. */
  47489. private debugFactor;
  47490. /**
  47491. * Defines the clear coat layer parameters for the material.
  47492. */
  47493. readonly clearCoat: PBRClearCoatConfiguration;
  47494. /**
  47495. * Defines the anisotropic parameters for the material.
  47496. */
  47497. readonly anisotropy: PBRAnisotropicConfiguration;
  47498. /**
  47499. * Defines the BRDF parameters for the material.
  47500. */
  47501. readonly brdf: PBRBRDFConfiguration;
  47502. /**
  47503. * Defines the Sheen parameters for the material.
  47504. */
  47505. readonly sheen: PBRSheenConfiguration;
  47506. /**
  47507. * Defines the SubSurface parameters for the material.
  47508. */
  47509. readonly subSurface: PBRSubSurfaceConfiguration;
  47510. /**
  47511. * Custom callback helping to override the default shader used in the material.
  47512. */
  47513. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  47514. /**
  47515. * Instantiates a new PBRMaterial instance.
  47516. *
  47517. * @param name The material name
  47518. * @param scene The scene the material will be use in.
  47519. */
  47520. constructor(name: string, scene: Scene);
  47521. /**
  47522. * Gets a boolean indicating that current material needs to register RTT
  47523. */
  47524. readonly hasRenderTargetTextures: boolean;
  47525. /**
  47526. * Gets the name of the material class.
  47527. */
  47528. getClassName(): string;
  47529. /**
  47530. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47531. */
  47532. /**
  47533. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  47534. */
  47535. useLogarithmicDepth: boolean;
  47536. /**
  47537. * Gets the current transparency mode.
  47538. */
  47539. /**
  47540. * Sets the transparency mode of the material.
  47541. *
  47542. * | Value | Type | Description |
  47543. * | ----- | ----------------------------------- | ----------- |
  47544. * | 0 | OPAQUE | |
  47545. * | 1 | ALPHATEST | |
  47546. * | 2 | ALPHABLEND | |
  47547. * | 3 | ALPHATESTANDBLEND | |
  47548. *
  47549. */
  47550. transparencyMode: Nullable<number>;
  47551. /**
  47552. * Returns true if alpha blending should be disabled.
  47553. */
  47554. private readonly _disableAlphaBlending;
  47555. /**
  47556. * Specifies whether or not this material should be rendered in alpha blend mode.
  47557. */
  47558. needAlphaBlending(): boolean;
  47559. /**
  47560. * Specifies if the mesh will require alpha blending.
  47561. * @param mesh - BJS mesh.
  47562. */
  47563. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  47564. /**
  47565. * Specifies whether or not this material should be rendered in alpha test mode.
  47566. */
  47567. needAlphaTesting(): boolean;
  47568. /**
  47569. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47570. */
  47571. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47572. /**
  47573. * Gets the texture used for the alpha test.
  47574. */
  47575. getAlphaTestTexture(): Nullable<BaseTexture>;
  47576. /**
  47577. * Specifies that the submesh is ready to be used.
  47578. * @param mesh - BJS mesh.
  47579. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47580. * @param useInstances - Specifies that instances should be used.
  47581. * @returns - boolean indicating that the submesh is ready or not.
  47582. */
  47583. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47584. /**
  47585. * Specifies if the material uses metallic roughness workflow.
  47586. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47587. */
  47588. isMetallicWorkflow(): boolean;
  47589. private _prepareEffect;
  47590. private _prepareDefines;
  47591. /**
  47592. * Force shader compilation
  47593. */
  47594. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47595. clipPlane: boolean;
  47596. }>): void;
  47597. /**
  47598. * Initializes the uniform buffer layout for the shader.
  47599. */
  47600. buildUniformLayout(): void;
  47601. /**
  47602. * Unbinds the material from the mesh
  47603. */
  47604. unbind(): void;
  47605. /**
  47606. * Binds the submesh data.
  47607. * @param world - The world matrix.
  47608. * @param mesh - The BJS mesh.
  47609. * @param subMesh - A submesh of the BJS mesh.
  47610. */
  47611. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47612. /**
  47613. * Returns the animatable textures.
  47614. * @returns - Array of animatable textures.
  47615. */
  47616. getAnimatables(): IAnimatable[];
  47617. /**
  47618. * Returns the texture used for reflections.
  47619. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47620. */
  47621. private _getReflectionTexture;
  47622. /**
  47623. * Returns an array of the actively used textures.
  47624. * @returns - Array of BaseTextures
  47625. */
  47626. getActiveTextures(): BaseTexture[];
  47627. /**
  47628. * Checks to see if a texture is used in the material.
  47629. * @param texture - Base texture to use.
  47630. * @returns - Boolean specifying if a texture is used in the material.
  47631. */
  47632. hasTexture(texture: BaseTexture): boolean;
  47633. /**
  47634. * Disposes the resources of the material.
  47635. * @param forceDisposeEffect - Forces the disposal of effects.
  47636. * @param forceDisposeTextures - Forces the disposal of all textures.
  47637. */
  47638. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47639. }
  47640. }
  47641. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47642. import { Nullable } from "babylonjs/types";
  47643. import { Scene } from "babylonjs/scene";
  47644. import { Color3 } from "babylonjs/Maths/math";
  47645. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47646. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47647. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47648. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47649. /**
  47650. * The Physically based material of BJS.
  47651. *
  47652. * This offers the main features of a standard PBR material.
  47653. * For more information, please refer to the documentation :
  47654. * https://doc.babylonjs.com/how_to/physically_based_rendering
  47655. */
  47656. export class PBRMaterial extends PBRBaseMaterial {
  47657. /**
  47658. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47659. */
  47660. static readonly PBRMATERIAL_OPAQUE: number;
  47661. /**
  47662. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47663. */
  47664. static readonly PBRMATERIAL_ALPHATEST: number;
  47665. /**
  47666. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47667. */
  47668. static readonly PBRMATERIAL_ALPHABLEND: number;
  47669. /**
  47670. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47671. * They are also discarded below the alpha cutoff threshold to improve performances.
  47672. */
  47673. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47674. /**
  47675. * Defines the default value of how much AO map is occluding the analytical lights
  47676. * (point spot...).
  47677. */
  47678. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47679. /**
  47680. * Intensity of the direct lights e.g. the four lights available in your scene.
  47681. * This impacts both the direct diffuse and specular highlights.
  47682. */
  47683. directIntensity: number;
  47684. /**
  47685. * Intensity of the emissive part of the material.
  47686. * This helps controlling the emissive effect without modifying the emissive color.
  47687. */
  47688. emissiveIntensity: number;
  47689. /**
  47690. * Intensity of the environment e.g. how much the environment will light the object
  47691. * either through harmonics for rough material or through the refelction for shiny ones.
  47692. */
  47693. environmentIntensity: number;
  47694. /**
  47695. * This is a special control allowing the reduction of the specular highlights coming from the
  47696. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47697. */
  47698. specularIntensity: number;
  47699. /**
  47700. * Debug Control allowing disabling the bump map on this material.
  47701. */
  47702. disableBumpMap: boolean;
  47703. /**
  47704. * AKA Diffuse Texture in standard nomenclature.
  47705. */
  47706. albedoTexture: BaseTexture;
  47707. /**
  47708. * AKA Occlusion Texture in other nomenclature.
  47709. */
  47710. ambientTexture: BaseTexture;
  47711. /**
  47712. * AKA Occlusion Texture Intensity in other nomenclature.
  47713. */
  47714. ambientTextureStrength: number;
  47715. /**
  47716. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47717. * 1 means it completely occludes it
  47718. * 0 mean it has no impact
  47719. */
  47720. ambientTextureImpactOnAnalyticalLights: number;
  47721. /**
  47722. * Stores the alpha values in a texture.
  47723. */
  47724. opacityTexture: BaseTexture;
  47725. /**
  47726. * Stores the reflection values in a texture.
  47727. */
  47728. reflectionTexture: Nullable<BaseTexture>;
  47729. /**
  47730. * Stores the emissive values in a texture.
  47731. */
  47732. emissiveTexture: BaseTexture;
  47733. /**
  47734. * AKA Specular texture in other nomenclature.
  47735. */
  47736. reflectivityTexture: BaseTexture;
  47737. /**
  47738. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47739. */
  47740. metallicTexture: BaseTexture;
  47741. /**
  47742. * Specifies the metallic scalar of the metallic/roughness workflow.
  47743. * Can also be used to scale the metalness values of the metallic texture.
  47744. */
  47745. metallic: Nullable<number>;
  47746. /**
  47747. * Specifies the roughness scalar of the metallic/roughness workflow.
  47748. * Can also be used to scale the roughness values of the metallic texture.
  47749. */
  47750. roughness: Nullable<number>;
  47751. /**
  47752. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47753. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47754. */
  47755. microSurfaceTexture: BaseTexture;
  47756. /**
  47757. * Stores surface normal data used to displace a mesh in a texture.
  47758. */
  47759. bumpTexture: BaseTexture;
  47760. /**
  47761. * Stores the pre-calculated light information of a mesh in a texture.
  47762. */
  47763. lightmapTexture: BaseTexture;
  47764. /**
  47765. * Stores the refracted light information in a texture.
  47766. */
  47767. refractionTexture: Nullable<BaseTexture>;
  47768. /**
  47769. * The color of a material in ambient lighting.
  47770. */
  47771. ambientColor: Color3;
  47772. /**
  47773. * AKA Diffuse Color in other nomenclature.
  47774. */
  47775. albedoColor: Color3;
  47776. /**
  47777. * AKA Specular Color in other nomenclature.
  47778. */
  47779. reflectivityColor: Color3;
  47780. /**
  47781. * The color reflected from the material.
  47782. */
  47783. reflectionColor: Color3;
  47784. /**
  47785. * The color emitted from the material.
  47786. */
  47787. emissiveColor: Color3;
  47788. /**
  47789. * AKA Glossiness in other nomenclature.
  47790. */
  47791. microSurface: number;
  47792. /**
  47793. * source material index of refraction (IOR)' / 'destination material IOR.
  47794. */
  47795. indexOfRefraction: number;
  47796. /**
  47797. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47798. */
  47799. invertRefractionY: boolean;
  47800. /**
  47801. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47802. * Materials half opaque for instance using refraction could benefit from this control.
  47803. */
  47804. linkRefractionWithTransparency: boolean;
  47805. /**
  47806. * If true, the light map contains occlusion information instead of lighting info.
  47807. */
  47808. useLightmapAsShadowmap: boolean;
  47809. /**
  47810. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47811. */
  47812. useAlphaFromAlbedoTexture: boolean;
  47813. /**
  47814. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47815. */
  47816. forceAlphaTest: boolean;
  47817. /**
  47818. * Defines the alpha limits in alpha test mode.
  47819. */
  47820. alphaCutOff: number;
  47821. /**
  47822. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47823. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47824. */
  47825. useSpecularOverAlpha: boolean;
  47826. /**
  47827. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47828. */
  47829. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47830. /**
  47831. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47832. */
  47833. useRoughnessFromMetallicTextureAlpha: boolean;
  47834. /**
  47835. * Specifies if the metallic texture contains the roughness information in its green channel.
  47836. */
  47837. useRoughnessFromMetallicTextureGreen: boolean;
  47838. /**
  47839. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47840. */
  47841. useMetallnessFromMetallicTextureBlue: boolean;
  47842. /**
  47843. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47844. */
  47845. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47846. /**
  47847. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47848. */
  47849. useAmbientInGrayScale: boolean;
  47850. /**
  47851. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47852. * The material will try to infer what glossiness each pixel should be.
  47853. */
  47854. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47855. /**
  47856. * BJS is using an harcoded light falloff based on a manually sets up range.
  47857. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47858. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47859. */
  47860. /**
  47861. * BJS is using an harcoded light falloff based on a manually sets up range.
  47862. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47863. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47864. */
  47865. usePhysicalLightFalloff: boolean;
  47866. /**
  47867. * In order to support the falloff compatibility with gltf, a special mode has been added
  47868. * to reproduce the gltf light falloff.
  47869. */
  47870. /**
  47871. * In order to support the falloff compatibility with gltf, a special mode has been added
  47872. * to reproduce the gltf light falloff.
  47873. */
  47874. useGLTFLightFalloff: boolean;
  47875. /**
  47876. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47877. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47878. */
  47879. useRadianceOverAlpha: boolean;
  47880. /**
  47881. * Allows using an object space normal map (instead of tangent space).
  47882. */
  47883. useObjectSpaceNormalMap: boolean;
  47884. /**
  47885. * Allows using the bump map in parallax mode.
  47886. */
  47887. useParallax: boolean;
  47888. /**
  47889. * Allows using the bump map in parallax occlusion mode.
  47890. */
  47891. useParallaxOcclusion: boolean;
  47892. /**
  47893. * Controls the scale bias of the parallax mode.
  47894. */
  47895. parallaxScaleBias: number;
  47896. /**
  47897. * If sets to true, disables all the lights affecting the material.
  47898. */
  47899. disableLighting: boolean;
  47900. /**
  47901. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47902. */
  47903. forceIrradianceInFragment: boolean;
  47904. /**
  47905. * Number of Simultaneous lights allowed on the material.
  47906. */
  47907. maxSimultaneousLights: number;
  47908. /**
  47909. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47910. */
  47911. invertNormalMapX: boolean;
  47912. /**
  47913. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47914. */
  47915. invertNormalMapY: boolean;
  47916. /**
  47917. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47918. */
  47919. twoSidedLighting: boolean;
  47920. /**
  47921. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47922. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47923. */
  47924. useAlphaFresnel: boolean;
  47925. /**
  47926. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47927. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47928. */
  47929. useLinearAlphaFresnel: boolean;
  47930. /**
  47931. * Let user defines the brdf lookup texture used for IBL.
  47932. * A default 8bit version is embedded but you could point at :
  47933. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47934. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47935. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47936. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47937. */
  47938. environmentBRDFTexture: Nullable<BaseTexture>;
  47939. /**
  47940. * Force normal to face away from face.
  47941. */
  47942. forceNormalForward: boolean;
  47943. /**
  47944. * Enables specular anti aliasing in the PBR shader.
  47945. * It will both interacts on the Geometry for analytical and IBL lighting.
  47946. * It also prefilter the roughness map based on the bump values.
  47947. */
  47948. enableSpecularAntiAliasing: boolean;
  47949. /**
  47950. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47951. * makes the reflect vector face the model (under horizon).
  47952. */
  47953. useHorizonOcclusion: boolean;
  47954. /**
  47955. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47956. * too much the area relying on ambient texture to define their ambient occlusion.
  47957. */
  47958. useRadianceOcclusion: boolean;
  47959. /**
  47960. * If set to true, no lighting calculations will be applied.
  47961. */
  47962. unlit: boolean;
  47963. /**
  47964. * Gets the image processing configuration used either in this material.
  47965. */
  47966. /**
  47967. * Sets the Default image processing configuration used either in the this material.
  47968. *
  47969. * If sets to null, the scene one is in use.
  47970. */
  47971. imageProcessingConfiguration: ImageProcessingConfiguration;
  47972. /**
  47973. * Gets wether the color curves effect is enabled.
  47974. */
  47975. /**
  47976. * Sets wether the color curves effect is enabled.
  47977. */
  47978. cameraColorCurvesEnabled: boolean;
  47979. /**
  47980. * Gets wether the color grading effect is enabled.
  47981. */
  47982. /**
  47983. * Gets wether the color grading effect is enabled.
  47984. */
  47985. cameraColorGradingEnabled: boolean;
  47986. /**
  47987. * Gets wether tonemapping is enabled or not.
  47988. */
  47989. /**
  47990. * Sets wether tonemapping is enabled or not
  47991. */
  47992. cameraToneMappingEnabled: boolean;
  47993. /**
  47994. * The camera exposure used on this material.
  47995. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47996. * This corresponds to a photographic exposure.
  47997. */
  47998. /**
  47999. * The camera exposure used on this material.
  48000. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  48001. * This corresponds to a photographic exposure.
  48002. */
  48003. cameraExposure: number;
  48004. /**
  48005. * Gets The camera contrast used on this material.
  48006. */
  48007. /**
  48008. * Sets The camera contrast used on this material.
  48009. */
  48010. cameraContrast: number;
  48011. /**
  48012. * Gets the Color Grading 2D Lookup Texture.
  48013. */
  48014. /**
  48015. * Sets the Color Grading 2D Lookup Texture.
  48016. */
  48017. cameraColorGradingTexture: Nullable<BaseTexture>;
  48018. /**
  48019. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48020. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48021. * 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;
  48022. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48023. */
  48024. /**
  48025. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  48026. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  48027. * 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;
  48028. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  48029. */
  48030. cameraColorCurves: Nullable<ColorCurves>;
  48031. /**
  48032. * Instantiates a new PBRMaterial instance.
  48033. *
  48034. * @param name The material name
  48035. * @param scene The scene the material will be use in.
  48036. */
  48037. constructor(name: string, scene: Scene);
  48038. /**
  48039. * Returns the name of this material class.
  48040. */
  48041. getClassName(): string;
  48042. /**
  48043. * Makes a duplicate of the current material.
  48044. * @param name - name to use for the new material.
  48045. */
  48046. clone(name: string): PBRMaterial;
  48047. /**
  48048. * Serializes this PBR Material.
  48049. * @returns - An object with the serialized material.
  48050. */
  48051. serialize(): any;
  48052. /**
  48053. * Parses a PBR Material from a serialized object.
  48054. * @param source - Serialized object.
  48055. * @param scene - BJS scene instance.
  48056. * @param rootUrl - url for the scene object
  48057. * @returns - PBRMaterial
  48058. */
  48059. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  48060. }
  48061. }
  48062. declare module "babylonjs/Misc/dds" {
  48063. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48064. import { Engine } from "babylonjs/Engines/engine";
  48065. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48066. import { Nullable } from "babylonjs/types";
  48067. import { Scene } from "babylonjs/scene";
  48068. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  48069. /**
  48070. * Direct draw surface info
  48071. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  48072. */
  48073. export interface DDSInfo {
  48074. /**
  48075. * Width of the texture
  48076. */
  48077. width: number;
  48078. /**
  48079. * Width of the texture
  48080. */
  48081. height: number;
  48082. /**
  48083. * Number of Mipmaps for the texture
  48084. * @see https://en.wikipedia.org/wiki/Mipmap
  48085. */
  48086. mipmapCount: number;
  48087. /**
  48088. * If the textures format is a known fourCC format
  48089. * @see https://www.fourcc.org/
  48090. */
  48091. isFourCC: boolean;
  48092. /**
  48093. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  48094. */
  48095. isRGB: boolean;
  48096. /**
  48097. * If the texture is a lumincance format
  48098. */
  48099. isLuminance: boolean;
  48100. /**
  48101. * If this is a cube texture
  48102. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  48103. */
  48104. isCube: boolean;
  48105. /**
  48106. * If the texture is a compressed format eg. FOURCC_DXT1
  48107. */
  48108. isCompressed: boolean;
  48109. /**
  48110. * The dxgiFormat of the texture
  48111. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  48112. */
  48113. dxgiFormat: number;
  48114. /**
  48115. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  48116. */
  48117. textureType: number;
  48118. /**
  48119. * Sphericle polynomial created for the dds texture
  48120. */
  48121. sphericalPolynomial?: SphericalPolynomial;
  48122. }
  48123. /**
  48124. * Class used to provide DDS decompression tools
  48125. */
  48126. export class DDSTools {
  48127. /**
  48128. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  48129. */
  48130. static StoreLODInAlphaChannel: boolean;
  48131. /**
  48132. * Gets DDS information from an array buffer
  48133. * @param arrayBuffer defines the array buffer to read data from
  48134. * @returns the DDS information
  48135. */
  48136. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  48137. private static _FloatView;
  48138. private static _Int32View;
  48139. private static _ToHalfFloat;
  48140. private static _FromHalfFloat;
  48141. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  48142. private static _GetHalfFloatRGBAArrayBuffer;
  48143. private static _GetFloatRGBAArrayBuffer;
  48144. private static _GetFloatAsUIntRGBAArrayBuffer;
  48145. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  48146. private static _GetRGBAArrayBuffer;
  48147. private static _ExtractLongWordOrder;
  48148. private static _GetRGBArrayBuffer;
  48149. private static _GetLuminanceArrayBuffer;
  48150. /**
  48151. * Uploads DDS Levels to a Babylon Texture
  48152. * @hidden
  48153. */
  48154. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  48155. }
  48156. module "babylonjs/Engines/engine" {
  48157. interface Engine {
  48158. /**
  48159. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  48160. * @param rootUrl defines the url where the file to load is located
  48161. * @param scene defines the current scene
  48162. * @param lodScale defines scale to apply to the mip map selection
  48163. * @param lodOffset defines offset to apply to the mip map selection
  48164. * @param onLoad defines an optional callback raised when the texture is loaded
  48165. * @param onError defines an optional callback raised if there is an issue to load the texture
  48166. * @param format defines the format of the data
  48167. * @param forcedExtension defines the extension to use to pick the right loader
  48168. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  48169. * @returns the cube texture as an InternalTexture
  48170. */
  48171. 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;
  48172. }
  48173. }
  48174. }
  48175. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  48176. import { Nullable } from "babylonjs/types";
  48177. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48178. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48179. /**
  48180. * Implementation of the DDS Texture Loader.
  48181. * @hidden
  48182. */
  48183. export class _DDSTextureLoader implements IInternalTextureLoader {
  48184. /**
  48185. * Defines wether the loader supports cascade loading the different faces.
  48186. */
  48187. readonly supportCascades: boolean;
  48188. /**
  48189. * This returns if the loader support the current file information.
  48190. * @param extension defines the file extension of the file being loaded
  48191. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48192. * @param fallback defines the fallback internal texture if any
  48193. * @param isBase64 defines whether the texture is encoded as a base64
  48194. * @param isBuffer defines whether the texture data are stored as a buffer
  48195. * @returns true if the loader can load the specified file
  48196. */
  48197. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48198. /**
  48199. * Transform the url before loading if required.
  48200. * @param rootUrl the url of the texture
  48201. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48202. * @returns the transformed texture
  48203. */
  48204. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48205. /**
  48206. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48207. * @param rootUrl the url of the texture
  48208. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48209. * @returns the fallback texture
  48210. */
  48211. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48212. /**
  48213. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48214. * @param data contains the texture data
  48215. * @param texture defines the BabylonJS internal texture
  48216. * @param createPolynomials will be true if polynomials have been requested
  48217. * @param onLoad defines the callback to trigger once the texture is ready
  48218. * @param onError defines the callback to trigger in case of error
  48219. */
  48220. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48221. /**
  48222. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48223. * @param data contains the texture data
  48224. * @param texture defines the BabylonJS internal texture
  48225. * @param callback defines the method to call once ready to upload
  48226. */
  48227. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48228. }
  48229. }
  48230. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  48231. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  48232. /** @hidden */
  48233. export var rgbdEncodePixelShader: {
  48234. name: string;
  48235. shader: string;
  48236. };
  48237. }
  48238. declare module "babylonjs/Misc/environmentTextureTools" {
  48239. import { Nullable } from "babylonjs/types";
  48240. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  48241. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48242. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  48243. import "babylonjs/Engines/Extensions/engine.renderTarget";
  48244. import "babylonjs/Shaders/rgbdEncode.fragment";
  48245. import "babylonjs/Shaders/rgbdDecode.fragment";
  48246. /**
  48247. * Raw texture data and descriptor sufficient for WebGL texture upload
  48248. */
  48249. export interface EnvironmentTextureInfo {
  48250. /**
  48251. * Version of the environment map
  48252. */
  48253. version: number;
  48254. /**
  48255. * Width of image
  48256. */
  48257. width: number;
  48258. /**
  48259. * Irradiance information stored in the file.
  48260. */
  48261. irradiance: any;
  48262. /**
  48263. * Specular information stored in the file.
  48264. */
  48265. specular: any;
  48266. }
  48267. /**
  48268. * Sets of helpers addressing the serialization and deserialization of environment texture
  48269. * stored in a BabylonJS env file.
  48270. * Those files are usually stored as .env files.
  48271. */
  48272. export class EnvironmentTextureTools {
  48273. /**
  48274. * Magic number identifying the env file.
  48275. */
  48276. private static _MagicBytes;
  48277. /**
  48278. * Gets the environment info from an env file.
  48279. * @param data The array buffer containing the .env bytes.
  48280. * @returns the environment file info (the json header) if successfully parsed.
  48281. */
  48282. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  48283. /**
  48284. * Creates an environment texture from a loaded cube texture.
  48285. * @param texture defines the cube texture to convert in env file
  48286. * @return a promise containing the environment data if succesfull.
  48287. */
  48288. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  48289. /**
  48290. * Creates a JSON representation of the spherical data.
  48291. * @param texture defines the texture containing the polynomials
  48292. * @return the JSON representation of the spherical info
  48293. */
  48294. private static _CreateEnvTextureIrradiance;
  48295. /**
  48296. * Uploads the texture info contained in the env file to the GPU.
  48297. * @param texture defines the internal texture to upload to
  48298. * @param arrayBuffer defines the buffer cotaining the data to load
  48299. * @param info defines the texture info retrieved through the GetEnvInfo method
  48300. * @returns a promise
  48301. */
  48302. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  48303. /**
  48304. * Uploads the levels of image data to the GPU.
  48305. * @param texture defines the internal texture to upload to
  48306. * @param imageData defines the array buffer views of image data [mipmap][face]
  48307. * @returns a promise
  48308. */
  48309. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  48310. /**
  48311. * Uploads spherical polynomials information to the texture.
  48312. * @param texture defines the texture we are trying to upload the information to
  48313. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  48314. */
  48315. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  48316. /** @hidden */
  48317. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  48318. }
  48319. }
  48320. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  48321. import { Nullable } from "babylonjs/types";
  48322. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48323. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48324. /**
  48325. * Implementation of the ENV Texture Loader.
  48326. * @hidden
  48327. */
  48328. export class _ENVTextureLoader implements IInternalTextureLoader {
  48329. /**
  48330. * Defines wether the loader supports cascade loading the different faces.
  48331. */
  48332. readonly supportCascades: boolean;
  48333. /**
  48334. * This returns if the loader support the current file information.
  48335. * @param extension defines the file extension of the file being loaded
  48336. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48337. * @param fallback defines the fallback internal texture if any
  48338. * @param isBase64 defines whether the texture is encoded as a base64
  48339. * @param isBuffer defines whether the texture data are stored as a buffer
  48340. * @returns true if the loader can load the specified file
  48341. */
  48342. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48343. /**
  48344. * Transform the url before loading if required.
  48345. * @param rootUrl the url of the texture
  48346. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48347. * @returns the transformed texture
  48348. */
  48349. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48350. /**
  48351. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48352. * @param rootUrl the url of the texture
  48353. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48354. * @returns the fallback texture
  48355. */
  48356. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48357. /**
  48358. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48359. * @param data contains the texture data
  48360. * @param texture defines the BabylonJS internal texture
  48361. * @param createPolynomials will be true if polynomials have been requested
  48362. * @param onLoad defines the callback to trigger once the texture is ready
  48363. * @param onError defines the callback to trigger in case of error
  48364. */
  48365. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48366. /**
  48367. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48368. * @param data contains the texture data
  48369. * @param texture defines the BabylonJS internal texture
  48370. * @param callback defines the method to call once ready to upload
  48371. */
  48372. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  48373. }
  48374. }
  48375. declare module "babylonjs/Misc/khronosTextureContainer" {
  48376. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48377. /**
  48378. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  48379. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  48380. */
  48381. export class KhronosTextureContainer {
  48382. /** contents of the KTX container file */
  48383. arrayBuffer: any;
  48384. private static HEADER_LEN;
  48385. private static COMPRESSED_2D;
  48386. private static COMPRESSED_3D;
  48387. private static TEX_2D;
  48388. private static TEX_3D;
  48389. /**
  48390. * Gets the openGL type
  48391. */
  48392. glType: number;
  48393. /**
  48394. * Gets the openGL type size
  48395. */
  48396. glTypeSize: number;
  48397. /**
  48398. * Gets the openGL format
  48399. */
  48400. glFormat: number;
  48401. /**
  48402. * Gets the openGL internal format
  48403. */
  48404. glInternalFormat: number;
  48405. /**
  48406. * Gets the base internal format
  48407. */
  48408. glBaseInternalFormat: number;
  48409. /**
  48410. * Gets image width in pixel
  48411. */
  48412. pixelWidth: number;
  48413. /**
  48414. * Gets image height in pixel
  48415. */
  48416. pixelHeight: number;
  48417. /**
  48418. * Gets image depth in pixels
  48419. */
  48420. pixelDepth: number;
  48421. /**
  48422. * Gets the number of array elements
  48423. */
  48424. numberOfArrayElements: number;
  48425. /**
  48426. * Gets the number of faces
  48427. */
  48428. numberOfFaces: number;
  48429. /**
  48430. * Gets the number of mipmap levels
  48431. */
  48432. numberOfMipmapLevels: number;
  48433. /**
  48434. * Gets the bytes of key value data
  48435. */
  48436. bytesOfKeyValueData: number;
  48437. /**
  48438. * Gets the load type
  48439. */
  48440. loadType: number;
  48441. /**
  48442. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  48443. */
  48444. isInvalid: boolean;
  48445. /**
  48446. * Creates a new KhronosTextureContainer
  48447. * @param arrayBuffer contents of the KTX container file
  48448. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  48449. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  48450. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  48451. */
  48452. constructor(
  48453. /** contents of the KTX container file */
  48454. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  48455. /**
  48456. * Uploads KTX content to a Babylon Texture.
  48457. * It is assumed that the texture has already been created & is currently bound
  48458. * @hidden
  48459. */
  48460. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  48461. private _upload2DCompressedLevels;
  48462. }
  48463. }
  48464. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  48465. import { Nullable } from "babylonjs/types";
  48466. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48467. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  48468. /**
  48469. * Implementation of the KTX Texture Loader.
  48470. * @hidden
  48471. */
  48472. export class _KTXTextureLoader implements IInternalTextureLoader {
  48473. /**
  48474. * Defines wether the loader supports cascade loading the different faces.
  48475. */
  48476. readonly supportCascades: boolean;
  48477. /**
  48478. * This returns if the loader support the current file information.
  48479. * @param extension defines the file extension of the file being loaded
  48480. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48481. * @param fallback defines the fallback internal texture if any
  48482. * @param isBase64 defines whether the texture is encoded as a base64
  48483. * @param isBuffer defines whether the texture data are stored as a buffer
  48484. * @returns true if the loader can load the specified file
  48485. */
  48486. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  48487. /**
  48488. * Transform the url before loading if required.
  48489. * @param rootUrl the url of the texture
  48490. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48491. * @returns the transformed texture
  48492. */
  48493. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  48494. /**
  48495. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  48496. * @param rootUrl the url of the texture
  48497. * @param textureFormatInUse defines the current compressed format in use iun the engine
  48498. * @returns the fallback texture
  48499. */
  48500. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  48501. /**
  48502. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  48503. * @param data contains the texture data
  48504. * @param texture defines the BabylonJS internal texture
  48505. * @param createPolynomials will be true if polynomials have been requested
  48506. * @param onLoad defines the callback to trigger once the texture is ready
  48507. * @param onError defines the callback to trigger in case of error
  48508. */
  48509. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  48510. /**
  48511. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  48512. * @param data contains the texture data
  48513. * @param texture defines the BabylonJS internal texture
  48514. * @param callback defines the method to call once ready to upload
  48515. */
  48516. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  48517. }
  48518. }
  48519. declare module "babylonjs/Helpers/sceneHelpers" {
  48520. import { Nullable } from "babylonjs/types";
  48521. import { Mesh } from "babylonjs/Meshes/mesh";
  48522. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48523. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  48524. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  48525. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  48526. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  48527. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  48528. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  48529. import "babylonjs/Meshes/Builders/boxBuilder";
  48530. /** @hidden */
  48531. export var _forceSceneHelpersToBundle: boolean;
  48532. module "babylonjs/scene" {
  48533. interface Scene {
  48534. /**
  48535. * Creates a default light for the scene.
  48536. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  48537. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  48538. */
  48539. createDefaultLight(replace?: boolean): void;
  48540. /**
  48541. * Creates a default camera for the scene.
  48542. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  48543. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48544. * @param replace has default false, when true replaces the active camera in the scene
  48545. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  48546. */
  48547. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48548. /**
  48549. * Creates a default camera and a default light.
  48550. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  48551. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  48552. * @param replace has the default false, when true replaces the active camera/light in the scene
  48553. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  48554. */
  48555. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  48556. /**
  48557. * Creates a new sky box
  48558. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  48559. * @param environmentTexture defines the texture to use as environment texture
  48560. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  48561. * @param scale defines the overall scale of the skybox
  48562. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  48563. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  48564. * @returns a new mesh holding the sky box
  48565. */
  48566. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  48567. /**
  48568. * Creates a new environment
  48569. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48570. * @param options defines the options you can use to configure the environment
  48571. * @returns the new EnvironmentHelper
  48572. */
  48573. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48574. /**
  48575. * Creates a new VREXperienceHelper
  48576. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48577. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48578. * @returns a new VREXperienceHelper
  48579. */
  48580. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48581. /**
  48582. * Creates a new XREXperienceHelper
  48583. * @see http://doc.babylonjs.com/how_to/webxr
  48584. * @returns a promise for a new XREXperienceHelper
  48585. */
  48586. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48587. }
  48588. }
  48589. }
  48590. declare module "babylonjs/Helpers/videoDome" {
  48591. import { Scene } from "babylonjs/scene";
  48592. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48593. import { Mesh } from "babylonjs/Meshes/mesh";
  48594. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48595. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48596. import "babylonjs/Meshes/Builders/sphereBuilder";
  48597. /**
  48598. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48599. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48600. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48601. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48602. */
  48603. export class VideoDome extends TransformNode {
  48604. /**
  48605. * Define the video source as a Monoscopic panoramic 360 video.
  48606. */
  48607. static readonly MODE_MONOSCOPIC: number;
  48608. /**
  48609. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48610. */
  48611. static readonly MODE_TOPBOTTOM: number;
  48612. /**
  48613. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48614. */
  48615. static readonly MODE_SIDEBYSIDE: number;
  48616. private _useDirectMapping;
  48617. /**
  48618. * The video texture being displayed on the sphere
  48619. */
  48620. protected _videoTexture: VideoTexture;
  48621. /**
  48622. * Gets the video texture being displayed on the sphere
  48623. */
  48624. readonly videoTexture: VideoTexture;
  48625. /**
  48626. * The skybox material
  48627. */
  48628. protected _material: BackgroundMaterial;
  48629. /**
  48630. * The surface used for the skybox
  48631. */
  48632. protected _mesh: Mesh;
  48633. /**
  48634. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48635. * Also see the options.resolution property.
  48636. */
  48637. fovMultiplier: number;
  48638. private _videoMode;
  48639. /**
  48640. * Gets or set the current video mode for the video. It can be:
  48641. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48642. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48643. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48644. */
  48645. videoMode: number;
  48646. /**
  48647. * Oberserver used in Stereoscopic VR Mode.
  48648. */
  48649. private _onBeforeCameraRenderObserver;
  48650. /**
  48651. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48652. * @param name Element's name, child elements will append suffixes for their own names.
  48653. * @param urlsOrVideo defines the url(s) or the video element to use
  48654. * @param options An object containing optional or exposed sub element properties
  48655. */
  48656. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48657. resolution?: number;
  48658. clickToPlay?: boolean;
  48659. autoPlay?: boolean;
  48660. loop?: boolean;
  48661. size?: number;
  48662. poster?: string;
  48663. faceForward?: boolean;
  48664. useDirectMapping?: boolean;
  48665. }, scene: Scene);
  48666. private _changeVideoMode;
  48667. /**
  48668. * Releases resources associated with this node.
  48669. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48670. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48671. */
  48672. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48673. }
  48674. }
  48675. declare module "babylonjs/Helpers/index" {
  48676. export * from "babylonjs/Helpers/environmentHelper";
  48677. export * from "babylonjs/Helpers/photoDome";
  48678. export * from "babylonjs/Helpers/sceneHelpers";
  48679. export * from "babylonjs/Helpers/videoDome";
  48680. }
  48681. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48682. import { PerfCounter } from "babylonjs/Misc/tools";
  48683. import { IDisposable } from "babylonjs/scene";
  48684. import { Engine } from "babylonjs/Engines/engine";
  48685. /**
  48686. * This class can be used to get instrumentation data from a Babylon engine
  48687. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48688. */
  48689. export class EngineInstrumentation implements IDisposable {
  48690. /**
  48691. * Define the instrumented engine.
  48692. */
  48693. engine: Engine;
  48694. private _captureGPUFrameTime;
  48695. private _gpuFrameTimeToken;
  48696. private _gpuFrameTime;
  48697. private _captureShaderCompilationTime;
  48698. private _shaderCompilationTime;
  48699. private _onBeginFrameObserver;
  48700. private _onEndFrameObserver;
  48701. private _onBeforeShaderCompilationObserver;
  48702. private _onAfterShaderCompilationObserver;
  48703. /**
  48704. * Gets the perf counter used for GPU frame time
  48705. */
  48706. readonly gpuFrameTimeCounter: PerfCounter;
  48707. /**
  48708. * Gets the GPU frame time capture status
  48709. */
  48710. /**
  48711. * Enable or disable the GPU frame time capture
  48712. */
  48713. captureGPUFrameTime: boolean;
  48714. /**
  48715. * Gets the perf counter used for shader compilation time
  48716. */
  48717. readonly shaderCompilationTimeCounter: PerfCounter;
  48718. /**
  48719. * Gets the shader compilation time capture status
  48720. */
  48721. /**
  48722. * Enable or disable the shader compilation time capture
  48723. */
  48724. captureShaderCompilationTime: boolean;
  48725. /**
  48726. * Instantiates a new engine instrumentation.
  48727. * This class can be used to get instrumentation data from a Babylon engine
  48728. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48729. * @param engine Defines the engine to instrument
  48730. */
  48731. constructor(
  48732. /**
  48733. * Define the instrumented engine.
  48734. */
  48735. engine: Engine);
  48736. /**
  48737. * Dispose and release associated resources.
  48738. */
  48739. dispose(): void;
  48740. }
  48741. }
  48742. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48743. import { PerfCounter } from "babylonjs/Misc/tools";
  48744. import { Scene, IDisposable } from "babylonjs/scene";
  48745. /**
  48746. * This class can be used to get instrumentation data from a Babylon engine
  48747. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48748. */
  48749. export class SceneInstrumentation implements IDisposable {
  48750. /**
  48751. * Defines the scene to instrument
  48752. */
  48753. scene: Scene;
  48754. private _captureActiveMeshesEvaluationTime;
  48755. private _activeMeshesEvaluationTime;
  48756. private _captureRenderTargetsRenderTime;
  48757. private _renderTargetsRenderTime;
  48758. private _captureFrameTime;
  48759. private _frameTime;
  48760. private _captureRenderTime;
  48761. private _renderTime;
  48762. private _captureInterFrameTime;
  48763. private _interFrameTime;
  48764. private _captureParticlesRenderTime;
  48765. private _particlesRenderTime;
  48766. private _captureSpritesRenderTime;
  48767. private _spritesRenderTime;
  48768. private _capturePhysicsTime;
  48769. private _physicsTime;
  48770. private _captureAnimationsTime;
  48771. private _animationsTime;
  48772. private _captureCameraRenderTime;
  48773. private _cameraRenderTime;
  48774. private _onBeforeActiveMeshesEvaluationObserver;
  48775. private _onAfterActiveMeshesEvaluationObserver;
  48776. private _onBeforeRenderTargetsRenderObserver;
  48777. private _onAfterRenderTargetsRenderObserver;
  48778. private _onAfterRenderObserver;
  48779. private _onBeforeDrawPhaseObserver;
  48780. private _onAfterDrawPhaseObserver;
  48781. private _onBeforeAnimationsObserver;
  48782. private _onBeforeParticlesRenderingObserver;
  48783. private _onAfterParticlesRenderingObserver;
  48784. private _onBeforeSpritesRenderingObserver;
  48785. private _onAfterSpritesRenderingObserver;
  48786. private _onBeforePhysicsObserver;
  48787. private _onAfterPhysicsObserver;
  48788. private _onAfterAnimationsObserver;
  48789. private _onBeforeCameraRenderObserver;
  48790. private _onAfterCameraRenderObserver;
  48791. /**
  48792. * Gets the perf counter used for active meshes evaluation time
  48793. */
  48794. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48795. /**
  48796. * Gets the active meshes evaluation time capture status
  48797. */
  48798. /**
  48799. * Enable or disable the active meshes evaluation time capture
  48800. */
  48801. captureActiveMeshesEvaluationTime: boolean;
  48802. /**
  48803. * Gets the perf counter used for render targets render time
  48804. */
  48805. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48806. /**
  48807. * Gets the render targets render time capture status
  48808. */
  48809. /**
  48810. * Enable or disable the render targets render time capture
  48811. */
  48812. captureRenderTargetsRenderTime: boolean;
  48813. /**
  48814. * Gets the perf counter used for particles render time
  48815. */
  48816. readonly particlesRenderTimeCounter: PerfCounter;
  48817. /**
  48818. * Gets the particles render time capture status
  48819. */
  48820. /**
  48821. * Enable or disable the particles render time capture
  48822. */
  48823. captureParticlesRenderTime: boolean;
  48824. /**
  48825. * Gets the perf counter used for sprites render time
  48826. */
  48827. readonly spritesRenderTimeCounter: PerfCounter;
  48828. /**
  48829. * Gets the sprites render time capture status
  48830. */
  48831. /**
  48832. * Enable or disable the sprites render time capture
  48833. */
  48834. captureSpritesRenderTime: boolean;
  48835. /**
  48836. * Gets the perf counter used for physics time
  48837. */
  48838. readonly physicsTimeCounter: PerfCounter;
  48839. /**
  48840. * Gets the physics time capture status
  48841. */
  48842. /**
  48843. * Enable or disable the physics time capture
  48844. */
  48845. capturePhysicsTime: boolean;
  48846. /**
  48847. * Gets the perf counter used for animations time
  48848. */
  48849. readonly animationsTimeCounter: PerfCounter;
  48850. /**
  48851. * Gets the animations time capture status
  48852. */
  48853. /**
  48854. * Enable or disable the animations time capture
  48855. */
  48856. captureAnimationsTime: boolean;
  48857. /**
  48858. * Gets the perf counter used for frame time capture
  48859. */
  48860. readonly frameTimeCounter: PerfCounter;
  48861. /**
  48862. * Gets the frame time capture status
  48863. */
  48864. /**
  48865. * Enable or disable the frame time capture
  48866. */
  48867. captureFrameTime: boolean;
  48868. /**
  48869. * Gets the perf counter used for inter-frames time capture
  48870. */
  48871. readonly interFrameTimeCounter: PerfCounter;
  48872. /**
  48873. * Gets the inter-frames time capture status
  48874. */
  48875. /**
  48876. * Enable or disable the inter-frames time capture
  48877. */
  48878. captureInterFrameTime: boolean;
  48879. /**
  48880. * Gets the perf counter used for render time capture
  48881. */
  48882. readonly renderTimeCounter: PerfCounter;
  48883. /**
  48884. * Gets the render time capture status
  48885. */
  48886. /**
  48887. * Enable or disable the render time capture
  48888. */
  48889. captureRenderTime: boolean;
  48890. /**
  48891. * Gets the perf counter used for camera render time capture
  48892. */
  48893. readonly cameraRenderTimeCounter: PerfCounter;
  48894. /**
  48895. * Gets the camera render time capture status
  48896. */
  48897. /**
  48898. * Enable or disable the camera render time capture
  48899. */
  48900. captureCameraRenderTime: boolean;
  48901. /**
  48902. * Gets the perf counter used for draw calls
  48903. */
  48904. readonly drawCallsCounter: PerfCounter;
  48905. /**
  48906. * Instantiates a new scene instrumentation.
  48907. * This class can be used to get instrumentation data from a Babylon engine
  48908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48909. * @param scene Defines the scene to instrument
  48910. */
  48911. constructor(
  48912. /**
  48913. * Defines the scene to instrument
  48914. */
  48915. scene: Scene);
  48916. /**
  48917. * Dispose and release associated resources.
  48918. */
  48919. dispose(): void;
  48920. }
  48921. }
  48922. declare module "babylonjs/Instrumentation/index" {
  48923. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48924. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48925. export * from "babylonjs/Instrumentation/timeToken";
  48926. }
  48927. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48928. /** @hidden */
  48929. export var glowMapGenerationPixelShader: {
  48930. name: string;
  48931. shader: string;
  48932. };
  48933. }
  48934. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48935. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48936. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48937. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48938. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48939. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48940. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48941. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48942. /** @hidden */
  48943. export var glowMapGenerationVertexShader: {
  48944. name: string;
  48945. shader: string;
  48946. };
  48947. }
  48948. declare module "babylonjs/Layers/effectLayer" {
  48949. import { Observable } from "babylonjs/Misc/observable";
  48950. import { Nullable } from "babylonjs/types";
  48951. import { Camera } from "babylonjs/Cameras/camera";
  48952. import { Scene } from "babylonjs/scene";
  48953. import { Color4, ISize } from "babylonjs/Maths/math";
  48954. import { Engine } from "babylonjs/Engines/engine";
  48955. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48957. import { Mesh } from "babylonjs/Meshes/mesh";
  48958. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48959. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48960. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48961. import { Effect } from "babylonjs/Materials/effect";
  48962. import { Material } from "babylonjs/Materials/material";
  48963. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48964. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48965. /**
  48966. * Effect layer options. This helps customizing the behaviour
  48967. * of the effect layer.
  48968. */
  48969. export interface IEffectLayerOptions {
  48970. /**
  48971. * Multiplication factor apply to the canvas size to compute the render target size
  48972. * used to generated the objects (the smaller the faster).
  48973. */
  48974. mainTextureRatio: number;
  48975. /**
  48976. * Enforces a fixed size texture to ensure effect stability across devices.
  48977. */
  48978. mainTextureFixedSize?: number;
  48979. /**
  48980. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48981. */
  48982. alphaBlendingMode: number;
  48983. /**
  48984. * The camera attached to the layer.
  48985. */
  48986. camera: Nullable<Camera>;
  48987. /**
  48988. * The rendering group to draw the layer in.
  48989. */
  48990. renderingGroupId: number;
  48991. }
  48992. /**
  48993. * The effect layer Helps adding post process effect blended with the main pass.
  48994. *
  48995. * This can be for instance use to generate glow or higlight effects on the scene.
  48996. *
  48997. * The effect layer class can not be used directly and is intented to inherited from to be
  48998. * customized per effects.
  48999. */
  49000. export abstract class EffectLayer {
  49001. private _vertexBuffers;
  49002. private _indexBuffer;
  49003. private _cachedDefines;
  49004. private _effectLayerMapGenerationEffect;
  49005. private _effectLayerOptions;
  49006. private _mergeEffect;
  49007. protected _scene: Scene;
  49008. protected _engine: Engine;
  49009. protected _maxSize: number;
  49010. protected _mainTextureDesiredSize: ISize;
  49011. protected _mainTexture: RenderTargetTexture;
  49012. protected _shouldRender: boolean;
  49013. protected _postProcesses: PostProcess[];
  49014. protected _textures: BaseTexture[];
  49015. protected _emissiveTextureAndColor: {
  49016. texture: Nullable<BaseTexture>;
  49017. color: Color4;
  49018. };
  49019. /**
  49020. * The name of the layer
  49021. */
  49022. name: string;
  49023. /**
  49024. * The clear color of the texture used to generate the glow map.
  49025. */
  49026. neutralColor: Color4;
  49027. /**
  49028. * Specifies wether the highlight layer is enabled or not.
  49029. */
  49030. isEnabled: boolean;
  49031. /**
  49032. * Gets the camera attached to the layer.
  49033. */
  49034. readonly camera: Nullable<Camera>;
  49035. /**
  49036. * Gets the rendering group id the layer should render in.
  49037. */
  49038. readonly renderingGroupId: number;
  49039. /**
  49040. * An event triggered when the effect layer has been disposed.
  49041. */
  49042. onDisposeObservable: Observable<EffectLayer>;
  49043. /**
  49044. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  49045. */
  49046. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  49047. /**
  49048. * An event triggered when the generated texture is being merged in the scene.
  49049. */
  49050. onBeforeComposeObservable: Observable<EffectLayer>;
  49051. /**
  49052. * An event triggered when the generated texture has been merged in the scene.
  49053. */
  49054. onAfterComposeObservable: Observable<EffectLayer>;
  49055. /**
  49056. * An event triggered when the efffect layer changes its size.
  49057. */
  49058. onSizeChangedObservable: Observable<EffectLayer>;
  49059. /** @hidden */
  49060. static _SceneComponentInitialization: (scene: Scene) => void;
  49061. /**
  49062. * Instantiates a new effect Layer and references it in the scene.
  49063. * @param name The name of the layer
  49064. * @param scene The scene to use the layer in
  49065. */
  49066. constructor(
  49067. /** The Friendly of the effect in the scene */
  49068. name: string, scene: Scene);
  49069. /**
  49070. * Get the effect name of the layer.
  49071. * @return The effect name
  49072. */
  49073. abstract getEffectName(): string;
  49074. /**
  49075. * Checks for the readiness of the element composing the layer.
  49076. * @param subMesh the mesh to check for
  49077. * @param useInstances specify wether or not to use instances to render the mesh
  49078. * @return true if ready otherwise, false
  49079. */
  49080. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49081. /**
  49082. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49083. * @returns true if the effect requires stencil during the main canvas render pass.
  49084. */
  49085. abstract needStencil(): boolean;
  49086. /**
  49087. * Create the merge effect. This is the shader use to blit the information back
  49088. * to the main canvas at the end of the scene rendering.
  49089. * @returns The effect containing the shader used to merge the effect on the main canvas
  49090. */
  49091. protected abstract _createMergeEffect(): Effect;
  49092. /**
  49093. * Creates the render target textures and post processes used in the effect layer.
  49094. */
  49095. protected abstract _createTextureAndPostProcesses(): void;
  49096. /**
  49097. * Implementation specific of rendering the generating effect on the main canvas.
  49098. * @param effect The effect used to render through
  49099. */
  49100. protected abstract _internalRender(effect: Effect): void;
  49101. /**
  49102. * Sets the required values for both the emissive texture and and the main color.
  49103. */
  49104. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49105. /**
  49106. * Free any resources and references associated to a mesh.
  49107. * Internal use
  49108. * @param mesh The mesh to free.
  49109. */
  49110. abstract _disposeMesh(mesh: Mesh): void;
  49111. /**
  49112. * Serializes this layer (Glow or Highlight for example)
  49113. * @returns a serialized layer object
  49114. */
  49115. abstract serialize?(): any;
  49116. /**
  49117. * Initializes the effect layer with the required options.
  49118. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  49119. */
  49120. protected _init(options: Partial<IEffectLayerOptions>): void;
  49121. /**
  49122. * Generates the index buffer of the full screen quad blending to the main canvas.
  49123. */
  49124. private _generateIndexBuffer;
  49125. /**
  49126. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  49127. */
  49128. private _generateVertexBuffer;
  49129. /**
  49130. * Sets the main texture desired size which is the closest power of two
  49131. * of the engine canvas size.
  49132. */
  49133. private _setMainTextureSize;
  49134. /**
  49135. * Creates the main texture for the effect layer.
  49136. */
  49137. protected _createMainTexture(): void;
  49138. /**
  49139. * Adds specific effects defines.
  49140. * @param defines The defines to add specifics to.
  49141. */
  49142. protected _addCustomEffectDefines(defines: string[]): void;
  49143. /**
  49144. * Checks for the readiness of the element composing the layer.
  49145. * @param subMesh the mesh to check for
  49146. * @param useInstances specify wether or not to use instances to render the mesh
  49147. * @param emissiveTexture the associated emissive texture used to generate the glow
  49148. * @return true if ready otherwise, false
  49149. */
  49150. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  49151. /**
  49152. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  49153. */
  49154. render(): void;
  49155. /**
  49156. * Determine if a given mesh will be used in the current effect.
  49157. * @param mesh mesh to test
  49158. * @returns true if the mesh will be used
  49159. */
  49160. hasMesh(mesh: AbstractMesh): boolean;
  49161. /**
  49162. * Returns true if the layer contains information to display, otherwise false.
  49163. * @returns true if the glow layer should be rendered
  49164. */
  49165. shouldRender(): boolean;
  49166. /**
  49167. * Returns true if the mesh should render, otherwise false.
  49168. * @param mesh The mesh to render
  49169. * @returns true if it should render otherwise false
  49170. */
  49171. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  49172. /**
  49173. * Returns true if the mesh can be rendered, otherwise false.
  49174. * @param mesh The mesh to render
  49175. * @param material The material used on the mesh
  49176. * @returns true if it can be rendered otherwise false
  49177. */
  49178. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49179. /**
  49180. * Returns true if the mesh should render, otherwise false.
  49181. * @param mesh The mesh to render
  49182. * @returns true if it should render otherwise false
  49183. */
  49184. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  49185. /**
  49186. * Renders the submesh passed in parameter to the generation map.
  49187. */
  49188. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  49189. /**
  49190. * Rebuild the required buffers.
  49191. * @hidden Internal use only.
  49192. */
  49193. _rebuild(): void;
  49194. /**
  49195. * Dispose only the render target textures and post process.
  49196. */
  49197. private _disposeTextureAndPostProcesses;
  49198. /**
  49199. * Dispose the highlight layer and free resources.
  49200. */
  49201. dispose(): void;
  49202. /**
  49203. * Gets the class name of the effect layer
  49204. * @returns the string with the class name of the effect layer
  49205. */
  49206. getClassName(): string;
  49207. /**
  49208. * Creates an effect layer from parsed effect layer data
  49209. * @param parsedEffectLayer defines effect layer data
  49210. * @param scene defines the current scene
  49211. * @param rootUrl defines the root URL containing the effect layer information
  49212. * @returns a parsed effect Layer
  49213. */
  49214. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  49215. }
  49216. }
  49217. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  49218. import { Scene } from "babylonjs/scene";
  49219. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49220. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49221. import { AbstractScene } from "babylonjs/abstractScene";
  49222. module "babylonjs/abstractScene" {
  49223. interface AbstractScene {
  49224. /**
  49225. * The list of effect layers (highlights/glow) added to the scene
  49226. * @see http://doc.babylonjs.com/how_to/highlight_layer
  49227. * @see http://doc.babylonjs.com/how_to/glow_layer
  49228. */
  49229. effectLayers: Array<EffectLayer>;
  49230. /**
  49231. * Removes the given effect layer from this scene.
  49232. * @param toRemove defines the effect layer to remove
  49233. * @returns the index of the removed effect layer
  49234. */
  49235. removeEffectLayer(toRemove: EffectLayer): number;
  49236. /**
  49237. * Adds the given effect layer to this scene
  49238. * @param newEffectLayer defines the effect layer to add
  49239. */
  49240. addEffectLayer(newEffectLayer: EffectLayer): void;
  49241. }
  49242. }
  49243. /**
  49244. * Defines the layer scene component responsible to manage any effect layers
  49245. * in a given scene.
  49246. */
  49247. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  49248. /**
  49249. * The component name helpfull to identify the component in the list of scene components.
  49250. */
  49251. readonly name: string;
  49252. /**
  49253. * The scene the component belongs to.
  49254. */
  49255. scene: Scene;
  49256. private _engine;
  49257. private _renderEffects;
  49258. private _needStencil;
  49259. private _previousStencilState;
  49260. /**
  49261. * Creates a new instance of the component for the given scene
  49262. * @param scene Defines the scene to register the component in
  49263. */
  49264. constructor(scene: Scene);
  49265. /**
  49266. * Registers the component in a given scene
  49267. */
  49268. register(): void;
  49269. /**
  49270. * Rebuilds the elements related to this component in case of
  49271. * context lost for instance.
  49272. */
  49273. rebuild(): void;
  49274. /**
  49275. * Serializes the component data to the specified json object
  49276. * @param serializationObject The object to serialize to
  49277. */
  49278. serialize(serializationObject: any): void;
  49279. /**
  49280. * Adds all the elements from the container to the scene
  49281. * @param container the container holding the elements
  49282. */
  49283. addFromContainer(container: AbstractScene): void;
  49284. /**
  49285. * Removes all the elements in the container from the scene
  49286. * @param container contains the elements to remove
  49287. * @param dispose if the removed element should be disposed (default: false)
  49288. */
  49289. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49290. /**
  49291. * Disposes the component and the associated ressources.
  49292. */
  49293. dispose(): void;
  49294. private _isReadyForMesh;
  49295. private _renderMainTexture;
  49296. private _setStencil;
  49297. private _setStencilBack;
  49298. private _draw;
  49299. private _drawCamera;
  49300. private _drawRenderingGroup;
  49301. }
  49302. }
  49303. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  49304. /** @hidden */
  49305. export var glowMapMergePixelShader: {
  49306. name: string;
  49307. shader: string;
  49308. };
  49309. }
  49310. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  49311. /** @hidden */
  49312. export var glowMapMergeVertexShader: {
  49313. name: string;
  49314. shader: string;
  49315. };
  49316. }
  49317. declare module "babylonjs/Layers/glowLayer" {
  49318. import { Nullable } from "babylonjs/types";
  49319. import { Camera } from "babylonjs/Cameras/camera";
  49320. import { Scene } from "babylonjs/scene";
  49321. import { Color4 } from "babylonjs/Maths/math";
  49322. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49323. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49324. import { Mesh } from "babylonjs/Meshes/mesh";
  49325. import { Texture } from "babylonjs/Materials/Textures/texture";
  49326. import { Effect } from "babylonjs/Materials/effect";
  49327. import { Material } from "babylonjs/Materials/material";
  49328. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49329. import "babylonjs/Shaders/glowMapMerge.fragment";
  49330. import "babylonjs/Shaders/glowMapMerge.vertex";
  49331. import "babylonjs/Layers/effectLayerSceneComponent";
  49332. module "babylonjs/abstractScene" {
  49333. interface AbstractScene {
  49334. /**
  49335. * Return a the first highlight layer of the scene with a given name.
  49336. * @param name The name of the highlight layer to look for.
  49337. * @return The highlight layer if found otherwise null.
  49338. */
  49339. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  49340. }
  49341. }
  49342. /**
  49343. * Glow layer options. This helps customizing the behaviour
  49344. * of the glow layer.
  49345. */
  49346. export interface IGlowLayerOptions {
  49347. /**
  49348. * Multiplication factor apply to the canvas size to compute the render target size
  49349. * used to generated the glowing objects (the smaller the faster).
  49350. */
  49351. mainTextureRatio: number;
  49352. /**
  49353. * Enforces a fixed size texture to ensure resize independant blur.
  49354. */
  49355. mainTextureFixedSize?: number;
  49356. /**
  49357. * How big is the kernel of the blur texture.
  49358. */
  49359. blurKernelSize: number;
  49360. /**
  49361. * The camera attached to the layer.
  49362. */
  49363. camera: Nullable<Camera>;
  49364. /**
  49365. * Enable MSAA by chosing the number of samples.
  49366. */
  49367. mainTextureSamples?: number;
  49368. /**
  49369. * The rendering group to draw the layer in.
  49370. */
  49371. renderingGroupId: number;
  49372. }
  49373. /**
  49374. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  49375. *
  49376. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49377. * glowy meshes to your scene.
  49378. *
  49379. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  49380. */
  49381. export class GlowLayer extends EffectLayer {
  49382. /**
  49383. * Effect Name of the layer.
  49384. */
  49385. static readonly EffectName: string;
  49386. /**
  49387. * The default blur kernel size used for the glow.
  49388. */
  49389. static DefaultBlurKernelSize: number;
  49390. /**
  49391. * The default texture size ratio used for the glow.
  49392. */
  49393. static DefaultTextureRatio: number;
  49394. /**
  49395. * Sets the kernel size of the blur.
  49396. */
  49397. /**
  49398. * Gets the kernel size of the blur.
  49399. */
  49400. blurKernelSize: number;
  49401. /**
  49402. * Sets the glow intensity.
  49403. */
  49404. /**
  49405. * Gets the glow intensity.
  49406. */
  49407. intensity: number;
  49408. private _options;
  49409. private _intensity;
  49410. private _horizontalBlurPostprocess1;
  49411. private _verticalBlurPostprocess1;
  49412. private _horizontalBlurPostprocess2;
  49413. private _verticalBlurPostprocess2;
  49414. private _blurTexture1;
  49415. private _blurTexture2;
  49416. private _postProcesses1;
  49417. private _postProcesses2;
  49418. private _includedOnlyMeshes;
  49419. private _excludedMeshes;
  49420. /**
  49421. * Callback used to let the user override the color selection on a per mesh basis
  49422. */
  49423. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  49424. /**
  49425. * Callback used to let the user override the texture selection on a per mesh basis
  49426. */
  49427. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  49428. /**
  49429. * Instantiates a new glow Layer and references it to the scene.
  49430. * @param name The name of the layer
  49431. * @param scene The scene to use the layer in
  49432. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  49433. */
  49434. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  49435. /**
  49436. * Get the effect name of the layer.
  49437. * @return The effect name
  49438. */
  49439. getEffectName(): string;
  49440. /**
  49441. * Create the merge effect. This is the shader use to blit the information back
  49442. * to the main canvas at the end of the scene rendering.
  49443. */
  49444. protected _createMergeEffect(): Effect;
  49445. /**
  49446. * Creates the render target textures and post processes used in the glow layer.
  49447. */
  49448. protected _createTextureAndPostProcesses(): void;
  49449. /**
  49450. * Checks for the readiness of the element composing the layer.
  49451. * @param subMesh the mesh to check for
  49452. * @param useInstances specify wether or not to use instances to render the mesh
  49453. * @param emissiveTexture the associated emissive texture used to generate the glow
  49454. * @return true if ready otherwise, false
  49455. */
  49456. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49457. /**
  49458. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49459. */
  49460. needStencil(): boolean;
  49461. /**
  49462. * Returns true if the mesh can be rendered, otherwise false.
  49463. * @param mesh The mesh to render
  49464. * @param material The material used on the mesh
  49465. * @returns true if it can be rendered otherwise false
  49466. */
  49467. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  49468. /**
  49469. * Implementation specific of rendering the generating effect on the main canvas.
  49470. * @param effect The effect used to render through
  49471. */
  49472. protected _internalRender(effect: Effect): void;
  49473. /**
  49474. * Sets the required values for both the emissive texture and and the main color.
  49475. */
  49476. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49477. /**
  49478. * Returns true if the mesh should render, otherwise false.
  49479. * @param mesh The mesh to render
  49480. * @returns true if it should render otherwise false
  49481. */
  49482. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49483. /**
  49484. * Adds specific effects defines.
  49485. * @param defines The defines to add specifics to.
  49486. */
  49487. protected _addCustomEffectDefines(defines: string[]): void;
  49488. /**
  49489. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  49490. * @param mesh The mesh to exclude from the glow layer
  49491. */
  49492. addExcludedMesh(mesh: Mesh): void;
  49493. /**
  49494. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  49495. * @param mesh The mesh to remove
  49496. */
  49497. removeExcludedMesh(mesh: Mesh): void;
  49498. /**
  49499. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  49500. * @param mesh The mesh to include in the glow layer
  49501. */
  49502. addIncludedOnlyMesh(mesh: Mesh): void;
  49503. /**
  49504. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  49505. * @param mesh The mesh to remove
  49506. */
  49507. removeIncludedOnlyMesh(mesh: Mesh): void;
  49508. /**
  49509. * Determine if a given mesh will be used in the glow layer
  49510. * @param mesh The mesh to test
  49511. * @returns true if the mesh will be highlighted by the current glow layer
  49512. */
  49513. hasMesh(mesh: AbstractMesh): boolean;
  49514. /**
  49515. * Free any resources and references associated to a mesh.
  49516. * Internal use
  49517. * @param mesh The mesh to free.
  49518. * @hidden
  49519. */
  49520. _disposeMesh(mesh: Mesh): void;
  49521. /**
  49522. * Gets the class name of the effect layer
  49523. * @returns the string with the class name of the effect layer
  49524. */
  49525. getClassName(): string;
  49526. /**
  49527. * Serializes this glow layer
  49528. * @returns a serialized glow layer object
  49529. */
  49530. serialize(): any;
  49531. /**
  49532. * Creates a Glow Layer from parsed glow layer data
  49533. * @param parsedGlowLayer defines glow layer data
  49534. * @param scene defines the current scene
  49535. * @param rootUrl defines the root URL containing the glow layer information
  49536. * @returns a parsed Glow Layer
  49537. */
  49538. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  49539. }
  49540. }
  49541. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  49542. /** @hidden */
  49543. export var glowBlurPostProcessPixelShader: {
  49544. name: string;
  49545. shader: string;
  49546. };
  49547. }
  49548. declare module "babylonjs/Layers/highlightLayer" {
  49549. import { Observable } from "babylonjs/Misc/observable";
  49550. import { Nullable } from "babylonjs/types";
  49551. import { Camera } from "babylonjs/Cameras/camera";
  49552. import { Scene } from "babylonjs/scene";
  49553. import { Color3, Color4 } from "babylonjs/Maths/math";
  49554. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49555. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49556. import { Mesh } from "babylonjs/Meshes/mesh";
  49557. import { Effect } from "babylonjs/Materials/effect";
  49558. import { Material } from "babylonjs/Materials/material";
  49559. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  49560. import "babylonjs/Shaders/glowMapMerge.fragment";
  49561. import "babylonjs/Shaders/glowMapMerge.vertex";
  49562. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  49563. module "babylonjs/abstractScene" {
  49564. interface AbstractScene {
  49565. /**
  49566. * Return a the first highlight layer of the scene with a given name.
  49567. * @param name The name of the highlight layer to look for.
  49568. * @return The highlight layer if found otherwise null.
  49569. */
  49570. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49571. }
  49572. }
  49573. /**
  49574. * Highlight layer options. This helps customizing the behaviour
  49575. * of the highlight layer.
  49576. */
  49577. export interface IHighlightLayerOptions {
  49578. /**
  49579. * Multiplication factor apply to the canvas size to compute the render target size
  49580. * used to generated the glowing objects (the smaller the faster).
  49581. */
  49582. mainTextureRatio: number;
  49583. /**
  49584. * Enforces a fixed size texture to ensure resize independant blur.
  49585. */
  49586. mainTextureFixedSize?: number;
  49587. /**
  49588. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49589. * of the picture to blur (the smaller the faster).
  49590. */
  49591. blurTextureSizeRatio: number;
  49592. /**
  49593. * How big in texel of the blur texture is the vertical blur.
  49594. */
  49595. blurVerticalSize: number;
  49596. /**
  49597. * How big in texel of the blur texture is the horizontal blur.
  49598. */
  49599. blurHorizontalSize: number;
  49600. /**
  49601. * Alpha blending mode used to apply the blur. Default is combine.
  49602. */
  49603. alphaBlendingMode: number;
  49604. /**
  49605. * The camera attached to the layer.
  49606. */
  49607. camera: Nullable<Camera>;
  49608. /**
  49609. * Should we display highlight as a solid stroke?
  49610. */
  49611. isStroke?: boolean;
  49612. /**
  49613. * The rendering group to draw the layer in.
  49614. */
  49615. renderingGroupId: number;
  49616. }
  49617. /**
  49618. * The highlight layer Helps adding a glow effect around a mesh.
  49619. *
  49620. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49621. * glowy meshes to your scene.
  49622. *
  49623. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49624. */
  49625. export class HighlightLayer extends EffectLayer {
  49626. name: string;
  49627. /**
  49628. * Effect Name of the highlight layer.
  49629. */
  49630. static readonly EffectName: string;
  49631. /**
  49632. * The neutral color used during the preparation of the glow effect.
  49633. * This is black by default as the blend operation is a blend operation.
  49634. */
  49635. static NeutralColor: Color4;
  49636. /**
  49637. * Stencil value used for glowing meshes.
  49638. */
  49639. static GlowingMeshStencilReference: number;
  49640. /**
  49641. * Stencil value used for the other meshes in the scene.
  49642. */
  49643. static NormalMeshStencilReference: number;
  49644. /**
  49645. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49646. */
  49647. innerGlow: boolean;
  49648. /**
  49649. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49650. */
  49651. outerGlow: boolean;
  49652. /**
  49653. * Specifies the horizontal size of the blur.
  49654. */
  49655. /**
  49656. * Gets the horizontal size of the blur.
  49657. */
  49658. blurHorizontalSize: number;
  49659. /**
  49660. * Specifies the vertical size of the blur.
  49661. */
  49662. /**
  49663. * Gets the vertical size of the blur.
  49664. */
  49665. blurVerticalSize: number;
  49666. /**
  49667. * An event triggered when the highlight layer is being blurred.
  49668. */
  49669. onBeforeBlurObservable: Observable<HighlightLayer>;
  49670. /**
  49671. * An event triggered when the highlight layer has been blurred.
  49672. */
  49673. onAfterBlurObservable: Observable<HighlightLayer>;
  49674. private _instanceGlowingMeshStencilReference;
  49675. private _options;
  49676. private _downSamplePostprocess;
  49677. private _horizontalBlurPostprocess;
  49678. private _verticalBlurPostprocess;
  49679. private _blurTexture;
  49680. private _meshes;
  49681. private _excludedMeshes;
  49682. /**
  49683. * Instantiates a new highlight Layer and references it to the scene..
  49684. * @param name The name of the layer
  49685. * @param scene The scene to use the layer in
  49686. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49687. */
  49688. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49689. /**
  49690. * Get the effect name of the layer.
  49691. * @return The effect name
  49692. */
  49693. getEffectName(): string;
  49694. /**
  49695. * Create the merge effect. This is the shader use to blit the information back
  49696. * to the main canvas at the end of the scene rendering.
  49697. */
  49698. protected _createMergeEffect(): Effect;
  49699. /**
  49700. * Creates the render target textures and post processes used in the highlight layer.
  49701. */
  49702. protected _createTextureAndPostProcesses(): void;
  49703. /**
  49704. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49705. */
  49706. needStencil(): boolean;
  49707. /**
  49708. * Checks for the readiness of the element composing the layer.
  49709. * @param subMesh the mesh to check for
  49710. * @param useInstances specify wether or not to use instances to render the mesh
  49711. * @param emissiveTexture the associated emissive texture used to generate the glow
  49712. * @return true if ready otherwise, false
  49713. */
  49714. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49715. /**
  49716. * Implementation specific of rendering the generating effect on the main canvas.
  49717. * @param effect The effect used to render through
  49718. */
  49719. protected _internalRender(effect: Effect): void;
  49720. /**
  49721. * Returns true if the layer contains information to display, otherwise false.
  49722. */
  49723. shouldRender(): boolean;
  49724. /**
  49725. * Returns true if the mesh should render, otherwise false.
  49726. * @param mesh The mesh to render
  49727. * @returns true if it should render otherwise false
  49728. */
  49729. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49730. /**
  49731. * Sets the required values for both the emissive texture and and the main color.
  49732. */
  49733. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49734. /**
  49735. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49736. * @param mesh The mesh to exclude from the highlight layer
  49737. */
  49738. addExcludedMesh(mesh: Mesh): void;
  49739. /**
  49740. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49741. * @param mesh The mesh to highlight
  49742. */
  49743. removeExcludedMesh(mesh: Mesh): void;
  49744. /**
  49745. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49746. * @param mesh mesh to test
  49747. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49748. */
  49749. hasMesh(mesh: AbstractMesh): boolean;
  49750. /**
  49751. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49752. * @param mesh The mesh to highlight
  49753. * @param color The color of the highlight
  49754. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49755. */
  49756. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49757. /**
  49758. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49759. * @param mesh The mesh to highlight
  49760. */
  49761. removeMesh(mesh: Mesh): void;
  49762. /**
  49763. * Force the stencil to the normal expected value for none glowing parts
  49764. */
  49765. private _defaultStencilReference;
  49766. /**
  49767. * Free any resources and references associated to a mesh.
  49768. * Internal use
  49769. * @param mesh The mesh to free.
  49770. * @hidden
  49771. */
  49772. _disposeMesh(mesh: Mesh): void;
  49773. /**
  49774. * Dispose the highlight layer and free resources.
  49775. */
  49776. dispose(): void;
  49777. /**
  49778. * Gets the class name of the effect layer
  49779. * @returns the string with the class name of the effect layer
  49780. */
  49781. getClassName(): string;
  49782. /**
  49783. * Serializes this Highlight layer
  49784. * @returns a serialized Highlight layer object
  49785. */
  49786. serialize(): any;
  49787. /**
  49788. * Creates a Highlight layer from parsed Highlight layer data
  49789. * @param parsedHightlightLayer defines the Highlight layer data
  49790. * @param scene defines the current scene
  49791. * @param rootUrl defines the root URL containing the Highlight layer information
  49792. * @returns a parsed Highlight layer
  49793. */
  49794. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49795. }
  49796. }
  49797. declare module "babylonjs/Layers/layerSceneComponent" {
  49798. import { Scene } from "babylonjs/scene";
  49799. import { ISceneComponent } from "babylonjs/sceneComponent";
  49800. import { Layer } from "babylonjs/Layers/layer";
  49801. import { AbstractScene } from "babylonjs/abstractScene";
  49802. module "babylonjs/abstractScene" {
  49803. interface AbstractScene {
  49804. /**
  49805. * The list of layers (background and foreground) of the scene
  49806. */
  49807. layers: Array<Layer>;
  49808. }
  49809. }
  49810. /**
  49811. * Defines the layer scene component responsible to manage any layers
  49812. * in a given scene.
  49813. */
  49814. export class LayerSceneComponent implements ISceneComponent {
  49815. /**
  49816. * The component name helpfull to identify the component in the list of scene components.
  49817. */
  49818. readonly name: string;
  49819. /**
  49820. * The scene the component belongs to.
  49821. */
  49822. scene: Scene;
  49823. private _engine;
  49824. /**
  49825. * Creates a new instance of the component for the given scene
  49826. * @param scene Defines the scene to register the component in
  49827. */
  49828. constructor(scene: Scene);
  49829. /**
  49830. * Registers the component in a given scene
  49831. */
  49832. register(): void;
  49833. /**
  49834. * Rebuilds the elements related to this component in case of
  49835. * context lost for instance.
  49836. */
  49837. rebuild(): void;
  49838. /**
  49839. * Disposes the component and the associated ressources.
  49840. */
  49841. dispose(): void;
  49842. private _draw;
  49843. private _drawCameraPredicate;
  49844. private _drawCameraBackground;
  49845. private _drawCameraForeground;
  49846. private _drawRenderTargetPredicate;
  49847. private _drawRenderTargetBackground;
  49848. private _drawRenderTargetForeground;
  49849. /**
  49850. * Adds all the elements from the container to the scene
  49851. * @param container the container holding the elements
  49852. */
  49853. addFromContainer(container: AbstractScene): void;
  49854. /**
  49855. * Removes all the elements in the container from the scene
  49856. * @param container contains the elements to remove
  49857. * @param dispose if the removed element should be disposed (default: false)
  49858. */
  49859. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49860. }
  49861. }
  49862. declare module "babylonjs/Shaders/layer.fragment" {
  49863. /** @hidden */
  49864. export var layerPixelShader: {
  49865. name: string;
  49866. shader: string;
  49867. };
  49868. }
  49869. declare module "babylonjs/Shaders/layer.vertex" {
  49870. /** @hidden */
  49871. export var layerVertexShader: {
  49872. name: string;
  49873. shader: string;
  49874. };
  49875. }
  49876. declare module "babylonjs/Layers/layer" {
  49877. import { Observable } from "babylonjs/Misc/observable";
  49878. import { Nullable } from "babylonjs/types";
  49879. import { Scene } from "babylonjs/scene";
  49880. import { Vector2, Color4 } from "babylonjs/Maths/math";
  49881. import { Texture } from "babylonjs/Materials/Textures/texture";
  49882. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49883. import "babylonjs/Shaders/layer.fragment";
  49884. import "babylonjs/Shaders/layer.vertex";
  49885. /**
  49886. * This represents a full screen 2d layer.
  49887. * This can be useful to display a picture in the background of your scene for instance.
  49888. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49889. */
  49890. export class Layer {
  49891. /**
  49892. * Define the name of the layer.
  49893. */
  49894. name: string;
  49895. /**
  49896. * Define the texture the layer should display.
  49897. */
  49898. texture: Nullable<Texture>;
  49899. /**
  49900. * Is the layer in background or foreground.
  49901. */
  49902. isBackground: boolean;
  49903. /**
  49904. * Define the color of the layer (instead of texture).
  49905. */
  49906. color: Color4;
  49907. /**
  49908. * Define the scale of the layer in order to zoom in out of the texture.
  49909. */
  49910. scale: Vector2;
  49911. /**
  49912. * Define an offset for the layer in order to shift the texture.
  49913. */
  49914. offset: Vector2;
  49915. /**
  49916. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  49917. */
  49918. alphaBlendingMode: number;
  49919. /**
  49920. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  49921. * Alpha test will not mix with the background color in case of transparency.
  49922. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  49923. */
  49924. alphaTest: boolean;
  49925. /**
  49926. * Define a mask to restrict the layer to only some of the scene cameras.
  49927. */
  49928. layerMask: number;
  49929. /**
  49930. * Define the list of render target the layer is visible into.
  49931. */
  49932. renderTargetTextures: RenderTargetTexture[];
  49933. /**
  49934. * Define if the layer is only used in renderTarget or if it also
  49935. * renders in the main frame buffer of the canvas.
  49936. */
  49937. renderOnlyInRenderTargetTextures: boolean;
  49938. private _scene;
  49939. private _vertexBuffers;
  49940. private _indexBuffer;
  49941. private _effect;
  49942. private _alphaTestEffect;
  49943. /**
  49944. * An event triggered when the layer is disposed.
  49945. */
  49946. onDisposeObservable: Observable<Layer>;
  49947. private _onDisposeObserver;
  49948. /**
  49949. * Back compatibility with callback before the onDisposeObservable existed.
  49950. * The set callback will be triggered when the layer has been disposed.
  49951. */
  49952. onDispose: () => void;
  49953. /**
  49954. * An event triggered before rendering the scene
  49955. */
  49956. onBeforeRenderObservable: Observable<Layer>;
  49957. private _onBeforeRenderObserver;
  49958. /**
  49959. * Back compatibility with callback before the onBeforeRenderObservable existed.
  49960. * The set callback will be triggered just before rendering the layer.
  49961. */
  49962. onBeforeRender: () => void;
  49963. /**
  49964. * An event triggered after rendering the scene
  49965. */
  49966. onAfterRenderObservable: Observable<Layer>;
  49967. private _onAfterRenderObserver;
  49968. /**
  49969. * Back compatibility with callback before the onAfterRenderObservable existed.
  49970. * The set callback will be triggered just after rendering the layer.
  49971. */
  49972. onAfterRender: () => void;
  49973. /**
  49974. * Instantiates a new layer.
  49975. * This represents a full screen 2d layer.
  49976. * This can be useful to display a picture in the background of your scene for instance.
  49977. * @see https://www.babylonjs-playground.com/#08A2BS#1
  49978. * @param name Define the name of the layer in the scene
  49979. * @param imgUrl Define the url of the texture to display in the layer
  49980. * @param scene Define the scene the layer belongs to
  49981. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  49982. * @param color Defines a color for the layer
  49983. */
  49984. constructor(
  49985. /**
  49986. * Define the name of the layer.
  49987. */
  49988. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  49989. private _createIndexBuffer;
  49990. /** @hidden */
  49991. _rebuild(): void;
  49992. /**
  49993. * Renders the layer in the scene.
  49994. */
  49995. render(): void;
  49996. /**
  49997. * Disposes and releases the associated ressources.
  49998. */
  49999. dispose(): void;
  50000. }
  50001. }
  50002. declare module "babylonjs/Layers/index" {
  50003. export * from "babylonjs/Layers/effectLayer";
  50004. export * from "babylonjs/Layers/effectLayerSceneComponent";
  50005. export * from "babylonjs/Layers/glowLayer";
  50006. export * from "babylonjs/Layers/highlightLayer";
  50007. export * from "babylonjs/Layers/layer";
  50008. export * from "babylonjs/Layers/layerSceneComponent";
  50009. }
  50010. declare module "babylonjs/Shaders/lensFlare.fragment" {
  50011. /** @hidden */
  50012. export var lensFlarePixelShader: {
  50013. name: string;
  50014. shader: string;
  50015. };
  50016. }
  50017. declare module "babylonjs/Shaders/lensFlare.vertex" {
  50018. /** @hidden */
  50019. export var lensFlareVertexShader: {
  50020. name: string;
  50021. shader: string;
  50022. };
  50023. }
  50024. declare module "babylonjs/LensFlares/lensFlareSystem" {
  50025. import { Scene } from "babylonjs/scene";
  50026. import { Vector3, Viewport } from "babylonjs/Maths/math";
  50027. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50028. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  50029. import "babylonjs/Shaders/lensFlare.fragment";
  50030. import "babylonjs/Shaders/lensFlare.vertex";
  50031. /**
  50032. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50033. * It is usually composed of several `lensFlare`.
  50034. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50035. */
  50036. export class LensFlareSystem {
  50037. /**
  50038. * Define the name of the lens flare system
  50039. */
  50040. name: string;
  50041. /**
  50042. * List of lens flares used in this system.
  50043. */
  50044. lensFlares: LensFlare[];
  50045. /**
  50046. * Define a limit from the border the lens flare can be visible.
  50047. */
  50048. borderLimit: number;
  50049. /**
  50050. * Define a viewport border we do not want to see the lens flare in.
  50051. */
  50052. viewportBorder: number;
  50053. /**
  50054. * Define a predicate which could limit the list of meshes able to occlude the effect.
  50055. */
  50056. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  50057. /**
  50058. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  50059. */
  50060. layerMask: number;
  50061. /**
  50062. * Define the id of the lens flare system in the scene.
  50063. * (equal to name by default)
  50064. */
  50065. id: string;
  50066. private _scene;
  50067. private _emitter;
  50068. private _vertexBuffers;
  50069. private _indexBuffer;
  50070. private _effect;
  50071. private _positionX;
  50072. private _positionY;
  50073. private _isEnabled;
  50074. /** @hidden */
  50075. static _SceneComponentInitialization: (scene: Scene) => void;
  50076. /**
  50077. * Instantiates a lens flare system.
  50078. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  50079. * It is usually composed of several `lensFlare`.
  50080. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50081. * @param name Define the name of the lens flare system in the scene
  50082. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  50083. * @param scene Define the scene the lens flare system belongs to
  50084. */
  50085. constructor(
  50086. /**
  50087. * Define the name of the lens flare system
  50088. */
  50089. name: string, emitter: any, scene: Scene);
  50090. /**
  50091. * Define if the lens flare system is enabled.
  50092. */
  50093. isEnabled: boolean;
  50094. /**
  50095. * Get the scene the effects belongs to.
  50096. * @returns the scene holding the lens flare system
  50097. */
  50098. getScene(): Scene;
  50099. /**
  50100. * Get the emitter of the lens flare system.
  50101. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50102. * @returns the emitter of the lens flare system
  50103. */
  50104. getEmitter(): any;
  50105. /**
  50106. * Set the emitter of the lens flare system.
  50107. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  50108. * @param newEmitter Define the new emitter of the system
  50109. */
  50110. setEmitter(newEmitter: any): void;
  50111. /**
  50112. * Get the lens flare system emitter position.
  50113. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  50114. * @returns the position
  50115. */
  50116. getEmitterPosition(): Vector3;
  50117. /**
  50118. * @hidden
  50119. */
  50120. computeEffectivePosition(globalViewport: Viewport): boolean;
  50121. /** @hidden */
  50122. _isVisible(): boolean;
  50123. /**
  50124. * @hidden
  50125. */
  50126. render(): boolean;
  50127. /**
  50128. * Dispose and release the lens flare with its associated resources.
  50129. */
  50130. dispose(): void;
  50131. /**
  50132. * Parse a lens flare system from a JSON repressentation
  50133. * @param parsedLensFlareSystem Define the JSON to parse
  50134. * @param scene Define the scene the parsed system should be instantiated in
  50135. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  50136. * @returns the parsed system
  50137. */
  50138. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  50139. /**
  50140. * Serialize the current Lens Flare System into a JSON representation.
  50141. * @returns the serialized JSON
  50142. */
  50143. serialize(): any;
  50144. }
  50145. }
  50146. declare module "babylonjs/LensFlares/lensFlare" {
  50147. import { Nullable } from "babylonjs/types";
  50148. import { Color3 } from "babylonjs/Maths/math";
  50149. import { Texture } from "babylonjs/Materials/Textures/texture";
  50150. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50151. /**
  50152. * This represents one of the lens effect in a `lensFlareSystem`.
  50153. * It controls one of the indiviual texture used in the effect.
  50154. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50155. */
  50156. export class LensFlare {
  50157. /**
  50158. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50159. */
  50160. size: number;
  50161. /**
  50162. * 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.
  50163. */
  50164. position: number;
  50165. /**
  50166. * Define the lens color.
  50167. */
  50168. color: Color3;
  50169. /**
  50170. * Define the lens texture.
  50171. */
  50172. texture: Nullable<Texture>;
  50173. /**
  50174. * Define the alpha mode to render this particular lens.
  50175. */
  50176. alphaMode: number;
  50177. private _system;
  50178. /**
  50179. * Creates a new Lens Flare.
  50180. * This represents one of the lens effect in a `lensFlareSystem`.
  50181. * It controls one of the indiviual texture used in the effect.
  50182. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50183. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  50184. * @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.
  50185. * @param color Define the lens color
  50186. * @param imgUrl Define the lens texture url
  50187. * @param system Define the `lensFlareSystem` this flare is part of
  50188. * @returns The newly created Lens Flare
  50189. */
  50190. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  50191. /**
  50192. * Instantiates a new Lens Flare.
  50193. * This represents one of the lens effect in a `lensFlareSystem`.
  50194. * It controls one of the indiviual texture used in the effect.
  50195. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50196. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  50197. * @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.
  50198. * @param color Define the lens color
  50199. * @param imgUrl Define the lens texture url
  50200. * @param system Define the `lensFlareSystem` this flare is part of
  50201. */
  50202. constructor(
  50203. /**
  50204. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  50205. */
  50206. size: number,
  50207. /**
  50208. * 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.
  50209. */
  50210. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  50211. /**
  50212. * Dispose and release the lens flare with its associated resources.
  50213. */
  50214. dispose(): void;
  50215. }
  50216. }
  50217. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  50218. import { Nullable } from "babylonjs/types";
  50219. import { Scene } from "babylonjs/scene";
  50220. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50221. import { AbstractScene } from "babylonjs/abstractScene";
  50222. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  50223. module "babylonjs/abstractScene" {
  50224. interface AbstractScene {
  50225. /**
  50226. * The list of lens flare system added to the scene
  50227. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  50228. */
  50229. lensFlareSystems: Array<LensFlareSystem>;
  50230. /**
  50231. * Removes the given lens flare system from this scene.
  50232. * @param toRemove The lens flare system to remove
  50233. * @returns The index of the removed lens flare system
  50234. */
  50235. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  50236. /**
  50237. * Adds the given lens flare system to this scene
  50238. * @param newLensFlareSystem The lens flare system to add
  50239. */
  50240. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  50241. /**
  50242. * Gets a lens flare system using its name
  50243. * @param name defines the name to look for
  50244. * @returns the lens flare system or null if not found
  50245. */
  50246. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  50247. /**
  50248. * Gets a lens flare system using its id
  50249. * @param id defines the id to look for
  50250. * @returns the lens flare system or null if not found
  50251. */
  50252. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  50253. }
  50254. }
  50255. /**
  50256. * Defines the lens flare scene component responsible to manage any lens flares
  50257. * in a given scene.
  50258. */
  50259. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  50260. /**
  50261. * The component name helpfull to identify the component in the list of scene components.
  50262. */
  50263. readonly name: string;
  50264. /**
  50265. * The scene the component belongs to.
  50266. */
  50267. scene: Scene;
  50268. /**
  50269. * Creates a new instance of the component for the given scene
  50270. * @param scene Defines the scene to register the component in
  50271. */
  50272. constructor(scene: Scene);
  50273. /**
  50274. * Registers the component in a given scene
  50275. */
  50276. register(): void;
  50277. /**
  50278. * Rebuilds the elements related to this component in case of
  50279. * context lost for instance.
  50280. */
  50281. rebuild(): void;
  50282. /**
  50283. * Adds all the elements from the container to the scene
  50284. * @param container the container holding the elements
  50285. */
  50286. addFromContainer(container: AbstractScene): void;
  50287. /**
  50288. * Removes all the elements in the container from the scene
  50289. * @param container contains the elements to remove
  50290. * @param dispose if the removed element should be disposed (default: false)
  50291. */
  50292. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50293. /**
  50294. * Serializes the component data to the specified json object
  50295. * @param serializationObject The object to serialize to
  50296. */
  50297. serialize(serializationObject: any): void;
  50298. /**
  50299. * Disposes the component and the associated ressources.
  50300. */
  50301. dispose(): void;
  50302. private _draw;
  50303. }
  50304. }
  50305. declare module "babylonjs/LensFlares/index" {
  50306. export * from "babylonjs/LensFlares/lensFlare";
  50307. export * from "babylonjs/LensFlares/lensFlareSystem";
  50308. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  50309. }
  50310. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  50311. import { Scene } from "babylonjs/scene";
  50312. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  50313. import { AbstractScene } from "babylonjs/abstractScene";
  50314. /**
  50315. * Defines the shadow generator component responsible to manage any shadow generators
  50316. * in a given scene.
  50317. */
  50318. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  50319. /**
  50320. * The component name helpfull to identify the component in the list of scene components.
  50321. */
  50322. readonly name: string;
  50323. /**
  50324. * The scene the component belongs to.
  50325. */
  50326. scene: Scene;
  50327. /**
  50328. * Creates a new instance of the component for the given scene
  50329. * @param scene Defines the scene to register the component in
  50330. */
  50331. constructor(scene: Scene);
  50332. /**
  50333. * Registers the component in a given scene
  50334. */
  50335. register(): void;
  50336. /**
  50337. * Rebuilds the elements related to this component in case of
  50338. * context lost for instance.
  50339. */
  50340. rebuild(): void;
  50341. /**
  50342. * Serializes the component data to the specified json object
  50343. * @param serializationObject The object to serialize to
  50344. */
  50345. serialize(serializationObject: any): void;
  50346. /**
  50347. * Adds all the elements from the container to the scene
  50348. * @param container the container holding the elements
  50349. */
  50350. addFromContainer(container: AbstractScene): void;
  50351. /**
  50352. * Removes all the elements in the container from the scene
  50353. * @param container contains the elements to remove
  50354. * @param dispose if the removed element should be disposed (default: false)
  50355. */
  50356. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  50357. /**
  50358. * Rebuilds the elements related to this component in case of
  50359. * context lost for instance.
  50360. */
  50361. dispose(): void;
  50362. private _gatherRenderTargets;
  50363. }
  50364. }
  50365. declare module "babylonjs/Lights/Shadows/index" {
  50366. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  50367. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  50368. }
  50369. declare module "babylonjs/Lights/pointLight" {
  50370. import { Scene } from "babylonjs/scene";
  50371. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50373. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  50374. import { Effect } from "babylonjs/Materials/effect";
  50375. /**
  50376. * A point light is a light defined by an unique point in world space.
  50377. * The light is emitted in every direction from this point.
  50378. * A good example of a point light is a standard light bulb.
  50379. * Documentation: https://doc.babylonjs.com/babylon101/lights
  50380. */
  50381. export class PointLight extends ShadowLight {
  50382. private _shadowAngle;
  50383. /**
  50384. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50385. * This specifies what angle the shadow will use to be created.
  50386. *
  50387. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50388. */
  50389. /**
  50390. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50391. * This specifies what angle the shadow will use to be created.
  50392. *
  50393. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  50394. */
  50395. shadowAngle: number;
  50396. /**
  50397. * Gets the direction if it has been set.
  50398. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50399. */
  50400. /**
  50401. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  50402. */
  50403. direction: Vector3;
  50404. /**
  50405. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  50406. * A PointLight emits the light in every direction.
  50407. * It can cast shadows.
  50408. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  50409. * ```javascript
  50410. * var pointLight = new PointLight("pl", camera.position, scene);
  50411. * ```
  50412. * Documentation : https://doc.babylonjs.com/babylon101/lights
  50413. * @param name The light friendly name
  50414. * @param position The position of the point light in the scene
  50415. * @param scene The scene the lights belongs to
  50416. */
  50417. constructor(name: string, position: Vector3, scene: Scene);
  50418. /**
  50419. * Returns the string "PointLight"
  50420. * @returns the class name
  50421. */
  50422. getClassName(): string;
  50423. /**
  50424. * Returns the integer 0.
  50425. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  50426. */
  50427. getTypeID(): number;
  50428. /**
  50429. * Specifies wether or not the shadowmap should be a cube texture.
  50430. * @returns true if the shadowmap needs to be a cube texture.
  50431. */
  50432. needCube(): boolean;
  50433. /**
  50434. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  50435. * @param faceIndex The index of the face we are computed the direction to generate shadow
  50436. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  50437. */
  50438. getShadowDirection(faceIndex?: number): Vector3;
  50439. /**
  50440. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  50441. * - fov = PI / 2
  50442. * - aspect ratio : 1.0
  50443. * - z-near and far equal to the active camera minZ and maxZ.
  50444. * Returns the PointLight.
  50445. */
  50446. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  50447. protected _buildUniformLayout(): void;
  50448. /**
  50449. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  50450. * @param effect The effect to update
  50451. * @param lightIndex The index of the light in the effect to update
  50452. * @returns The point light
  50453. */
  50454. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  50455. /**
  50456. * Prepares the list of defines specific to the light type.
  50457. * @param defines the list of defines
  50458. * @param lightIndex defines the index of the light for the effect
  50459. */
  50460. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  50461. }
  50462. }
  50463. declare module "babylonjs/Lights/index" {
  50464. export * from "babylonjs/Lights/light";
  50465. export * from "babylonjs/Lights/shadowLight";
  50466. export * from "babylonjs/Lights/Shadows/index";
  50467. export * from "babylonjs/Lights/directionalLight";
  50468. export * from "babylonjs/Lights/hemisphericLight";
  50469. export * from "babylonjs/Lights/pointLight";
  50470. export * from "babylonjs/Lights/spotLight";
  50471. }
  50472. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  50473. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  50474. /**
  50475. * Header information of HDR texture files.
  50476. */
  50477. export interface HDRInfo {
  50478. /**
  50479. * The height of the texture in pixels.
  50480. */
  50481. height: number;
  50482. /**
  50483. * The width of the texture in pixels.
  50484. */
  50485. width: number;
  50486. /**
  50487. * The index of the beginning of the data in the binary file.
  50488. */
  50489. dataPosition: number;
  50490. }
  50491. /**
  50492. * This groups tools to convert HDR texture to native colors array.
  50493. */
  50494. export class HDRTools {
  50495. private static Ldexp;
  50496. private static Rgbe2float;
  50497. private static readStringLine;
  50498. /**
  50499. * Reads header information from an RGBE texture stored in a native array.
  50500. * More information on this format are available here:
  50501. * https://en.wikipedia.org/wiki/RGBE_image_format
  50502. *
  50503. * @param uint8array The binary file stored in native array.
  50504. * @return The header information.
  50505. */
  50506. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  50507. /**
  50508. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  50509. * This RGBE texture needs to store the information as a panorama.
  50510. *
  50511. * More information on this format are available here:
  50512. * https://en.wikipedia.org/wiki/RGBE_image_format
  50513. *
  50514. * @param buffer The binary file stored in an array buffer.
  50515. * @param size The expected size of the extracted cubemap.
  50516. * @return The Cube Map information.
  50517. */
  50518. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  50519. /**
  50520. * Returns the pixels data extracted from an RGBE texture.
  50521. * This pixels will be stored left to right up to down in the R G B order in one array.
  50522. *
  50523. * More information on this format are available here:
  50524. * https://en.wikipedia.org/wiki/RGBE_image_format
  50525. *
  50526. * @param uint8array The binary file stored in an array buffer.
  50527. * @param hdrInfo The header information of the file.
  50528. * @return The pixels data in RGB right to left up to down order.
  50529. */
  50530. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  50531. private static RGBE_ReadPixels_RLE;
  50532. }
  50533. }
  50534. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  50535. import { Nullable } from "babylonjs/types";
  50536. import { Scene } from "babylonjs/scene";
  50537. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  50538. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50539. import "babylonjs/Engines/Extensions/engine.rawTexture";
  50540. /**
  50541. * This represents a texture coming from an HDR input.
  50542. *
  50543. * The only supported format is currently panorama picture stored in RGBE format.
  50544. * Example of such files can be found on HDRLib: http://hdrlib.com/
  50545. */
  50546. export class HDRCubeTexture extends BaseTexture {
  50547. private static _facesMapping;
  50548. private _generateHarmonics;
  50549. private _noMipmap;
  50550. private _textureMatrix;
  50551. private _size;
  50552. private _onLoad;
  50553. private _onError;
  50554. /**
  50555. * The texture URL.
  50556. */
  50557. url: string;
  50558. /**
  50559. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  50560. */
  50561. coordinatesMode: number;
  50562. protected _isBlocking: boolean;
  50563. /**
  50564. * Sets wether or not the texture is blocking during loading.
  50565. */
  50566. /**
  50567. * Gets wether or not the texture is blocking during loading.
  50568. */
  50569. isBlocking: boolean;
  50570. protected _rotationY: number;
  50571. /**
  50572. * Sets texture matrix rotation angle around Y axis in radians.
  50573. */
  50574. /**
  50575. * Gets texture matrix rotation angle around Y axis radians.
  50576. */
  50577. rotationY: number;
  50578. /**
  50579. * Gets or sets the center of the bounding box associated with the cube texture
  50580. * It must define where the camera used to render the texture was set
  50581. */
  50582. boundingBoxPosition: Vector3;
  50583. private _boundingBoxSize;
  50584. /**
  50585. * Gets or sets the size of the bounding box associated with the cube texture
  50586. * When defined, the cubemap will switch to local mode
  50587. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  50588. * @example https://www.babylonjs-playground.com/#RNASML
  50589. */
  50590. boundingBoxSize: Vector3;
  50591. /**
  50592. * Instantiates an HDRTexture from the following parameters.
  50593. *
  50594. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  50595. * @param scene The scene the texture will be used in
  50596. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50597. * @param noMipmap Forces to not generate the mipmap if true
  50598. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  50599. * @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)
  50600. * @param reserved Reserved flag for internal use.
  50601. */
  50602. 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>);
  50603. /**
  50604. * Get the current class name of the texture useful for serialization or dynamic coding.
  50605. * @returns "HDRCubeTexture"
  50606. */
  50607. getClassName(): string;
  50608. /**
  50609. * Occurs when the file is raw .hdr file.
  50610. */
  50611. private loadTexture;
  50612. clone(): HDRCubeTexture;
  50613. delayLoad(): void;
  50614. /**
  50615. * Get the texture reflection matrix used to rotate/transform the reflection.
  50616. * @returns the reflection matrix
  50617. */
  50618. getReflectionTextureMatrix(): Matrix;
  50619. /**
  50620. * Set the texture reflection matrix used to rotate/transform the reflection.
  50621. * @param value Define the reflection matrix to set
  50622. */
  50623. setReflectionTextureMatrix(value: Matrix): void;
  50624. /**
  50625. * Parses a JSON representation of an HDR Texture in order to create the texture
  50626. * @param parsedTexture Define the JSON representation
  50627. * @param scene Define the scene the texture should be created in
  50628. * @param rootUrl Define the root url in case we need to load relative dependencies
  50629. * @returns the newly created texture after parsing
  50630. */
  50631. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  50632. serialize(): any;
  50633. }
  50634. }
  50635. declare module "babylonjs/Physics/physicsEngine" {
  50636. import { Nullable } from "babylonjs/types";
  50637. import { Vector3 } from "babylonjs/Maths/math";
  50638. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  50639. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  50640. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  50641. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50642. /**
  50643. * Class used to control physics engine
  50644. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  50645. */
  50646. export class PhysicsEngine implements IPhysicsEngine {
  50647. private _physicsPlugin;
  50648. /**
  50649. * Global value used to control the smallest number supported by the simulation
  50650. */
  50651. static Epsilon: number;
  50652. private _impostors;
  50653. private _joints;
  50654. /**
  50655. * Gets the gravity vector used by the simulation
  50656. */
  50657. gravity: Vector3;
  50658. /**
  50659. * Factory used to create the default physics plugin.
  50660. * @returns The default physics plugin
  50661. */
  50662. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  50663. /**
  50664. * Creates a new Physics Engine
  50665. * @param gravity defines the gravity vector used by the simulation
  50666. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  50667. */
  50668. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  50669. /**
  50670. * Sets the gravity vector used by the simulation
  50671. * @param gravity defines the gravity vector to use
  50672. */
  50673. setGravity(gravity: Vector3): void;
  50674. /**
  50675. * Set the time step of the physics engine.
  50676. * Default is 1/60.
  50677. * To slow it down, enter 1/600 for example.
  50678. * To speed it up, 1/30
  50679. * @param newTimeStep defines the new timestep to apply to this world.
  50680. */
  50681. setTimeStep(newTimeStep?: number): void;
  50682. /**
  50683. * Get the time step of the physics engine.
  50684. * @returns the current time step
  50685. */
  50686. getTimeStep(): number;
  50687. /**
  50688. * Release all resources
  50689. */
  50690. dispose(): void;
  50691. /**
  50692. * Gets the name of the current physics plugin
  50693. * @returns the name of the plugin
  50694. */
  50695. getPhysicsPluginName(): string;
  50696. /**
  50697. * Adding a new impostor for the impostor tracking.
  50698. * This will be done by the impostor itself.
  50699. * @param impostor the impostor to add
  50700. */
  50701. addImpostor(impostor: PhysicsImpostor): void;
  50702. /**
  50703. * Remove an impostor from the engine.
  50704. * This impostor and its mesh will not longer be updated by the physics engine.
  50705. * @param impostor the impostor to remove
  50706. */
  50707. removeImpostor(impostor: PhysicsImpostor): void;
  50708. /**
  50709. * Add a joint to the physics engine
  50710. * @param mainImpostor defines the main impostor to which the joint is added.
  50711. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  50712. * @param joint defines the joint that will connect both impostors.
  50713. */
  50714. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50715. /**
  50716. * Removes a joint from the simulation
  50717. * @param mainImpostor defines the impostor used with the joint
  50718. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  50719. * @param joint defines the joint to remove
  50720. */
  50721. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  50722. /**
  50723. * Called by the scene. No need to call it.
  50724. * @param delta defines the timespam between frames
  50725. */
  50726. _step(delta: number): void;
  50727. /**
  50728. * Gets the current plugin used to run the simulation
  50729. * @returns current plugin
  50730. */
  50731. getPhysicsPlugin(): IPhysicsEnginePlugin;
  50732. /**
  50733. * Gets the list of physic impostors
  50734. * @returns an array of PhysicsImpostor
  50735. */
  50736. getImpostors(): Array<PhysicsImpostor>;
  50737. /**
  50738. * Gets the impostor for a physics enabled object
  50739. * @param object defines the object impersonated by the impostor
  50740. * @returns the PhysicsImpostor or null if not found
  50741. */
  50742. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  50743. /**
  50744. * Gets the impostor for a physics body object
  50745. * @param body defines physics body used by the impostor
  50746. * @returns the PhysicsImpostor or null if not found
  50747. */
  50748. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  50749. /**
  50750. * Does a raycast in the physics world
  50751. * @param from when should the ray start?
  50752. * @param to when should the ray end?
  50753. * @returns PhysicsRaycastResult
  50754. */
  50755. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50756. }
  50757. }
  50758. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  50759. import { Nullable } from "babylonjs/types";
  50760. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50761. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50762. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50763. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50764. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50765. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50766. /** @hidden */
  50767. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  50768. private _useDeltaForWorldStep;
  50769. world: any;
  50770. name: string;
  50771. private _physicsMaterials;
  50772. private _fixedTimeStep;
  50773. private _cannonRaycastResult;
  50774. private _raycastResult;
  50775. private _removeAfterStep;
  50776. BJSCANNON: any;
  50777. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50778. setGravity(gravity: Vector3): void;
  50779. setTimeStep(timeStep: number): void;
  50780. getTimeStep(): number;
  50781. executeStep(delta: number): void;
  50782. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50783. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50784. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50785. private _processChildMeshes;
  50786. removePhysicsBody(impostor: PhysicsImpostor): void;
  50787. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50788. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50789. private _addMaterial;
  50790. private _checkWithEpsilon;
  50791. private _createShape;
  50792. private _createHeightmap;
  50793. private _minus90X;
  50794. private _plus90X;
  50795. private _tmpPosition;
  50796. private _tmpDeltaPosition;
  50797. private _tmpUnityRotation;
  50798. private _updatePhysicsBodyTransformation;
  50799. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50800. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50801. isSupported(): boolean;
  50802. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50803. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50804. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50805. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50806. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50807. getBodyMass(impostor: PhysicsImpostor): number;
  50808. getBodyFriction(impostor: PhysicsImpostor): number;
  50809. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50810. getBodyRestitution(impostor: PhysicsImpostor): number;
  50811. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50812. sleepBody(impostor: PhysicsImpostor): void;
  50813. wakeUpBody(impostor: PhysicsImpostor): void;
  50814. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50815. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50816. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50817. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50818. getRadius(impostor: PhysicsImpostor): number;
  50819. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50820. dispose(): void;
  50821. private _extendNamespace;
  50822. /**
  50823. * Does a raycast in the physics world
  50824. * @param from when should the ray start?
  50825. * @param to when should the ray end?
  50826. * @returns PhysicsRaycastResult
  50827. */
  50828. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50829. }
  50830. }
  50831. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50832. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50833. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50834. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50836. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50837. import { Nullable } from "babylonjs/types";
  50838. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50839. /** @hidden */
  50840. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50841. world: any;
  50842. name: string;
  50843. BJSOIMO: any;
  50844. private _raycastResult;
  50845. constructor(iterations?: number, oimoInjection?: any);
  50846. setGravity(gravity: Vector3): void;
  50847. setTimeStep(timeStep: number): void;
  50848. getTimeStep(): number;
  50849. private _tmpImpostorsArray;
  50850. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50851. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50852. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50853. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50854. private _tmpPositionVector;
  50855. removePhysicsBody(impostor: PhysicsImpostor): void;
  50856. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50857. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50858. isSupported(): boolean;
  50859. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50860. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50861. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50862. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50863. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50864. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50865. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50866. getBodyMass(impostor: PhysicsImpostor): number;
  50867. getBodyFriction(impostor: PhysicsImpostor): number;
  50868. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50869. getBodyRestitution(impostor: PhysicsImpostor): number;
  50870. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50871. sleepBody(impostor: PhysicsImpostor): void;
  50872. wakeUpBody(impostor: PhysicsImpostor): void;
  50873. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50874. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50875. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50876. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50877. getRadius(impostor: PhysicsImpostor): number;
  50878. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50879. dispose(): void;
  50880. /**
  50881. * Does a raycast in the physics world
  50882. * @param from when should the ray start?
  50883. * @param to when should the ray end?
  50884. * @returns PhysicsRaycastResult
  50885. */
  50886. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50887. }
  50888. }
  50889. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50890. import { Nullable } from "babylonjs/types";
  50891. import { Scene } from "babylonjs/scene";
  50892. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50893. import { Mesh } from "babylonjs/Meshes/mesh";
  50894. /**
  50895. * Class containing static functions to help procedurally build meshes
  50896. */
  50897. export class RibbonBuilder {
  50898. /**
  50899. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50900. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50901. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50902. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50903. * * 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
  50904. * * 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
  50905. * * 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
  50906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50908. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50909. * * 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
  50910. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50911. * * 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
  50912. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50913. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50914. * @param name defines the name of the mesh
  50915. * @param options defines the options used to create the mesh
  50916. * @param scene defines the hosting scene
  50917. * @returns the ribbon mesh
  50918. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50919. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50920. */
  50921. static CreateRibbon(name: string, options: {
  50922. pathArray: Vector3[][];
  50923. closeArray?: boolean;
  50924. closePath?: boolean;
  50925. offset?: number;
  50926. updatable?: boolean;
  50927. sideOrientation?: number;
  50928. frontUVs?: Vector4;
  50929. backUVs?: Vector4;
  50930. instance?: Mesh;
  50931. invertUV?: boolean;
  50932. uvs?: Vector2[];
  50933. colors?: Color4[];
  50934. }, scene?: Nullable<Scene>): Mesh;
  50935. }
  50936. }
  50937. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50938. import { Nullable } from "babylonjs/types";
  50939. import { Scene } from "babylonjs/scene";
  50940. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50941. import { Mesh } from "babylonjs/Meshes/mesh";
  50942. /**
  50943. * Class containing static functions to help procedurally build meshes
  50944. */
  50945. export class ShapeBuilder {
  50946. /**
  50947. * 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.
  50948. * * 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.
  50949. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50950. * * 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.
  50951. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50952. * * 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
  50953. * * 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
  50954. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50955. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50956. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50957. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50959. * @param name defines the name of the mesh
  50960. * @param options defines the options used to create the mesh
  50961. * @param scene defines the hosting scene
  50962. * @returns the extruded shape mesh
  50963. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50964. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50965. */
  50966. static ExtrudeShape(name: string, options: {
  50967. shape: Vector3[];
  50968. path: Vector3[];
  50969. scale?: number;
  50970. rotation?: number;
  50971. cap?: number;
  50972. updatable?: boolean;
  50973. sideOrientation?: number;
  50974. frontUVs?: Vector4;
  50975. backUVs?: Vector4;
  50976. instance?: Mesh;
  50977. invertUV?: boolean;
  50978. }, scene?: Nullable<Scene>): Mesh;
  50979. /**
  50980. * Creates an custom extruded shape mesh.
  50981. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50982. * * 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.
  50983. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50984. * * 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
  50985. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50986. * * 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
  50987. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50988. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50989. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50990. * * 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
  50991. * * 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
  50992. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50995. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50996. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50997. * @param name defines the name of the mesh
  50998. * @param options defines the options used to create the mesh
  50999. * @param scene defines the hosting scene
  51000. * @returns the custom extruded shape mesh
  51001. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  51002. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  51003. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  51004. */
  51005. static ExtrudeShapeCustom(name: string, options: {
  51006. shape: Vector3[];
  51007. path: Vector3[];
  51008. scaleFunction?: any;
  51009. rotationFunction?: any;
  51010. ribbonCloseArray?: boolean;
  51011. ribbonClosePath?: boolean;
  51012. cap?: number;
  51013. updatable?: boolean;
  51014. sideOrientation?: number;
  51015. frontUVs?: Vector4;
  51016. backUVs?: Vector4;
  51017. instance?: Mesh;
  51018. invertUV?: boolean;
  51019. }, scene?: Nullable<Scene>): Mesh;
  51020. private static _ExtrudeShapeGeneric;
  51021. }
  51022. }
  51023. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  51024. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  51025. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  51026. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  51027. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  51028. import { Nullable } from "babylonjs/types";
  51029. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51030. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  51031. /**
  51032. * AmmoJS Physics plugin
  51033. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  51034. * @see https://github.com/kripken/ammo.js/
  51035. */
  51036. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  51037. private _useDeltaForWorldStep;
  51038. /**
  51039. * Reference to the Ammo library
  51040. */
  51041. bjsAMMO: any;
  51042. /**
  51043. * Created ammoJS world which physics bodies are added to
  51044. */
  51045. world: any;
  51046. /**
  51047. * Name of the plugin
  51048. */
  51049. name: string;
  51050. private _timeStep;
  51051. private _fixedTimeStep;
  51052. private _maxSteps;
  51053. private _tmpQuaternion;
  51054. private _tmpAmmoTransform;
  51055. private _tmpAmmoQuaternion;
  51056. private _tmpAmmoConcreteContactResultCallback;
  51057. private _collisionConfiguration;
  51058. private _dispatcher;
  51059. private _overlappingPairCache;
  51060. private _solver;
  51061. private _softBodySolver;
  51062. private _tmpAmmoVectorA;
  51063. private _tmpAmmoVectorB;
  51064. private _tmpAmmoVectorC;
  51065. private _tmpAmmoVectorD;
  51066. private _tmpContactCallbackResult;
  51067. private _tmpAmmoVectorRCA;
  51068. private _tmpAmmoVectorRCB;
  51069. private _raycastResult;
  51070. private static readonly DISABLE_COLLISION_FLAG;
  51071. private static readonly KINEMATIC_FLAG;
  51072. private static readonly DISABLE_DEACTIVATION_FLAG;
  51073. /**
  51074. * Initializes the ammoJS plugin
  51075. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  51076. * @param ammoInjection can be used to inject your own ammo reference
  51077. */
  51078. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  51079. /**
  51080. * Sets the gravity of the physics world (m/(s^2))
  51081. * @param gravity Gravity to set
  51082. */
  51083. setGravity(gravity: Vector3): void;
  51084. /**
  51085. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  51086. * @param timeStep timestep to use in seconds
  51087. */
  51088. setTimeStep(timeStep: number): void;
  51089. /**
  51090. * 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)
  51091. * @param fixedTimeStep fixedTimeStep to use in seconds
  51092. */
  51093. setFixedTimeStep(fixedTimeStep: number): void;
  51094. /**
  51095. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  51096. * @param maxSteps the maximum number of steps by the physics engine per frame
  51097. */
  51098. setMaxSteps(maxSteps: number): void;
  51099. /**
  51100. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  51101. * @returns the current timestep in seconds
  51102. */
  51103. getTimeStep(): number;
  51104. private _isImpostorInContact;
  51105. private _isImpostorPairInContact;
  51106. private _stepSimulation;
  51107. /**
  51108. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  51109. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  51110. * After the step the babylon meshes are set to the position of the physics imposters
  51111. * @param delta amount of time to step forward
  51112. * @param impostors array of imposters to update before/after the step
  51113. */
  51114. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  51115. /**
  51116. * Update babylon mesh to match physics world object
  51117. * @param impostor imposter to match
  51118. */
  51119. private _afterSoftStep;
  51120. /**
  51121. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51122. * @param impostor imposter to match
  51123. */
  51124. private _ropeStep;
  51125. /**
  51126. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  51127. * @param impostor imposter to match
  51128. */
  51129. private _softbodyOrClothStep;
  51130. private _tmpVector;
  51131. private _tmpMatrix;
  51132. /**
  51133. * Applies an impulse on the imposter
  51134. * @param impostor imposter to apply impulse to
  51135. * @param force amount of force to be applied to the imposter
  51136. * @param contactPoint the location to apply the impulse on the imposter
  51137. */
  51138. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51139. /**
  51140. * Applies a force on the imposter
  51141. * @param impostor imposter to apply force
  51142. * @param force amount of force to be applied to the imposter
  51143. * @param contactPoint the location to apply the force on the imposter
  51144. */
  51145. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  51146. /**
  51147. * Creates a physics body using the plugin
  51148. * @param impostor the imposter to create the physics body on
  51149. */
  51150. generatePhysicsBody(impostor: PhysicsImpostor): void;
  51151. /**
  51152. * Removes the physics body from the imposter and disposes of the body's memory
  51153. * @param impostor imposter to remove the physics body from
  51154. */
  51155. removePhysicsBody(impostor: PhysicsImpostor): void;
  51156. /**
  51157. * Generates a joint
  51158. * @param impostorJoint the imposter joint to create the joint with
  51159. */
  51160. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  51161. /**
  51162. * Removes a joint
  51163. * @param impostorJoint the imposter joint to remove the joint from
  51164. */
  51165. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  51166. private _addMeshVerts;
  51167. /**
  51168. * Initialise the soft body vertices to match its object's (mesh) vertices
  51169. * Softbody vertices (nodes) are in world space and to match this
  51170. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  51171. * @param impostor to create the softbody for
  51172. */
  51173. private _softVertexData;
  51174. /**
  51175. * Create an impostor's soft body
  51176. * @param impostor to create the softbody for
  51177. */
  51178. private _createSoftbody;
  51179. /**
  51180. * Create cloth for an impostor
  51181. * @param impostor to create the softbody for
  51182. */
  51183. private _createCloth;
  51184. /**
  51185. * Create rope for an impostor
  51186. * @param impostor to create the softbody for
  51187. */
  51188. private _createRope;
  51189. private _addHullVerts;
  51190. private _createShape;
  51191. /**
  51192. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  51193. * @param impostor imposter containing the physics body and babylon object
  51194. */
  51195. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  51196. /**
  51197. * Sets the babylon object's position/rotation from the physics body's position/rotation
  51198. * @param impostor imposter containing the physics body and babylon object
  51199. * @param newPosition new position
  51200. * @param newRotation new rotation
  51201. */
  51202. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  51203. /**
  51204. * If this plugin is supported
  51205. * @returns true if its supported
  51206. */
  51207. isSupported(): boolean;
  51208. /**
  51209. * Sets the linear velocity of the physics body
  51210. * @param impostor imposter to set the velocity on
  51211. * @param velocity velocity to set
  51212. */
  51213. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51214. /**
  51215. * Sets the angular velocity of the physics body
  51216. * @param impostor imposter to set the velocity on
  51217. * @param velocity velocity to set
  51218. */
  51219. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  51220. /**
  51221. * gets the linear velocity
  51222. * @param impostor imposter to get linear velocity from
  51223. * @returns linear velocity
  51224. */
  51225. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51226. /**
  51227. * gets the angular velocity
  51228. * @param impostor imposter to get angular velocity from
  51229. * @returns angular velocity
  51230. */
  51231. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  51232. /**
  51233. * Sets the mass of physics body
  51234. * @param impostor imposter to set the mass on
  51235. * @param mass mass to set
  51236. */
  51237. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  51238. /**
  51239. * Gets the mass of the physics body
  51240. * @param impostor imposter to get the mass from
  51241. * @returns mass
  51242. */
  51243. getBodyMass(impostor: PhysicsImpostor): number;
  51244. /**
  51245. * Gets friction of the impostor
  51246. * @param impostor impostor to get friction from
  51247. * @returns friction value
  51248. */
  51249. getBodyFriction(impostor: PhysicsImpostor): number;
  51250. /**
  51251. * Sets friction of the impostor
  51252. * @param impostor impostor to set friction on
  51253. * @param friction friction value
  51254. */
  51255. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  51256. /**
  51257. * Gets restitution of the impostor
  51258. * @param impostor impostor to get restitution from
  51259. * @returns restitution value
  51260. */
  51261. getBodyRestitution(impostor: PhysicsImpostor): number;
  51262. /**
  51263. * Sets resitution of the impostor
  51264. * @param impostor impostor to set resitution on
  51265. * @param restitution resitution value
  51266. */
  51267. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  51268. /**
  51269. * Gets pressure inside the impostor
  51270. * @param impostor impostor to get pressure from
  51271. * @returns pressure value
  51272. */
  51273. getBodyPressure(impostor: PhysicsImpostor): number;
  51274. /**
  51275. * Sets pressure inside a soft body impostor
  51276. * Cloth and rope must remain 0 pressure
  51277. * @param impostor impostor to set pressure on
  51278. * @param pressure pressure value
  51279. */
  51280. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  51281. /**
  51282. * Gets stiffness of the impostor
  51283. * @param impostor impostor to get stiffness from
  51284. * @returns pressure value
  51285. */
  51286. getBodyStiffness(impostor: PhysicsImpostor): number;
  51287. /**
  51288. * Sets stiffness of the impostor
  51289. * @param impostor impostor to set stiffness on
  51290. * @param stiffness stiffness value from 0 to 1
  51291. */
  51292. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  51293. /**
  51294. * Gets velocityIterations of the impostor
  51295. * @param impostor impostor to get velocity iterations from
  51296. * @returns velocityIterations value
  51297. */
  51298. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  51299. /**
  51300. * Sets velocityIterations of the impostor
  51301. * @param impostor impostor to set velocity iterations on
  51302. * @param velocityIterations velocityIterations value
  51303. */
  51304. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  51305. /**
  51306. * Gets positionIterations of the impostor
  51307. * @param impostor impostor to get position iterations from
  51308. * @returns positionIterations value
  51309. */
  51310. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  51311. /**
  51312. * Sets positionIterations of the impostor
  51313. * @param impostor impostor to set position on
  51314. * @param positionIterations positionIterations value
  51315. */
  51316. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  51317. /**
  51318. * Append an anchor to a cloth object
  51319. * @param impostor is the cloth impostor to add anchor to
  51320. * @param otherImpostor is the rigid impostor to anchor to
  51321. * @param width ratio across width from 0 to 1
  51322. * @param height ratio up height from 0 to 1
  51323. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  51324. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51325. */
  51326. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51327. /**
  51328. * Append an hook to a rope object
  51329. * @param impostor is the rope impostor to add hook to
  51330. * @param otherImpostor is the rigid impostor to hook to
  51331. * @param length ratio along the rope from 0 to 1
  51332. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  51333. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  51334. */
  51335. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  51336. /**
  51337. * Sleeps the physics body and stops it from being active
  51338. * @param impostor impostor to sleep
  51339. */
  51340. sleepBody(impostor: PhysicsImpostor): void;
  51341. /**
  51342. * Activates the physics body
  51343. * @param impostor impostor to activate
  51344. */
  51345. wakeUpBody(impostor: PhysicsImpostor): void;
  51346. /**
  51347. * Updates the distance parameters of the joint
  51348. * @param joint joint to update
  51349. * @param maxDistance maximum distance of the joint
  51350. * @param minDistance minimum distance of the joint
  51351. */
  51352. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  51353. /**
  51354. * Sets a motor on the joint
  51355. * @param joint joint to set motor on
  51356. * @param speed speed of the motor
  51357. * @param maxForce maximum force of the motor
  51358. * @param motorIndex index of the motor
  51359. */
  51360. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  51361. /**
  51362. * Sets the motors limit
  51363. * @param joint joint to set limit on
  51364. * @param upperLimit upper limit
  51365. * @param lowerLimit lower limit
  51366. */
  51367. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  51368. /**
  51369. * Syncs the position and rotation of a mesh with the impostor
  51370. * @param mesh mesh to sync
  51371. * @param impostor impostor to update the mesh with
  51372. */
  51373. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  51374. /**
  51375. * Gets the radius of the impostor
  51376. * @param impostor impostor to get radius from
  51377. * @returns the radius
  51378. */
  51379. getRadius(impostor: PhysicsImpostor): number;
  51380. /**
  51381. * Gets the box size of the impostor
  51382. * @param impostor impostor to get box size from
  51383. * @param result the resulting box size
  51384. */
  51385. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  51386. /**
  51387. * Disposes of the impostor
  51388. */
  51389. dispose(): void;
  51390. /**
  51391. * Does a raycast in the physics world
  51392. * @param from when should the ray start?
  51393. * @param to when should the ray end?
  51394. * @returns PhysicsRaycastResult
  51395. */
  51396. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  51397. }
  51398. }
  51399. declare module "babylonjs/Probes/reflectionProbe" {
  51400. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51401. import { Vector3 } from "babylonjs/Maths/math";
  51402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51403. import { Nullable } from "babylonjs/types";
  51404. import { Scene } from "babylonjs/scene";
  51405. module "babylonjs/abstractScene" {
  51406. interface AbstractScene {
  51407. /**
  51408. * The list of reflection probes added to the scene
  51409. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51410. */
  51411. reflectionProbes: Array<ReflectionProbe>;
  51412. /**
  51413. * Removes the given reflection probe from this scene.
  51414. * @param toRemove The reflection probe to remove
  51415. * @returns The index of the removed reflection probe
  51416. */
  51417. removeReflectionProbe(toRemove: ReflectionProbe): number;
  51418. /**
  51419. * Adds the given reflection probe to this scene.
  51420. * @param newReflectionProbe The reflection probe to add
  51421. */
  51422. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  51423. }
  51424. }
  51425. /**
  51426. * Class used to generate realtime reflection / refraction cube textures
  51427. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  51428. */
  51429. export class ReflectionProbe {
  51430. /** defines the name of the probe */
  51431. name: string;
  51432. private _scene;
  51433. private _renderTargetTexture;
  51434. private _projectionMatrix;
  51435. private _viewMatrix;
  51436. private _target;
  51437. private _add;
  51438. private _attachedMesh;
  51439. private _invertYAxis;
  51440. /** Gets or sets probe position (center of the cube map) */
  51441. position: Vector3;
  51442. /**
  51443. * Creates a new reflection probe
  51444. * @param name defines the name of the probe
  51445. * @param size defines the texture resolution (for each face)
  51446. * @param scene defines the hosting scene
  51447. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  51448. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  51449. */
  51450. constructor(
  51451. /** defines the name of the probe */
  51452. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  51453. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  51454. samples: number;
  51455. /** Gets or sets the refresh rate to use (on every frame by default) */
  51456. refreshRate: number;
  51457. /**
  51458. * Gets the hosting scene
  51459. * @returns a Scene
  51460. */
  51461. getScene(): Scene;
  51462. /** Gets the internal CubeTexture used to render to */
  51463. readonly cubeTexture: RenderTargetTexture;
  51464. /** Gets the list of meshes to render */
  51465. readonly renderList: Nullable<AbstractMesh[]>;
  51466. /**
  51467. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  51468. * @param mesh defines the mesh to attach to
  51469. */
  51470. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51471. /**
  51472. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  51473. * @param renderingGroupId The rendering group id corresponding to its index
  51474. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  51475. */
  51476. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  51477. /**
  51478. * Clean all associated resources
  51479. */
  51480. dispose(): void;
  51481. /**
  51482. * Converts the reflection probe information to a readable string for debug purpose.
  51483. * @param fullDetails Supports for multiple levels of logging within scene loading
  51484. * @returns the human readable reflection probe info
  51485. */
  51486. toString(fullDetails?: boolean): string;
  51487. /**
  51488. * Get the class name of the relfection probe.
  51489. * @returns "ReflectionProbe"
  51490. */
  51491. getClassName(): string;
  51492. /**
  51493. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  51494. * @returns The JSON representation of the texture
  51495. */
  51496. serialize(): any;
  51497. /**
  51498. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  51499. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  51500. * @param scene Define the scene the parsed reflection probe should be instantiated in
  51501. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  51502. * @returns The parsed reflection probe if successful
  51503. */
  51504. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  51505. }
  51506. }
  51507. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  51508. /** @hidden */
  51509. export var _BabylonLoaderRegistered: boolean;
  51510. }
  51511. declare module "babylonjs/Loading/Plugins/index" {
  51512. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  51513. }
  51514. declare module "babylonjs/Loading/index" {
  51515. export * from "babylonjs/Loading/loadingScreen";
  51516. export * from "babylonjs/Loading/Plugins/index";
  51517. export * from "babylonjs/Loading/sceneLoader";
  51518. export * from "babylonjs/Loading/sceneLoaderFlags";
  51519. }
  51520. declare module "babylonjs/Materials/Background/index" {
  51521. export * from "babylonjs/Materials/Background/backgroundMaterial";
  51522. }
  51523. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  51524. import { Scene } from "babylonjs/scene";
  51525. import { Color3 } from "babylonjs/Maths/math";
  51526. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51527. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51528. /**
  51529. * The Physically based simple base material of BJS.
  51530. *
  51531. * This enables better naming and convention enforcements on top of the pbrMaterial.
  51532. * It is used as the base class for both the specGloss and metalRough conventions.
  51533. */
  51534. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  51535. /**
  51536. * Number of Simultaneous lights allowed on the material.
  51537. */
  51538. maxSimultaneousLights: number;
  51539. /**
  51540. * If sets to true, disables all the lights affecting the material.
  51541. */
  51542. disableLighting: boolean;
  51543. /**
  51544. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  51545. */
  51546. environmentTexture: BaseTexture;
  51547. /**
  51548. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  51549. */
  51550. invertNormalMapX: boolean;
  51551. /**
  51552. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  51553. */
  51554. invertNormalMapY: boolean;
  51555. /**
  51556. * Normal map used in the model.
  51557. */
  51558. normalTexture: BaseTexture;
  51559. /**
  51560. * Emissivie color used to self-illuminate the model.
  51561. */
  51562. emissiveColor: Color3;
  51563. /**
  51564. * Emissivie texture used to self-illuminate the model.
  51565. */
  51566. emissiveTexture: BaseTexture;
  51567. /**
  51568. * Occlusion Channel Strenght.
  51569. */
  51570. occlusionStrength: number;
  51571. /**
  51572. * Occlusion Texture of the material (adding extra occlusion effects).
  51573. */
  51574. occlusionTexture: BaseTexture;
  51575. /**
  51576. * Defines the alpha limits in alpha test mode.
  51577. */
  51578. alphaCutOff: number;
  51579. /**
  51580. * Gets the current double sided mode.
  51581. */
  51582. /**
  51583. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  51584. */
  51585. doubleSided: boolean;
  51586. /**
  51587. * Stores the pre-calculated light information of a mesh in a texture.
  51588. */
  51589. lightmapTexture: BaseTexture;
  51590. /**
  51591. * If true, the light map contains occlusion information instead of lighting info.
  51592. */
  51593. useLightmapAsShadowmap: boolean;
  51594. /**
  51595. * Instantiates a new PBRMaterial instance.
  51596. *
  51597. * @param name The material name
  51598. * @param scene The scene the material will be use in.
  51599. */
  51600. constructor(name: string, scene: Scene);
  51601. getClassName(): string;
  51602. }
  51603. }
  51604. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  51605. import { Scene } from "babylonjs/scene";
  51606. import { Color3 } from "babylonjs/Maths/math";
  51607. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51608. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51609. /**
  51610. * The PBR material of BJS following the metal roughness convention.
  51611. *
  51612. * This fits to the PBR convention in the GLTF definition:
  51613. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  51614. */
  51615. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  51616. /**
  51617. * The base color has two different interpretations depending on the value of metalness.
  51618. * When the material is a metal, the base color is the specific measured reflectance value
  51619. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  51620. * of the material.
  51621. */
  51622. baseColor: Color3;
  51623. /**
  51624. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  51625. * well as opacity information in the alpha channel.
  51626. */
  51627. baseTexture: BaseTexture;
  51628. /**
  51629. * Specifies the metallic scalar value of the material.
  51630. * Can also be used to scale the metalness values of the metallic texture.
  51631. */
  51632. metallic: number;
  51633. /**
  51634. * Specifies the roughness scalar value of the material.
  51635. * Can also be used to scale the roughness values of the metallic texture.
  51636. */
  51637. roughness: number;
  51638. /**
  51639. * Texture containing both the metallic value in the B channel and the
  51640. * roughness value in the G channel to keep better precision.
  51641. */
  51642. metallicRoughnessTexture: BaseTexture;
  51643. /**
  51644. * Instantiates a new PBRMetalRoughnessMaterial instance.
  51645. *
  51646. * @param name The material name
  51647. * @param scene The scene the material will be use in.
  51648. */
  51649. constructor(name: string, scene: Scene);
  51650. /**
  51651. * Return the currrent class name of the material.
  51652. */
  51653. getClassName(): string;
  51654. /**
  51655. * Makes a duplicate of the current material.
  51656. * @param name - name to use for the new material.
  51657. */
  51658. clone(name: string): PBRMetallicRoughnessMaterial;
  51659. /**
  51660. * Serialize the material to a parsable JSON object.
  51661. */
  51662. serialize(): any;
  51663. /**
  51664. * Parses a JSON object correponding to the serialize function.
  51665. */
  51666. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  51667. }
  51668. }
  51669. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  51670. import { Scene } from "babylonjs/scene";
  51671. import { Color3 } from "babylonjs/Maths/math";
  51672. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51673. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51674. /**
  51675. * The PBR material of BJS following the specular glossiness convention.
  51676. *
  51677. * This fits to the PBR convention in the GLTF definition:
  51678. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  51679. */
  51680. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  51681. /**
  51682. * Specifies the diffuse color of the material.
  51683. */
  51684. diffuseColor: Color3;
  51685. /**
  51686. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  51687. * channel.
  51688. */
  51689. diffuseTexture: BaseTexture;
  51690. /**
  51691. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  51692. */
  51693. specularColor: Color3;
  51694. /**
  51695. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  51696. */
  51697. glossiness: number;
  51698. /**
  51699. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  51700. */
  51701. specularGlossinessTexture: BaseTexture;
  51702. /**
  51703. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  51704. *
  51705. * @param name The material name
  51706. * @param scene The scene the material will be use in.
  51707. */
  51708. constructor(name: string, scene: Scene);
  51709. /**
  51710. * Return the currrent class name of the material.
  51711. */
  51712. getClassName(): string;
  51713. /**
  51714. * Makes a duplicate of the current material.
  51715. * @param name - name to use for the new material.
  51716. */
  51717. clone(name: string): PBRSpecularGlossinessMaterial;
  51718. /**
  51719. * Serialize the material to a parsable JSON object.
  51720. */
  51721. serialize(): any;
  51722. /**
  51723. * Parses a JSON object correponding to the serialize function.
  51724. */
  51725. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  51726. }
  51727. }
  51728. declare module "babylonjs/Materials/PBR/index" {
  51729. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  51730. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  51731. export * from "babylonjs/Materials/PBR/pbrMaterial";
  51732. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  51733. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  51734. }
  51735. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  51736. import { Nullable } from "babylonjs/types";
  51737. import { Scene } from "babylonjs/scene";
  51738. import { Matrix } from "babylonjs/Maths/math";
  51739. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51740. /**
  51741. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  51742. * It can help converting any input color in a desired output one. This can then be used to create effects
  51743. * from sepia, black and white to sixties or futuristic rendering...
  51744. *
  51745. * The only supported format is currently 3dl.
  51746. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  51747. */
  51748. export class ColorGradingTexture extends BaseTexture {
  51749. /**
  51750. * The current texture matrix. (will always be identity in color grading texture)
  51751. */
  51752. private _textureMatrix;
  51753. /**
  51754. * The texture URL.
  51755. */
  51756. url: string;
  51757. /**
  51758. * Empty line regex stored for GC.
  51759. */
  51760. private static _noneEmptyLineRegex;
  51761. private _engine;
  51762. /**
  51763. * Instantiates a ColorGradingTexture from the following parameters.
  51764. *
  51765. * @param url The location of the color gradind data (currently only supporting 3dl)
  51766. * @param scene The scene the texture will be used in
  51767. */
  51768. constructor(url: string, scene: Scene);
  51769. /**
  51770. * Returns the texture matrix used in most of the material.
  51771. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  51772. */
  51773. getTextureMatrix(): Matrix;
  51774. /**
  51775. * Occurs when the file being loaded is a .3dl LUT file.
  51776. */
  51777. private load3dlTexture;
  51778. /**
  51779. * Starts the loading process of the texture.
  51780. */
  51781. private loadTexture;
  51782. /**
  51783. * Clones the color gradind texture.
  51784. */
  51785. clone(): ColorGradingTexture;
  51786. /**
  51787. * Called during delayed load for textures.
  51788. */
  51789. delayLoad(): void;
  51790. /**
  51791. * Parses a color grading texture serialized by Babylon.
  51792. * @param parsedTexture The texture information being parsedTexture
  51793. * @param scene The scene to load the texture in
  51794. * @param rootUrl The root url of the data assets to load
  51795. * @return A color gradind texture
  51796. */
  51797. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51798. /**
  51799. * Serializes the LUT texture to json format.
  51800. */
  51801. serialize(): any;
  51802. }
  51803. }
  51804. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51805. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51806. import { Scene } from "babylonjs/scene";
  51807. import { Nullable } from "babylonjs/types";
  51808. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51809. /**
  51810. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51811. */
  51812. export class EquiRectangularCubeTexture extends BaseTexture {
  51813. /** The six faces of the cube. */
  51814. private static _FacesMapping;
  51815. private _noMipmap;
  51816. private _onLoad;
  51817. private _onError;
  51818. /** The size of the cubemap. */
  51819. private _size;
  51820. /** The buffer of the image. */
  51821. private _buffer;
  51822. /** The width of the input image. */
  51823. private _width;
  51824. /** The height of the input image. */
  51825. private _height;
  51826. /** The URL to the image. */
  51827. url: string;
  51828. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51829. coordinatesMode: number;
  51830. /**
  51831. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51832. * @param url The location of the image
  51833. * @param scene The scene the texture will be used in
  51834. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51835. * @param noMipmap Forces to not generate the mipmap if true
  51836. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51837. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51838. * @param onLoad — defines a callback called when texture is loaded
  51839. * @param onError — defines a callback called if there is an error
  51840. */
  51841. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51842. /**
  51843. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51844. */
  51845. private loadImage;
  51846. /**
  51847. * Convert the image buffer into a cubemap and create a CubeTexture.
  51848. */
  51849. private loadTexture;
  51850. /**
  51851. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51852. * @param buffer The ArrayBuffer that should be converted.
  51853. * @returns The buffer as Float32Array.
  51854. */
  51855. private getFloat32ArrayFromArrayBuffer;
  51856. /**
  51857. * Get the current class name of the texture useful for serialization or dynamic coding.
  51858. * @returns "EquiRectangularCubeTexture"
  51859. */
  51860. getClassName(): string;
  51861. /**
  51862. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51863. * @returns A clone of the current EquiRectangularCubeTexture.
  51864. */
  51865. clone(): EquiRectangularCubeTexture;
  51866. }
  51867. }
  51868. declare module "babylonjs/Misc/tga" {
  51869. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51870. /**
  51871. * Based on jsTGALoader - Javascript loader for TGA file
  51872. * By Vincent Thibault
  51873. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51874. */
  51875. export class TGATools {
  51876. private static _TYPE_INDEXED;
  51877. private static _TYPE_RGB;
  51878. private static _TYPE_GREY;
  51879. private static _TYPE_RLE_INDEXED;
  51880. private static _TYPE_RLE_RGB;
  51881. private static _TYPE_RLE_GREY;
  51882. private static _ORIGIN_MASK;
  51883. private static _ORIGIN_SHIFT;
  51884. private static _ORIGIN_BL;
  51885. private static _ORIGIN_BR;
  51886. private static _ORIGIN_UL;
  51887. private static _ORIGIN_UR;
  51888. /**
  51889. * Gets the header of a TGA file
  51890. * @param data defines the TGA data
  51891. * @returns the header
  51892. */
  51893. static GetTGAHeader(data: Uint8Array): any;
  51894. /**
  51895. * Uploads TGA content to a Babylon Texture
  51896. * @hidden
  51897. */
  51898. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51899. /** @hidden */
  51900. 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;
  51901. /** @hidden */
  51902. 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;
  51903. /** @hidden */
  51904. 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;
  51905. /** @hidden */
  51906. 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;
  51907. /** @hidden */
  51908. 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;
  51909. /** @hidden */
  51910. 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;
  51911. }
  51912. }
  51913. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51914. import { Nullable } from "babylonjs/types";
  51915. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51916. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51917. /**
  51918. * Implementation of the TGA Texture Loader.
  51919. * @hidden
  51920. */
  51921. export class _TGATextureLoader implements IInternalTextureLoader {
  51922. /**
  51923. * Defines wether the loader supports cascade loading the different faces.
  51924. */
  51925. readonly supportCascades: boolean;
  51926. /**
  51927. * This returns if the loader support the current file information.
  51928. * @param extension defines the file extension of the file being loaded
  51929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51930. * @param fallback defines the fallback internal texture if any
  51931. * @param isBase64 defines whether the texture is encoded as a base64
  51932. * @param isBuffer defines whether the texture data are stored as a buffer
  51933. * @returns true if the loader can load the specified file
  51934. */
  51935. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51936. /**
  51937. * Transform the url before loading if required.
  51938. * @param rootUrl the url of the texture
  51939. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51940. * @returns the transformed texture
  51941. */
  51942. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51943. /**
  51944. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51945. * @param rootUrl the url of the texture
  51946. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51947. * @returns the fallback texture
  51948. */
  51949. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51950. /**
  51951. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51952. * @param data contains the texture data
  51953. * @param texture defines the BabylonJS internal texture
  51954. * @param createPolynomials will be true if polynomials have been requested
  51955. * @param onLoad defines the callback to trigger once the texture is ready
  51956. * @param onError defines the callback to trigger in case of error
  51957. */
  51958. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51959. /**
  51960. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51961. * @param data contains the texture data
  51962. * @param texture defines the BabylonJS internal texture
  51963. * @param callback defines the method to call once ready to upload
  51964. */
  51965. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51966. }
  51967. }
  51968. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51969. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51970. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51971. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51972. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51973. }
  51974. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51975. import { Scene } from "babylonjs/scene";
  51976. import { Texture } from "babylonjs/Materials/Textures/texture";
  51977. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51978. /**
  51979. * 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.
  51980. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51981. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51982. */
  51983. export class CustomProceduralTexture extends ProceduralTexture {
  51984. private _animate;
  51985. private _time;
  51986. private _config;
  51987. private _texturePath;
  51988. /**
  51989. * Instantiates a new Custom Procedural Texture.
  51990. * 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.
  51991. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51992. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51993. * @param name Define the name of the texture
  51994. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51995. * @param size Define the size of the texture to create
  51996. * @param scene Define the scene the texture belongs to
  51997. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51998. * @param generateMipMaps Define if the texture should creates mip maps or not
  51999. */
  52000. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52001. private _loadJson;
  52002. /**
  52003. * Is the texture ready to be used ? (rendered at least once)
  52004. * @returns true if ready, otherwise, false.
  52005. */
  52006. isReady(): boolean;
  52007. /**
  52008. * Render the texture to its associated render target.
  52009. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  52010. */
  52011. render(useCameraPostProcess?: boolean): void;
  52012. /**
  52013. * Update the list of dependant textures samplers in the shader.
  52014. */
  52015. updateTextures(): void;
  52016. /**
  52017. * Update the uniform values of the procedural texture in the shader.
  52018. */
  52019. updateShaderUniforms(): void;
  52020. /**
  52021. * Define if the texture animates or not.
  52022. */
  52023. animate: boolean;
  52024. }
  52025. }
  52026. declare module "babylonjs/Shaders/noise.fragment" {
  52027. /** @hidden */
  52028. export var noisePixelShader: {
  52029. name: string;
  52030. shader: string;
  52031. };
  52032. }
  52033. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  52034. import { Nullable } from "babylonjs/types";
  52035. import { Scene } from "babylonjs/scene";
  52036. import { Texture } from "babylonjs/Materials/Textures/texture";
  52037. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52038. import "babylonjs/Shaders/noise.fragment";
  52039. /**
  52040. * Class used to generate noise procedural textures
  52041. */
  52042. export class NoiseProceduralTexture extends ProceduralTexture {
  52043. private _time;
  52044. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  52045. brightness: number;
  52046. /** Defines the number of octaves to process */
  52047. octaves: number;
  52048. /** Defines the level of persistence (0.8 by default) */
  52049. persistence: number;
  52050. /** Gets or sets animation speed factor (default is 1) */
  52051. animationSpeedFactor: number;
  52052. /**
  52053. * Creates a new NoiseProceduralTexture
  52054. * @param name defines the name fo the texture
  52055. * @param size defines the size of the texture (default is 256)
  52056. * @param scene defines the hosting scene
  52057. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  52058. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  52059. */
  52060. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  52061. private _updateShaderUniforms;
  52062. protected _getDefines(): string;
  52063. /** Generate the current state of the procedural texture */
  52064. render(useCameraPostProcess?: boolean): void;
  52065. /**
  52066. * Serializes this noise procedural texture
  52067. * @returns a serialized noise procedural texture object
  52068. */
  52069. serialize(): any;
  52070. /**
  52071. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  52072. * @param parsedTexture defines parsed texture data
  52073. * @param scene defines the current scene
  52074. * @param rootUrl defines the root URL containing noise procedural texture information
  52075. * @returns a parsed NoiseProceduralTexture
  52076. */
  52077. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  52078. }
  52079. }
  52080. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  52081. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  52082. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  52083. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  52084. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  52085. }
  52086. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  52087. import { Nullable } from "babylonjs/types";
  52088. import { Scene } from "babylonjs/scene";
  52089. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  52090. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  52091. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  52092. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52093. /**
  52094. * Raw cube texture where the raw buffers are passed in
  52095. */
  52096. export class RawCubeTexture extends CubeTexture {
  52097. /**
  52098. * Creates a cube texture where the raw buffers are passed in.
  52099. * @param scene defines the scene the texture is attached to
  52100. * @param data defines the array of data to use to create each face
  52101. * @param size defines the size of the textures
  52102. * @param format defines the format of the data
  52103. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  52104. * @param generateMipMaps defines if the engine should generate the mip levels
  52105. * @param invertY defines if data must be stored with Y axis inverted
  52106. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  52107. * @param compression defines the compression used (null by default)
  52108. */
  52109. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  52110. /**
  52111. * Updates the raw cube texture.
  52112. * @param data defines the data to store
  52113. * @param format defines the data format
  52114. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  52115. * @param invertY defines if data must be stored with Y axis inverted
  52116. * @param compression defines the compression used (null by default)
  52117. * @param level defines which level of the texture to update
  52118. */
  52119. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  52120. /**
  52121. * Updates a raw cube texture with RGBD encoded data.
  52122. * @param data defines the array of data [mipmap][face] to use to create each face
  52123. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  52124. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  52125. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  52126. * @returns a promsie that resolves when the operation is complete
  52127. */
  52128. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  52129. /**
  52130. * Clones the raw cube texture.
  52131. * @return a new cube texture
  52132. */
  52133. clone(): CubeTexture;
  52134. /** @hidden */
  52135. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  52136. }
  52137. }
  52138. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  52139. import { Scene } from "babylonjs/scene";
  52140. import { Texture } from "babylonjs/Materials/Textures/texture";
  52141. import "babylonjs/Engines/Extensions/engine.rawTexture";
  52142. /**
  52143. * Class used to store 3D textures containing user data
  52144. */
  52145. export class RawTexture3D extends Texture {
  52146. /** Gets or sets the texture format to use */
  52147. format: number;
  52148. private _engine;
  52149. /**
  52150. * Create a new RawTexture3D
  52151. * @param data defines the data of the texture
  52152. * @param width defines the width of the texture
  52153. * @param height defines the height of the texture
  52154. * @param depth defines the depth of the texture
  52155. * @param format defines the texture format to use
  52156. * @param scene defines the hosting scene
  52157. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  52158. * @param invertY defines if texture must be stored with Y axis inverted
  52159. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  52160. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  52161. */
  52162. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  52163. /** Gets or sets the texture format to use */
  52164. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  52165. /**
  52166. * Update the texture with new data
  52167. * @param data defines the data to store in the texture
  52168. */
  52169. update(data: ArrayBufferView): void;
  52170. }
  52171. }
  52172. declare module "babylonjs/Materials/Textures/refractionTexture" {
  52173. import { Scene } from "babylonjs/scene";
  52174. import { Plane } from "babylonjs/Maths/math";
  52175. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52176. /**
  52177. * Creates a refraction texture used by refraction channel of the standard material.
  52178. * It is like a mirror but to see through a material.
  52179. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52180. */
  52181. export class RefractionTexture extends RenderTargetTexture {
  52182. /**
  52183. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  52184. * 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.
  52185. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52186. */
  52187. refractionPlane: Plane;
  52188. /**
  52189. * Define how deep under the surface we should see.
  52190. */
  52191. depth: number;
  52192. /**
  52193. * Creates a refraction texture used by refraction channel of the standard material.
  52194. * It is like a mirror but to see through a material.
  52195. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  52196. * @param name Define the texture name
  52197. * @param size Define the size of the underlying texture
  52198. * @param scene Define the scene the refraction belongs to
  52199. * @param generateMipMaps Define if we need to generate mips level for the refraction
  52200. */
  52201. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  52202. /**
  52203. * Clone the refraction texture.
  52204. * @returns the cloned texture
  52205. */
  52206. clone(): RefractionTexture;
  52207. /**
  52208. * Serialize the texture to a JSON representation you could use in Parse later on
  52209. * @returns the serialized JSON representation
  52210. */
  52211. serialize(): any;
  52212. }
  52213. }
  52214. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  52215. import { Nullable } from "babylonjs/types";
  52216. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52217. import { Matrix } from "babylonjs/Maths/math";
  52218. import { Engine } from "babylonjs/Engines/engine";
  52219. import { Scene } from "babylonjs/scene";
  52220. /**
  52221. * Defines the options related to the creation of an HtmlElementTexture
  52222. */
  52223. export interface IHtmlElementTextureOptions {
  52224. /**
  52225. * Defines wether mip maps should be created or not.
  52226. */
  52227. generateMipMaps?: boolean;
  52228. /**
  52229. * Defines the sampling mode of the texture.
  52230. */
  52231. samplingMode?: number;
  52232. /**
  52233. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  52234. */
  52235. engine: Nullable<Engine>;
  52236. /**
  52237. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  52238. */
  52239. scene: Nullable<Scene>;
  52240. }
  52241. /**
  52242. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  52243. * To be as efficient as possible depending on your constraints nothing aside the first upload
  52244. * is automatically managed.
  52245. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  52246. * in your application.
  52247. *
  52248. * As the update is not automatic, you need to call them manually.
  52249. */
  52250. export class HtmlElementTexture extends BaseTexture {
  52251. /**
  52252. * The texture URL.
  52253. */
  52254. element: HTMLVideoElement | HTMLCanvasElement;
  52255. private static readonly DefaultOptions;
  52256. private _textureMatrix;
  52257. private _engine;
  52258. private _isVideo;
  52259. private _generateMipMaps;
  52260. private _samplingMode;
  52261. /**
  52262. * Instantiates a HtmlElementTexture from the following parameters.
  52263. *
  52264. * @param name Defines the name of the texture
  52265. * @param element Defines the video or canvas the texture is filled with
  52266. * @param options Defines the other none mandatory texture creation options
  52267. */
  52268. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  52269. private _createInternalTexture;
  52270. /**
  52271. * Returns the texture matrix used in most of the material.
  52272. */
  52273. getTextureMatrix(): Matrix;
  52274. /**
  52275. * Updates the content of the texture.
  52276. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  52277. */
  52278. update(invertY?: Nullable<boolean>): void;
  52279. }
  52280. }
  52281. declare module "babylonjs/Materials/Textures/index" {
  52282. export * from "babylonjs/Materials/Textures/baseTexture";
  52283. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  52284. export * from "babylonjs/Materials/Textures/cubeTexture";
  52285. export * from "babylonjs/Materials/Textures/dynamicTexture";
  52286. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  52287. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  52288. export * from "babylonjs/Materials/Textures/internalTexture";
  52289. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  52290. export * from "babylonjs/Materials/Textures/Loaders/index";
  52291. export * from "babylonjs/Materials/Textures/mirrorTexture";
  52292. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  52293. export * from "babylonjs/Materials/Textures/Procedurals/index";
  52294. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  52295. export * from "babylonjs/Materials/Textures/rawTexture";
  52296. export * from "babylonjs/Materials/Textures/rawTexture3D";
  52297. export * from "babylonjs/Materials/Textures/refractionTexture";
  52298. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  52299. export * from "babylonjs/Materials/Textures/texture";
  52300. export * from "babylonjs/Materials/Textures/videoTexture";
  52301. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  52302. }
  52303. declare module "babylonjs/Materials/Node/nodeMaterialBlockTargets" {
  52304. /**
  52305. * Enum used to define the target of a block
  52306. */
  52307. export enum NodeMaterialBlockTargets {
  52308. /** Vertex shader */
  52309. Vertex = 1,
  52310. /** Fragment shader */
  52311. Fragment = 2,
  52312. /** Vertex and Fragment */
  52313. VertexAndFragment = 3
  52314. }
  52315. }
  52316. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes" {
  52317. /**
  52318. * Defines the kind of connection point for node based material
  52319. */
  52320. export enum NodeMaterialBlockConnectionPointTypes {
  52321. /** Float */
  52322. Float = 1,
  52323. /** Int */
  52324. Int = 2,
  52325. /** Vector2 */
  52326. Vector2 = 4,
  52327. /** Vector3 */
  52328. Vector3 = 8,
  52329. /** Vector4 */
  52330. Vector4 = 16,
  52331. /** Color3 */
  52332. Color3 = 32,
  52333. /** Color4 */
  52334. Color4 = 64,
  52335. /** Matrix */
  52336. Matrix = 128,
  52337. /** Texture */
  52338. Texture = 256,
  52339. /** Texture3D */
  52340. Texture3D = 512,
  52341. /** Vector3 or Color3 */
  52342. Vector3OrColor3 = 40,
  52343. /** Vector3 or Vector4 */
  52344. Vector3OrVector4 = 24,
  52345. /** Vector4 or Color4 */
  52346. Vector4OrColor4 = 80,
  52347. /** Color3 or Color4 */
  52348. Color3OrColor4 = 96,
  52349. /** Vector3 or Color3 */
  52350. Vector3OrColor3OrVector4OrColor4 = 120
  52351. }
  52352. }
  52353. declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
  52354. /**
  52355. * Enum used to define well known values e.g. values automatically provided by the system
  52356. */
  52357. export enum NodeMaterialWellKnownValues {
  52358. /** World */
  52359. World = 1,
  52360. /** View */
  52361. View = 2,
  52362. /** Projection */
  52363. Projection = 3,
  52364. /** ViewProjection */
  52365. ViewProjection = 4,
  52366. /** WorldView */
  52367. WorldView = 5,
  52368. /** WorldViewProjection */
  52369. WorldViewProjection = 6,
  52370. /** Will be filled by the block itself */
  52371. Automatic = 7
  52372. }
  52373. }
  52374. declare module "babylonjs/Materials/Node/NodeMaterialBlockConnectionPointMode" {
  52375. /**
  52376. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  52377. */
  52378. export enum NodeMaterialBlockConnectionPointMode {
  52379. /** Value is an uniform */
  52380. Uniform = 0,
  52381. /** Value is a mesh attribute */
  52382. Attribute = 1,
  52383. /** Value is a varying between vertex and fragment shaders */
  52384. Varying = 2,
  52385. /** Mode is undefined */
  52386. Undefined = 3
  52387. }
  52388. }
  52389. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  52390. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52391. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52392. /**
  52393. * Class used to store shared data between 2 NodeMaterialBuildState
  52394. */
  52395. export class NodeMaterialBuildStateSharedData {
  52396. /**
  52397. * Gets the list of emitted varyings
  52398. */
  52399. varyings: string[];
  52400. /**
  52401. * Gets the varying declaration string
  52402. */
  52403. varyingDeclaration: string;
  52404. /**
  52405. * Uniform connection points
  52406. */
  52407. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  52408. /**
  52409. * Bindable blocks (Blocks that need to set data to the effect)
  52410. */
  52411. bindableBlocks: NodeMaterialBlock[];
  52412. /**
  52413. * List of blocks that can provide a compilation fallback
  52414. */
  52415. blocksWithFallbacks: NodeMaterialBlock[];
  52416. /**
  52417. * List of blocks that can provide a define update
  52418. */
  52419. blocksWithDefines: NodeMaterialBlock[];
  52420. /**
  52421. * List of blocks that can provide a repeatable content
  52422. */
  52423. repeatableContentBlocks: NodeMaterialBlock[];
  52424. /**
  52425. * List of blocks that can block the isReady function for the material
  52426. */
  52427. blockingBlocks: NodeMaterialBlock[];
  52428. /**
  52429. * Build Id used to avoid multiple recompilations
  52430. */
  52431. buildId: number;
  52432. /** List of emitted variables */
  52433. variableNames: {
  52434. [key: string]: number;
  52435. };
  52436. /** List of emitted defines */
  52437. defineNames: {
  52438. [key: string]: number;
  52439. };
  52440. /** Should emit comments? */
  52441. emitComments: boolean;
  52442. /** Emit build activity */
  52443. verbose: boolean;
  52444. /**
  52445. * Gets the compilation hints emitted at compilation time
  52446. */
  52447. hints: {
  52448. needWorldViewMatrix: boolean;
  52449. needWorldViewProjectionMatrix: boolean;
  52450. needAlphaBlending: boolean;
  52451. needAlphaTesting: boolean;
  52452. };
  52453. /**
  52454. * List of compilation checks
  52455. */
  52456. checks: {
  52457. emitVertex: boolean;
  52458. emitFragment: boolean;
  52459. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  52460. };
  52461. /** Creates a new shared data */
  52462. constructor();
  52463. /**
  52464. * Emits console errors and exceptions if there is a failing check
  52465. */
  52466. emitErrors(): void;
  52467. }
  52468. }
  52469. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  52470. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52471. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52472. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52473. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  52474. /**
  52475. * Class used to store node based material build state
  52476. */
  52477. export class NodeMaterialBuildState {
  52478. /**
  52479. * Gets the list of emitted attributes
  52480. */
  52481. attributes: string[];
  52482. /**
  52483. * Gets the list of emitted uniforms
  52484. */
  52485. uniforms: string[];
  52486. /**
  52487. * Gets the list of emitted samplers
  52488. */
  52489. samplers: string[];
  52490. /**
  52491. * Gets the list of emitted functions
  52492. */
  52493. functions: {
  52494. [key: string]: string;
  52495. };
  52496. /**
  52497. * Gets the target of the compilation state
  52498. */
  52499. target: NodeMaterialBlockTargets;
  52500. /**
  52501. * Shared data between multiple NodeMaterialBuildState instances
  52502. */
  52503. sharedData: NodeMaterialBuildStateSharedData;
  52504. /** @hidden */
  52505. _vertexState: NodeMaterialBuildState;
  52506. private _attributeDeclaration;
  52507. private _uniformDeclaration;
  52508. private _samplerDeclaration;
  52509. private _varyingTransfer;
  52510. private _repeatableContentAnchorIndex;
  52511. /** @hidden */
  52512. _builtCompilationString: string;
  52513. /**
  52514. * Gets the emitted compilation strings
  52515. */
  52516. compilationString: string;
  52517. /**
  52518. * Finalize the compilation strings
  52519. * @param state defines the current compilation state
  52520. */
  52521. finalize(state: NodeMaterialBuildState): void;
  52522. /** @hidden */
  52523. readonly _repeatableContentAnchor: string;
  52524. /** @hidden */
  52525. _getFreeVariableName(prefix: string): string;
  52526. /** @hidden */
  52527. _getFreeDefineName(prefix: string): string;
  52528. /** @hidden */
  52529. _excludeVariableName(name: string): void;
  52530. /** @hidden */
  52531. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  52532. /** @hidden */
  52533. _emitFunction(name: string, code: string, comments: string): void;
  52534. /** @hidden */
  52535. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  52536. replaceStrings?: {
  52537. search: RegExp;
  52538. replace: string;
  52539. }[];
  52540. }): string;
  52541. /** @hidden */
  52542. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  52543. repeatKey?: string;
  52544. removeAttributes?: boolean;
  52545. removeUniforms?: boolean;
  52546. removeVaryings?: boolean;
  52547. removeIfDef?: boolean;
  52548. replaceStrings?: {
  52549. search: RegExp;
  52550. replace: string;
  52551. }[];
  52552. }): void;
  52553. /** @hidden */
  52554. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  52555. private _emitDefine;
  52556. /** @hidden */
  52557. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  52558. }
  52559. }
  52560. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  52561. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52562. /**
  52563. * Root class for all node material optimizers
  52564. */
  52565. export class NodeMaterialOptimizer {
  52566. /**
  52567. * Function used to optimize a NodeMaterial graph
  52568. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  52569. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  52570. */
  52571. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  52572. }
  52573. }
  52574. declare module "babylonjs/Materials/Node/nodeMaterial" {
  52575. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52576. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  52577. import { Scene } from "babylonjs/scene";
  52578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52579. import { Matrix } from "babylonjs/Maths/math";
  52580. import { Mesh } from "babylonjs/Meshes/mesh";
  52581. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52582. import { Observable } from "babylonjs/Misc/observable";
  52583. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52584. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  52585. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  52586. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  52587. import { Nullable } from "babylonjs/types";
  52588. /**
  52589. * Interface used to configure the node material editor
  52590. */
  52591. export interface INodeMaterialEditorOptions {
  52592. /** Define the URl to load node editor script */
  52593. editorURL?: string;
  52594. }
  52595. /** @hidden */
  52596. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  52597. /** BONES */
  52598. NUM_BONE_INFLUENCERS: number;
  52599. BonesPerMesh: number;
  52600. BONETEXTURE: boolean;
  52601. /** MORPH TARGETS */
  52602. MORPHTARGETS: boolean;
  52603. MORPHTARGETS_NORMAL: boolean;
  52604. MORPHTARGETS_TANGENT: boolean;
  52605. NUM_MORPH_INFLUENCERS: number;
  52606. /** IMAGE PROCESSING */
  52607. IMAGEPROCESSING: boolean;
  52608. VIGNETTE: boolean;
  52609. VIGNETTEBLENDMODEMULTIPLY: boolean;
  52610. VIGNETTEBLENDMODEOPAQUE: boolean;
  52611. TONEMAPPING: boolean;
  52612. TONEMAPPING_ACES: boolean;
  52613. CONTRAST: boolean;
  52614. EXPOSURE: boolean;
  52615. COLORCURVES: boolean;
  52616. COLORGRADING: boolean;
  52617. COLORGRADING3D: boolean;
  52618. SAMPLER3DGREENDEPTH: boolean;
  52619. SAMPLER3DBGRMAP: boolean;
  52620. IMAGEPROCESSINGPOSTPROCESS: boolean;
  52621. constructor();
  52622. setValue(name: string, value: boolean): void;
  52623. }
  52624. /**
  52625. * Class used to configure NodeMaterial
  52626. */
  52627. export interface INodeMaterialOptions {
  52628. /**
  52629. * Defines if blocks should emit comments
  52630. */
  52631. emitComments: boolean;
  52632. }
  52633. /**
  52634. * Class used to create a node based material built by assembling shader blocks
  52635. */
  52636. export class NodeMaterial extends PushMaterial {
  52637. private _options;
  52638. private _vertexCompilationState;
  52639. private _fragmentCompilationState;
  52640. private _sharedData;
  52641. private _buildId;
  52642. private _buildWasSuccessful;
  52643. private _cachedWorldViewMatrix;
  52644. private _cachedWorldViewProjectionMatrix;
  52645. private _textureConnectionPoints;
  52646. private _optimizers;
  52647. /** Define the URl to load node editor script */
  52648. static EditorURL: string;
  52649. private BJSNODEMATERIALEDITOR;
  52650. /** Get the inspector from bundle or global */
  52651. private _getGlobalNodeMaterialEditor;
  52652. /**
  52653. * Defines the maximum number of lights that can be used in the material
  52654. */
  52655. maxSimultaneousLights: number;
  52656. /**
  52657. * Observable raised when the material is built
  52658. */
  52659. onBuildObservable: Observable<NodeMaterial>;
  52660. /**
  52661. * Gets or sets the root nodes of the material vertex shader
  52662. */
  52663. _vertexOutputNodes: NodeMaterialBlock[];
  52664. /**
  52665. * Gets or sets the root nodes of the material fragment (pixel) shader
  52666. */
  52667. _fragmentOutputNodes: NodeMaterialBlock[];
  52668. /** Gets or sets options to control the node material overall behavior */
  52669. options: INodeMaterialOptions;
  52670. /**
  52671. * Default configuration related to image processing available in the standard Material.
  52672. */
  52673. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  52674. /**
  52675. * Gets the image processing configuration used either in this material.
  52676. */
  52677. /**
  52678. * Sets the Default image processing configuration used either in the this material.
  52679. *
  52680. * If sets to null, the scene one is in use.
  52681. */
  52682. imageProcessingConfiguration: ImageProcessingConfiguration;
  52683. /**
  52684. * Create a new node based material
  52685. * @param name defines the material name
  52686. * @param scene defines the hosting scene
  52687. * @param options defines creation option
  52688. */
  52689. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  52690. /**
  52691. * Gets the current class name of the material e.g. "NodeMaterial"
  52692. * @returns the class name
  52693. */
  52694. getClassName(): string;
  52695. /**
  52696. * Keep track of the image processing observer to allow dispose and replace.
  52697. */
  52698. private _imageProcessingObserver;
  52699. /**
  52700. * Attaches a new image processing configuration to the Standard Material.
  52701. * @param configuration
  52702. */
  52703. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  52704. /**
  52705. * Adds a new optimizer to the list of optimizers
  52706. * @param optimizer defines the optimizers to add
  52707. * @returns the current material
  52708. */
  52709. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52710. /**
  52711. * Remove an optimizer from the list of optimizers
  52712. * @param optimizer defines the optimizers to remove
  52713. * @returns the current material
  52714. */
  52715. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  52716. /**
  52717. * Add a new block to the list of output nodes
  52718. * @param node defines the node to add
  52719. * @returns the current material
  52720. */
  52721. addOutputNode(node: NodeMaterialBlock): this;
  52722. /**
  52723. * Remove a block from the list of root nodes
  52724. * @param node defines the node to remove
  52725. * @returns the current material
  52726. */
  52727. removeOutputNode(node: NodeMaterialBlock): this;
  52728. private _addVertexOutputNode;
  52729. private _removeVertexOutputNode;
  52730. private _addFragmentOutputNode;
  52731. private _removeFragmentOutputNode;
  52732. /**
  52733. * Specifies if the material will require alpha blending
  52734. * @returns a boolean specifying if alpha blending is needed
  52735. */
  52736. needAlphaBlending(): boolean;
  52737. /**
  52738. * Specifies if this material should be rendered in alpha test mode
  52739. * @returns a boolean specifying if an alpha test is needed.
  52740. */
  52741. needAlphaTesting(): boolean;
  52742. private _initializeBlock;
  52743. private _resetDualBlocks;
  52744. /**
  52745. * Build the material and generates the inner effect
  52746. * @param verbose defines if the build should log activity
  52747. */
  52748. build(verbose?: boolean): void;
  52749. /**
  52750. * Runs an otpimization phase to try to improve the shader code
  52751. */
  52752. optimize(): void;
  52753. private _prepareDefinesForAttributes;
  52754. /**
  52755. * Get if the submesh is ready to be used and all its information available.
  52756. * Child classes can use it to update shaders
  52757. * @param mesh defines the mesh to check
  52758. * @param subMesh defines which submesh to check
  52759. * @param useInstances specifies that instances should be used
  52760. * @returns a boolean indicating that the submesh is ready or not
  52761. */
  52762. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  52763. /**
  52764. * Binds the world matrix to the material
  52765. * @param world defines the world transformation matrix
  52766. */
  52767. bindOnlyWorldMatrix(world: Matrix): void;
  52768. /**
  52769. * Binds the submesh to this material by preparing the effect and shader to draw
  52770. * @param world defines the world transformation matrix
  52771. * @param mesh defines the mesh containing the submesh
  52772. * @param subMesh defines the submesh to bind the material to
  52773. */
  52774. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  52775. /**
  52776. * Gets the active textures from the material
  52777. * @returns an array of textures
  52778. */
  52779. getActiveTextures(): BaseTexture[];
  52780. /**
  52781. * Specifies if the material uses a texture
  52782. * @param texture defines the texture to check against the material
  52783. * @returns a boolean specifying if the material uses the texture
  52784. */
  52785. hasTexture(texture: BaseTexture): boolean;
  52786. /**
  52787. * Disposes the material
  52788. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  52789. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  52790. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  52791. */
  52792. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  52793. /** Creates the node editor window. */
  52794. private _createNodeEditor;
  52795. /**
  52796. * Launch the node material editor
  52797. * @param config Define the configuration of the editor
  52798. * @return a promise fulfilled when the node editor is visible
  52799. */
  52800. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  52801. }
  52802. }
  52803. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  52804. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  52806. import { Nullable } from "babylonjs/types";
  52807. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  52808. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52809. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  52810. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52811. import { Mesh } from "babylonjs/Meshes/mesh";
  52812. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  52813. /**
  52814. * Defines a block that can be used inside a node based material
  52815. */
  52816. export class NodeMaterialBlock {
  52817. private _buildId;
  52818. private _target;
  52819. private _isFinalMerger;
  52820. /** @hidden */
  52821. _inputs: NodeMaterialConnectionPoint[];
  52822. /** @hidden */
  52823. _outputs: NodeMaterialConnectionPoint[];
  52824. /**
  52825. * Gets or sets the name of the block
  52826. */
  52827. name: string;
  52828. /**
  52829. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  52830. */
  52831. readonly isFinalMerger: boolean;
  52832. /**
  52833. * Gets or sets the build Id
  52834. */
  52835. buildId: number;
  52836. /**
  52837. * Gets or sets the target of the block
  52838. */
  52839. target: NodeMaterialBlockTargets;
  52840. /**
  52841. * Gets the list of input points
  52842. */
  52843. readonly inputs: NodeMaterialConnectionPoint[];
  52844. /** Gets the list of output points */
  52845. readonly outputs: NodeMaterialConnectionPoint[];
  52846. /**
  52847. * Find an input by its name
  52848. * @param name defines the name of the input to look for
  52849. * @returns the input or null if not found
  52850. */
  52851. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52852. /**
  52853. * Find an output by its name
  52854. * @param name defines the name of the outputto look for
  52855. * @returns the output or null if not found
  52856. */
  52857. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  52858. /**
  52859. * Creates a new NodeMaterialBlock
  52860. * @param name defines the block name
  52861. * @param target defines the target of that block (Vertex by default)
  52862. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  52863. */
  52864. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  52865. /**
  52866. * Initialize the block and prepare the context for build
  52867. * @param state defines the state that will be used for the build
  52868. */
  52869. initialize(state: NodeMaterialBuildState): void;
  52870. /**
  52871. * Bind data to effect. Will only be called for blocks with isBindable === true
  52872. * @param effect defines the effect to bind data to
  52873. * @param nodeMaterial defines the hosting NodeMaterial
  52874. * @param mesh defines the mesh that will be rendered
  52875. */
  52876. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52877. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  52878. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  52879. protected _writeFloat(value: number): string;
  52880. /**
  52881. * Gets the current class name e.g. "NodeMaterialBlock"
  52882. * @returns the class name
  52883. */
  52884. getClassName(): string;
  52885. /**
  52886. * Register a new input. Must be called inside a block constructor
  52887. * @param name defines the connection point name
  52888. * @param type defines the connection point type
  52889. * @param isOptional defines a boolean indicating that this input can be omitted
  52890. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52891. * @returns the current block
  52892. */
  52893. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  52894. /**
  52895. * Register a new output. Must be called inside a block constructor
  52896. * @param name defines the connection point name
  52897. * @param type defines the connection point type
  52898. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  52899. * @returns the current block
  52900. */
  52901. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  52902. /**
  52903. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  52904. * @param forOutput defines an optional connection point to check compatibility with
  52905. * @returns the first available input or null
  52906. */
  52907. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  52908. /**
  52909. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  52910. * @param forBlock defines an optional block to check compatibility with
  52911. * @returns the first available input or null
  52912. */
  52913. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  52914. /**
  52915. * Connect current block with another block
  52916. * @param other defines the block to connect with
  52917. * @param options define the various options to help pick the right connections
  52918. * @returns the current block
  52919. */
  52920. connectTo(other: NodeMaterialBlock, options?: {
  52921. input?: string;
  52922. output?: string;
  52923. outputSwizzle?: string;
  52924. }): this | undefined;
  52925. protected _buildBlock(state: NodeMaterialBuildState): void;
  52926. /**
  52927. * Add potential fallbacks if shader compilation fails
  52928. * @param mesh defines the mesh to be rendered
  52929. * @param fallbacks defines the current prioritized list of fallbacks
  52930. */
  52931. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52932. /**
  52933. * Update defines for shader compilation
  52934. * @param mesh defines the mesh to be rendered
  52935. * @param nodeMaterial defines the node material requesting the update
  52936. * @param defines defines the material defines to update
  52937. * @param useInstances specifies that instances should be used
  52938. */
  52939. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52940. /**
  52941. * Lets the block try to connect some inputs automatically
  52942. */
  52943. autoConfigure(): void;
  52944. /**
  52945. * Function called when a block is declared as repeatable content generator
  52946. * @param vertexShaderState defines the current compilation state for the vertex shader
  52947. * @param fragmentShaderState defines the current compilation state for the fragment shader
  52948. * @param mesh defines the mesh to be rendered
  52949. * @param defines defines the material defines to update
  52950. */
  52951. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52952. /**
  52953. * Checks if the block is ready
  52954. * @param mesh defines the mesh to be rendered
  52955. * @param nodeMaterial defines the node material requesting the update
  52956. * @param defines defines the material defines to update
  52957. * @param useInstances specifies that instances should be used
  52958. * @returns true if the block is ready
  52959. */
  52960. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  52961. /**
  52962. * Compile the current node and generate the shader code
  52963. * @param state defines the current compilation state (uniforms, samplers, current string)
  52964. * @returns the current block
  52965. */
  52966. build(state: NodeMaterialBuildState): this | undefined;
  52967. }
  52968. }
  52969. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  52970. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  52971. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  52972. import { Nullable } from "babylonjs/types";
  52973. import { Effect } from "babylonjs/Materials/effect";
  52974. import { NodeMaterialWellKnownValues } from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  52975. import { Scene } from "babylonjs/scene";
  52976. import { Matrix } from "babylonjs/Maths/math";
  52977. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  52978. /**
  52979. * Defines a connection point for a block
  52980. */
  52981. export class NodeMaterialConnectionPoint {
  52982. /** @hidden */
  52983. _ownerBlock: NodeMaterialBlock;
  52984. /** @hidden */
  52985. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  52986. private _associatedVariableName;
  52987. private _endpoints;
  52988. private _storedValue;
  52989. private _valueCallback;
  52990. private _mode;
  52991. /** @hidden */
  52992. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  52993. /**
  52994. * Gets or sets the connection point type (default is float)
  52995. */
  52996. type: NodeMaterialBlockConnectionPointTypes;
  52997. /**
  52998. * Gets or sets the connection point name
  52999. */
  53000. name: string;
  53001. /**
  53002. * Gets or sets the swizzle to apply to this connection point when reading or writing
  53003. */
  53004. swizzle: string;
  53005. /**
  53006. * Gets or sets a boolean indicating that this connection point can be omitted
  53007. */
  53008. isOptional: boolean;
  53009. /**
  53010. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  53011. */
  53012. define: string;
  53013. /** Gets or sets the target of that connection point */
  53014. target: NodeMaterialBlockTargets;
  53015. /**
  53016. * Gets or sets the value of that point.
  53017. * Please note that this value will be ignored if valueCallback is defined
  53018. */
  53019. value: any;
  53020. /**
  53021. * Gets or sets a callback used to get the value of that point.
  53022. * Please note that setting this value will force the connection point to ignore the value property
  53023. */
  53024. valueCallback: () => any;
  53025. /**
  53026. * Gets or sets the associated variable name in the shader
  53027. */
  53028. associatedVariableName: string;
  53029. /**
  53030. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  53031. * In this case the connection point name must be the name of the uniform to use.
  53032. * Can only be set on inputs
  53033. */
  53034. isUniform: boolean;
  53035. /**
  53036. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  53037. * In this case the connection point name must be the name of the attribute to use
  53038. * Can only be set on inputs
  53039. */
  53040. isAttribute: boolean;
  53041. /**
  53042. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  53043. * Can only be set on exit points
  53044. */
  53045. isVarying: boolean;
  53046. /** Get the other side of the connection (if any) */
  53047. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  53048. /** Get the block that owns this connection point */
  53049. readonly ownerBlock: NodeMaterialBlock;
  53050. /** Get the block connected on the other side of this connection (if any) */
  53051. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  53052. /** Get the block connected on the endpoints of this connection (if any) */
  53053. readonly connectedBlocks: Array<NodeMaterialBlock>;
  53054. /**
  53055. * Creates a new connection point
  53056. * @param name defines the connection point name
  53057. * @param ownerBlock defines the block hosting this connection point
  53058. */
  53059. constructor(name: string, ownerBlock: NodeMaterialBlock);
  53060. /**
  53061. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  53062. * @returns the class name
  53063. */
  53064. getClassName(): string;
  53065. /**
  53066. * Set the source of this connection point to a vertex attribute
  53067. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  53068. * @returns the current connection point
  53069. */
  53070. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  53071. /**
  53072. * Set the source of this connection point to a well known value
  53073. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  53074. * @returns the current connection point
  53075. */
  53076. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  53077. /**
  53078. * Gets a boolean indicating that the current connection point is a well known value
  53079. */
  53080. readonly isWellKnownValue: boolean;
  53081. /**
  53082. * Gets or sets the current well known value or null if not defined as well know value
  53083. */
  53084. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  53085. private _getTypeLength;
  53086. /**
  53087. * Connect this point to another connection point
  53088. * @param connectionPoint defines the other connection point
  53089. * @returns the current connection point
  53090. */
  53091. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53092. /**
  53093. * Disconnect this point from one of his endpoint
  53094. * @param endpoint defines the other connection point
  53095. * @returns the current connection point
  53096. */
  53097. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  53098. /**
  53099. * When connection point is an uniform, this function will send its value to the effect
  53100. * @param effect defines the effect to transmit value to
  53101. * @param world defines the world matrix
  53102. * @param worldView defines the worldxview matrix
  53103. * @param worldViewProjection defines the worldxviewxprojection matrix
  53104. */
  53105. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  53106. /**
  53107. * When connection point is an uniform, this function will send its value to the effect
  53108. * @param effect defines the effect to transmit value to
  53109. * @param scene defines the hosting scene
  53110. */
  53111. transmit(effect: Effect, scene: Scene): void;
  53112. }
  53113. }
  53114. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  53115. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53116. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53117. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53118. /**
  53119. * Block used to output the vertex position
  53120. */
  53121. export class VertexOutputBlock extends NodeMaterialBlock {
  53122. /**
  53123. * Creates a new VertexOutputBlock
  53124. * @param name defines the block name
  53125. */
  53126. constructor(name: string);
  53127. /**
  53128. * Gets the current class name
  53129. * @returns the class name
  53130. */
  53131. getClassName(): string;
  53132. /**
  53133. * Gets the vector input component
  53134. */
  53135. readonly vector: NodeMaterialConnectionPoint;
  53136. protected _buildBlock(state: NodeMaterialBuildState): this;
  53137. }
  53138. }
  53139. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  53140. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53141. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53142. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53143. import { Mesh } from "babylonjs/Meshes/mesh";
  53144. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53146. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53147. /**
  53148. * Block used to add support for vertex skinning (bones)
  53149. */
  53150. export class BonesBlock extends NodeMaterialBlock {
  53151. /**
  53152. * Creates a new BonesBlock
  53153. * @param name defines the block name
  53154. */
  53155. constructor(name: string);
  53156. /**
  53157. * Initialize the block and prepare the context for build
  53158. * @param state defines the state that will be used for the build
  53159. */
  53160. initialize(state: NodeMaterialBuildState): void;
  53161. /**
  53162. * Gets the current class name
  53163. * @returns the class name
  53164. */
  53165. getClassName(): string;
  53166. /**
  53167. * Gets the matrix indices input component
  53168. */
  53169. readonly matricesIndices: NodeMaterialConnectionPoint;
  53170. /**
  53171. * Gets the matrix weights input component
  53172. */
  53173. readonly matricesWeights: NodeMaterialConnectionPoint;
  53174. /**
  53175. * Gets the extra matrix indices input component
  53176. */
  53177. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  53178. /**
  53179. * Gets the extra matrix weights input component
  53180. */
  53181. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  53182. /**
  53183. * Gets the world input component
  53184. */
  53185. readonly world: NodeMaterialConnectionPoint;
  53186. autoConfigure(): void;
  53187. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  53188. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53189. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53190. protected _buildBlock(state: NodeMaterialBuildState): this;
  53191. }
  53192. }
  53193. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  53194. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53195. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53196. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53197. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53198. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53199. /**
  53200. * Block used to add support for instances
  53201. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  53202. */
  53203. export class InstancesBlock extends NodeMaterialBlock {
  53204. /**
  53205. * Creates a new InstancesBlock
  53206. * @param name defines the block name
  53207. */
  53208. constructor(name: string);
  53209. /**
  53210. * Gets the current class name
  53211. * @returns the class name
  53212. */
  53213. getClassName(): string;
  53214. /**
  53215. * Gets the first world row input component
  53216. */
  53217. readonly world0: NodeMaterialConnectionPoint;
  53218. /**
  53219. * Gets the second world row input component
  53220. */
  53221. readonly world1: NodeMaterialConnectionPoint;
  53222. /**
  53223. * Gets the third world row input component
  53224. */
  53225. readonly world2: NodeMaterialConnectionPoint;
  53226. /**
  53227. * Gets the forth world row input component
  53228. */
  53229. readonly world3: NodeMaterialConnectionPoint;
  53230. /**
  53231. * Gets the world input component
  53232. */
  53233. readonly world: NodeMaterialConnectionPoint;
  53234. /**
  53235. * Gets the output component
  53236. */
  53237. readonly output: NodeMaterialConnectionPoint;
  53238. autoConfigure(): void;
  53239. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  53240. protected _buildBlock(state: NodeMaterialBuildState): this;
  53241. }
  53242. }
  53243. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  53244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53248. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53249. import { Effect } from "babylonjs/Materials/effect";
  53250. import { Mesh } from "babylonjs/Meshes/mesh";
  53251. /**
  53252. * Block used to add morph targets support to vertex shader
  53253. */
  53254. export class MorphTargetsBlock extends NodeMaterialBlock {
  53255. private _repeatableContentAnchor;
  53256. private _repeatebleContentGenerated;
  53257. /**
  53258. * Create a new MorphTargetsBlock
  53259. * @param name defines the block name
  53260. */
  53261. constructor(name: string);
  53262. /**
  53263. * Gets the current class name
  53264. * @returns the class name
  53265. */
  53266. getClassName(): string;
  53267. /**
  53268. * Gets the position input component
  53269. */
  53270. readonly position: NodeMaterialConnectionPoint;
  53271. /**
  53272. * Gets the normal input component
  53273. */
  53274. readonly normal: NodeMaterialConnectionPoint;
  53275. /**
  53276. * Gets the tangent input component
  53277. */
  53278. readonly tangent: NodeMaterialConnectionPoint;
  53279. /**
  53280. * Gets the position output component
  53281. */
  53282. readonly positionOutput: NodeMaterialConnectionPoint;
  53283. /**
  53284. * Gets the normal output component
  53285. */
  53286. readonly normalOutput: NodeMaterialConnectionPoint;
  53287. /**
  53288. * Gets the tangent output component
  53289. */
  53290. readonly tangentOutput: NodeMaterialConnectionPoint;
  53291. initialize(state: NodeMaterialBuildState): void;
  53292. autoConfigure(): void;
  53293. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53294. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53295. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  53296. protected _buildBlock(state: NodeMaterialBuildState): this;
  53297. }
  53298. }
  53299. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  53300. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  53301. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  53302. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  53303. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  53304. }
  53305. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  53306. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53307. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53308. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53309. /**
  53310. * Block used to output the final color
  53311. */
  53312. export class FragmentOutputBlock extends NodeMaterialBlock {
  53313. /**
  53314. * Gets or sets a boolean indicating if this block will output an alpha value
  53315. */
  53316. alphaBlendingEnabled: boolean;
  53317. /**
  53318. * Create a new FragmentOutputBlock
  53319. * @param name defines the block name
  53320. */
  53321. constructor(name: string);
  53322. /**
  53323. * Gets the current class name
  53324. * @returns the class name
  53325. */
  53326. getClassName(): string;
  53327. /**
  53328. * Gets the color input component
  53329. */
  53330. readonly color: NodeMaterialConnectionPoint;
  53331. protected _buildBlock(state: NodeMaterialBuildState): this;
  53332. }
  53333. }
  53334. declare module "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock" {
  53335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53338. /**
  53339. * Block used to add an alpha test in the fragment shader
  53340. */
  53341. export class AlphaTestBlock extends NodeMaterialBlock {
  53342. /**
  53343. * Gets or sets the alpha value where alpha testing happens
  53344. */
  53345. alphaCutOff: number;
  53346. /**
  53347. * Create a new AlphaTestBlock
  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 color input component
  53358. */
  53359. readonly color: NodeMaterialConnectionPoint;
  53360. protected _buildBlock(state: NodeMaterialBuildState): this;
  53361. }
  53362. }
  53363. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock" {
  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 create a Color4 out of 4 inputs (one for each component)
  53369. */
  53370. export class RGBAMergerBlock extends NodeMaterialBlock {
  53371. /**
  53372. * Create a new RGBAMergerBlock
  53373. * @param name defines the block name
  53374. */
  53375. constructor(name: string);
  53376. /**
  53377. * Gets the current class name
  53378. * @returns the class name
  53379. */
  53380. getClassName(): string;
  53381. /**
  53382. * Gets the R input component
  53383. */
  53384. readonly r: NodeMaterialConnectionPoint;
  53385. /**
  53386. * Gets the G input component
  53387. */
  53388. readonly g: NodeMaterialConnectionPoint;
  53389. /**
  53390. * Gets the B input component
  53391. */
  53392. readonly b: NodeMaterialConnectionPoint;
  53393. /**
  53394. * Gets the RGB input component
  53395. */
  53396. readonly rgb: NodeMaterialConnectionPoint;
  53397. /**
  53398. * Gets the R input component
  53399. */
  53400. readonly a: NodeMaterialConnectionPoint;
  53401. protected _buildBlock(state: NodeMaterialBuildState): this;
  53402. }
  53403. }
  53404. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock" {
  53405. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53406. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53407. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53408. /**
  53409. * Block used to create a Color3 out of 3 inputs (one for each component)
  53410. */
  53411. export class RGBMergerBlock extends NodeMaterialBlock {
  53412. /**
  53413. * Create a new RGBMergerBlock
  53414. * @param name defines the block name
  53415. */
  53416. constructor(name: string);
  53417. /**
  53418. * Gets the current class name
  53419. * @returns the class name
  53420. */
  53421. getClassName(): string;
  53422. /**
  53423. * Gets the R component input
  53424. */
  53425. readonly r: NodeMaterialConnectionPoint;
  53426. /**
  53427. * Gets the G component input
  53428. */
  53429. readonly g: NodeMaterialConnectionPoint;
  53430. /**
  53431. * Gets the B component input
  53432. */
  53433. readonly b: NodeMaterialConnectionPoint;
  53434. protected _buildBlock(state: NodeMaterialBuildState): this;
  53435. }
  53436. }
  53437. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock" {
  53438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53441. /**
  53442. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  53443. */
  53444. export class RGBASplitterBlock extends NodeMaterialBlock {
  53445. /**
  53446. * Create a new RGBASplitterBlock
  53447. * @param name defines the block name
  53448. */
  53449. constructor(name: string);
  53450. /**
  53451. * Gets the current class name
  53452. * @returns the class name
  53453. */
  53454. getClassName(): string;
  53455. /**
  53456. * Gets the input component
  53457. */
  53458. readonly input: NodeMaterialConnectionPoint;
  53459. protected _buildBlock(state: NodeMaterialBuildState): this;
  53460. }
  53461. }
  53462. declare module "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock" {
  53463. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53464. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53465. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53466. /**
  53467. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  53468. */
  53469. export class RGBSplitterBlock extends NodeMaterialBlock {
  53470. /**
  53471. * Create a new RGBSplitterBlock
  53472. * @param name defines the block name
  53473. */
  53474. constructor(name: string);
  53475. /**
  53476. * Gets the current class name
  53477. * @returns the class name
  53478. */
  53479. getClassName(): string;
  53480. /**
  53481. * Gets the input component
  53482. */
  53483. readonly input: NodeMaterialConnectionPoint;
  53484. protected _buildBlock(state: NodeMaterialBuildState): this;
  53485. }
  53486. }
  53487. declare module "babylonjs/Materials/Node/Blocks/Fragment/textureBlock" {
  53488. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53489. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53490. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53491. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53492. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53493. /**
  53494. * Block used to read a texture from a sampler
  53495. */
  53496. export class TextureBlock extends NodeMaterialBlock {
  53497. private _defineName;
  53498. /**
  53499. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  53500. */
  53501. autoConnectTextureMatrix: boolean;
  53502. /**
  53503. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  53504. */
  53505. autoSelectUV: boolean;
  53506. /**
  53507. * Create a new TextureBlock
  53508. * @param name defines the block name
  53509. */
  53510. constructor(name: string);
  53511. /**
  53512. * Gets the current class name
  53513. * @returns the class name
  53514. */
  53515. getClassName(): string;
  53516. /**
  53517. * Gets the uv input component
  53518. */
  53519. readonly uv: NodeMaterialConnectionPoint;
  53520. /**
  53521. * Gets the texture information input component
  53522. */
  53523. readonly textureInfo: NodeMaterialConnectionPoint;
  53524. /**
  53525. * Gets the transformed uv input component
  53526. */
  53527. readonly transformedUV: NodeMaterialConnectionPoint;
  53528. /**
  53529. * Gets the texture input component
  53530. */
  53531. readonly texture: NodeMaterialConnectionPoint;
  53532. /**
  53533. * Gets the texture transform input component
  53534. */
  53535. readonly textureTransform: NodeMaterialConnectionPoint;
  53536. autoConfigure(): void;
  53537. initialize(state: NodeMaterialBuildState): void;
  53538. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53539. isReady(): boolean;
  53540. private _injectVertexCode;
  53541. protected _buildBlock(state: NodeMaterialBuildState): this;
  53542. }
  53543. }
  53544. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  53545. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53546. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53547. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53549. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53550. import { Effect } from "babylonjs/Materials/effect";
  53551. import { Mesh } from "babylonjs/Meshes/mesh";
  53552. /**
  53553. * Block used to add image processing support to fragment shader
  53554. */
  53555. export class ImageProcessingBlock extends NodeMaterialBlock {
  53556. /**
  53557. * Create a new ImageProcessingBlock
  53558. * @param name defines the block name
  53559. */
  53560. constructor(name: string);
  53561. /**
  53562. * Gets the current class name
  53563. * @returns the class name
  53564. */
  53565. getClassName(): string;
  53566. /**
  53567. * Gets the color input component
  53568. */
  53569. readonly color: NodeMaterialConnectionPoint;
  53570. /**
  53571. * Initialize the block and prepare the context for build
  53572. * @param state defines the state that will be used for the build
  53573. */
  53574. initialize(state: NodeMaterialBuildState): void;
  53575. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  53576. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53577. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53578. protected _buildBlock(state: NodeMaterialBuildState): this;
  53579. }
  53580. }
  53581. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  53582. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  53583. export * from "babylonjs/Materials/Node/Blocks/Fragment/alphaTestBlock";
  53584. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaMergerBlock";
  53585. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbMergerBlock";
  53586. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbaSplitterBlock";
  53587. export * from "babylonjs/Materials/Node/Blocks/Fragment/rgbSplitterBlock";
  53588. export * from "babylonjs/Materials/Node/Blocks/Fragment/textureBlock";
  53589. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  53590. }
  53591. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  53592. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53593. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53594. import { Mesh } from "babylonjs/Meshes/mesh";
  53595. import { Effect } from "babylonjs/Materials/effect";
  53596. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53597. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53598. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  53599. /**
  53600. * Block used to add support for scene fog
  53601. */
  53602. export class FogBlock extends NodeMaterialBlock {
  53603. /**
  53604. * Create a new FogBlock
  53605. * @param name defines the block name
  53606. */
  53607. constructor(name: string);
  53608. /**
  53609. * Gets the current class name
  53610. * @returns the class name
  53611. */
  53612. getClassName(): string;
  53613. /**
  53614. * Gets the world position input component
  53615. */
  53616. readonly worldPosition: NodeMaterialConnectionPoint;
  53617. /**
  53618. * Gets the view input component
  53619. */
  53620. readonly view: NodeMaterialConnectionPoint;
  53621. /**
  53622. * Gets the color input component
  53623. */
  53624. readonly color: NodeMaterialConnectionPoint;
  53625. /**
  53626. * Gets the fog color input component
  53627. */
  53628. readonly fogColor: NodeMaterialConnectionPoint;
  53629. /**
  53630. * Gets the for parameter input component
  53631. */
  53632. readonly fogParameters: NodeMaterialConnectionPoint;
  53633. autoConfigure(): void;
  53634. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  53635. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  53636. protected _buildBlock(state: NodeMaterialBuildState): this;
  53637. }
  53638. }
  53639. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  53640. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  53641. }
  53642. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  53643. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53644. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53645. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53646. /**
  53647. * Block used to multiply 2 vector4
  53648. */
  53649. export class MultiplyBlock extends NodeMaterialBlock {
  53650. /**
  53651. * Creates a new MultiplyBlock
  53652. * @param name defines the block name
  53653. */
  53654. constructor(name: string);
  53655. /**
  53656. * Gets the current class name
  53657. * @returns the class name
  53658. */
  53659. getClassName(): string;
  53660. /**
  53661. * Gets the left operand input component
  53662. */
  53663. readonly left: NodeMaterialConnectionPoint;
  53664. /**
  53665. * Gets the right operand input component
  53666. */
  53667. readonly right: NodeMaterialConnectionPoint;
  53668. protected _buildBlock(state: NodeMaterialBuildState): this;
  53669. }
  53670. }
  53671. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  53672. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53673. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53674. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53675. /**
  53676. * Block used to add 2 vector4
  53677. */
  53678. export class AddBlock extends NodeMaterialBlock {
  53679. /**
  53680. * Creates a new AddBlock
  53681. * @param name defines the block name
  53682. */
  53683. constructor(name: string);
  53684. /**
  53685. * Gets the current class name
  53686. * @returns the class name
  53687. */
  53688. getClassName(): string;
  53689. /**
  53690. * Gets the left operand input component
  53691. */
  53692. readonly left: NodeMaterialConnectionPoint;
  53693. /**
  53694. * Gets the right operand input component
  53695. */
  53696. readonly right: NodeMaterialConnectionPoint;
  53697. protected _buildBlock(state: NodeMaterialBuildState): this;
  53698. }
  53699. }
  53700. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  53701. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53702. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53703. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53704. /**
  53705. * Block used to clamp a float
  53706. */
  53707. export class ClampBlock extends NodeMaterialBlock {
  53708. /** Gets or sets the minimum range */
  53709. minimum: number;
  53710. /** Gets or sets the maximum range */
  53711. maximum: number;
  53712. /**
  53713. * Creates a new ClampBlock
  53714. * @param name defines the block name
  53715. */
  53716. constructor(name: string);
  53717. /**
  53718. * Gets the current class name
  53719. * @returns the class name
  53720. */
  53721. getClassName(): string;
  53722. /**
  53723. * Gets the value input component
  53724. */
  53725. readonly value: NodeMaterialConnectionPoint;
  53726. protected _buildBlock(state: NodeMaterialBuildState): this;
  53727. }
  53728. }
  53729. declare module "babylonjs/Materials/Node/Blocks/vector2TransformBlock" {
  53730. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53731. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53732. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53733. /**
  53734. * Block used to transform a vector2 with a matrix
  53735. */
  53736. export class Vector2TransformBlock extends NodeMaterialBlock {
  53737. /**
  53738. * Defines the value to use to complement Vector2 to transform it to a Vector4
  53739. */
  53740. complementZ: number;
  53741. /**
  53742. * Defines the value to use to complement Vector2 to transform it to a Vector4
  53743. */
  53744. complementW: number;
  53745. /**
  53746. * Creates a new Vector2TransformBlock
  53747. * @param name defines the block name
  53748. */
  53749. constructor(name: string);
  53750. /**
  53751. * Gets the vector input
  53752. */
  53753. readonly vector: NodeMaterialConnectionPoint;
  53754. /**
  53755. * Gets the matrix transform input
  53756. */
  53757. readonly transform: NodeMaterialConnectionPoint;
  53758. /**
  53759. * Gets the current class name
  53760. * @returns the class name
  53761. */
  53762. getClassName(): string;
  53763. protected _buildBlock(state: NodeMaterialBuildState): this;
  53764. }
  53765. }
  53766. declare module "babylonjs/Materials/Node/Blocks/vector3TransformBlock" {
  53767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53770. /**
  53771. * Block used to transform a vector3 with a matrix
  53772. */
  53773. export class Vector3TransformBlock extends NodeMaterialBlock {
  53774. /**
  53775. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53776. */
  53777. complement: number;
  53778. /**
  53779. * Creates a new Vector3TransformBlock
  53780. * @param name defines the block name
  53781. */
  53782. constructor(name: string);
  53783. /**
  53784. * Gets the vector input
  53785. */
  53786. readonly vector: NodeMaterialConnectionPoint;
  53787. /**
  53788. * Gets the matrix transform input
  53789. */
  53790. readonly transform: NodeMaterialConnectionPoint;
  53791. /**
  53792. * Gets the current class name
  53793. * @returns the class name
  53794. */
  53795. getClassName(): string;
  53796. protected _buildBlock(state: NodeMaterialBuildState): this;
  53797. }
  53798. }
  53799. declare module "babylonjs/Materials/Node/Blocks/vector4TransformBlock" {
  53800. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53801. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53802. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53803. /**
  53804. * Block used to transform a vector4 with a matrix
  53805. */
  53806. export class Vector4TransformBlock extends NodeMaterialBlock {
  53807. /**
  53808. * Defines the value to use to complement Vector3 to transform it to a Vector4
  53809. */
  53810. complementW: number;
  53811. /**
  53812. * Creates a new Vector4TransformBlock
  53813. * @param name defines the block name
  53814. */
  53815. constructor(name: string);
  53816. /**
  53817. * Gets the current class name
  53818. * @returns the class name
  53819. */
  53820. getClassName(): string;
  53821. /**
  53822. * Gets the vector input
  53823. */
  53824. readonly vector: NodeMaterialConnectionPoint;
  53825. /**
  53826. * Gets the matrix transform input
  53827. */
  53828. readonly transform: NodeMaterialConnectionPoint;
  53829. protected _buildBlock(state: NodeMaterialBuildState): this;
  53830. }
  53831. }
  53832. declare module "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock" {
  53833. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  53834. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  53835. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53836. /**
  53837. * Block used to multiply two matrices
  53838. */
  53839. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  53840. /**
  53841. * Creates a new MatrixMultiplicationBlock
  53842. * @param name defines the block name
  53843. */
  53844. constructor(name: string);
  53845. /**
  53846. * Gets the left operand
  53847. */
  53848. readonly left: NodeMaterialConnectionPoint;
  53849. /**
  53850. * Gets the right operand
  53851. */
  53852. readonly right: NodeMaterialConnectionPoint;
  53853. /**
  53854. * Gets the current class name
  53855. * @returns the class name
  53856. */
  53857. getClassName(): string;
  53858. protected _buildBlock(state: NodeMaterialBuildState): this;
  53859. }
  53860. }
  53861. declare module "babylonjs/Materials/Node/Blocks/index" {
  53862. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  53863. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  53864. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  53865. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  53866. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  53867. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  53868. export * from "babylonjs/Materials/Node/Blocks/vector2TransformBlock";
  53869. export * from "babylonjs/Materials/Node/Blocks/vector3TransformBlock";
  53870. export * from "babylonjs/Materials/Node/Blocks/vector4TransformBlock";
  53871. export * from "babylonjs/Materials/Node/Blocks/matrixMultiplicationBlock";
  53872. }
  53873. declare module "babylonjs/Materials/Node/Optimizers/index" {
  53874. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  53875. }
  53876. declare module "babylonjs/Materials/Node/index" {
  53877. export * from "babylonjs/Materials/Node/nodeMaterialBlockTargets";
  53878. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
  53879. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  53880. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  53881. export * from "babylonjs/Materials/Node/nodeMaterial";
  53882. export * from "babylonjs/Materials/Node/nodeMaterialWellKnownValues";
  53883. export * from "babylonjs/Materials/Node/Blocks/index";
  53884. export * from "babylonjs/Materials/Node/Optimizers/index";
  53885. }
  53886. declare module "babylonjs/Materials/index" {
  53887. export * from "babylonjs/Materials/Background/index";
  53888. export * from "babylonjs/Materials/colorCurves";
  53889. export * from "babylonjs/Materials/effect";
  53890. export * from "babylonjs/Materials/fresnelParameters";
  53891. export * from "babylonjs/Materials/imageProcessingConfiguration";
  53892. export * from "babylonjs/Materials/material";
  53893. export * from "babylonjs/Materials/materialDefines";
  53894. export * from "babylonjs/Materials/materialHelper";
  53895. export * from "babylonjs/Materials/multiMaterial";
  53896. export * from "babylonjs/Materials/PBR/index";
  53897. export * from "babylonjs/Materials/pushMaterial";
  53898. export * from "babylonjs/Materials/shaderMaterial";
  53899. export * from "babylonjs/Materials/standardMaterial";
  53900. export * from "babylonjs/Materials/Textures/index";
  53901. export * from "babylonjs/Materials/uniformBuffer";
  53902. export * from "babylonjs/Materials/materialFlags";
  53903. export * from "babylonjs/Materials/Node/index";
  53904. }
  53905. declare module "babylonjs/Maths/index" {
  53906. export * from "babylonjs/Maths/math.scalar";
  53907. export * from "babylonjs/Maths/math";
  53908. export * from "babylonjs/Maths/sphericalPolynomial";
  53909. }
  53910. declare module "babylonjs/Misc/workerPool" {
  53911. import { IDisposable } from "babylonjs/scene";
  53912. /**
  53913. * Helper class to push actions to a pool of workers.
  53914. */
  53915. export class WorkerPool implements IDisposable {
  53916. private _workerInfos;
  53917. private _pendingActions;
  53918. /**
  53919. * Constructor
  53920. * @param workers Array of workers to use for actions
  53921. */
  53922. constructor(workers: Array<Worker>);
  53923. /**
  53924. * Terminates all workers and clears any pending actions.
  53925. */
  53926. dispose(): void;
  53927. /**
  53928. * Pushes an action to the worker pool. If all the workers are active, the action will be
  53929. * pended until a worker has completed its action.
  53930. * @param action The action to perform. Call onComplete when the action is complete.
  53931. */
  53932. push(action: (worker: Worker, onComplete: () => void) => void): void;
  53933. private _execute;
  53934. }
  53935. }
  53936. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  53937. import { IDisposable } from "babylonjs/scene";
  53938. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  53939. /**
  53940. * Configuration for Draco compression
  53941. */
  53942. export interface IDracoCompressionConfiguration {
  53943. /**
  53944. * Configuration for the decoder.
  53945. */
  53946. decoder: {
  53947. /**
  53948. * The url to the WebAssembly module.
  53949. */
  53950. wasmUrl?: string;
  53951. /**
  53952. * The url to the WebAssembly binary.
  53953. */
  53954. wasmBinaryUrl?: string;
  53955. /**
  53956. * The url to the fallback JavaScript module.
  53957. */
  53958. fallbackUrl?: string;
  53959. };
  53960. }
  53961. /**
  53962. * Draco compression (https://google.github.io/draco/)
  53963. *
  53964. * This class wraps the Draco module.
  53965. *
  53966. * **Encoder**
  53967. *
  53968. * The encoder is not currently implemented.
  53969. *
  53970. * **Decoder**
  53971. *
  53972. * 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.
  53973. *
  53974. * To update the configuration, use the following code:
  53975. * ```javascript
  53976. * DracoCompression.Configuration = {
  53977. * decoder: {
  53978. * wasmUrl: "<url to the WebAssembly library>",
  53979. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  53980. * fallbackUrl: "<url to the fallback JavaScript library>",
  53981. * }
  53982. * };
  53983. * ```
  53984. *
  53985. * 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.
  53986. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  53987. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  53988. *
  53989. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  53990. * ```javascript
  53991. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  53992. * ```
  53993. *
  53994. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  53995. */
  53996. export class DracoCompression implements IDisposable {
  53997. private _workerPoolPromise?;
  53998. private _decoderModulePromise?;
  53999. /**
  54000. * The configuration. Defaults to the following urls:
  54001. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  54002. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  54003. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  54004. */
  54005. static Configuration: IDracoCompressionConfiguration;
  54006. /**
  54007. * Returns true if the decoder configuration is available.
  54008. */
  54009. static readonly DecoderAvailable: boolean;
  54010. /**
  54011. * Default number of workers to create when creating the draco compression object.
  54012. */
  54013. static DefaultNumWorkers: number;
  54014. private static GetDefaultNumWorkers;
  54015. private static _Default;
  54016. /**
  54017. * Default instance for the draco compression object.
  54018. */
  54019. static readonly Default: DracoCompression;
  54020. /**
  54021. * Constructor
  54022. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  54023. */
  54024. constructor(numWorkers?: number);
  54025. /**
  54026. * Stop all async operations and release resources.
  54027. */
  54028. dispose(): void;
  54029. /**
  54030. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  54031. * @returns a promise that resolves when ready
  54032. */
  54033. whenReadyAsync(): Promise<void>;
  54034. /**
  54035. * Decode Draco compressed mesh data to vertex data.
  54036. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  54037. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  54038. * @returns A promise that resolves with the decoded vertex data
  54039. */
  54040. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  54041. [kind: string]: number;
  54042. }): Promise<VertexData>;
  54043. }
  54044. }
  54045. declare module "babylonjs/Meshes/Compression/index" {
  54046. export * from "babylonjs/Meshes/Compression/dracoCompression";
  54047. }
  54048. declare module "babylonjs/Meshes/csg" {
  54049. import { Nullable } from "babylonjs/types";
  54050. import { Scene } from "babylonjs/scene";
  54051. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  54052. import { Mesh } from "babylonjs/Meshes/mesh";
  54053. import { Material } from "babylonjs/Materials/material";
  54054. /**
  54055. * Class for building Constructive Solid Geometry
  54056. */
  54057. export class CSG {
  54058. private polygons;
  54059. /**
  54060. * The world matrix
  54061. */
  54062. matrix: Matrix;
  54063. /**
  54064. * Stores the position
  54065. */
  54066. position: Vector3;
  54067. /**
  54068. * Stores the rotation
  54069. */
  54070. rotation: Vector3;
  54071. /**
  54072. * Stores the rotation quaternion
  54073. */
  54074. rotationQuaternion: Nullable<Quaternion>;
  54075. /**
  54076. * Stores the scaling vector
  54077. */
  54078. scaling: Vector3;
  54079. /**
  54080. * Convert the Mesh to CSG
  54081. * @param mesh The Mesh to convert to CSG
  54082. * @returns A new CSG from the Mesh
  54083. */
  54084. static FromMesh(mesh: Mesh): CSG;
  54085. /**
  54086. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  54087. * @param polygons Polygons used to construct a CSG solid
  54088. */
  54089. private static FromPolygons;
  54090. /**
  54091. * Clones, or makes a deep copy, of the CSG
  54092. * @returns A new CSG
  54093. */
  54094. clone(): CSG;
  54095. /**
  54096. * Unions this CSG with another CSG
  54097. * @param csg The CSG to union against this CSG
  54098. * @returns The unioned CSG
  54099. */
  54100. union(csg: CSG): CSG;
  54101. /**
  54102. * Unions this CSG with another CSG in place
  54103. * @param csg The CSG to union against this CSG
  54104. */
  54105. unionInPlace(csg: CSG): void;
  54106. /**
  54107. * Subtracts this CSG with another CSG
  54108. * @param csg The CSG to subtract against this CSG
  54109. * @returns A new CSG
  54110. */
  54111. subtract(csg: CSG): CSG;
  54112. /**
  54113. * Subtracts this CSG with another CSG in place
  54114. * @param csg The CSG to subtact against this CSG
  54115. */
  54116. subtractInPlace(csg: CSG): void;
  54117. /**
  54118. * Intersect this CSG with another CSG
  54119. * @param csg The CSG to intersect against this CSG
  54120. * @returns A new CSG
  54121. */
  54122. intersect(csg: CSG): CSG;
  54123. /**
  54124. * Intersects this CSG with another CSG in place
  54125. * @param csg The CSG to intersect against this CSG
  54126. */
  54127. intersectInPlace(csg: CSG): void;
  54128. /**
  54129. * Return a new CSG solid with solid and empty space switched. This solid is
  54130. * not modified.
  54131. * @returns A new CSG solid with solid and empty space switched
  54132. */
  54133. inverse(): CSG;
  54134. /**
  54135. * Inverses the CSG in place
  54136. */
  54137. inverseInPlace(): void;
  54138. /**
  54139. * This is used to keep meshes transformations so they can be restored
  54140. * when we build back a Babylon Mesh
  54141. * NB : All CSG operations are performed in world coordinates
  54142. * @param csg The CSG to copy the transform attributes from
  54143. * @returns This CSG
  54144. */
  54145. copyTransformAttributes(csg: CSG): CSG;
  54146. /**
  54147. * Build Raw mesh from CSG
  54148. * Coordinates here are in world space
  54149. * @param name The name of the mesh geometry
  54150. * @param scene The Scene
  54151. * @param keepSubMeshes Specifies if the submeshes should be kept
  54152. * @returns A new Mesh
  54153. */
  54154. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  54155. /**
  54156. * Build Mesh from CSG taking material and transforms into account
  54157. * @param name The name of the Mesh
  54158. * @param material The material of the Mesh
  54159. * @param scene The Scene
  54160. * @param keepSubMeshes Specifies if submeshes should be kept
  54161. * @returns The new Mesh
  54162. */
  54163. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  54164. }
  54165. }
  54166. declare module "babylonjs/Meshes/trailMesh" {
  54167. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54168. import { Mesh } from "babylonjs/Meshes/mesh";
  54169. import { Scene } from "babylonjs/scene";
  54170. /**
  54171. * Class used to create a trail following a mesh
  54172. */
  54173. export class TrailMesh extends Mesh {
  54174. private _generator;
  54175. private _autoStart;
  54176. private _running;
  54177. private _diameter;
  54178. private _length;
  54179. private _sectionPolygonPointsCount;
  54180. private _sectionVectors;
  54181. private _sectionNormalVectors;
  54182. private _beforeRenderObserver;
  54183. /**
  54184. * @constructor
  54185. * @param name The value used by scene.getMeshByName() to do a lookup.
  54186. * @param generator The mesh to generate a trail.
  54187. * @param scene The scene to add this mesh to.
  54188. * @param diameter Diameter of trailing mesh. Default is 1.
  54189. * @param length Length of trailing mesh. Default is 60.
  54190. * @param autoStart Automatically start trailing mesh. Default true.
  54191. */
  54192. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  54193. /**
  54194. * "TrailMesh"
  54195. * @returns "TrailMesh"
  54196. */
  54197. getClassName(): string;
  54198. private _createMesh;
  54199. /**
  54200. * Start trailing mesh.
  54201. */
  54202. start(): void;
  54203. /**
  54204. * Stop trailing mesh.
  54205. */
  54206. stop(): void;
  54207. /**
  54208. * Update trailing mesh geometry.
  54209. */
  54210. update(): void;
  54211. /**
  54212. * Returns a new TrailMesh object.
  54213. * @param name is a string, the name given to the new mesh
  54214. * @param newGenerator use new generator object for cloned trail mesh
  54215. * @returns a new mesh
  54216. */
  54217. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  54218. /**
  54219. * Serializes this trail mesh
  54220. * @param serializationObject object to write serialization to
  54221. */
  54222. serialize(serializationObject: any): void;
  54223. /**
  54224. * Parses a serialized trail mesh
  54225. * @param parsedMesh the serialized mesh
  54226. * @param scene the scene to create the trail mesh in
  54227. * @returns the created trail mesh
  54228. */
  54229. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  54230. }
  54231. }
  54232. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  54233. import { Nullable } from "babylonjs/types";
  54234. import { Scene } from "babylonjs/scene";
  54235. import { Vector4, Color4 } from "babylonjs/Maths/math";
  54236. import { Mesh } from "babylonjs/Meshes/mesh";
  54237. /**
  54238. * Class containing static functions to help procedurally build meshes
  54239. */
  54240. export class TiledBoxBuilder {
  54241. /**
  54242. * Creates a box mesh
  54243. * 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)
  54244. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54245. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54246. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54248. * @param name defines the name of the mesh
  54249. * @param options defines the options used to create the mesh
  54250. * @param scene defines the hosting scene
  54251. * @returns the box mesh
  54252. */
  54253. static CreateTiledBox(name: string, options: {
  54254. pattern?: number;
  54255. width?: number;
  54256. height?: number;
  54257. depth?: number;
  54258. tileSize?: number;
  54259. tileWidth?: number;
  54260. tileHeight?: number;
  54261. alignHorizontal?: number;
  54262. alignVertical?: number;
  54263. faceUV?: Vector4[];
  54264. faceColors?: Color4[];
  54265. sideOrientation?: number;
  54266. updatable?: boolean;
  54267. }, scene?: Nullable<Scene>): Mesh;
  54268. }
  54269. }
  54270. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  54271. import { Vector4 } from "babylonjs/Maths/math";
  54272. import { Mesh } from "babylonjs/Meshes/mesh";
  54273. /**
  54274. * Class containing static functions to help procedurally build meshes
  54275. */
  54276. export class TorusKnotBuilder {
  54277. /**
  54278. * Creates a torus knot mesh
  54279. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54280. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54281. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54282. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54283. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54284. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54285. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54286. * @param name defines the name of the mesh
  54287. * @param options defines the options used to create the mesh
  54288. * @param scene defines the hosting scene
  54289. * @returns the torus knot mesh
  54290. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54291. */
  54292. static CreateTorusKnot(name: string, options: {
  54293. radius?: number;
  54294. tube?: number;
  54295. radialSegments?: number;
  54296. tubularSegments?: number;
  54297. p?: number;
  54298. q?: number;
  54299. updatable?: boolean;
  54300. sideOrientation?: number;
  54301. frontUVs?: Vector4;
  54302. backUVs?: Vector4;
  54303. }, scene: any): Mesh;
  54304. }
  54305. }
  54306. declare module "babylonjs/Meshes/polygonMesh" {
  54307. import { Scene } from "babylonjs/scene";
  54308. import { Vector2, Path2 } from "babylonjs/Maths/math";
  54309. import { Mesh } from "babylonjs/Meshes/mesh";
  54310. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  54311. /**
  54312. * Polygon
  54313. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  54314. */
  54315. export class Polygon {
  54316. /**
  54317. * Creates a rectangle
  54318. * @param xmin bottom X coord
  54319. * @param ymin bottom Y coord
  54320. * @param xmax top X coord
  54321. * @param ymax top Y coord
  54322. * @returns points that make the resulting rectation
  54323. */
  54324. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  54325. /**
  54326. * Creates a circle
  54327. * @param radius radius of circle
  54328. * @param cx scale in x
  54329. * @param cy scale in y
  54330. * @param numberOfSides number of sides that make up the circle
  54331. * @returns points that make the resulting circle
  54332. */
  54333. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  54334. /**
  54335. * Creates a polygon from input string
  54336. * @param input Input polygon data
  54337. * @returns the parsed points
  54338. */
  54339. static Parse(input: string): Vector2[];
  54340. /**
  54341. * Starts building a polygon from x and y coordinates
  54342. * @param x x coordinate
  54343. * @param y y coordinate
  54344. * @returns the started path2
  54345. */
  54346. static StartingAt(x: number, y: number): Path2;
  54347. }
  54348. /**
  54349. * Builds a polygon
  54350. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  54351. */
  54352. export class PolygonMeshBuilder {
  54353. private _points;
  54354. private _outlinepoints;
  54355. private _holes;
  54356. private _name;
  54357. private _scene;
  54358. private _epoints;
  54359. private _eholes;
  54360. private _addToepoint;
  54361. /**
  54362. * Babylon reference to the earcut plugin.
  54363. */
  54364. bjsEarcut: any;
  54365. /**
  54366. * Creates a PolygonMeshBuilder
  54367. * @param name name of the builder
  54368. * @param contours Path of the polygon
  54369. * @param scene scene to add to when creating the mesh
  54370. * @param earcutInjection can be used to inject your own earcut reference
  54371. */
  54372. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  54373. /**
  54374. * Adds a whole within the polygon
  54375. * @param hole Array of points defining the hole
  54376. * @returns this
  54377. */
  54378. addHole(hole: Vector2[]): PolygonMeshBuilder;
  54379. /**
  54380. * Creates the polygon
  54381. * @param updatable If the mesh should be updatable
  54382. * @param depth The depth of the mesh created
  54383. * @returns the created mesh
  54384. */
  54385. build(updatable?: boolean, depth?: number): Mesh;
  54386. /**
  54387. * Creates the polygon
  54388. * @param depth The depth of the mesh created
  54389. * @returns the created VertexData
  54390. */
  54391. buildVertexData(depth?: number): VertexData;
  54392. /**
  54393. * Adds a side to the polygon
  54394. * @param positions points that make the polygon
  54395. * @param normals normals of the polygon
  54396. * @param uvs uvs of the polygon
  54397. * @param indices indices of the polygon
  54398. * @param bounds bounds of the polygon
  54399. * @param points points of the polygon
  54400. * @param depth depth of the polygon
  54401. * @param flip flip of the polygon
  54402. */
  54403. private addSide;
  54404. }
  54405. }
  54406. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  54407. import { Scene } from "babylonjs/scene";
  54408. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  54409. import { Mesh } from "babylonjs/Meshes/mesh";
  54410. import { Nullable } from "babylonjs/types";
  54411. /**
  54412. * Class containing static functions to help procedurally build meshes
  54413. */
  54414. export class PolygonBuilder {
  54415. /**
  54416. * Creates a polygon mesh
  54417. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54418. * * 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
  54419. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54420. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54421. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  54422. * * Remember you can only change the shape positions, not their number when updating a polygon
  54423. * @param name defines the name of the mesh
  54424. * @param options defines the options used to create the mesh
  54425. * @param scene defines the hosting scene
  54426. * @param earcutInjection can be used to inject your own earcut reference
  54427. * @returns the polygon mesh
  54428. */
  54429. static CreatePolygon(name: string, options: {
  54430. shape: Vector3[];
  54431. holes?: Vector3[][];
  54432. depth?: number;
  54433. faceUV?: Vector4[];
  54434. faceColors?: Color4[];
  54435. updatable?: boolean;
  54436. sideOrientation?: number;
  54437. frontUVs?: Vector4;
  54438. backUVs?: Vector4;
  54439. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54440. /**
  54441. * Creates an extruded polygon mesh, with depth in the Y direction.
  54442. * * 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)
  54443. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54444. * @param name defines the name of the mesh
  54445. * @param options defines the options used to create the mesh
  54446. * @param scene defines the hosting scene
  54447. * @param earcutInjection can be used to inject your own earcut reference
  54448. * @returns the polygon mesh
  54449. */
  54450. static ExtrudePolygon(name: string, options: {
  54451. shape: Vector3[];
  54452. holes?: Vector3[][];
  54453. depth?: number;
  54454. faceUV?: Vector4[];
  54455. faceColors?: Color4[];
  54456. updatable?: boolean;
  54457. sideOrientation?: number;
  54458. frontUVs?: Vector4;
  54459. backUVs?: Vector4;
  54460. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54461. }
  54462. }
  54463. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  54464. import { Scene } from "babylonjs/scene";
  54465. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54466. import { Mesh } from "babylonjs/Meshes/mesh";
  54467. import { Nullable } from "babylonjs/types";
  54468. /**
  54469. * Class containing static functions to help procedurally build meshes
  54470. */
  54471. export class LatheBuilder {
  54472. /**
  54473. * Creates lathe mesh.
  54474. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54475. * * 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
  54476. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54477. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54478. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54479. * * 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
  54480. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54481. * * 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
  54482. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54483. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54484. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54486. * @param name defines the name of the mesh
  54487. * @param options defines the options used to create the mesh
  54488. * @param scene defines the hosting scene
  54489. * @returns the lathe mesh
  54490. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54491. */
  54492. static CreateLathe(name: string, options: {
  54493. shape: Vector3[];
  54494. radius?: number;
  54495. tessellation?: number;
  54496. clip?: number;
  54497. arc?: number;
  54498. closed?: boolean;
  54499. updatable?: boolean;
  54500. sideOrientation?: number;
  54501. frontUVs?: Vector4;
  54502. backUVs?: Vector4;
  54503. cap?: number;
  54504. invertUV?: boolean;
  54505. }, scene?: Nullable<Scene>): Mesh;
  54506. }
  54507. }
  54508. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  54509. import { Nullable } from "babylonjs/types";
  54510. import { Scene } from "babylonjs/scene";
  54511. import { Vector4 } from "babylonjs/Maths/math";
  54512. import { Mesh } from "babylonjs/Meshes/mesh";
  54513. /**
  54514. * Class containing static functions to help procedurally build meshes
  54515. */
  54516. export class TiledPlaneBuilder {
  54517. /**
  54518. * Creates a tiled plane mesh
  54519. * * The parameter `pattern` will, depending on value, do nothing or
  54520. * * * flip (reflect about central vertical) alternate tiles across and up
  54521. * * * flip every tile on alternate rows
  54522. * * * rotate (180 degs) alternate tiles across and up
  54523. * * * rotate every tile on alternate rows
  54524. * * * flip and rotate alternate tiles across and up
  54525. * * * flip and rotate every tile on alternate rows
  54526. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  54527. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  54528. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54529. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54530. * * 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)
  54531. * * 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)
  54532. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54533. * @param name defines the name of the mesh
  54534. * @param options defines the options used to create the mesh
  54535. * @param scene defines the hosting scene
  54536. * @returns the box mesh
  54537. */
  54538. static CreateTiledPlane(name: string, options: {
  54539. pattern?: number;
  54540. tileSize?: number;
  54541. tileWidth?: number;
  54542. tileHeight?: number;
  54543. size?: number;
  54544. width?: number;
  54545. height?: number;
  54546. alignHorizontal?: number;
  54547. alignVertical?: number;
  54548. sideOrientation?: number;
  54549. frontUVs?: Vector4;
  54550. backUVs?: Vector4;
  54551. updatable?: boolean;
  54552. }, scene?: Nullable<Scene>): Mesh;
  54553. }
  54554. }
  54555. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  54556. import { Nullable } from "babylonjs/types";
  54557. import { Scene } from "babylonjs/scene";
  54558. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  54559. import { Mesh } from "babylonjs/Meshes/mesh";
  54560. /**
  54561. * Class containing static functions to help procedurally build meshes
  54562. */
  54563. export class TubeBuilder {
  54564. /**
  54565. * Creates a tube mesh.
  54566. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54567. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54568. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54569. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54570. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54571. * * 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)
  54572. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54573. * * 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
  54574. * * 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
  54575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54577. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54578. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54579. * @param name defines the name of the mesh
  54580. * @param options defines the options used to create the mesh
  54581. * @param scene defines the hosting scene
  54582. * @returns the tube mesh
  54583. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54584. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54585. */
  54586. static CreateTube(name: string, options: {
  54587. path: Vector3[];
  54588. radius?: number;
  54589. tessellation?: number;
  54590. radiusFunction?: {
  54591. (i: number, distance: number): number;
  54592. };
  54593. cap?: number;
  54594. arc?: number;
  54595. updatable?: boolean;
  54596. sideOrientation?: number;
  54597. frontUVs?: Vector4;
  54598. backUVs?: Vector4;
  54599. instance?: Mesh;
  54600. invertUV?: boolean;
  54601. }, scene?: Nullable<Scene>): Mesh;
  54602. }
  54603. }
  54604. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  54605. import { Scene } from "babylonjs/scene";
  54606. import { Vector4 } from "babylonjs/Maths/math";
  54607. import { Mesh } from "babylonjs/Meshes/mesh";
  54608. import { Nullable } from "babylonjs/types";
  54609. /**
  54610. * Class containing static functions to help procedurally build meshes
  54611. */
  54612. export class IcoSphereBuilder {
  54613. /**
  54614. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54615. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54616. * * 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`)
  54617. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54618. * * 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
  54619. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54620. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54621. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54622. * @param name defines the name of the mesh
  54623. * @param options defines the options used to create the mesh
  54624. * @param scene defines the hosting scene
  54625. * @returns the icosahedron mesh
  54626. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54627. */
  54628. static CreateIcoSphere(name: string, options: {
  54629. radius?: number;
  54630. radiusX?: number;
  54631. radiusY?: number;
  54632. radiusZ?: number;
  54633. flat?: boolean;
  54634. subdivisions?: number;
  54635. sideOrientation?: number;
  54636. frontUVs?: Vector4;
  54637. backUVs?: Vector4;
  54638. updatable?: boolean;
  54639. }, scene?: Nullable<Scene>): Mesh;
  54640. }
  54641. }
  54642. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  54643. import { Vector3 } from "babylonjs/Maths/math";
  54644. import { Mesh } from "babylonjs/Meshes/mesh";
  54645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54646. /**
  54647. * Class containing static functions to help procedurally build meshes
  54648. */
  54649. export class DecalBuilder {
  54650. /**
  54651. * Creates a decal mesh.
  54652. * 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
  54653. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54654. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54655. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54656. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54657. * @param name defines the name of the mesh
  54658. * @param sourceMesh defines the mesh where the decal must be applied
  54659. * @param options defines the options used to create the mesh
  54660. * @param scene defines the hosting scene
  54661. * @returns the decal mesh
  54662. * @see https://doc.babylonjs.com/how_to/decals
  54663. */
  54664. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54665. position?: Vector3;
  54666. normal?: Vector3;
  54667. size?: Vector3;
  54668. angle?: number;
  54669. }): Mesh;
  54670. }
  54671. }
  54672. declare module "babylonjs/Meshes/meshBuilder" {
  54673. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  54674. import { Nullable } from "babylonjs/types";
  54675. import { Scene } from "babylonjs/scene";
  54676. import { Mesh } from "babylonjs/Meshes/mesh";
  54677. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  54678. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  54679. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  54680. /**
  54681. * Class containing static functions to help procedurally build meshes
  54682. */
  54683. export class MeshBuilder {
  54684. /**
  54685. * Creates a box mesh
  54686. * * The parameter `size` sets the size (float) of each box side (default 1)
  54687. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  54688. * * 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)
  54689. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54693. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  54694. * @param name defines the name of the mesh
  54695. * @param options defines the options used to create the mesh
  54696. * @param scene defines the hosting scene
  54697. * @returns the box mesh
  54698. */
  54699. static CreateBox(name: string, options: {
  54700. size?: number;
  54701. width?: number;
  54702. height?: number;
  54703. depth?: number;
  54704. faceUV?: Vector4[];
  54705. faceColors?: Color4[];
  54706. sideOrientation?: number;
  54707. frontUVs?: Vector4;
  54708. backUVs?: Vector4;
  54709. updatable?: boolean;
  54710. }, scene?: Nullable<Scene>): Mesh;
  54711. /**
  54712. * Creates a tiled box mesh
  54713. * * faceTiles sets the pattern, tile size and number of tiles for a face
  54714. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54715. * @param name defines the name of the mesh
  54716. * @param options defines the options used to create the mesh
  54717. * @param scene defines the hosting scene
  54718. * @returns the tiled box mesh
  54719. */
  54720. static CreateTiledBox(name: string, options: {
  54721. pattern?: number;
  54722. size?: number;
  54723. width?: number;
  54724. height?: number;
  54725. depth: number;
  54726. tileSize?: number;
  54727. tileWidth?: number;
  54728. tileHeight?: number;
  54729. faceUV?: Vector4[];
  54730. faceColors?: Color4[];
  54731. alignHorizontal?: number;
  54732. alignVertical?: number;
  54733. sideOrientation?: number;
  54734. updatable?: boolean;
  54735. }, scene?: Nullable<Scene>): Mesh;
  54736. /**
  54737. * Creates a sphere mesh
  54738. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  54739. * * 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`)
  54740. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  54741. * * 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
  54742. * * 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)
  54743. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54744. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54745. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54746. * @param name defines the name of the mesh
  54747. * @param options defines the options used to create the mesh
  54748. * @param scene defines the hosting scene
  54749. * @returns the sphere mesh
  54750. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  54751. */
  54752. static CreateSphere(name: string, options: {
  54753. segments?: number;
  54754. diameter?: number;
  54755. diameterX?: number;
  54756. diameterY?: number;
  54757. diameterZ?: number;
  54758. arc?: number;
  54759. slice?: number;
  54760. sideOrientation?: number;
  54761. frontUVs?: Vector4;
  54762. backUVs?: Vector4;
  54763. updatable?: boolean;
  54764. }, scene?: Nullable<Scene>): Mesh;
  54765. /**
  54766. * Creates a plane polygonal mesh. By default, this is a disc
  54767. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  54768. * * 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
  54769. * * 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
  54770. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54771. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54772. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54773. * @param name defines the name of the mesh
  54774. * @param options defines the options used to create the mesh
  54775. * @param scene defines the hosting scene
  54776. * @returns the plane polygonal mesh
  54777. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  54778. */
  54779. static CreateDisc(name: string, options: {
  54780. radius?: number;
  54781. tessellation?: number;
  54782. arc?: number;
  54783. updatable?: boolean;
  54784. sideOrientation?: number;
  54785. frontUVs?: Vector4;
  54786. backUVs?: Vector4;
  54787. }, scene?: Nullable<Scene>): Mesh;
  54788. /**
  54789. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  54790. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  54791. * * 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`)
  54792. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  54793. * * 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
  54794. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54795. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54796. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54797. * @param name defines the name of the mesh
  54798. * @param options defines the options used to create the mesh
  54799. * @param scene defines the hosting scene
  54800. * @returns the icosahedron mesh
  54801. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  54802. */
  54803. static CreateIcoSphere(name: string, options: {
  54804. radius?: number;
  54805. radiusX?: number;
  54806. radiusY?: number;
  54807. radiusZ?: number;
  54808. flat?: boolean;
  54809. subdivisions?: number;
  54810. sideOrientation?: number;
  54811. frontUVs?: Vector4;
  54812. backUVs?: Vector4;
  54813. updatable?: boolean;
  54814. }, scene?: Nullable<Scene>): Mesh;
  54815. /**
  54816. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54817. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  54818. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  54819. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  54820. * * 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
  54821. * * 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
  54822. * * 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
  54823. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54824. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54825. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54826. * * 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
  54827. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  54828. * * 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
  54829. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  54830. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54831. * @param name defines the name of the mesh
  54832. * @param options defines the options used to create the mesh
  54833. * @param scene defines the hosting scene
  54834. * @returns the ribbon mesh
  54835. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  54836. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54837. */
  54838. static CreateRibbon(name: string, options: {
  54839. pathArray: Vector3[][];
  54840. closeArray?: boolean;
  54841. closePath?: boolean;
  54842. offset?: number;
  54843. updatable?: boolean;
  54844. sideOrientation?: number;
  54845. frontUVs?: Vector4;
  54846. backUVs?: Vector4;
  54847. instance?: Mesh;
  54848. invertUV?: boolean;
  54849. uvs?: Vector2[];
  54850. colors?: Color4[];
  54851. }, scene?: Nullable<Scene>): Mesh;
  54852. /**
  54853. * Creates a cylinder or a cone mesh
  54854. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  54855. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  54856. * * 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.
  54857. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  54858. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  54859. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  54860. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  54861. * * 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).
  54862. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  54863. * * 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).
  54864. * * 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
  54865. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  54866. * * 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
  54867. * * 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.
  54868. * * If `enclose` is false, a ring surface is one element.
  54869. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  54870. * * 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
  54871. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54872. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54874. * @param name defines the name of the mesh
  54875. * @param options defines the options used to create the mesh
  54876. * @param scene defines the hosting scene
  54877. * @returns the cylinder mesh
  54878. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  54879. */
  54880. static CreateCylinder(name: string, options: {
  54881. height?: number;
  54882. diameterTop?: number;
  54883. diameterBottom?: number;
  54884. diameter?: number;
  54885. tessellation?: number;
  54886. subdivisions?: number;
  54887. arc?: number;
  54888. faceColors?: Color4[];
  54889. faceUV?: Vector4[];
  54890. updatable?: boolean;
  54891. hasRings?: boolean;
  54892. enclose?: boolean;
  54893. cap?: number;
  54894. sideOrientation?: number;
  54895. frontUVs?: Vector4;
  54896. backUVs?: Vector4;
  54897. }, scene?: Nullable<Scene>): Mesh;
  54898. /**
  54899. * Creates a torus mesh
  54900. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  54901. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  54902. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  54903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54906. * @param name defines the name of the mesh
  54907. * @param options defines the options used to create the mesh
  54908. * @param scene defines the hosting scene
  54909. * @returns the torus mesh
  54910. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  54911. */
  54912. static CreateTorus(name: string, options: {
  54913. diameter?: number;
  54914. thickness?: number;
  54915. tessellation?: number;
  54916. updatable?: boolean;
  54917. sideOrientation?: number;
  54918. frontUVs?: Vector4;
  54919. backUVs?: Vector4;
  54920. }, scene?: Nullable<Scene>): Mesh;
  54921. /**
  54922. * Creates a torus knot mesh
  54923. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  54924. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  54925. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  54926. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  54927. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54928. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  54929. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54930. * @param name defines the name of the mesh
  54931. * @param options defines the options used to create the mesh
  54932. * @param scene defines the hosting scene
  54933. * @returns the torus knot mesh
  54934. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  54935. */
  54936. static CreateTorusKnot(name: string, options: {
  54937. radius?: number;
  54938. tube?: number;
  54939. radialSegments?: number;
  54940. tubularSegments?: number;
  54941. p?: number;
  54942. q?: number;
  54943. updatable?: boolean;
  54944. sideOrientation?: number;
  54945. frontUVs?: Vector4;
  54946. backUVs?: Vector4;
  54947. }, scene?: Nullable<Scene>): Mesh;
  54948. /**
  54949. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  54950. * * 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
  54951. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  54952. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  54953. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  54954. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  54955. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  54956. * * 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
  54957. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  54958. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54959. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  54960. * @param name defines the name of the new line system
  54961. * @param options defines the options used to create the line system
  54962. * @param scene defines the hosting scene
  54963. * @returns a new line system mesh
  54964. */
  54965. static CreateLineSystem(name: string, options: {
  54966. lines: Vector3[][];
  54967. updatable?: boolean;
  54968. instance?: Nullable<LinesMesh>;
  54969. colors?: Nullable<Color4[][]>;
  54970. useVertexAlpha?: boolean;
  54971. }, scene: Nullable<Scene>): LinesMesh;
  54972. /**
  54973. * Creates a line mesh
  54974. * 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
  54975. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54976. * * The parameter `points` is an array successive Vector3
  54977. * * 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
  54978. * * The optional parameter `colors` is an array of successive Color4, one per line point
  54979. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  54980. * * When updating an instance, remember that only point positions can change, not the number of points
  54981. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  54983. * @param name defines the name of the new line system
  54984. * @param options defines the options used to create the line system
  54985. * @param scene defines the hosting scene
  54986. * @returns a new line mesh
  54987. */
  54988. static CreateLines(name: string, options: {
  54989. points: Vector3[];
  54990. updatable?: boolean;
  54991. instance?: Nullable<LinesMesh>;
  54992. colors?: Color4[];
  54993. useVertexAlpha?: boolean;
  54994. }, scene?: Nullable<Scene>): LinesMesh;
  54995. /**
  54996. * Creates a dashed line mesh
  54997. * * 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
  54998. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  54999. * * The parameter `points` is an array successive Vector3
  55000. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  55001. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  55002. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  55003. * * 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
  55004. * * When updating an instance, remember that only point positions can change, not the number of points
  55005. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55006. * @param name defines the name of the mesh
  55007. * @param options defines the options used to create the mesh
  55008. * @param scene defines the hosting scene
  55009. * @returns the dashed line mesh
  55010. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  55011. */
  55012. static CreateDashedLines(name: string, options: {
  55013. points: Vector3[];
  55014. dashSize?: number;
  55015. gapSize?: number;
  55016. dashNb?: number;
  55017. updatable?: boolean;
  55018. instance?: LinesMesh;
  55019. }, scene?: Nullable<Scene>): LinesMesh;
  55020. /**
  55021. * 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.
  55022. * * 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.
  55023. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55024. * * 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.
  55025. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  55026. * * 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
  55027. * * 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
  55028. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  55029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55031. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  55032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55033. * @param name defines the name of the mesh
  55034. * @param options defines the options used to create the mesh
  55035. * @param scene defines the hosting scene
  55036. * @returns the extruded shape mesh
  55037. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55038. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55039. */
  55040. static ExtrudeShape(name: string, options: {
  55041. shape: Vector3[];
  55042. path: Vector3[];
  55043. scale?: number;
  55044. rotation?: number;
  55045. cap?: number;
  55046. updatable?: boolean;
  55047. sideOrientation?: number;
  55048. frontUVs?: Vector4;
  55049. backUVs?: Vector4;
  55050. instance?: Mesh;
  55051. invertUV?: boolean;
  55052. }, scene?: Nullable<Scene>): Mesh;
  55053. /**
  55054. * Creates an custom extruded shape mesh.
  55055. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  55056. * * 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.
  55057. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  55058. * * 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
  55059. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  55060. * * 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
  55061. * * It must returns a float value that will be the scale value applied to the shape on each path point
  55062. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  55063. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  55064. * * 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
  55065. * * 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
  55066. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  55067. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55068. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55069. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55070. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55071. * @param name defines the name of the mesh
  55072. * @param options defines the options used to create the mesh
  55073. * @param scene defines the hosting scene
  55074. * @returns the custom extruded shape mesh
  55075. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  55076. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55077. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  55078. */
  55079. static ExtrudeShapeCustom(name: string, options: {
  55080. shape: Vector3[];
  55081. path: Vector3[];
  55082. scaleFunction?: any;
  55083. rotationFunction?: any;
  55084. ribbonCloseArray?: boolean;
  55085. ribbonClosePath?: boolean;
  55086. cap?: number;
  55087. updatable?: boolean;
  55088. sideOrientation?: number;
  55089. frontUVs?: Vector4;
  55090. backUVs?: Vector4;
  55091. instance?: Mesh;
  55092. invertUV?: boolean;
  55093. }, scene?: Nullable<Scene>): Mesh;
  55094. /**
  55095. * Creates lathe mesh.
  55096. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  55097. * * 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
  55098. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  55099. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  55100. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  55101. * * 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
  55102. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  55103. * * 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
  55104. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55105. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55106. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55108. * @param name defines the name of the mesh
  55109. * @param options defines the options used to create the mesh
  55110. * @param scene defines the hosting scene
  55111. * @returns the lathe mesh
  55112. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  55113. */
  55114. static CreateLathe(name: string, options: {
  55115. shape: Vector3[];
  55116. radius?: number;
  55117. tessellation?: number;
  55118. clip?: number;
  55119. arc?: number;
  55120. closed?: boolean;
  55121. updatable?: boolean;
  55122. sideOrientation?: number;
  55123. frontUVs?: Vector4;
  55124. backUVs?: Vector4;
  55125. cap?: number;
  55126. invertUV?: boolean;
  55127. }, scene?: Nullable<Scene>): Mesh;
  55128. /**
  55129. * Creates a tiled plane mesh
  55130. * * You can set a limited pattern arrangement with the tiles
  55131. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55132. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55133. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55134. * @param name defines the name of the mesh
  55135. * @param options defines the options used to create the mesh
  55136. * @param scene defines the hosting scene
  55137. * @returns the plane mesh
  55138. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55139. */
  55140. static CreateTiledPlane(name: string, options: {
  55141. pattern?: number;
  55142. tileSize?: number;
  55143. tileWidth?: number;
  55144. tileHeight?: number;
  55145. size?: number;
  55146. width?: number;
  55147. height?: number;
  55148. alignHorizontal?: number;
  55149. alignVertical?: number;
  55150. sideOrientation?: number;
  55151. frontUVs?: Vector4;
  55152. backUVs?: Vector4;
  55153. updatable?: boolean;
  55154. }, scene?: Nullable<Scene>): Mesh;
  55155. /**
  55156. * Creates a plane mesh
  55157. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  55158. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  55159. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  55160. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55161. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55162. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55163. * @param name defines the name of the mesh
  55164. * @param options defines the options used to create the mesh
  55165. * @param scene defines the hosting scene
  55166. * @returns the plane mesh
  55167. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  55168. */
  55169. static CreatePlane(name: string, options: {
  55170. size?: number;
  55171. width?: number;
  55172. height?: number;
  55173. sideOrientation?: number;
  55174. frontUVs?: Vector4;
  55175. backUVs?: Vector4;
  55176. updatable?: boolean;
  55177. sourcePlane?: Plane;
  55178. }, scene?: Nullable<Scene>): Mesh;
  55179. /**
  55180. * Creates a ground mesh
  55181. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  55182. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  55183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55184. * @param name defines the name of the mesh
  55185. * @param options defines the options used to create the mesh
  55186. * @param scene defines the hosting scene
  55187. * @returns the ground mesh
  55188. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  55189. */
  55190. static CreateGround(name: string, options: {
  55191. width?: number;
  55192. height?: number;
  55193. subdivisions?: number;
  55194. subdivisionsX?: number;
  55195. subdivisionsY?: number;
  55196. updatable?: boolean;
  55197. }, scene?: Nullable<Scene>): Mesh;
  55198. /**
  55199. * Creates a tiled ground mesh
  55200. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  55201. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  55202. * * 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
  55203. * * 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
  55204. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55205. * @param name defines the name of the mesh
  55206. * @param options defines the options used to create the mesh
  55207. * @param scene defines the hosting scene
  55208. * @returns the tiled ground mesh
  55209. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  55210. */
  55211. static CreateTiledGround(name: string, options: {
  55212. xmin: number;
  55213. zmin: number;
  55214. xmax: number;
  55215. zmax: number;
  55216. subdivisions?: {
  55217. w: number;
  55218. h: number;
  55219. };
  55220. precision?: {
  55221. w: number;
  55222. h: number;
  55223. };
  55224. updatable?: boolean;
  55225. }, scene?: Nullable<Scene>): Mesh;
  55226. /**
  55227. * Creates a ground mesh from a height map
  55228. * * The parameter `url` sets the URL of the height map image resource.
  55229. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  55230. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  55231. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  55232. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  55233. * * 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.
  55234. * * 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).
  55235. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  55236. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  55237. * @param name defines the name of the mesh
  55238. * @param url defines the url to the height map
  55239. * @param options defines the options used to create the mesh
  55240. * @param scene defines the hosting scene
  55241. * @returns the ground mesh
  55242. * @see https://doc.babylonjs.com/babylon101/height_map
  55243. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  55244. */
  55245. static CreateGroundFromHeightMap(name: string, url: string, options: {
  55246. width?: number;
  55247. height?: number;
  55248. subdivisions?: number;
  55249. minHeight?: number;
  55250. maxHeight?: number;
  55251. colorFilter?: Color3;
  55252. alphaFilter?: number;
  55253. updatable?: boolean;
  55254. onReady?: (mesh: GroundMesh) => void;
  55255. }, scene?: Nullable<Scene>): GroundMesh;
  55256. /**
  55257. * Creates a polygon mesh
  55258. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  55259. * * 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
  55260. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  55261. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55262. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  55263. * * Remember you can only change the shape positions, not their number when updating a polygon
  55264. * @param name defines the name of the mesh
  55265. * @param options defines the options used to create the mesh
  55266. * @param scene defines the hosting scene
  55267. * @param earcutInjection can be used to inject your own earcut reference
  55268. * @returns the polygon mesh
  55269. */
  55270. static CreatePolygon(name: string, options: {
  55271. shape: Vector3[];
  55272. holes?: Vector3[][];
  55273. depth?: number;
  55274. faceUV?: Vector4[];
  55275. faceColors?: Color4[];
  55276. updatable?: boolean;
  55277. sideOrientation?: number;
  55278. frontUVs?: Vector4;
  55279. backUVs?: Vector4;
  55280. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55281. /**
  55282. * Creates an extruded polygon mesh, with depth in the Y direction.
  55283. * * 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)
  55284. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  55285. * @param name defines the name of the mesh
  55286. * @param options defines the options used to create the mesh
  55287. * @param scene defines the hosting scene
  55288. * @param earcutInjection can be used to inject your own earcut reference
  55289. * @returns the polygon mesh
  55290. */
  55291. static ExtrudePolygon(name: string, options: {
  55292. shape: Vector3[];
  55293. holes?: Vector3[][];
  55294. depth?: number;
  55295. faceUV?: Vector4[];
  55296. faceColors?: Color4[];
  55297. updatable?: boolean;
  55298. sideOrientation?: number;
  55299. frontUVs?: Vector4;
  55300. backUVs?: Vector4;
  55301. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  55302. /**
  55303. * Creates a tube mesh.
  55304. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  55305. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  55306. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  55307. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  55308. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  55309. * * 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)
  55310. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  55311. * * 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
  55312. * * 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
  55313. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55314. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55315. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  55316. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55317. * @param name defines the name of the mesh
  55318. * @param options defines the options used to create the mesh
  55319. * @param scene defines the hosting scene
  55320. * @returns the tube mesh
  55321. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  55322. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  55323. */
  55324. static CreateTube(name: string, options: {
  55325. path: Vector3[];
  55326. radius?: number;
  55327. tessellation?: number;
  55328. radiusFunction?: {
  55329. (i: number, distance: number): number;
  55330. };
  55331. cap?: number;
  55332. arc?: number;
  55333. updatable?: boolean;
  55334. sideOrientation?: number;
  55335. frontUVs?: Vector4;
  55336. backUVs?: Vector4;
  55337. instance?: Mesh;
  55338. invertUV?: boolean;
  55339. }, scene?: Nullable<Scene>): Mesh;
  55340. /**
  55341. * Creates a polyhedron mesh
  55342. * * 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
  55343. * * The parameter `size` (positive float, default 1) sets the polygon size
  55344. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  55345. * * 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`
  55346. * * 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
  55347. * * 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)`)
  55348. * * 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
  55349. * * 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
  55350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  55351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  55352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  55353. * @param name defines the name of the mesh
  55354. * @param options defines the options used to create the mesh
  55355. * @param scene defines the hosting scene
  55356. * @returns the polyhedron mesh
  55357. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  55358. */
  55359. static CreatePolyhedron(name: string, options: {
  55360. type?: number;
  55361. size?: number;
  55362. sizeX?: number;
  55363. sizeY?: number;
  55364. sizeZ?: number;
  55365. custom?: any;
  55366. faceUV?: Vector4[];
  55367. faceColors?: Color4[];
  55368. flat?: boolean;
  55369. updatable?: boolean;
  55370. sideOrientation?: number;
  55371. frontUVs?: Vector4;
  55372. backUVs?: Vector4;
  55373. }, scene?: Nullable<Scene>): Mesh;
  55374. /**
  55375. * Creates a decal mesh.
  55376. * 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
  55377. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  55378. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  55379. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  55380. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  55381. * @param name defines the name of the mesh
  55382. * @param sourceMesh defines the mesh where the decal must be applied
  55383. * @param options defines the options used to create the mesh
  55384. * @param scene defines the hosting scene
  55385. * @returns the decal mesh
  55386. * @see https://doc.babylonjs.com/how_to/decals
  55387. */
  55388. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  55389. position?: Vector3;
  55390. normal?: Vector3;
  55391. size?: Vector3;
  55392. angle?: number;
  55393. }): Mesh;
  55394. }
  55395. }
  55396. declare module "babylonjs/Meshes/meshSimplification" {
  55397. import { Mesh } from "babylonjs/Meshes/mesh";
  55398. /**
  55399. * A simplifier interface for future simplification implementations
  55400. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55401. */
  55402. export interface ISimplifier {
  55403. /**
  55404. * Simplification of a given mesh according to the given settings.
  55405. * Since this requires computation, it is assumed that the function runs async.
  55406. * @param settings The settings of the simplification, including quality and distance
  55407. * @param successCallback A callback that will be called after the mesh was simplified.
  55408. * @param errorCallback in case of an error, this callback will be called. optional.
  55409. */
  55410. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  55411. }
  55412. /**
  55413. * Expected simplification settings.
  55414. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  55415. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55416. */
  55417. export interface ISimplificationSettings {
  55418. /**
  55419. * Gets or sets the expected quality
  55420. */
  55421. quality: number;
  55422. /**
  55423. * Gets or sets the distance when this optimized version should be used
  55424. */
  55425. distance: number;
  55426. /**
  55427. * Gets an already optimized mesh
  55428. */
  55429. optimizeMesh?: boolean;
  55430. }
  55431. /**
  55432. * Class used to specify simplification options
  55433. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55434. */
  55435. export class SimplificationSettings implements ISimplificationSettings {
  55436. /** expected quality */
  55437. quality: number;
  55438. /** distance when this optimized version should be used */
  55439. distance: number;
  55440. /** already optimized mesh */
  55441. optimizeMesh?: boolean | undefined;
  55442. /**
  55443. * Creates a SimplificationSettings
  55444. * @param quality expected quality
  55445. * @param distance distance when this optimized version should be used
  55446. * @param optimizeMesh already optimized mesh
  55447. */
  55448. constructor(
  55449. /** expected quality */
  55450. quality: number,
  55451. /** distance when this optimized version should be used */
  55452. distance: number,
  55453. /** already optimized mesh */
  55454. optimizeMesh?: boolean | undefined);
  55455. }
  55456. /**
  55457. * Interface used to define a simplification task
  55458. */
  55459. export interface ISimplificationTask {
  55460. /**
  55461. * Array of settings
  55462. */
  55463. settings: Array<ISimplificationSettings>;
  55464. /**
  55465. * Simplification type
  55466. */
  55467. simplificationType: SimplificationType;
  55468. /**
  55469. * Mesh to simplify
  55470. */
  55471. mesh: Mesh;
  55472. /**
  55473. * Callback called on success
  55474. */
  55475. successCallback?: () => void;
  55476. /**
  55477. * Defines if parallel processing can be used
  55478. */
  55479. parallelProcessing: boolean;
  55480. }
  55481. /**
  55482. * Queue used to order the simplification tasks
  55483. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55484. */
  55485. export class SimplificationQueue {
  55486. private _simplificationArray;
  55487. /**
  55488. * Gets a boolean indicating that the process is still running
  55489. */
  55490. running: boolean;
  55491. /**
  55492. * Creates a new queue
  55493. */
  55494. constructor();
  55495. /**
  55496. * Adds a new simplification task
  55497. * @param task defines a task to add
  55498. */
  55499. addTask(task: ISimplificationTask): void;
  55500. /**
  55501. * Execute next task
  55502. */
  55503. executeNext(): void;
  55504. /**
  55505. * Execute a simplification task
  55506. * @param task defines the task to run
  55507. */
  55508. runSimplification(task: ISimplificationTask): void;
  55509. private getSimplifier;
  55510. }
  55511. /**
  55512. * The implemented types of simplification
  55513. * At the moment only Quadratic Error Decimation is implemented
  55514. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55515. */
  55516. export enum SimplificationType {
  55517. /** Quadratic error decimation */
  55518. QUADRATIC = 0
  55519. }
  55520. }
  55521. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  55522. import { Scene } from "babylonjs/scene";
  55523. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  55524. import { ISceneComponent } from "babylonjs/sceneComponent";
  55525. module "babylonjs/scene" {
  55526. interface Scene {
  55527. /** @hidden (Backing field) */
  55528. _simplificationQueue: SimplificationQueue;
  55529. /**
  55530. * Gets or sets the simplification queue attached to the scene
  55531. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  55532. */
  55533. simplificationQueue: SimplificationQueue;
  55534. }
  55535. }
  55536. module "babylonjs/Meshes/mesh" {
  55537. interface Mesh {
  55538. /**
  55539. * Simplify the mesh according to the given array of settings.
  55540. * Function will return immediately and will simplify async
  55541. * @param settings a collection of simplification settings
  55542. * @param parallelProcessing should all levels calculate parallel or one after the other
  55543. * @param simplificationType the type of simplification to run
  55544. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  55545. * @returns the current mesh
  55546. */
  55547. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  55548. }
  55549. }
  55550. /**
  55551. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  55552. * created in a scene
  55553. */
  55554. export class SimplicationQueueSceneComponent implements ISceneComponent {
  55555. /**
  55556. * The component name helpfull to identify the component in the list of scene components.
  55557. */
  55558. readonly name: string;
  55559. /**
  55560. * The scene the component belongs to.
  55561. */
  55562. scene: Scene;
  55563. /**
  55564. * Creates a new instance of the component for the given scene
  55565. * @param scene Defines the scene to register the component in
  55566. */
  55567. constructor(scene: Scene);
  55568. /**
  55569. * Registers the component in a given scene
  55570. */
  55571. register(): void;
  55572. /**
  55573. * Rebuilds the elements related to this component in case of
  55574. * context lost for instance.
  55575. */
  55576. rebuild(): void;
  55577. /**
  55578. * Disposes the component and the associated ressources
  55579. */
  55580. dispose(): void;
  55581. private _beforeCameraUpdate;
  55582. }
  55583. }
  55584. declare module "babylonjs/Meshes/Builders/index" {
  55585. export * from "babylonjs/Meshes/Builders/boxBuilder";
  55586. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  55587. export * from "babylonjs/Meshes/Builders/discBuilder";
  55588. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  55589. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  55590. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  55591. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  55592. export * from "babylonjs/Meshes/Builders/torusBuilder";
  55593. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  55594. export * from "babylonjs/Meshes/Builders/linesBuilder";
  55595. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  55596. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  55597. export * from "babylonjs/Meshes/Builders/latheBuilder";
  55598. export * from "babylonjs/Meshes/Builders/planeBuilder";
  55599. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  55600. export * from "babylonjs/Meshes/Builders/groundBuilder";
  55601. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  55602. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  55603. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  55604. export * from "babylonjs/Meshes/Builders/decalBuilder";
  55605. }
  55606. declare module "babylonjs/Meshes/index" {
  55607. export * from "babylonjs/Meshes/abstractMesh";
  55608. export * from "babylonjs/Meshes/buffer";
  55609. export * from "babylonjs/Meshes/Compression/index";
  55610. export * from "babylonjs/Meshes/csg";
  55611. export * from "babylonjs/Meshes/geometry";
  55612. export * from "babylonjs/Meshes/groundMesh";
  55613. export * from "babylonjs/Meshes/trailMesh";
  55614. export * from "babylonjs/Meshes/instancedMesh";
  55615. export * from "babylonjs/Meshes/linesMesh";
  55616. export * from "babylonjs/Meshes/mesh";
  55617. export * from "babylonjs/Meshes/mesh.vertexData";
  55618. export * from "babylonjs/Meshes/meshBuilder";
  55619. export * from "babylonjs/Meshes/meshSimplification";
  55620. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  55621. export * from "babylonjs/Meshes/polygonMesh";
  55622. export * from "babylonjs/Meshes/subMesh";
  55623. export * from "babylonjs/Meshes/meshLODLevel";
  55624. export * from "babylonjs/Meshes/transformNode";
  55625. export * from "babylonjs/Meshes/Builders/index";
  55626. export * from "babylonjs/Meshes/dataBuffer";
  55627. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  55628. }
  55629. declare module "babylonjs/Morph/index" {
  55630. export * from "babylonjs/Morph/morphTarget";
  55631. export * from "babylonjs/Morph/morphTargetManager";
  55632. }
  55633. declare module "babylonjs/Offline/database" {
  55634. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  55635. /**
  55636. * Class used to enable access to IndexedDB
  55637. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  55638. */
  55639. export class Database implements IOfflineProvider {
  55640. private _callbackManifestChecked;
  55641. private _currentSceneUrl;
  55642. private _db;
  55643. private _enableSceneOffline;
  55644. private _enableTexturesOffline;
  55645. private _manifestVersionFound;
  55646. private _mustUpdateRessources;
  55647. private _hasReachedQuota;
  55648. private _isSupported;
  55649. private _idbFactory;
  55650. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  55651. private static IsUASupportingBlobStorage;
  55652. /**
  55653. * Gets a boolean indicating if Database storate is enabled (off by default)
  55654. */
  55655. static IDBStorageEnabled: boolean;
  55656. /**
  55657. * Gets a boolean indicating if scene must be saved in the database
  55658. */
  55659. readonly enableSceneOffline: boolean;
  55660. /**
  55661. * Gets a boolean indicating if textures must be saved in the database
  55662. */
  55663. readonly enableTexturesOffline: boolean;
  55664. /**
  55665. * Creates a new Database
  55666. * @param urlToScene defines the url to load the scene
  55667. * @param callbackManifestChecked defines the callback to use when manifest is checked
  55668. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  55669. */
  55670. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  55671. private static _ParseURL;
  55672. private static _ReturnFullUrlLocation;
  55673. private _checkManifestFile;
  55674. /**
  55675. * Open the database and make it available
  55676. * @param successCallback defines the callback to call on success
  55677. * @param errorCallback defines the callback to call on error
  55678. */
  55679. open(successCallback: () => void, errorCallback: () => void): void;
  55680. /**
  55681. * Loads an image from the database
  55682. * @param url defines the url to load from
  55683. * @param image defines the target DOM image
  55684. */
  55685. loadImage(url: string, image: HTMLImageElement): void;
  55686. private _loadImageFromDBAsync;
  55687. private _saveImageIntoDBAsync;
  55688. private _checkVersionFromDB;
  55689. private _loadVersionFromDBAsync;
  55690. private _saveVersionIntoDBAsync;
  55691. /**
  55692. * Loads a file from database
  55693. * @param url defines the URL to load from
  55694. * @param sceneLoaded defines a callback to call on success
  55695. * @param progressCallBack defines a callback to call when progress changed
  55696. * @param errorCallback defines a callback to call on error
  55697. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  55698. */
  55699. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  55700. private _loadFileAsync;
  55701. private _saveFileAsync;
  55702. /**
  55703. * Validates if xhr data is correct
  55704. * @param xhr defines the request to validate
  55705. * @param dataType defines the expected data type
  55706. * @returns true if data is correct
  55707. */
  55708. private static _ValidateXHRData;
  55709. }
  55710. }
  55711. declare module "babylonjs/Offline/index" {
  55712. export * from "babylonjs/Offline/database";
  55713. export * from "babylonjs/Offline/IOfflineProvider";
  55714. }
  55715. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  55716. /** @hidden */
  55717. export var gpuUpdateParticlesPixelShader: {
  55718. name: string;
  55719. shader: string;
  55720. };
  55721. }
  55722. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  55723. /** @hidden */
  55724. export var gpuUpdateParticlesVertexShader: {
  55725. name: string;
  55726. shader: string;
  55727. };
  55728. }
  55729. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  55730. /** @hidden */
  55731. export var clipPlaneFragmentDeclaration2: {
  55732. name: string;
  55733. shader: string;
  55734. };
  55735. }
  55736. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  55737. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  55738. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  55739. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55740. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  55741. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  55742. /** @hidden */
  55743. export var gpuRenderParticlesPixelShader: {
  55744. name: string;
  55745. shader: string;
  55746. };
  55747. }
  55748. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  55749. /** @hidden */
  55750. export var clipPlaneVertexDeclaration2: {
  55751. name: string;
  55752. shader: string;
  55753. };
  55754. }
  55755. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  55756. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  55757. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  55758. /** @hidden */
  55759. export var gpuRenderParticlesVertexShader: {
  55760. name: string;
  55761. shader: string;
  55762. };
  55763. }
  55764. declare module "babylonjs/Particles/gpuParticleSystem" {
  55765. import { Nullable } from "babylonjs/types";
  55766. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  55767. import { Observable } from "babylonjs/Misc/observable";
  55768. import { Color4, Color3 } from "babylonjs/Maths/math";
  55769. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  55770. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  55771. import { Scene, IDisposable } from "babylonjs/scene";
  55772. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  55773. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  55774. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  55775. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  55776. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  55777. /**
  55778. * This represents a GPU particle system in Babylon
  55779. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  55780. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  55781. */
  55782. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  55783. /**
  55784. * The layer mask we are rendering the particles through.
  55785. */
  55786. layerMask: number;
  55787. private _capacity;
  55788. private _activeCount;
  55789. private _currentActiveCount;
  55790. private _accumulatedCount;
  55791. private _renderEffect;
  55792. private _updateEffect;
  55793. private _buffer0;
  55794. private _buffer1;
  55795. private _spriteBuffer;
  55796. private _updateVAO;
  55797. private _renderVAO;
  55798. private _targetIndex;
  55799. private _sourceBuffer;
  55800. private _targetBuffer;
  55801. private _engine;
  55802. private _currentRenderId;
  55803. private _started;
  55804. private _stopped;
  55805. private _timeDelta;
  55806. private _randomTexture;
  55807. private _randomTexture2;
  55808. private _attributesStrideSize;
  55809. private _updateEffectOptions;
  55810. private _randomTextureSize;
  55811. private _actualFrame;
  55812. private readonly _rawTextureWidth;
  55813. /**
  55814. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55815. */
  55816. static readonly IsSupported: boolean;
  55817. /**
  55818. * An event triggered when the system is disposed.
  55819. */
  55820. onDisposeObservable: Observable<GPUParticleSystem>;
  55821. /**
  55822. * Gets the maximum number of particles active at the same time.
  55823. * @returns The max number of active particles.
  55824. */
  55825. getCapacity(): number;
  55826. /**
  55827. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55828. * to override the particles.
  55829. */
  55830. forceDepthWrite: boolean;
  55831. /**
  55832. * Gets or set the number of active particles
  55833. */
  55834. activeParticleCount: number;
  55835. private _preWarmDone;
  55836. /**
  55837. * Is this system ready to be used/rendered
  55838. * @return true if the system is ready
  55839. */
  55840. isReady(): boolean;
  55841. /**
  55842. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55843. * @returns True if it has been started, otherwise false.
  55844. */
  55845. isStarted(): boolean;
  55846. /**
  55847. * Starts the particle system and begins to emit
  55848. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55849. */
  55850. start(delay?: number): void;
  55851. /**
  55852. * Stops the particle system.
  55853. */
  55854. stop(): void;
  55855. /**
  55856. * Remove all active particles
  55857. */
  55858. reset(): void;
  55859. /**
  55860. * Returns the string "GPUParticleSystem"
  55861. * @returns a string containing the class name
  55862. */
  55863. getClassName(): string;
  55864. private _colorGradientsTexture;
  55865. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55866. /**
  55867. * Adds a new color gradient
  55868. * @param gradient defines the gradient to use (between 0 and 1)
  55869. * @param color1 defines the color to affect to the specified gradient
  55870. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55871. * @returns the current particle system
  55872. */
  55873. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55874. /**
  55875. * Remove a specific color gradient
  55876. * @param gradient defines the gradient to remove
  55877. * @returns the current particle system
  55878. */
  55879. removeColorGradient(gradient: number): GPUParticleSystem;
  55880. private _angularSpeedGradientsTexture;
  55881. private _sizeGradientsTexture;
  55882. private _velocityGradientsTexture;
  55883. private _limitVelocityGradientsTexture;
  55884. private _dragGradientsTexture;
  55885. private _addFactorGradient;
  55886. /**
  55887. * Adds a new size gradient
  55888. * @param gradient defines the gradient to use (between 0 and 1)
  55889. * @param factor defines the size factor to affect to the specified gradient
  55890. * @returns the current particle system
  55891. */
  55892. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55893. /**
  55894. * Remove a specific size gradient
  55895. * @param gradient defines the gradient to remove
  55896. * @returns the current particle system
  55897. */
  55898. removeSizeGradient(gradient: number): GPUParticleSystem;
  55899. /**
  55900. * Adds a new angular speed gradient
  55901. * @param gradient defines the gradient to use (between 0 and 1)
  55902. * @param factor defines the angular speed to affect to the specified gradient
  55903. * @returns the current particle system
  55904. */
  55905. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55906. /**
  55907. * Remove a specific angular speed gradient
  55908. * @param gradient defines the gradient to remove
  55909. * @returns the current particle system
  55910. */
  55911. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55912. /**
  55913. * Adds a new velocity gradient
  55914. * @param gradient defines the gradient to use (between 0 and 1)
  55915. * @param factor defines the velocity to affect to the specified gradient
  55916. * @returns the current particle system
  55917. */
  55918. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55919. /**
  55920. * Remove a specific velocity gradient
  55921. * @param gradient defines the gradient to remove
  55922. * @returns the current particle system
  55923. */
  55924. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55925. /**
  55926. * Adds a new limit velocity gradient
  55927. * @param gradient defines the gradient to use (between 0 and 1)
  55928. * @param factor defines the limit velocity value to affect to the specified gradient
  55929. * @returns the current particle system
  55930. */
  55931. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55932. /**
  55933. * Remove a specific limit velocity gradient
  55934. * @param gradient defines the gradient to remove
  55935. * @returns the current particle system
  55936. */
  55937. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55938. /**
  55939. * Adds a new drag gradient
  55940. * @param gradient defines the gradient to use (between 0 and 1)
  55941. * @param factor defines the drag value to affect to the specified gradient
  55942. * @returns the current particle system
  55943. */
  55944. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55945. /**
  55946. * Remove a specific drag gradient
  55947. * @param gradient defines the gradient to remove
  55948. * @returns the current particle system
  55949. */
  55950. removeDragGradient(gradient: number): GPUParticleSystem;
  55951. /**
  55952. * Not supported by GPUParticleSystem
  55953. * @param gradient defines the gradient to use (between 0 and 1)
  55954. * @param factor defines the emit rate value to affect to the specified gradient
  55955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55956. * @returns the current particle system
  55957. */
  55958. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55959. /**
  55960. * Not supported by GPUParticleSystem
  55961. * @param gradient defines the gradient to remove
  55962. * @returns the current particle system
  55963. */
  55964. removeEmitRateGradient(gradient: number): IParticleSystem;
  55965. /**
  55966. * Not supported by GPUParticleSystem
  55967. * @param gradient defines the gradient to use (between 0 and 1)
  55968. * @param factor defines the start size value to affect to the specified gradient
  55969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55970. * @returns the current particle system
  55971. */
  55972. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55973. /**
  55974. * Not supported by GPUParticleSystem
  55975. * @param gradient defines the gradient to remove
  55976. * @returns the current particle system
  55977. */
  55978. removeStartSizeGradient(gradient: number): IParticleSystem;
  55979. /**
  55980. * Not supported by GPUParticleSystem
  55981. * @param gradient defines the gradient to use (between 0 and 1)
  55982. * @param min defines the color remap minimal range
  55983. * @param max defines the color remap maximal range
  55984. * @returns the current particle system
  55985. */
  55986. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55987. /**
  55988. * Not supported by GPUParticleSystem
  55989. * @param gradient defines the gradient to remove
  55990. * @returns the current particle system
  55991. */
  55992. removeColorRemapGradient(): IParticleSystem;
  55993. /**
  55994. * Not supported by GPUParticleSystem
  55995. * @param gradient defines the gradient to use (between 0 and 1)
  55996. * @param min defines the alpha remap minimal range
  55997. * @param max defines the alpha remap maximal range
  55998. * @returns the current particle system
  55999. */
  56000. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  56001. /**
  56002. * Not supported by GPUParticleSystem
  56003. * @param gradient defines the gradient to remove
  56004. * @returns the current particle system
  56005. */
  56006. removeAlphaRemapGradient(): IParticleSystem;
  56007. /**
  56008. * Not supported by GPUParticleSystem
  56009. * @param gradient defines the gradient to use (between 0 and 1)
  56010. * @param color defines the color to affect to the specified gradient
  56011. * @returns the current particle system
  56012. */
  56013. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  56014. /**
  56015. * Not supported by GPUParticleSystem
  56016. * @param gradient defines the gradient to remove
  56017. * @returns the current particle system
  56018. */
  56019. removeRampGradient(): IParticleSystem;
  56020. /**
  56021. * Not supported by GPUParticleSystem
  56022. * @returns the list of ramp gradients
  56023. */
  56024. getRampGradients(): Nullable<Array<Color3Gradient>>;
  56025. /**
  56026. * Not supported by GPUParticleSystem
  56027. * Gets or sets a boolean indicating that ramp gradients must be used
  56028. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  56029. */
  56030. useRampGradients: boolean;
  56031. /**
  56032. * Not supported by GPUParticleSystem
  56033. * @param gradient defines the gradient to use (between 0 and 1)
  56034. * @param factor defines the life time factor to affect to the specified gradient
  56035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  56036. * @returns the current particle system
  56037. */
  56038. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  56039. /**
  56040. * Not supported by GPUParticleSystem
  56041. * @param gradient defines the gradient to remove
  56042. * @returns the current particle system
  56043. */
  56044. removeLifeTimeGradient(gradient: number): IParticleSystem;
  56045. /**
  56046. * Instantiates a GPU particle system.
  56047. * 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.
  56048. * @param name The name of the particle system
  56049. * @param options The options used to create the system
  56050. * @param scene The scene the particle system belongs to
  56051. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  56052. */
  56053. constructor(name: string, options: Partial<{
  56054. capacity: number;
  56055. randomTextureSize: number;
  56056. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  56057. protected _reset(): void;
  56058. private _createUpdateVAO;
  56059. private _createRenderVAO;
  56060. private _initialize;
  56061. /** @hidden */
  56062. _recreateUpdateEffect(): void;
  56063. /** @hidden */
  56064. _recreateRenderEffect(): void;
  56065. /**
  56066. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  56067. * @param preWarm defines if we are in the pre-warmimg phase
  56068. */
  56069. animate(preWarm?: boolean): void;
  56070. private _createFactorGradientTexture;
  56071. private _createSizeGradientTexture;
  56072. private _createAngularSpeedGradientTexture;
  56073. private _createVelocityGradientTexture;
  56074. private _createLimitVelocityGradientTexture;
  56075. private _createDragGradientTexture;
  56076. private _createColorGradientTexture;
  56077. /**
  56078. * Renders the particle system in its current state
  56079. * @param preWarm defines if the system should only update the particles but not render them
  56080. * @returns the current number of particles
  56081. */
  56082. render(preWarm?: boolean): number;
  56083. /**
  56084. * Rebuilds the particle system
  56085. */
  56086. rebuild(): void;
  56087. private _releaseBuffers;
  56088. private _releaseVAOs;
  56089. /**
  56090. * Disposes the particle system and free the associated resources
  56091. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  56092. */
  56093. dispose(disposeTexture?: boolean): void;
  56094. /**
  56095. * Clones the particle system.
  56096. * @param name The name of the cloned object
  56097. * @param newEmitter The new emitter to use
  56098. * @returns the cloned particle system
  56099. */
  56100. clone(name: string, newEmitter: any): GPUParticleSystem;
  56101. /**
  56102. * Serializes the particle system to a JSON object.
  56103. * @returns the JSON object
  56104. */
  56105. serialize(): any;
  56106. /**
  56107. * Parses a JSON object to create a GPU particle system.
  56108. * @param parsedParticleSystem The JSON object to parse
  56109. * @param scene The scene to create the particle system in
  56110. * @param rootUrl The root url to use to load external dependencies like texture
  56111. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  56112. * @returns the parsed GPU particle system
  56113. */
  56114. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  56115. }
  56116. }
  56117. declare module "babylonjs/Particles/particleSystemSet" {
  56118. import { Nullable } from "babylonjs/types";
  56119. import { Color3 } from "babylonjs/Maths/math";
  56120. import { TransformNode } from "babylonjs/Meshes/transformNode";
  56121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56122. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56123. import { Scene, IDisposable } from "babylonjs/scene";
  56124. /**
  56125. * Represents a set of particle systems working together to create a specific effect
  56126. */
  56127. export class ParticleSystemSet implements IDisposable {
  56128. private _emitterCreationOptions;
  56129. private _emitterNode;
  56130. /**
  56131. * Gets the particle system list
  56132. */
  56133. systems: IParticleSystem[];
  56134. /**
  56135. * Gets the emitter node used with this set
  56136. */
  56137. readonly emitterNode: Nullable<TransformNode>;
  56138. /**
  56139. * Creates a new emitter mesh as a sphere
  56140. * @param options defines the options used to create the sphere
  56141. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  56142. * @param scene defines the hosting scene
  56143. */
  56144. setEmitterAsSphere(options: {
  56145. diameter: number;
  56146. segments: number;
  56147. color: Color3;
  56148. }, renderingGroupId: number, scene: Scene): void;
  56149. /**
  56150. * Starts all particle systems of the set
  56151. * @param emitter defines an optional mesh to use as emitter for the particle systems
  56152. */
  56153. start(emitter?: AbstractMesh): void;
  56154. /**
  56155. * Release all associated resources
  56156. */
  56157. dispose(): void;
  56158. /**
  56159. * Serialize the set into a JSON compatible object
  56160. * @returns a JSON compatible representation of the set
  56161. */
  56162. serialize(): any;
  56163. /**
  56164. * Parse a new ParticleSystemSet from a serialized source
  56165. * @param data defines a JSON compatible representation of the set
  56166. * @param scene defines the hosting scene
  56167. * @param gpu defines if we want GPU particles or CPU particles
  56168. * @returns a new ParticleSystemSet
  56169. */
  56170. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  56171. }
  56172. }
  56173. declare module "babylonjs/Particles/particleHelper" {
  56174. import { Nullable } from "babylonjs/types";
  56175. import { Scene } from "babylonjs/scene";
  56176. import { Vector3 } from "babylonjs/Maths/math";
  56177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56178. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56179. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  56180. /**
  56181. * This class is made for on one-liner static method to help creating particle system set.
  56182. */
  56183. export class ParticleHelper {
  56184. /**
  56185. * Gets or sets base Assets URL
  56186. */
  56187. static BaseAssetsUrl: string;
  56188. /**
  56189. * Create a default particle system that you can tweak
  56190. * @param emitter defines the emitter to use
  56191. * @param capacity defines the system capacity (default is 500 particles)
  56192. * @param scene defines the hosting scene
  56193. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  56194. * @returns the new Particle system
  56195. */
  56196. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  56197. /**
  56198. * This is the main static method (one-liner) of this helper to create different particle systems
  56199. * @param type This string represents the type to the particle system to create
  56200. * @param scene The scene where the particle system should live
  56201. * @param gpu If the system will use gpu
  56202. * @returns the ParticleSystemSet created
  56203. */
  56204. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  56205. /**
  56206. * Static function used to export a particle system to a ParticleSystemSet variable.
  56207. * Please note that the emitter shape is not exported
  56208. * @param systems defines the particle systems to export
  56209. * @returns the created particle system set
  56210. */
  56211. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  56212. }
  56213. }
  56214. declare module "babylonjs/Particles/particleSystemComponent" {
  56215. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  56216. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  56217. import "babylonjs/Shaders/particles.vertex";
  56218. module "babylonjs/Engines/engine" {
  56219. interface Engine {
  56220. /**
  56221. * Create an effect to use with particle systems.
  56222. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  56223. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  56224. * @param uniformsNames defines a list of attribute names
  56225. * @param samplers defines an array of string used to represent textures
  56226. * @param defines defines the string containing the defines to use to compile the shaders
  56227. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  56228. * @param onCompiled defines a function to call when the effect creation is successful
  56229. * @param onError defines a function to call when the effect creation has failed
  56230. * @returns the new Effect
  56231. */
  56232. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  56233. }
  56234. }
  56235. module "babylonjs/Meshes/mesh" {
  56236. interface Mesh {
  56237. /**
  56238. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  56239. * @returns an array of IParticleSystem
  56240. */
  56241. getEmittedParticleSystems(): IParticleSystem[];
  56242. /**
  56243. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  56244. * @returns an array of IParticleSystem
  56245. */
  56246. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  56247. }
  56248. }
  56249. /**
  56250. * @hidden
  56251. */
  56252. export var _IDoNeedToBeInTheBuild: number;
  56253. }
  56254. declare module "babylonjs/Particles/index" {
  56255. export * from "babylonjs/Particles/baseParticleSystem";
  56256. export * from "babylonjs/Particles/EmitterTypes/index";
  56257. export * from "babylonjs/Particles/gpuParticleSystem";
  56258. export * from "babylonjs/Particles/IParticleSystem";
  56259. export * from "babylonjs/Particles/particle";
  56260. export * from "babylonjs/Particles/particleHelper";
  56261. export * from "babylonjs/Particles/particleSystem";
  56262. export * from "babylonjs/Particles/particleSystemComponent";
  56263. export * from "babylonjs/Particles/particleSystemSet";
  56264. export * from "babylonjs/Particles/solidParticle";
  56265. export * from "babylonjs/Particles/solidParticleSystem";
  56266. export * from "babylonjs/Particles/subEmitter";
  56267. }
  56268. declare module "babylonjs/Physics/physicsEngineComponent" {
  56269. import { Nullable } from "babylonjs/types";
  56270. import { Observable, Observer } from "babylonjs/Misc/observable";
  56271. import { Vector3 } from "babylonjs/Maths/math";
  56272. import { Mesh } from "babylonjs/Meshes/mesh";
  56273. import { ISceneComponent } from "babylonjs/sceneComponent";
  56274. import { Scene } from "babylonjs/scene";
  56275. import { Node } from "babylonjs/node";
  56276. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  56277. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56278. module "babylonjs/scene" {
  56279. interface Scene {
  56280. /** @hidden (Backing field) */
  56281. _physicsEngine: Nullable<IPhysicsEngine>;
  56282. /**
  56283. * Gets the current physics engine
  56284. * @returns a IPhysicsEngine or null if none attached
  56285. */
  56286. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  56287. /**
  56288. * Enables physics to the current scene
  56289. * @param gravity defines the scene's gravity for the physics engine
  56290. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  56291. * @return a boolean indicating if the physics engine was initialized
  56292. */
  56293. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  56294. /**
  56295. * Disables and disposes the physics engine associated with the scene
  56296. */
  56297. disablePhysicsEngine(): void;
  56298. /**
  56299. * Gets a boolean indicating if there is an active physics engine
  56300. * @returns a boolean indicating if there is an active physics engine
  56301. */
  56302. isPhysicsEnabled(): boolean;
  56303. /**
  56304. * Deletes a physics compound impostor
  56305. * @param compound defines the compound to delete
  56306. */
  56307. deleteCompoundImpostor(compound: any): void;
  56308. /**
  56309. * An event triggered when physic simulation is about to be run
  56310. */
  56311. onBeforePhysicsObservable: Observable<Scene>;
  56312. /**
  56313. * An event triggered when physic simulation has been done
  56314. */
  56315. onAfterPhysicsObservable: Observable<Scene>;
  56316. }
  56317. }
  56318. module "babylonjs/Meshes/abstractMesh" {
  56319. interface AbstractMesh {
  56320. /** @hidden */
  56321. _physicsImpostor: Nullable<PhysicsImpostor>;
  56322. /**
  56323. * Gets or sets impostor used for physic simulation
  56324. * @see http://doc.babylonjs.com/features/physics_engine
  56325. */
  56326. physicsImpostor: Nullable<PhysicsImpostor>;
  56327. /**
  56328. * Gets the current physics impostor
  56329. * @see http://doc.babylonjs.com/features/physics_engine
  56330. * @returns a physics impostor or null
  56331. */
  56332. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  56333. /** Apply a physic impulse to the mesh
  56334. * @param force defines the force to apply
  56335. * @param contactPoint defines where to apply the force
  56336. * @returns the current mesh
  56337. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  56338. */
  56339. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  56340. /**
  56341. * Creates a physic joint between two meshes
  56342. * @param otherMesh defines the other mesh to use
  56343. * @param pivot1 defines the pivot to use on this mesh
  56344. * @param pivot2 defines the pivot to use on the other mesh
  56345. * @param options defines additional options (can be plugin dependent)
  56346. * @returns the current mesh
  56347. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  56348. */
  56349. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  56350. /** @hidden */
  56351. _disposePhysicsObserver: Nullable<Observer<Node>>;
  56352. }
  56353. }
  56354. /**
  56355. * Defines the physics engine scene component responsible to manage a physics engine
  56356. */
  56357. export class PhysicsEngineSceneComponent implements ISceneComponent {
  56358. /**
  56359. * The component name helpful to identify the component in the list of scene components.
  56360. */
  56361. readonly name: string;
  56362. /**
  56363. * The scene the component belongs to.
  56364. */
  56365. scene: Scene;
  56366. /**
  56367. * Creates a new instance of the component for the given scene
  56368. * @param scene Defines the scene to register the component in
  56369. */
  56370. constructor(scene: Scene);
  56371. /**
  56372. * Registers the component in a given scene
  56373. */
  56374. register(): void;
  56375. /**
  56376. * Rebuilds the elements related to this component in case of
  56377. * context lost for instance.
  56378. */
  56379. rebuild(): void;
  56380. /**
  56381. * Disposes the component and the associated ressources
  56382. */
  56383. dispose(): void;
  56384. }
  56385. }
  56386. declare module "babylonjs/Physics/physicsHelper" {
  56387. import { Nullable } from "babylonjs/types";
  56388. import { Vector3 } from "babylonjs/Maths/math";
  56389. import { Mesh } from "babylonjs/Meshes/mesh";
  56390. import { Scene } from "babylonjs/scene";
  56391. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  56392. /**
  56393. * A helper for physics simulations
  56394. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56395. */
  56396. export class PhysicsHelper {
  56397. private _scene;
  56398. private _physicsEngine;
  56399. /**
  56400. * Initializes the Physics helper
  56401. * @param scene Babylon.js scene
  56402. */
  56403. constructor(scene: Scene);
  56404. /**
  56405. * Applies a radial explosion impulse
  56406. * @param origin the origin of the explosion
  56407. * @param radiusOrEventOptions the radius or the options of radial explosion
  56408. * @param strength the explosion strength
  56409. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56410. * @returns A physics radial explosion event, or null
  56411. */
  56412. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56413. /**
  56414. * Applies a radial explosion force
  56415. * @param origin the origin of the explosion
  56416. * @param radiusOrEventOptions the radius or the options of radial explosion
  56417. * @param strength the explosion strength
  56418. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56419. * @returns A physics radial explosion event, or null
  56420. */
  56421. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  56422. /**
  56423. * Creates a gravitational field
  56424. * @param origin the origin of the explosion
  56425. * @param radiusOrEventOptions the radius or the options of radial explosion
  56426. * @param strength the explosion strength
  56427. * @param falloff possible options: Constant & Linear. Defaults to Constant
  56428. * @returns A physics gravitational field event, or null
  56429. */
  56430. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  56431. /**
  56432. * Creates a physics updraft event
  56433. * @param origin the origin of the updraft
  56434. * @param radiusOrEventOptions the radius or the options of the updraft
  56435. * @param strength the strength of the updraft
  56436. * @param height the height of the updraft
  56437. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  56438. * @returns A physics updraft event, or null
  56439. */
  56440. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  56441. /**
  56442. * Creates a physics vortex event
  56443. * @param origin the of the vortex
  56444. * @param radiusOrEventOptions the radius or the options of the vortex
  56445. * @param strength the strength of the vortex
  56446. * @param height the height of the vortex
  56447. * @returns a Physics vortex event, or null
  56448. * A physics vortex event or null
  56449. */
  56450. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  56451. }
  56452. /**
  56453. * Represents a physics radial explosion event
  56454. */
  56455. class PhysicsRadialExplosionEvent {
  56456. private _scene;
  56457. private _options;
  56458. private _sphere;
  56459. private _dataFetched;
  56460. /**
  56461. * Initializes a radial explosioin event
  56462. * @param _scene BabylonJS scene
  56463. * @param _options The options for the vortex event
  56464. */
  56465. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  56466. /**
  56467. * Returns the data related to the radial explosion event (sphere).
  56468. * @returns The radial explosion event data
  56469. */
  56470. getData(): PhysicsRadialExplosionEventData;
  56471. /**
  56472. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  56473. * @param impostor A physics imposter
  56474. * @param origin the origin of the explosion
  56475. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  56476. */
  56477. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  56478. /**
  56479. * Triggers affecterd impostors callbacks
  56480. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  56481. */
  56482. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  56483. /**
  56484. * Disposes the sphere.
  56485. * @param force Specifies if the sphere should be disposed by force
  56486. */
  56487. dispose(force?: boolean): void;
  56488. /*** Helpers ***/
  56489. private _prepareSphere;
  56490. private _intersectsWithSphere;
  56491. }
  56492. /**
  56493. * Represents a gravitational field event
  56494. */
  56495. class PhysicsGravitationalFieldEvent {
  56496. private _physicsHelper;
  56497. private _scene;
  56498. private _origin;
  56499. private _options;
  56500. private _tickCallback;
  56501. private _sphere;
  56502. private _dataFetched;
  56503. /**
  56504. * Initializes the physics gravitational field event
  56505. * @param _physicsHelper A physics helper
  56506. * @param _scene BabylonJS scene
  56507. * @param _origin The origin position of the gravitational field event
  56508. * @param _options The options for the vortex event
  56509. */
  56510. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  56511. /**
  56512. * Returns the data related to the gravitational field event (sphere).
  56513. * @returns A gravitational field event
  56514. */
  56515. getData(): PhysicsGravitationalFieldEventData;
  56516. /**
  56517. * Enables the gravitational field.
  56518. */
  56519. enable(): void;
  56520. /**
  56521. * Disables the gravitational field.
  56522. */
  56523. disable(): void;
  56524. /**
  56525. * Disposes the sphere.
  56526. * @param force The force to dispose from the gravitational field event
  56527. */
  56528. dispose(force?: boolean): void;
  56529. private _tick;
  56530. }
  56531. /**
  56532. * Represents a physics updraft event
  56533. */
  56534. class PhysicsUpdraftEvent {
  56535. private _scene;
  56536. private _origin;
  56537. private _options;
  56538. private _physicsEngine;
  56539. private _originTop;
  56540. private _originDirection;
  56541. private _tickCallback;
  56542. private _cylinder;
  56543. private _cylinderPosition;
  56544. private _dataFetched;
  56545. /**
  56546. * Initializes the physics updraft event
  56547. * @param _scene BabylonJS scene
  56548. * @param _origin The origin position of the updraft
  56549. * @param _options The options for the updraft event
  56550. */
  56551. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  56552. /**
  56553. * Returns the data related to the updraft event (cylinder).
  56554. * @returns A physics updraft event
  56555. */
  56556. getData(): PhysicsUpdraftEventData;
  56557. /**
  56558. * Enables the updraft.
  56559. */
  56560. enable(): void;
  56561. /**
  56562. * Disables the updraft.
  56563. */
  56564. disable(): void;
  56565. /**
  56566. * Disposes the cylinder.
  56567. * @param force Specifies if the updraft should be disposed by force
  56568. */
  56569. dispose(force?: boolean): void;
  56570. private getImpostorHitData;
  56571. private _tick;
  56572. /*** Helpers ***/
  56573. private _prepareCylinder;
  56574. private _intersectsWithCylinder;
  56575. }
  56576. /**
  56577. * Represents a physics vortex event
  56578. */
  56579. class PhysicsVortexEvent {
  56580. private _scene;
  56581. private _origin;
  56582. private _options;
  56583. private _physicsEngine;
  56584. private _originTop;
  56585. private _tickCallback;
  56586. private _cylinder;
  56587. private _cylinderPosition;
  56588. private _dataFetched;
  56589. /**
  56590. * Initializes the physics vortex event
  56591. * @param _scene The BabylonJS scene
  56592. * @param _origin The origin position of the vortex
  56593. * @param _options The options for the vortex event
  56594. */
  56595. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  56596. /**
  56597. * Returns the data related to the vortex event (cylinder).
  56598. * @returns The physics vortex event data
  56599. */
  56600. getData(): PhysicsVortexEventData;
  56601. /**
  56602. * Enables the vortex.
  56603. */
  56604. enable(): void;
  56605. /**
  56606. * Disables the cortex.
  56607. */
  56608. disable(): void;
  56609. /**
  56610. * Disposes the sphere.
  56611. * @param force
  56612. */
  56613. dispose(force?: boolean): void;
  56614. private getImpostorHitData;
  56615. private _tick;
  56616. /*** Helpers ***/
  56617. private _prepareCylinder;
  56618. private _intersectsWithCylinder;
  56619. }
  56620. /**
  56621. * Options fot the radial explosion event
  56622. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56623. */
  56624. export class PhysicsRadialExplosionEventOptions {
  56625. /**
  56626. * The radius of the sphere for the radial explosion.
  56627. */
  56628. radius: number;
  56629. /**
  56630. * The strenth of the explosion.
  56631. */
  56632. strength: number;
  56633. /**
  56634. * The strenght of the force in correspondence to the distance of the affected object
  56635. */
  56636. falloff: PhysicsRadialImpulseFalloff;
  56637. /**
  56638. * Sphere options for the radial explosion.
  56639. */
  56640. sphere: {
  56641. segments: number;
  56642. diameter: number;
  56643. };
  56644. /**
  56645. * Sphere options for the radial explosion.
  56646. */
  56647. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  56648. }
  56649. /**
  56650. * Options fot the updraft event
  56651. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56652. */
  56653. export class PhysicsUpdraftEventOptions {
  56654. /**
  56655. * The radius of the cylinder for the vortex
  56656. */
  56657. radius: number;
  56658. /**
  56659. * The strenth of the updraft.
  56660. */
  56661. strength: number;
  56662. /**
  56663. * The height of the cylinder for the updraft.
  56664. */
  56665. height: number;
  56666. /**
  56667. * The mode for the the updraft.
  56668. */
  56669. updraftMode: PhysicsUpdraftMode;
  56670. }
  56671. /**
  56672. * Options fot the vortex event
  56673. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56674. */
  56675. export class PhysicsVortexEventOptions {
  56676. /**
  56677. * The radius of the cylinder for the vortex
  56678. */
  56679. radius: number;
  56680. /**
  56681. * The strenth of the vortex.
  56682. */
  56683. strength: number;
  56684. /**
  56685. * The height of the cylinder for the vortex.
  56686. */
  56687. height: number;
  56688. /**
  56689. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  56690. */
  56691. centripetalForceThreshold: number;
  56692. /**
  56693. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  56694. */
  56695. centripetalForceMultiplier: number;
  56696. /**
  56697. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  56698. */
  56699. centrifugalForceMultiplier: number;
  56700. /**
  56701. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  56702. */
  56703. updraftForceMultiplier: number;
  56704. }
  56705. /**
  56706. * The strenght of the force in correspondence to the distance of the affected object
  56707. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56708. */
  56709. export enum PhysicsRadialImpulseFalloff {
  56710. /** Defines that impulse is constant in strength across it's whole radius */
  56711. Constant = 0,
  56712. /** Defines that impulse gets weaker if it's further from the origin */
  56713. Linear = 1
  56714. }
  56715. /**
  56716. * The strength of the force in correspondence to the distance of the affected object
  56717. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56718. */
  56719. export enum PhysicsUpdraftMode {
  56720. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  56721. Center = 0,
  56722. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  56723. Perpendicular = 1
  56724. }
  56725. /**
  56726. * Interface for a physics hit data
  56727. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56728. */
  56729. export interface PhysicsHitData {
  56730. /**
  56731. * The force applied at the contact point
  56732. */
  56733. force: Vector3;
  56734. /**
  56735. * The contact point
  56736. */
  56737. contactPoint: Vector3;
  56738. /**
  56739. * The distance from the origin to the contact point
  56740. */
  56741. distanceFromOrigin: number;
  56742. }
  56743. /**
  56744. * Interface for radial explosion event data
  56745. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56746. */
  56747. export interface PhysicsRadialExplosionEventData {
  56748. /**
  56749. * A sphere used for the radial explosion event
  56750. */
  56751. sphere: Mesh;
  56752. }
  56753. /**
  56754. * Interface for gravitational field event data
  56755. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56756. */
  56757. export interface PhysicsGravitationalFieldEventData {
  56758. /**
  56759. * A sphere mesh used for the gravitational field event
  56760. */
  56761. sphere: Mesh;
  56762. }
  56763. /**
  56764. * Interface for updraft event data
  56765. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56766. */
  56767. export interface PhysicsUpdraftEventData {
  56768. /**
  56769. * A cylinder used for the updraft event
  56770. */
  56771. cylinder: Mesh;
  56772. }
  56773. /**
  56774. * Interface for vortex event data
  56775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56776. */
  56777. export interface PhysicsVortexEventData {
  56778. /**
  56779. * A cylinder used for the vortex event
  56780. */
  56781. cylinder: Mesh;
  56782. }
  56783. /**
  56784. * Interface for an affected physics impostor
  56785. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  56786. */
  56787. export interface PhysicsAffectedImpostorWithData {
  56788. /**
  56789. * The impostor affected by the effect
  56790. */
  56791. impostor: PhysicsImpostor;
  56792. /**
  56793. * The data about the hit/horce from the explosion
  56794. */
  56795. hitData: PhysicsHitData;
  56796. }
  56797. }
  56798. declare module "babylonjs/Physics/Plugins/index" {
  56799. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  56800. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  56801. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  56802. }
  56803. declare module "babylonjs/Physics/index" {
  56804. export * from "babylonjs/Physics/IPhysicsEngine";
  56805. export * from "babylonjs/Physics/physicsEngine";
  56806. export * from "babylonjs/Physics/physicsEngineComponent";
  56807. export * from "babylonjs/Physics/physicsHelper";
  56808. export * from "babylonjs/Physics/physicsImpostor";
  56809. export * from "babylonjs/Physics/physicsJoint";
  56810. export * from "babylonjs/Physics/Plugins/index";
  56811. }
  56812. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  56813. /** @hidden */
  56814. export var blackAndWhitePixelShader: {
  56815. name: string;
  56816. shader: string;
  56817. };
  56818. }
  56819. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  56820. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  56821. import { Camera } from "babylonjs/Cameras/camera";
  56822. import { Engine } from "babylonjs/Engines/engine";
  56823. import "babylonjs/Shaders/blackAndWhite.fragment";
  56824. /**
  56825. * Post process used to render in black and white
  56826. */
  56827. export class BlackAndWhitePostProcess extends PostProcess {
  56828. /**
  56829. * Linear about to convert he result to black and white (default: 1)
  56830. */
  56831. degree: number;
  56832. /**
  56833. * Creates a black and white post process
  56834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  56835. * @param name The name of the effect.
  56836. * @param options The required width/height ratio to downsize to before computing the render pass.
  56837. * @param camera The camera to apply the render pass to.
  56838. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56839. * @param engine The engine which the post process will be applied. (default: current engine)
  56840. * @param reusable If the post process can be reused on the same frame. (default: false)
  56841. */
  56842. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56843. }
  56844. }
  56845. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  56846. import { Nullable } from "babylonjs/types";
  56847. import { Camera } from "babylonjs/Cameras/camera";
  56848. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56849. import { Engine } from "babylonjs/Engines/engine";
  56850. /**
  56851. * This represents a set of one or more post processes in Babylon.
  56852. * A post process can be used to apply a shader to a texture after it is rendered.
  56853. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  56854. */
  56855. export class PostProcessRenderEffect {
  56856. private _postProcesses;
  56857. private _getPostProcesses;
  56858. private _singleInstance;
  56859. private _cameras;
  56860. private _indicesForCamera;
  56861. /**
  56862. * Name of the effect
  56863. * @hidden
  56864. */
  56865. _name: string;
  56866. /**
  56867. * Instantiates a post process render effect.
  56868. * A post process can be used to apply a shader to a texture after it is rendered.
  56869. * @param engine The engine the effect is tied to
  56870. * @param name The name of the effect
  56871. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  56872. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  56873. */
  56874. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  56875. /**
  56876. * Checks if all the post processes in the effect are supported.
  56877. */
  56878. readonly isSupported: boolean;
  56879. /**
  56880. * Updates the current state of the effect
  56881. * @hidden
  56882. */
  56883. _update(): void;
  56884. /**
  56885. * Attaches the effect on cameras
  56886. * @param cameras The camera to attach to.
  56887. * @hidden
  56888. */
  56889. _attachCameras(cameras: Camera): void;
  56890. /**
  56891. * Attaches the effect on cameras
  56892. * @param cameras The camera to attach to.
  56893. * @hidden
  56894. */
  56895. _attachCameras(cameras: Camera[]): void;
  56896. /**
  56897. * Detaches the effect on cameras
  56898. * @param cameras The camera to detatch from.
  56899. * @hidden
  56900. */
  56901. _detachCameras(cameras: Camera): void;
  56902. /**
  56903. * Detatches the effect on cameras
  56904. * @param cameras The camera to detatch from.
  56905. * @hidden
  56906. */
  56907. _detachCameras(cameras: Camera[]): void;
  56908. /**
  56909. * Enables the effect on given cameras
  56910. * @param cameras The camera to enable.
  56911. * @hidden
  56912. */
  56913. _enable(cameras: Camera): void;
  56914. /**
  56915. * Enables the effect on given cameras
  56916. * @param cameras The camera to enable.
  56917. * @hidden
  56918. */
  56919. _enable(cameras: Nullable<Camera[]>): void;
  56920. /**
  56921. * Disables the effect on the given cameras
  56922. * @param cameras The camera to disable.
  56923. * @hidden
  56924. */
  56925. _disable(cameras: Camera): void;
  56926. /**
  56927. * Disables the effect on the given cameras
  56928. * @param cameras The camera to disable.
  56929. * @hidden
  56930. */
  56931. _disable(cameras: Nullable<Camera[]>): void;
  56932. /**
  56933. * Gets a list of the post processes contained in the effect.
  56934. * @param camera The camera to get the post processes on.
  56935. * @returns The list of the post processes in the effect.
  56936. */
  56937. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56938. }
  56939. }
  56940. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  56941. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56942. /** @hidden */
  56943. export var extractHighlightsPixelShader: {
  56944. name: string;
  56945. shader: string;
  56946. };
  56947. }
  56948. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  56949. import { Nullable } from "babylonjs/types";
  56950. import { Camera } from "babylonjs/Cameras/camera";
  56951. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  56952. import { Engine } from "babylonjs/Engines/engine";
  56953. import "babylonjs/Shaders/extractHighlights.fragment";
  56954. /**
  56955. * 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.
  56956. */
  56957. export class ExtractHighlightsPostProcess extends PostProcess {
  56958. /**
  56959. * The luminance threshold, pixels below this value will be set to black.
  56960. */
  56961. threshold: number;
  56962. /** @hidden */
  56963. _exposure: number;
  56964. /**
  56965. * Post process which has the input texture to be used when performing highlight extraction
  56966. * @hidden
  56967. */
  56968. _inputPostProcess: Nullable<PostProcess>;
  56969. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56970. }
  56971. }
  56972. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  56973. /** @hidden */
  56974. export var bloomMergePixelShader: {
  56975. name: string;
  56976. shader: string;
  56977. };
  56978. }
  56979. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  56980. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  56981. import { Nullable } from "babylonjs/types";
  56982. import { Engine } from "babylonjs/Engines/engine";
  56983. import { Camera } from "babylonjs/Cameras/camera";
  56984. import "babylonjs/Shaders/bloomMerge.fragment";
  56985. /**
  56986. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56987. */
  56988. export class BloomMergePostProcess extends PostProcess {
  56989. /** Weight of the bloom to be added to the original input. */
  56990. weight: number;
  56991. /**
  56992. * Creates a new instance of @see BloomMergePostProcess
  56993. * @param name The name of the effect.
  56994. * @param originalFromInput Post process which's input will be used for the merge.
  56995. * @param blurred Blurred highlights post process which's output will be used.
  56996. * @param weight Weight of the bloom to be added to the original input.
  56997. * @param options The required width/height ratio to downsize to before computing the render pass.
  56998. * @param camera The camera to apply the render pass to.
  56999. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57000. * @param engine The engine which the post process will be applied. (default: current engine)
  57001. * @param reusable If the post process can be reused on the same frame. (default: false)
  57002. * @param textureType Type of textures used when performing the post process. (default: 0)
  57003. * @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)
  57004. */
  57005. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  57006. /** Weight of the bloom to be added to the original input. */
  57007. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57008. }
  57009. }
  57010. declare module "babylonjs/PostProcesses/bloomEffect" {
  57011. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57012. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57013. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  57014. import { Camera } from "babylonjs/Cameras/camera";
  57015. import { Scene } from "babylonjs/scene";
  57016. /**
  57017. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  57018. */
  57019. export class BloomEffect extends PostProcessRenderEffect {
  57020. private bloomScale;
  57021. /**
  57022. * @hidden Internal
  57023. */
  57024. _effects: Array<PostProcess>;
  57025. /**
  57026. * @hidden Internal
  57027. */
  57028. _downscale: ExtractHighlightsPostProcess;
  57029. private _blurX;
  57030. private _blurY;
  57031. private _merge;
  57032. /**
  57033. * The luminance threshold to find bright areas of the image to bloom.
  57034. */
  57035. threshold: number;
  57036. /**
  57037. * The strength of the bloom.
  57038. */
  57039. weight: number;
  57040. /**
  57041. * Specifies the size of the bloom blur kernel, relative to the final output size
  57042. */
  57043. kernel: number;
  57044. /**
  57045. * Creates a new instance of @see BloomEffect
  57046. * @param scene The scene the effect belongs to.
  57047. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  57048. * @param bloomKernel The size of the kernel to be used when applying the blur.
  57049. * @param bloomWeight The the strength of bloom.
  57050. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57051. * @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)
  57052. */
  57053. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  57054. /**
  57055. * Disposes each of the internal effects for a given camera.
  57056. * @param camera The camera to dispose the effect on.
  57057. */
  57058. disposeEffects(camera: Camera): void;
  57059. /**
  57060. * @hidden Internal
  57061. */
  57062. _updateEffects(): void;
  57063. /**
  57064. * Internal
  57065. * @returns if all the contained post processes are ready.
  57066. * @hidden
  57067. */
  57068. _isReady(): boolean;
  57069. }
  57070. }
  57071. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  57072. /** @hidden */
  57073. export var chromaticAberrationPixelShader: {
  57074. name: string;
  57075. shader: string;
  57076. };
  57077. }
  57078. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  57079. import { Vector2 } from "babylonjs/Maths/math";
  57080. import { Nullable } from "babylonjs/types";
  57081. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57082. import { Camera } from "babylonjs/Cameras/camera";
  57083. import { Engine } from "babylonjs/Engines/engine";
  57084. import "babylonjs/Shaders/chromaticAberration.fragment";
  57085. /**
  57086. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  57087. */
  57088. export class ChromaticAberrationPostProcess extends PostProcess {
  57089. /**
  57090. * The amount of seperation of rgb channels (default: 30)
  57091. */
  57092. aberrationAmount: number;
  57093. /**
  57094. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  57095. */
  57096. radialIntensity: number;
  57097. /**
  57098. * 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))
  57099. */
  57100. direction: Vector2;
  57101. /**
  57102. * 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))
  57103. */
  57104. centerPosition: Vector2;
  57105. /**
  57106. * Creates a new instance ChromaticAberrationPostProcess
  57107. * @param name The name of the effect.
  57108. * @param screenWidth The width of the screen to apply the effect on.
  57109. * @param screenHeight The height of the screen to apply the effect on.
  57110. * @param options The required width/height ratio to downsize to before computing the render pass.
  57111. * @param camera The camera to apply the render pass to.
  57112. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57113. * @param engine The engine which the post process will be applied. (default: current engine)
  57114. * @param reusable If the post process can be reused on the same frame. (default: false)
  57115. * @param textureType Type of textures used when performing the post process. (default: 0)
  57116. * @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)
  57117. */
  57118. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57119. }
  57120. }
  57121. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  57122. /** @hidden */
  57123. export var circleOfConfusionPixelShader: {
  57124. name: string;
  57125. shader: string;
  57126. };
  57127. }
  57128. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  57129. import { Nullable } from "babylonjs/types";
  57130. import { Engine } from "babylonjs/Engines/engine";
  57131. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57132. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57133. import { Camera } from "babylonjs/Cameras/camera";
  57134. import "babylonjs/Shaders/circleOfConfusion.fragment";
  57135. /**
  57136. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  57137. */
  57138. export class CircleOfConfusionPostProcess extends PostProcess {
  57139. /**
  57140. * 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.
  57141. */
  57142. lensSize: number;
  57143. /**
  57144. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57145. */
  57146. fStop: number;
  57147. /**
  57148. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57149. */
  57150. focusDistance: number;
  57151. /**
  57152. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  57153. */
  57154. focalLength: number;
  57155. private _depthTexture;
  57156. /**
  57157. * Creates a new instance CircleOfConfusionPostProcess
  57158. * @param name The name of the effect.
  57159. * @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.
  57160. * @param options The required width/height ratio to downsize to before computing the render pass.
  57161. * @param camera The camera to apply the render pass to.
  57162. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57163. * @param engine The engine which the post process will be applied. (default: current engine)
  57164. * @param reusable If the post process can be reused on the same frame. (default: false)
  57165. * @param textureType Type of textures used when performing the post process. (default: 0)
  57166. * @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)
  57167. */
  57168. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57169. /**
  57170. * 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.
  57171. */
  57172. depthTexture: RenderTargetTexture;
  57173. }
  57174. }
  57175. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  57176. /** @hidden */
  57177. export var colorCorrectionPixelShader: {
  57178. name: string;
  57179. shader: string;
  57180. };
  57181. }
  57182. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  57183. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57184. import { Engine } from "babylonjs/Engines/engine";
  57185. import { Camera } from "babylonjs/Cameras/camera";
  57186. import "babylonjs/Shaders/colorCorrection.fragment";
  57187. /**
  57188. *
  57189. * This post-process allows the modification of rendered colors by using
  57190. * a 'look-up table' (LUT). This effect is also called Color Grading.
  57191. *
  57192. * The object needs to be provided an url to a texture containing the color
  57193. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  57194. * Use an image editing software to tweak the LUT to match your needs.
  57195. *
  57196. * For an example of a color LUT, see here:
  57197. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  57198. * For explanations on color grading, see here:
  57199. * @see http://udn.epicgames.com/Three/ColorGrading.html
  57200. *
  57201. */
  57202. export class ColorCorrectionPostProcess extends PostProcess {
  57203. private _colorTableTexture;
  57204. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57205. }
  57206. }
  57207. declare module "babylonjs/Shaders/convolution.fragment" {
  57208. /** @hidden */
  57209. export var convolutionPixelShader: {
  57210. name: string;
  57211. shader: string;
  57212. };
  57213. }
  57214. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  57215. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57216. import { Nullable } from "babylonjs/types";
  57217. import { Camera } from "babylonjs/Cameras/camera";
  57218. import { Engine } from "babylonjs/Engines/engine";
  57219. import "babylonjs/Shaders/convolution.fragment";
  57220. /**
  57221. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  57222. * input texture to perform effects such as edge detection or sharpening
  57223. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  57224. */
  57225. export class ConvolutionPostProcess extends PostProcess {
  57226. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57227. kernel: number[];
  57228. /**
  57229. * Creates a new instance ConvolutionPostProcess
  57230. * @param name The name of the effect.
  57231. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  57232. * @param options The required width/height ratio to downsize to before computing the render pass.
  57233. * @param camera The camera to apply the render pass to.
  57234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57235. * @param engine The engine which the post process will be applied. (default: current engine)
  57236. * @param reusable If the post process can be reused on the same frame. (default: false)
  57237. * @param textureType Type of textures used when performing the post process. (default: 0)
  57238. */
  57239. constructor(name: string,
  57240. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  57241. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57242. /**
  57243. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57244. */
  57245. static EdgeDetect0Kernel: number[];
  57246. /**
  57247. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57248. */
  57249. static EdgeDetect1Kernel: number[];
  57250. /**
  57251. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57252. */
  57253. static EdgeDetect2Kernel: number[];
  57254. /**
  57255. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57256. */
  57257. static SharpenKernel: number[];
  57258. /**
  57259. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57260. */
  57261. static EmbossKernel: number[];
  57262. /**
  57263. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  57264. */
  57265. static GaussianKernel: number[];
  57266. }
  57267. }
  57268. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  57269. import { Nullable } from "babylonjs/types";
  57270. import { Vector2 } from "babylonjs/Maths/math";
  57271. import { Camera } from "babylonjs/Cameras/camera";
  57272. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57273. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  57274. import { Engine } from "babylonjs/Engines/engine";
  57275. import { Scene } from "babylonjs/scene";
  57276. /**
  57277. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  57278. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  57279. * based on samples that have a large difference in distance than the center pixel.
  57280. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  57281. */
  57282. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  57283. direction: Vector2;
  57284. /**
  57285. * Creates a new instance CircleOfConfusionPostProcess
  57286. * @param name The name of the effect.
  57287. * @param scene The scene the effect belongs to.
  57288. * @param direction The direction the blur should be applied.
  57289. * @param kernel The size of the kernel used to blur.
  57290. * @param options The required width/height ratio to downsize to before computing the render pass.
  57291. * @param camera The camera to apply the render pass to.
  57292. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  57293. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  57294. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57295. * @param engine The engine which the post process will be applied. (default: current engine)
  57296. * @param reusable If the post process can be reused on the same frame. (default: false)
  57297. * @param textureType Type of textures used when performing the post process. (default: 0)
  57298. * @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)
  57299. */
  57300. 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);
  57301. }
  57302. }
  57303. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  57304. /** @hidden */
  57305. export var depthOfFieldMergePixelShader: {
  57306. name: string;
  57307. shader: string;
  57308. };
  57309. }
  57310. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  57311. import { Nullable } from "babylonjs/types";
  57312. import { Camera } from "babylonjs/Cameras/camera";
  57313. import { Effect } from "babylonjs/Materials/effect";
  57314. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57315. import { Engine } from "babylonjs/Engines/engine";
  57316. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  57317. /**
  57318. * Options to be set when merging outputs from the default pipeline.
  57319. */
  57320. export class DepthOfFieldMergePostProcessOptions {
  57321. /**
  57322. * The original image to merge on top of
  57323. */
  57324. originalFromInput: PostProcess;
  57325. /**
  57326. * Parameters to perform the merge of the depth of field effect
  57327. */
  57328. depthOfField?: {
  57329. circleOfConfusion: PostProcess;
  57330. blurSteps: Array<PostProcess>;
  57331. };
  57332. /**
  57333. * Parameters to perform the merge of bloom effect
  57334. */
  57335. bloom?: {
  57336. blurred: PostProcess;
  57337. weight: number;
  57338. };
  57339. }
  57340. /**
  57341. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  57342. */
  57343. export class DepthOfFieldMergePostProcess extends PostProcess {
  57344. private blurSteps;
  57345. /**
  57346. * Creates a new instance of DepthOfFieldMergePostProcess
  57347. * @param name The name of the effect.
  57348. * @param originalFromInput Post process which's input will be used for the merge.
  57349. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  57350. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  57351. * @param options The required width/height ratio to downsize to before computing the render pass.
  57352. * @param camera The camera to apply the render pass to.
  57353. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57354. * @param engine The engine which the post process will be applied. (default: current engine)
  57355. * @param reusable If the post process can be reused on the same frame. (default: false)
  57356. * @param textureType Type of textures used when performing the post process. (default: 0)
  57357. * @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)
  57358. */
  57359. 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);
  57360. /**
  57361. * Updates the effect with the current post process compile time values and recompiles the shader.
  57362. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  57363. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  57364. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  57365. * @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
  57366. * @param onCompiled Called when the shader has been compiled.
  57367. * @param onError Called if there is an error when compiling a shader.
  57368. */
  57369. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  57370. }
  57371. }
  57372. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  57373. import { Nullable } from "babylonjs/types";
  57374. import { Camera } from "babylonjs/Cameras/camera";
  57375. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57376. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57377. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  57378. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  57379. import { Scene } from "babylonjs/scene";
  57380. /**
  57381. * Specifies the level of max blur that should be applied when using the depth of field effect
  57382. */
  57383. export enum DepthOfFieldEffectBlurLevel {
  57384. /**
  57385. * Subtle blur
  57386. */
  57387. Low = 0,
  57388. /**
  57389. * Medium blur
  57390. */
  57391. Medium = 1,
  57392. /**
  57393. * Large blur
  57394. */
  57395. High = 2
  57396. }
  57397. /**
  57398. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  57399. */
  57400. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  57401. private _circleOfConfusion;
  57402. /**
  57403. * @hidden Internal, blurs from high to low
  57404. */
  57405. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  57406. private _depthOfFieldBlurY;
  57407. private _dofMerge;
  57408. /**
  57409. * @hidden Internal post processes in depth of field effect
  57410. */
  57411. _effects: Array<PostProcess>;
  57412. /**
  57413. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  57414. */
  57415. focalLength: number;
  57416. /**
  57417. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  57418. */
  57419. fStop: number;
  57420. /**
  57421. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  57422. */
  57423. focusDistance: number;
  57424. /**
  57425. * 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.
  57426. */
  57427. lensSize: number;
  57428. /**
  57429. * Creates a new instance DepthOfFieldEffect
  57430. * @param scene The scene the effect belongs to.
  57431. * @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.
  57432. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  57433. * @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)
  57434. */
  57435. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  57436. /**
  57437. * Get the current class name of the current effet
  57438. * @returns "DepthOfFieldEffect"
  57439. */
  57440. getClassName(): string;
  57441. /**
  57442. * 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.
  57443. */
  57444. depthTexture: RenderTargetTexture;
  57445. /**
  57446. * Disposes each of the internal effects for a given camera.
  57447. * @param camera The camera to dispose the effect on.
  57448. */
  57449. disposeEffects(camera: Camera): void;
  57450. /**
  57451. * @hidden Internal
  57452. */
  57453. _updateEffects(): void;
  57454. /**
  57455. * Internal
  57456. * @returns if all the contained post processes are ready.
  57457. * @hidden
  57458. */
  57459. _isReady(): boolean;
  57460. }
  57461. }
  57462. declare module "babylonjs/Shaders/displayPass.fragment" {
  57463. /** @hidden */
  57464. export var displayPassPixelShader: {
  57465. name: string;
  57466. shader: string;
  57467. };
  57468. }
  57469. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  57470. import { Nullable } from "babylonjs/types";
  57471. import { Camera } from "babylonjs/Cameras/camera";
  57472. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57473. import { Engine } from "babylonjs/Engines/engine";
  57474. import "babylonjs/Shaders/displayPass.fragment";
  57475. /**
  57476. * DisplayPassPostProcess which produces an output the same as it's input
  57477. */
  57478. export class DisplayPassPostProcess extends PostProcess {
  57479. /**
  57480. * Creates the DisplayPassPostProcess
  57481. * @param name The name of the effect.
  57482. * @param options The required width/height ratio to downsize to before computing the render pass.
  57483. * @param camera The camera to apply the render pass to.
  57484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57485. * @param engine The engine which the post process will be applied. (default: current engine)
  57486. * @param reusable If the post process can be reused on the same frame. (default: false)
  57487. */
  57488. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57489. }
  57490. }
  57491. declare module "babylonjs/Shaders/filter.fragment" {
  57492. /** @hidden */
  57493. export var filterPixelShader: {
  57494. name: string;
  57495. shader: string;
  57496. };
  57497. }
  57498. declare module "babylonjs/PostProcesses/filterPostProcess" {
  57499. import { Nullable } from "babylonjs/types";
  57500. import { Matrix } from "babylonjs/Maths/math";
  57501. import { Camera } from "babylonjs/Cameras/camera";
  57502. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57503. import { Engine } from "babylonjs/Engines/engine";
  57504. import "babylonjs/Shaders/filter.fragment";
  57505. /**
  57506. * Applies a kernel filter to the image
  57507. */
  57508. export class FilterPostProcess extends PostProcess {
  57509. /** The matrix to be applied to the image */
  57510. kernelMatrix: Matrix;
  57511. /**
  57512. *
  57513. * @param name The name of the effect.
  57514. * @param kernelMatrix The matrix to be applied to the image
  57515. * @param options The required width/height ratio to downsize to before computing the render pass.
  57516. * @param camera The camera to apply the render pass to.
  57517. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57518. * @param engine The engine which the post process will be applied. (default: current engine)
  57519. * @param reusable If the post process can be reused on the same frame. (default: false)
  57520. */
  57521. constructor(name: string,
  57522. /** The matrix to be applied to the image */
  57523. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57524. }
  57525. }
  57526. declare module "babylonjs/Shaders/fxaa.fragment" {
  57527. /** @hidden */
  57528. export var fxaaPixelShader: {
  57529. name: string;
  57530. shader: string;
  57531. };
  57532. }
  57533. declare module "babylonjs/Shaders/fxaa.vertex" {
  57534. /** @hidden */
  57535. export var fxaaVertexShader: {
  57536. name: string;
  57537. shader: string;
  57538. };
  57539. }
  57540. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  57541. import { Nullable } from "babylonjs/types";
  57542. import { Camera } from "babylonjs/Cameras/camera";
  57543. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57544. import { Engine } from "babylonjs/Engines/engine";
  57545. import "babylonjs/Shaders/fxaa.fragment";
  57546. import "babylonjs/Shaders/fxaa.vertex";
  57547. /**
  57548. * Fxaa post process
  57549. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  57550. */
  57551. export class FxaaPostProcess extends PostProcess {
  57552. /** @hidden */
  57553. texelWidth: number;
  57554. /** @hidden */
  57555. texelHeight: number;
  57556. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57557. private _getDefines;
  57558. }
  57559. }
  57560. declare module "babylonjs/Shaders/grain.fragment" {
  57561. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57562. /** @hidden */
  57563. export var grainPixelShader: {
  57564. name: string;
  57565. shader: string;
  57566. };
  57567. }
  57568. declare module "babylonjs/PostProcesses/grainPostProcess" {
  57569. import { Nullable } from "babylonjs/types";
  57570. import { Camera } from "babylonjs/Cameras/camera";
  57571. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57572. import { Engine } from "babylonjs/Engines/engine";
  57573. import "babylonjs/Shaders/grain.fragment";
  57574. /**
  57575. * The GrainPostProcess adds noise to the image at mid luminance levels
  57576. */
  57577. export class GrainPostProcess extends PostProcess {
  57578. /**
  57579. * The intensity of the grain added (default: 30)
  57580. */
  57581. intensity: number;
  57582. /**
  57583. * If the grain should be randomized on every frame
  57584. */
  57585. animated: boolean;
  57586. /**
  57587. * Creates a new instance of @see GrainPostProcess
  57588. * @param name The name of the effect.
  57589. * @param options The required width/height ratio to downsize to before computing the render pass.
  57590. * @param camera The camera to apply the render pass to.
  57591. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57592. * @param engine The engine which the post process will be applied. (default: current engine)
  57593. * @param reusable If the post process can be reused on the same frame. (default: false)
  57594. * @param textureType Type of textures used when performing the post process. (default: 0)
  57595. * @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)
  57596. */
  57597. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57598. }
  57599. }
  57600. declare module "babylonjs/Shaders/highlights.fragment" {
  57601. /** @hidden */
  57602. export var highlightsPixelShader: {
  57603. name: string;
  57604. shader: string;
  57605. };
  57606. }
  57607. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  57608. import { Nullable } from "babylonjs/types";
  57609. import { Camera } from "babylonjs/Cameras/camera";
  57610. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57611. import { Engine } from "babylonjs/Engines/engine";
  57612. import "babylonjs/Shaders/highlights.fragment";
  57613. /**
  57614. * Extracts highlights from the image
  57615. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57616. */
  57617. export class HighlightsPostProcess extends PostProcess {
  57618. /**
  57619. * Extracts highlights from the image
  57620. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  57621. * @param name The name of the effect.
  57622. * @param options The required width/height ratio to downsize to before computing the render pass.
  57623. * @param camera The camera to apply the render pass to.
  57624. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57625. * @param engine The engine which the post process will be applied. (default: current engine)
  57626. * @param reusable If the post process can be reused on the same frame. (default: false)
  57627. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  57628. */
  57629. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  57630. }
  57631. }
  57632. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  57633. /** @hidden */
  57634. export var mrtFragmentDeclaration: {
  57635. name: string;
  57636. shader: string;
  57637. };
  57638. }
  57639. declare module "babylonjs/Shaders/geometry.fragment" {
  57640. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  57641. /** @hidden */
  57642. export var geometryPixelShader: {
  57643. name: string;
  57644. shader: string;
  57645. };
  57646. }
  57647. declare module "babylonjs/Shaders/geometry.vertex" {
  57648. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57649. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57650. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57651. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57652. /** @hidden */
  57653. export var geometryVertexShader: {
  57654. name: string;
  57655. shader: string;
  57656. };
  57657. }
  57658. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  57659. import { Matrix } from "babylonjs/Maths/math";
  57660. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57661. import { Mesh } from "babylonjs/Meshes/mesh";
  57662. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  57663. import { Effect } from "babylonjs/Materials/effect";
  57664. import { Scene } from "babylonjs/scene";
  57665. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57666. import "babylonjs/Shaders/geometry.fragment";
  57667. import "babylonjs/Shaders/geometry.vertex";
  57668. /** @hidden */
  57669. interface ISavedTransformationMatrix {
  57670. world: Matrix;
  57671. viewProjection: Matrix;
  57672. }
  57673. /**
  57674. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  57675. */
  57676. export class GeometryBufferRenderer {
  57677. /**
  57678. * Constant used to retrieve the position texture index in the G-Buffer textures array
  57679. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  57680. */
  57681. static readonly POSITION_TEXTURE_TYPE: number;
  57682. /**
  57683. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  57684. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  57685. */
  57686. static readonly VELOCITY_TEXTURE_TYPE: number;
  57687. /**
  57688. * Dictionary used to store the previous transformation matrices of each rendered mesh
  57689. * in order to compute objects velocities when enableVelocity is set to "true"
  57690. * @hidden
  57691. */
  57692. _previousTransformationMatrices: {
  57693. [index: number]: ISavedTransformationMatrix;
  57694. };
  57695. /**
  57696. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  57697. * in order to compute objects velocities when enableVelocity is set to "true"
  57698. * @hidden
  57699. */
  57700. _previousBonesTransformationMatrices: {
  57701. [index: number]: Float32Array;
  57702. };
  57703. /**
  57704. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  57705. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  57706. */
  57707. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  57708. private _scene;
  57709. private _multiRenderTarget;
  57710. private _ratio;
  57711. private _enablePosition;
  57712. private _enableVelocity;
  57713. private _positionIndex;
  57714. private _velocityIndex;
  57715. protected _effect: Effect;
  57716. protected _cachedDefines: string;
  57717. /**
  57718. * Set the render list (meshes to be rendered) used in the G buffer.
  57719. */
  57720. renderList: Mesh[];
  57721. /**
  57722. * Gets wether or not G buffer are supported by the running hardware.
  57723. * This requires draw buffer supports
  57724. */
  57725. readonly isSupported: boolean;
  57726. /**
  57727. * Returns the index of the given texture type in the G-Buffer textures array
  57728. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  57729. * @returns the index of the given texture type in the G-Buffer textures array
  57730. */
  57731. getTextureIndex(textureType: number): number;
  57732. /**
  57733. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  57734. */
  57735. /**
  57736. * Sets whether or not objects positions are enabled for the G buffer.
  57737. */
  57738. enablePosition: boolean;
  57739. /**
  57740. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  57741. */
  57742. /**
  57743. * Sets wether or not objects velocities are enabled for the G buffer.
  57744. */
  57745. enableVelocity: boolean;
  57746. /**
  57747. * Gets the scene associated with the buffer.
  57748. */
  57749. readonly scene: Scene;
  57750. /**
  57751. * Gets the ratio used by the buffer during its creation.
  57752. * How big is the buffer related to the main canvas.
  57753. */
  57754. readonly ratio: number;
  57755. /** @hidden */
  57756. static _SceneComponentInitialization: (scene: Scene) => void;
  57757. /**
  57758. * Creates a new G Buffer for the scene
  57759. * @param scene The scene the buffer belongs to
  57760. * @param ratio How big is the buffer related to the main canvas.
  57761. */
  57762. constructor(scene: Scene, ratio?: number);
  57763. /**
  57764. * Checks wether everything is ready to render a submesh to the G buffer.
  57765. * @param subMesh the submesh to check readiness for
  57766. * @param useInstances is the mesh drawn using instance or not
  57767. * @returns true if ready otherwise false
  57768. */
  57769. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57770. /**
  57771. * Gets the current underlying G Buffer.
  57772. * @returns the buffer
  57773. */
  57774. getGBuffer(): MultiRenderTarget;
  57775. /**
  57776. * Gets the number of samples used to render the buffer (anti aliasing).
  57777. */
  57778. /**
  57779. * Sets the number of samples used to render the buffer (anti aliasing).
  57780. */
  57781. samples: number;
  57782. /**
  57783. * Disposes the renderer and frees up associated resources.
  57784. */
  57785. dispose(): void;
  57786. protected _createRenderTargets(): void;
  57787. private _copyBonesTransformationMatrices;
  57788. }
  57789. }
  57790. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  57791. import { Nullable } from "babylonjs/types";
  57792. import { Scene } from "babylonjs/scene";
  57793. import { ISceneComponent } from "babylonjs/sceneComponent";
  57794. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  57795. module "babylonjs/scene" {
  57796. interface Scene {
  57797. /** @hidden (Backing field) */
  57798. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57799. /**
  57800. * Gets or Sets the current geometry buffer associated to the scene.
  57801. */
  57802. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  57803. /**
  57804. * Enables a GeometryBufferRender and associates it with the scene
  57805. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  57806. * @returns the GeometryBufferRenderer
  57807. */
  57808. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  57809. /**
  57810. * Disables the GeometryBufferRender associated with the scene
  57811. */
  57812. disableGeometryBufferRenderer(): void;
  57813. }
  57814. }
  57815. /**
  57816. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  57817. * in several rendering techniques.
  57818. */
  57819. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  57820. /**
  57821. * The component name helpful to identify the component in the list of scene components.
  57822. */
  57823. readonly name: string;
  57824. /**
  57825. * The scene the component belongs to.
  57826. */
  57827. scene: Scene;
  57828. /**
  57829. * Creates a new instance of the component for the given scene
  57830. * @param scene Defines the scene to register the component in
  57831. */
  57832. constructor(scene: Scene);
  57833. /**
  57834. * Registers the component in a given scene
  57835. */
  57836. register(): void;
  57837. /**
  57838. * Rebuilds the elements related to this component in case of
  57839. * context lost for instance.
  57840. */
  57841. rebuild(): void;
  57842. /**
  57843. * Disposes the component and the associated ressources
  57844. */
  57845. dispose(): void;
  57846. private _gatherRenderTargets;
  57847. }
  57848. }
  57849. declare module "babylonjs/Shaders/motionBlur.fragment" {
  57850. /** @hidden */
  57851. export var motionBlurPixelShader: {
  57852. name: string;
  57853. shader: string;
  57854. };
  57855. }
  57856. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  57857. import { Nullable } from "babylonjs/types";
  57858. import { Camera } from "babylonjs/Cameras/camera";
  57859. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57860. import { Scene } from "babylonjs/scene";
  57861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57862. import "babylonjs/Animations/animatable";
  57863. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57864. import "babylonjs/Shaders/motionBlur.fragment";
  57865. import { Engine } from "babylonjs/Engines/engine";
  57866. /**
  57867. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  57868. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  57869. * As an example, all you have to do is to create the post-process:
  57870. * var mb = new BABYLON.MotionBlurPostProcess(
  57871. * 'mb', // The name of the effect.
  57872. * scene, // The scene containing the objects to blur according to their velocity.
  57873. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  57874. * camera // The camera to apply the render pass to.
  57875. * );
  57876. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  57877. */
  57878. export class MotionBlurPostProcess extends PostProcess {
  57879. /**
  57880. * Defines how much the image is blurred by the movement. Default value is equal to 1
  57881. */
  57882. motionStrength: number;
  57883. /**
  57884. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  57885. */
  57886. /**
  57887. * Sets the number of iterations to be used for motion blur quality
  57888. */
  57889. motionBlurSamples: number;
  57890. private _motionBlurSamples;
  57891. private _geometryBufferRenderer;
  57892. /**
  57893. * Creates a new instance MotionBlurPostProcess
  57894. * @param name The name of the effect.
  57895. * @param scene The scene containing the objects to blur according to their velocity.
  57896. * @param options The required width/height ratio to downsize to before computing the render pass.
  57897. * @param camera The camera to apply the render pass to.
  57898. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57899. * @param engine The engine which the post process will be applied. (default: current engine)
  57900. * @param reusable If the post process can be reused on the same frame. (default: false)
  57901. * @param textureType Type of textures used when performing the post process. (default: 0)
  57902. * @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)
  57903. */
  57904. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  57905. /**
  57906. * Excludes the given skinned mesh from computing bones velocities.
  57907. * 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.
  57908. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  57909. */
  57910. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57911. /**
  57912. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  57913. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  57914. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  57915. */
  57916. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  57917. /**
  57918. * Disposes the post process.
  57919. * @param camera The camera to dispose the post process on.
  57920. */
  57921. dispose(camera?: Camera): void;
  57922. }
  57923. }
  57924. declare module "babylonjs/Shaders/refraction.fragment" {
  57925. /** @hidden */
  57926. export var refractionPixelShader: {
  57927. name: string;
  57928. shader: string;
  57929. };
  57930. }
  57931. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  57932. import { Color3 } from "babylonjs/Maths/math";
  57933. import { Camera } from "babylonjs/Cameras/camera";
  57934. import { Texture } from "babylonjs/Materials/Textures/texture";
  57935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57936. import { Engine } from "babylonjs/Engines/engine";
  57937. import "babylonjs/Shaders/refraction.fragment";
  57938. /**
  57939. * Post process which applies a refractin texture
  57940. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57941. */
  57942. export class RefractionPostProcess extends PostProcess {
  57943. /** the base color of the refraction (used to taint the rendering) */
  57944. color: Color3;
  57945. /** simulated refraction depth */
  57946. depth: number;
  57947. /** the coefficient of the base color (0 to remove base color tainting) */
  57948. colorLevel: number;
  57949. private _refTexture;
  57950. private _ownRefractionTexture;
  57951. /**
  57952. * Gets or sets the refraction texture
  57953. * Please note that you are responsible for disposing the texture if you set it manually
  57954. */
  57955. refractionTexture: Texture;
  57956. /**
  57957. * Initializes the RefractionPostProcess
  57958. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  57959. * @param name The name of the effect.
  57960. * @param refractionTextureUrl Url of the refraction texture to use
  57961. * @param color the base color of the refraction (used to taint the rendering)
  57962. * @param depth simulated refraction depth
  57963. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  57964. * @param camera The camera to apply the render pass to.
  57965. * @param options The required width/height ratio to downsize to before computing the render pass.
  57966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  57967. * @param engine The engine which the post process will be applied. (default: current engine)
  57968. * @param reusable If the post process can be reused on the same frame. (default: false)
  57969. */
  57970. constructor(name: string, refractionTextureUrl: string,
  57971. /** the base color of the refraction (used to taint the rendering) */
  57972. color: Color3,
  57973. /** simulated refraction depth */
  57974. depth: number,
  57975. /** the coefficient of the base color (0 to remove base color tainting) */
  57976. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  57977. /**
  57978. * Disposes of the post process
  57979. * @param camera Camera to dispose post process on
  57980. */
  57981. dispose(camera: Camera): void;
  57982. }
  57983. }
  57984. declare module "babylonjs/Shaders/sharpen.fragment" {
  57985. /** @hidden */
  57986. export var sharpenPixelShader: {
  57987. name: string;
  57988. shader: string;
  57989. };
  57990. }
  57991. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  57992. import { Nullable } from "babylonjs/types";
  57993. import { Camera } from "babylonjs/Cameras/camera";
  57994. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  57995. import "babylonjs/Shaders/sharpen.fragment";
  57996. import { Engine } from "babylonjs/Engines/engine";
  57997. /**
  57998. * The SharpenPostProcess applies a sharpen kernel to every pixel
  57999. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  58000. */
  58001. export class SharpenPostProcess extends PostProcess {
  58002. /**
  58003. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  58004. */
  58005. colorAmount: number;
  58006. /**
  58007. * How much sharpness should be applied (default: 0.3)
  58008. */
  58009. edgeAmount: number;
  58010. /**
  58011. * Creates a new instance ConvolutionPostProcess
  58012. * @param name The name of the effect.
  58013. * @param options The required width/height ratio to downsize to before computing the render pass.
  58014. * @param camera The camera to apply the render pass to.
  58015. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  58016. * @param engine The engine which the post process will be applied. (default: current engine)
  58017. * @param reusable If the post process can be reused on the same frame. (default: false)
  58018. * @param textureType Type of textures used when performing the post process. (default: 0)
  58019. * @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)
  58020. */
  58021. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  58022. }
  58023. }
  58024. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  58025. import { Nullable } from "babylonjs/types";
  58026. import { Camera } from "babylonjs/Cameras/camera";
  58027. import { Engine } from "babylonjs/Engines/engine";
  58028. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  58029. import { IInspectable } from "babylonjs/Misc/iInspectable";
  58030. /**
  58031. * PostProcessRenderPipeline
  58032. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58033. */
  58034. export class PostProcessRenderPipeline {
  58035. private engine;
  58036. private _renderEffects;
  58037. private _renderEffectsForIsolatedPass;
  58038. /**
  58039. * List of inspectable custom properties (used by the Inspector)
  58040. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  58041. */
  58042. inspectableCustomProperties: IInspectable[];
  58043. /**
  58044. * @hidden
  58045. */
  58046. protected _cameras: Camera[];
  58047. /** @hidden */
  58048. _name: string;
  58049. /**
  58050. * Gets pipeline name
  58051. */
  58052. readonly name: string;
  58053. /**
  58054. * Initializes a PostProcessRenderPipeline
  58055. * @param engine engine to add the pipeline to
  58056. * @param name name of the pipeline
  58057. */
  58058. constructor(engine: Engine, name: string);
  58059. /**
  58060. * Gets the class name
  58061. * @returns "PostProcessRenderPipeline"
  58062. */
  58063. getClassName(): string;
  58064. /**
  58065. * If all the render effects in the pipeline are supported
  58066. */
  58067. readonly isSupported: boolean;
  58068. /**
  58069. * Adds an effect to the pipeline
  58070. * @param renderEffect the effect to add
  58071. */
  58072. addEffect(renderEffect: PostProcessRenderEffect): void;
  58073. /** @hidden */
  58074. _rebuild(): void;
  58075. /** @hidden */
  58076. _enableEffect(renderEffectName: string, cameras: Camera): void;
  58077. /** @hidden */
  58078. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  58079. /** @hidden */
  58080. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58081. /** @hidden */
  58082. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  58083. /** @hidden */
  58084. _attachCameras(cameras: Camera, unique: boolean): void;
  58085. /** @hidden */
  58086. _attachCameras(cameras: Camera[], unique: boolean): void;
  58087. /** @hidden */
  58088. _detachCameras(cameras: Camera): void;
  58089. /** @hidden */
  58090. _detachCameras(cameras: Nullable<Camera[]>): void;
  58091. /** @hidden */
  58092. _update(): void;
  58093. /** @hidden */
  58094. _reset(): void;
  58095. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  58096. /**
  58097. * Disposes of the pipeline
  58098. */
  58099. dispose(): void;
  58100. }
  58101. }
  58102. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  58103. import { Camera } from "babylonjs/Cameras/camera";
  58104. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58105. /**
  58106. * PostProcessRenderPipelineManager class
  58107. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58108. */
  58109. export class PostProcessRenderPipelineManager {
  58110. private _renderPipelines;
  58111. /**
  58112. * Initializes a PostProcessRenderPipelineManager
  58113. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58114. */
  58115. constructor();
  58116. /**
  58117. * Gets the list of supported render pipelines
  58118. */
  58119. readonly supportedPipelines: PostProcessRenderPipeline[];
  58120. /**
  58121. * Adds a pipeline to the manager
  58122. * @param renderPipeline The pipeline to add
  58123. */
  58124. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  58125. /**
  58126. * Attaches a camera to the pipeline
  58127. * @param renderPipelineName The name of the pipeline to attach to
  58128. * @param cameras the camera to attach
  58129. * @param unique if the camera can be attached multiple times to the pipeline
  58130. */
  58131. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  58132. /**
  58133. * Detaches a camera from the pipeline
  58134. * @param renderPipelineName The name of the pipeline to detach from
  58135. * @param cameras the camera to detach
  58136. */
  58137. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  58138. /**
  58139. * Enables an effect by name on a pipeline
  58140. * @param renderPipelineName the name of the pipeline to enable the effect in
  58141. * @param renderEffectName the name of the effect to enable
  58142. * @param cameras the cameras that the effect should be enabled on
  58143. */
  58144. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58145. /**
  58146. * Disables an effect by name on a pipeline
  58147. * @param renderPipelineName the name of the pipeline to disable the effect in
  58148. * @param renderEffectName the name of the effect to disable
  58149. * @param cameras the cameras that the effect should be disabled on
  58150. */
  58151. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  58152. /**
  58153. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  58154. */
  58155. update(): void;
  58156. /** @hidden */
  58157. _rebuild(): void;
  58158. /**
  58159. * Disposes of the manager and pipelines
  58160. */
  58161. dispose(): void;
  58162. }
  58163. }
  58164. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  58165. import { ISceneComponent } from "babylonjs/sceneComponent";
  58166. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  58167. import { Scene } from "babylonjs/scene";
  58168. module "babylonjs/scene" {
  58169. interface Scene {
  58170. /** @hidden (Backing field) */
  58171. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58172. /**
  58173. * Gets the postprocess render pipeline manager
  58174. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  58175. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58176. */
  58177. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  58178. }
  58179. }
  58180. /**
  58181. * Defines the Render Pipeline scene component responsible to rendering pipelines
  58182. */
  58183. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  58184. /**
  58185. * The component name helpfull to identify the component in the list of scene components.
  58186. */
  58187. readonly name: string;
  58188. /**
  58189. * The scene the component belongs to.
  58190. */
  58191. scene: Scene;
  58192. /**
  58193. * Creates a new instance of the component for the given scene
  58194. * @param scene Defines the scene to register the component in
  58195. */
  58196. constructor(scene: Scene);
  58197. /**
  58198. * Registers the component in a given scene
  58199. */
  58200. register(): void;
  58201. /**
  58202. * Rebuilds the elements related to this component in case of
  58203. * context lost for instance.
  58204. */
  58205. rebuild(): void;
  58206. /**
  58207. * Disposes the component and the associated ressources
  58208. */
  58209. dispose(): void;
  58210. private _gatherRenderTargets;
  58211. }
  58212. }
  58213. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  58214. import { Nullable } from "babylonjs/types";
  58215. import { IAnimatable } from "babylonjs/Misc/tools";
  58216. import { Camera } from "babylonjs/Cameras/camera";
  58217. import { IDisposable } from "babylonjs/scene";
  58218. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  58219. import { Scene } from "babylonjs/scene";
  58220. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  58221. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  58222. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  58223. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  58224. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58225. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58226. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  58227. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  58228. import { Animation } from "babylonjs/Animations/animation";
  58229. /**
  58230. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  58231. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  58232. */
  58233. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58234. private _scene;
  58235. private _camerasToBeAttached;
  58236. /**
  58237. * ID of the sharpen post process,
  58238. */
  58239. private readonly SharpenPostProcessId;
  58240. /**
  58241. * @ignore
  58242. * ID of the image processing post process;
  58243. */
  58244. readonly ImageProcessingPostProcessId: string;
  58245. /**
  58246. * @ignore
  58247. * ID of the Fast Approximate Anti-Aliasing post process;
  58248. */
  58249. readonly FxaaPostProcessId: string;
  58250. /**
  58251. * ID of the chromatic aberration post process,
  58252. */
  58253. private readonly ChromaticAberrationPostProcessId;
  58254. /**
  58255. * ID of the grain post process
  58256. */
  58257. private readonly GrainPostProcessId;
  58258. /**
  58259. * Sharpen post process which will apply a sharpen convolution to enhance edges
  58260. */
  58261. sharpen: SharpenPostProcess;
  58262. private _sharpenEffect;
  58263. private bloom;
  58264. /**
  58265. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  58266. */
  58267. depthOfField: DepthOfFieldEffect;
  58268. /**
  58269. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  58270. */
  58271. fxaa: FxaaPostProcess;
  58272. /**
  58273. * Image post processing pass used to perform operations such as tone mapping or color grading.
  58274. */
  58275. imageProcessing: ImageProcessingPostProcess;
  58276. /**
  58277. * Chromatic aberration post process which will shift rgb colors in the image
  58278. */
  58279. chromaticAberration: ChromaticAberrationPostProcess;
  58280. private _chromaticAberrationEffect;
  58281. /**
  58282. * Grain post process which add noise to the image
  58283. */
  58284. grain: GrainPostProcess;
  58285. private _grainEffect;
  58286. /**
  58287. * Glow post process which adds a glow to emissive areas of the image
  58288. */
  58289. private _glowLayer;
  58290. /**
  58291. * Animations which can be used to tweak settings over a period of time
  58292. */
  58293. animations: Animation[];
  58294. private _imageProcessingConfigurationObserver;
  58295. private _sharpenEnabled;
  58296. private _bloomEnabled;
  58297. private _depthOfFieldEnabled;
  58298. private _depthOfFieldBlurLevel;
  58299. private _fxaaEnabled;
  58300. private _imageProcessingEnabled;
  58301. private _defaultPipelineTextureType;
  58302. private _bloomScale;
  58303. private _chromaticAberrationEnabled;
  58304. private _grainEnabled;
  58305. private _buildAllowed;
  58306. /**
  58307. * Gets active scene
  58308. */
  58309. readonly scene: Scene;
  58310. /**
  58311. * Enable or disable the sharpen process from the pipeline
  58312. */
  58313. sharpenEnabled: boolean;
  58314. private _resizeObserver;
  58315. private _hardwareScaleLevel;
  58316. private _bloomKernel;
  58317. /**
  58318. * Specifies the size of the bloom blur kernel, relative to the final output size
  58319. */
  58320. bloomKernel: number;
  58321. /**
  58322. * Specifies the weight of the bloom in the final rendering
  58323. */
  58324. private _bloomWeight;
  58325. /**
  58326. * Specifies the luma threshold for the area that will be blurred by the bloom
  58327. */
  58328. private _bloomThreshold;
  58329. private _hdr;
  58330. /**
  58331. * The strength of the bloom.
  58332. */
  58333. bloomWeight: number;
  58334. /**
  58335. * The strength of the bloom.
  58336. */
  58337. bloomThreshold: number;
  58338. /**
  58339. * The scale of the bloom, lower value will provide better performance.
  58340. */
  58341. bloomScale: number;
  58342. /**
  58343. * Enable or disable the bloom from the pipeline
  58344. */
  58345. bloomEnabled: boolean;
  58346. private _rebuildBloom;
  58347. /**
  58348. * If the depth of field is enabled.
  58349. */
  58350. depthOfFieldEnabled: boolean;
  58351. /**
  58352. * Blur level of the depth of field effect. (Higher blur will effect performance)
  58353. */
  58354. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  58355. /**
  58356. * If the anti aliasing is enabled.
  58357. */
  58358. fxaaEnabled: boolean;
  58359. private _samples;
  58360. /**
  58361. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58362. */
  58363. samples: number;
  58364. /**
  58365. * If image processing is enabled.
  58366. */
  58367. imageProcessingEnabled: boolean;
  58368. /**
  58369. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  58370. */
  58371. glowLayerEnabled: boolean;
  58372. /**
  58373. * Gets the glow layer (or null if not defined)
  58374. */
  58375. readonly glowLayer: Nullable<GlowLayer>;
  58376. /**
  58377. * Enable or disable the chromaticAberration process from the pipeline
  58378. */
  58379. chromaticAberrationEnabled: boolean;
  58380. /**
  58381. * Enable or disable the grain process from the pipeline
  58382. */
  58383. grainEnabled: boolean;
  58384. /**
  58385. * @constructor
  58386. * @param name - The rendering pipeline name (default: "")
  58387. * @param hdr - If high dynamic range textures should be used (default: true)
  58388. * @param scene - The scene linked to this pipeline (default: the last created scene)
  58389. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  58390. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  58391. */
  58392. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  58393. /**
  58394. * Get the class name
  58395. * @returns "DefaultRenderingPipeline"
  58396. */
  58397. getClassName(): string;
  58398. /**
  58399. * Force the compilation of the entire pipeline.
  58400. */
  58401. prepare(): void;
  58402. private _hasCleared;
  58403. private _prevPostProcess;
  58404. private _prevPrevPostProcess;
  58405. private _setAutoClearAndTextureSharing;
  58406. private _depthOfFieldSceneObserver;
  58407. private _buildPipeline;
  58408. private _disposePostProcesses;
  58409. /**
  58410. * Adds a camera to the pipeline
  58411. * @param camera the camera to be added
  58412. */
  58413. addCamera(camera: Camera): void;
  58414. /**
  58415. * Removes a camera from the pipeline
  58416. * @param camera the camera to remove
  58417. */
  58418. removeCamera(camera: Camera): void;
  58419. /**
  58420. * Dispose of the pipeline and stop all post processes
  58421. */
  58422. dispose(): void;
  58423. /**
  58424. * Serialize the rendering pipeline (Used when exporting)
  58425. * @returns the serialized object
  58426. */
  58427. serialize(): any;
  58428. /**
  58429. * Parse the serialized pipeline
  58430. * @param source Source pipeline.
  58431. * @param scene The scene to load the pipeline to.
  58432. * @param rootUrl The URL of the serialized pipeline.
  58433. * @returns An instantiated pipeline from the serialized object.
  58434. */
  58435. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  58436. }
  58437. }
  58438. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  58439. /** @hidden */
  58440. export var lensHighlightsPixelShader: {
  58441. name: string;
  58442. shader: string;
  58443. };
  58444. }
  58445. declare module "babylonjs/Shaders/depthOfField.fragment" {
  58446. /** @hidden */
  58447. export var depthOfFieldPixelShader: {
  58448. name: string;
  58449. shader: string;
  58450. };
  58451. }
  58452. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  58453. import { Camera } from "babylonjs/Cameras/camera";
  58454. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58455. import { Scene } from "babylonjs/scene";
  58456. import "babylonjs/Shaders/chromaticAberration.fragment";
  58457. import "babylonjs/Shaders/lensHighlights.fragment";
  58458. import "babylonjs/Shaders/depthOfField.fragment";
  58459. /**
  58460. * BABYLON.JS Chromatic Aberration GLSL Shader
  58461. * Author: Olivier Guyot
  58462. * Separates very slightly R, G and B colors on the edges of the screen
  58463. * Inspired by Francois Tarlier & Martins Upitis
  58464. */
  58465. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  58466. /**
  58467. * @ignore
  58468. * The chromatic aberration PostProcess id in the pipeline
  58469. */
  58470. LensChromaticAberrationEffect: string;
  58471. /**
  58472. * @ignore
  58473. * The highlights enhancing PostProcess id in the pipeline
  58474. */
  58475. HighlightsEnhancingEffect: string;
  58476. /**
  58477. * @ignore
  58478. * The depth-of-field PostProcess id in the pipeline
  58479. */
  58480. LensDepthOfFieldEffect: string;
  58481. private _scene;
  58482. private _depthTexture;
  58483. private _grainTexture;
  58484. private _chromaticAberrationPostProcess;
  58485. private _highlightsPostProcess;
  58486. private _depthOfFieldPostProcess;
  58487. private _edgeBlur;
  58488. private _grainAmount;
  58489. private _chromaticAberration;
  58490. private _distortion;
  58491. private _highlightsGain;
  58492. private _highlightsThreshold;
  58493. private _dofDistance;
  58494. private _dofAperture;
  58495. private _dofDarken;
  58496. private _dofPentagon;
  58497. private _blurNoise;
  58498. /**
  58499. * @constructor
  58500. *
  58501. * Effect parameters are as follow:
  58502. * {
  58503. * chromatic_aberration: number; // from 0 to x (1 for realism)
  58504. * edge_blur: number; // from 0 to x (1 for realism)
  58505. * distortion: number; // from 0 to x (1 for realism)
  58506. * grain_amount: number; // from 0 to 1
  58507. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  58508. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  58509. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  58510. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  58511. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  58512. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  58513. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  58514. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  58515. * }
  58516. * Note: if an effect parameter is unset, effect is disabled
  58517. *
  58518. * @param name The rendering pipeline name
  58519. * @param parameters - An object containing all parameters (see above)
  58520. * @param scene The scene linked to this pipeline
  58521. * @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)
  58522. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58523. */
  58524. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  58525. /**
  58526. * Get the class name
  58527. * @returns "LensRenderingPipeline"
  58528. */
  58529. getClassName(): string;
  58530. /**
  58531. * Gets associated scene
  58532. */
  58533. readonly scene: Scene;
  58534. /**
  58535. * Gets or sets the edge blur
  58536. */
  58537. edgeBlur: number;
  58538. /**
  58539. * Gets or sets the grain amount
  58540. */
  58541. grainAmount: number;
  58542. /**
  58543. * Gets or sets the chromatic aberration amount
  58544. */
  58545. chromaticAberration: number;
  58546. /**
  58547. * Gets or sets the depth of field aperture
  58548. */
  58549. dofAperture: number;
  58550. /**
  58551. * Gets or sets the edge distortion
  58552. */
  58553. edgeDistortion: number;
  58554. /**
  58555. * Gets or sets the depth of field distortion
  58556. */
  58557. dofDistortion: number;
  58558. /**
  58559. * Gets or sets the darken out of focus amount
  58560. */
  58561. darkenOutOfFocus: number;
  58562. /**
  58563. * Gets or sets a boolean indicating if blur noise is enabled
  58564. */
  58565. blurNoise: boolean;
  58566. /**
  58567. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  58568. */
  58569. pentagonBokeh: boolean;
  58570. /**
  58571. * Gets or sets the highlight grain amount
  58572. */
  58573. highlightsGain: number;
  58574. /**
  58575. * Gets or sets the highlight threshold
  58576. */
  58577. highlightsThreshold: number;
  58578. /**
  58579. * Sets the amount of blur at the edges
  58580. * @param amount blur amount
  58581. */
  58582. setEdgeBlur(amount: number): void;
  58583. /**
  58584. * Sets edge blur to 0
  58585. */
  58586. disableEdgeBlur(): void;
  58587. /**
  58588. * Sets the amout of grain
  58589. * @param amount Amount of grain
  58590. */
  58591. setGrainAmount(amount: number): void;
  58592. /**
  58593. * Set grain amount to 0
  58594. */
  58595. disableGrain(): void;
  58596. /**
  58597. * Sets the chromatic aberration amount
  58598. * @param amount amount of chromatic aberration
  58599. */
  58600. setChromaticAberration(amount: number): void;
  58601. /**
  58602. * Sets chromatic aberration amount to 0
  58603. */
  58604. disableChromaticAberration(): void;
  58605. /**
  58606. * Sets the EdgeDistortion amount
  58607. * @param amount amount of EdgeDistortion
  58608. */
  58609. setEdgeDistortion(amount: number): void;
  58610. /**
  58611. * Sets edge distortion to 0
  58612. */
  58613. disableEdgeDistortion(): void;
  58614. /**
  58615. * Sets the FocusDistance amount
  58616. * @param amount amount of FocusDistance
  58617. */
  58618. setFocusDistance(amount: number): void;
  58619. /**
  58620. * Disables depth of field
  58621. */
  58622. disableDepthOfField(): void;
  58623. /**
  58624. * Sets the Aperture amount
  58625. * @param amount amount of Aperture
  58626. */
  58627. setAperture(amount: number): void;
  58628. /**
  58629. * Sets the DarkenOutOfFocus amount
  58630. * @param amount amount of DarkenOutOfFocus
  58631. */
  58632. setDarkenOutOfFocus(amount: number): void;
  58633. private _pentagonBokehIsEnabled;
  58634. /**
  58635. * Creates a pentagon bokeh effect
  58636. */
  58637. enablePentagonBokeh(): void;
  58638. /**
  58639. * Disables the pentagon bokeh effect
  58640. */
  58641. disablePentagonBokeh(): void;
  58642. /**
  58643. * Enables noise blur
  58644. */
  58645. enableNoiseBlur(): void;
  58646. /**
  58647. * Disables noise blur
  58648. */
  58649. disableNoiseBlur(): void;
  58650. /**
  58651. * Sets the HighlightsGain amount
  58652. * @param amount amount of HighlightsGain
  58653. */
  58654. setHighlightsGain(amount: number): void;
  58655. /**
  58656. * Sets the HighlightsThreshold amount
  58657. * @param amount amount of HighlightsThreshold
  58658. */
  58659. setHighlightsThreshold(amount: number): void;
  58660. /**
  58661. * Disables highlights
  58662. */
  58663. disableHighlights(): void;
  58664. /**
  58665. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  58666. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  58667. */
  58668. dispose(disableDepthRender?: boolean): void;
  58669. private _createChromaticAberrationPostProcess;
  58670. private _createHighlightsPostProcess;
  58671. private _createDepthOfFieldPostProcess;
  58672. private _createGrainTexture;
  58673. }
  58674. }
  58675. declare module "babylonjs/Shaders/ssao2.fragment" {
  58676. /** @hidden */
  58677. export var ssao2PixelShader: {
  58678. name: string;
  58679. shader: string;
  58680. };
  58681. }
  58682. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  58683. /** @hidden */
  58684. export var ssaoCombinePixelShader: {
  58685. name: string;
  58686. shader: string;
  58687. };
  58688. }
  58689. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  58690. import { Camera } from "babylonjs/Cameras/camera";
  58691. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58692. import { Scene } from "babylonjs/scene";
  58693. import "babylonjs/Shaders/ssao2.fragment";
  58694. import "babylonjs/Shaders/ssaoCombine.fragment";
  58695. /**
  58696. * Render pipeline to produce ssao effect
  58697. */
  58698. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  58699. /**
  58700. * @ignore
  58701. * The PassPostProcess id in the pipeline that contains the original scene color
  58702. */
  58703. SSAOOriginalSceneColorEffect: string;
  58704. /**
  58705. * @ignore
  58706. * The SSAO PostProcess id in the pipeline
  58707. */
  58708. SSAORenderEffect: string;
  58709. /**
  58710. * @ignore
  58711. * The horizontal blur PostProcess id in the pipeline
  58712. */
  58713. SSAOBlurHRenderEffect: string;
  58714. /**
  58715. * @ignore
  58716. * The vertical blur PostProcess id in the pipeline
  58717. */
  58718. SSAOBlurVRenderEffect: string;
  58719. /**
  58720. * @ignore
  58721. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58722. */
  58723. SSAOCombineRenderEffect: string;
  58724. /**
  58725. * The output strength of the SSAO post-process. Default value is 1.0.
  58726. */
  58727. totalStrength: number;
  58728. /**
  58729. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  58730. */
  58731. maxZ: number;
  58732. /**
  58733. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  58734. */
  58735. minZAspect: number;
  58736. private _samples;
  58737. /**
  58738. * Number of samples used for the SSAO calculations. Default value is 8
  58739. */
  58740. samples: number;
  58741. private _textureSamples;
  58742. /**
  58743. * Number of samples to use for antialiasing
  58744. */
  58745. textureSamples: number;
  58746. /**
  58747. * Ratio object used for SSAO ratio and blur ratio
  58748. */
  58749. private _ratio;
  58750. /**
  58751. * Dynamically generated sphere sampler.
  58752. */
  58753. private _sampleSphere;
  58754. /**
  58755. * Blur filter offsets
  58756. */
  58757. private _samplerOffsets;
  58758. private _expensiveBlur;
  58759. /**
  58760. * If bilateral blur should be used
  58761. */
  58762. expensiveBlur: boolean;
  58763. /**
  58764. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  58765. */
  58766. radius: number;
  58767. /**
  58768. * The base color of the SSAO post-process
  58769. * The final result is "base + ssao" between [0, 1]
  58770. */
  58771. base: number;
  58772. /**
  58773. * Support test.
  58774. */
  58775. static readonly IsSupported: boolean;
  58776. private _scene;
  58777. private _depthTexture;
  58778. private _normalTexture;
  58779. private _randomTexture;
  58780. private _originalColorPostProcess;
  58781. private _ssaoPostProcess;
  58782. private _blurHPostProcess;
  58783. private _blurVPostProcess;
  58784. private _ssaoCombinePostProcess;
  58785. private _firstUpdate;
  58786. /**
  58787. * Gets active scene
  58788. */
  58789. readonly scene: Scene;
  58790. /**
  58791. * @constructor
  58792. * @param name The rendering pipeline name
  58793. * @param scene The scene linked to this pipeline
  58794. * @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 }
  58795. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58796. */
  58797. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58798. /**
  58799. * Get the class name
  58800. * @returns "SSAO2RenderingPipeline"
  58801. */
  58802. getClassName(): string;
  58803. /**
  58804. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58805. */
  58806. dispose(disableGeometryBufferRenderer?: boolean): void;
  58807. private _createBlurPostProcess;
  58808. /** @hidden */
  58809. _rebuild(): void;
  58810. private _bits;
  58811. private _radicalInverse_VdC;
  58812. private _hammersley;
  58813. private _hemisphereSample_uniform;
  58814. private _generateHemisphere;
  58815. private _createSSAOPostProcess;
  58816. private _createSSAOCombinePostProcess;
  58817. private _createRandomTexture;
  58818. /**
  58819. * Serialize the rendering pipeline (Used when exporting)
  58820. * @returns the serialized object
  58821. */
  58822. serialize(): any;
  58823. /**
  58824. * Parse the serialized pipeline
  58825. * @param source Source pipeline.
  58826. * @param scene The scene to load the pipeline to.
  58827. * @param rootUrl The URL of the serialized pipeline.
  58828. * @returns An instantiated pipeline from the serialized object.
  58829. */
  58830. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  58831. }
  58832. }
  58833. declare module "babylonjs/Shaders/ssao.fragment" {
  58834. /** @hidden */
  58835. export var ssaoPixelShader: {
  58836. name: string;
  58837. shader: string;
  58838. };
  58839. }
  58840. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  58841. import { Camera } from "babylonjs/Cameras/camera";
  58842. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58843. import { Scene } from "babylonjs/scene";
  58844. import "babylonjs/Shaders/ssao.fragment";
  58845. import "babylonjs/Shaders/ssaoCombine.fragment";
  58846. /**
  58847. * Render pipeline to produce ssao effect
  58848. */
  58849. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  58850. /**
  58851. * @ignore
  58852. * The PassPostProcess id in the pipeline that contains the original scene color
  58853. */
  58854. SSAOOriginalSceneColorEffect: string;
  58855. /**
  58856. * @ignore
  58857. * The SSAO PostProcess id in the pipeline
  58858. */
  58859. SSAORenderEffect: string;
  58860. /**
  58861. * @ignore
  58862. * The horizontal blur PostProcess id in the pipeline
  58863. */
  58864. SSAOBlurHRenderEffect: string;
  58865. /**
  58866. * @ignore
  58867. * The vertical blur PostProcess id in the pipeline
  58868. */
  58869. SSAOBlurVRenderEffect: string;
  58870. /**
  58871. * @ignore
  58872. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  58873. */
  58874. SSAOCombineRenderEffect: string;
  58875. /**
  58876. * The output strength of the SSAO post-process. Default value is 1.0.
  58877. */
  58878. totalStrength: number;
  58879. /**
  58880. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  58881. */
  58882. radius: number;
  58883. /**
  58884. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  58885. * Must not be equal to fallOff and superior to fallOff.
  58886. * Default value is 0.0075
  58887. */
  58888. area: number;
  58889. /**
  58890. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  58891. * Must not be equal to area and inferior to area.
  58892. * Default value is 0.000001
  58893. */
  58894. fallOff: number;
  58895. /**
  58896. * The base color of the SSAO post-process
  58897. * The final result is "base + ssao" between [0, 1]
  58898. */
  58899. base: number;
  58900. private _scene;
  58901. private _depthTexture;
  58902. private _randomTexture;
  58903. private _originalColorPostProcess;
  58904. private _ssaoPostProcess;
  58905. private _blurHPostProcess;
  58906. private _blurVPostProcess;
  58907. private _ssaoCombinePostProcess;
  58908. private _firstUpdate;
  58909. /**
  58910. * Gets active scene
  58911. */
  58912. readonly scene: Scene;
  58913. /**
  58914. * @constructor
  58915. * @param name - The rendering pipeline name
  58916. * @param scene - The scene linked to this pipeline
  58917. * @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 }
  58918. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  58919. */
  58920. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  58921. /**
  58922. * Get the class name
  58923. * @returns "SSAORenderingPipeline"
  58924. */
  58925. getClassName(): string;
  58926. /**
  58927. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  58928. */
  58929. dispose(disableDepthRender?: boolean): void;
  58930. private _createBlurPostProcess;
  58931. /** @hidden */
  58932. _rebuild(): void;
  58933. private _createSSAOPostProcess;
  58934. private _createSSAOCombinePostProcess;
  58935. private _createRandomTexture;
  58936. }
  58937. }
  58938. declare module "babylonjs/Shaders/standard.fragment" {
  58939. /** @hidden */
  58940. export var standardPixelShader: {
  58941. name: string;
  58942. shader: string;
  58943. };
  58944. }
  58945. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  58946. import { Nullable } from "babylonjs/types";
  58947. import { IAnimatable } from "babylonjs/Misc/tools";
  58948. import { Camera } from "babylonjs/Cameras/camera";
  58949. import { Texture } from "babylonjs/Materials/Textures/texture";
  58950. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  58951. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  58952. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  58953. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  58954. import { IDisposable } from "babylonjs/scene";
  58955. import { SpotLight } from "babylonjs/Lights/spotLight";
  58956. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  58957. import { Scene } from "babylonjs/scene";
  58958. import { Animation } from "babylonjs/Animations/animation";
  58959. import "babylonjs/Shaders/standard.fragment";
  58960. /**
  58961. * Standard rendering pipeline
  58962. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58963. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  58964. */
  58965. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  58966. /**
  58967. * Public members
  58968. */
  58969. /**
  58970. * Post-process which contains the original scene color before the pipeline applies all the effects
  58971. */
  58972. originalPostProcess: Nullable<PostProcess>;
  58973. /**
  58974. * Post-process used to down scale an image x4
  58975. */
  58976. downSampleX4PostProcess: Nullable<PostProcess>;
  58977. /**
  58978. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  58979. */
  58980. brightPassPostProcess: Nullable<PostProcess>;
  58981. /**
  58982. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  58983. */
  58984. blurHPostProcesses: PostProcess[];
  58985. /**
  58986. * Post-process array storing all the vertical blur post-processes used by the pipeline
  58987. */
  58988. blurVPostProcesses: PostProcess[];
  58989. /**
  58990. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  58991. */
  58992. textureAdderPostProcess: Nullable<PostProcess>;
  58993. /**
  58994. * Post-process used to create volumetric lighting effect
  58995. */
  58996. volumetricLightPostProcess: Nullable<PostProcess>;
  58997. /**
  58998. * Post-process used to smooth the previous volumetric light post-process on the X axis
  58999. */
  59000. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  59001. /**
  59002. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  59003. */
  59004. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  59005. /**
  59006. * Post-process used to merge the volumetric light effect and the real scene color
  59007. */
  59008. volumetricLightMergePostProces: Nullable<PostProcess>;
  59009. /**
  59010. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  59011. */
  59012. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  59013. /**
  59014. * Base post-process used to calculate the average luminance of the final image for HDR
  59015. */
  59016. luminancePostProcess: Nullable<PostProcess>;
  59017. /**
  59018. * Post-processes used to create down sample post-processes in order to get
  59019. * the average luminance of the final image for HDR
  59020. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  59021. */
  59022. luminanceDownSamplePostProcesses: PostProcess[];
  59023. /**
  59024. * Post-process used to create a HDR effect (light adaptation)
  59025. */
  59026. hdrPostProcess: Nullable<PostProcess>;
  59027. /**
  59028. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  59029. */
  59030. textureAdderFinalPostProcess: Nullable<PostProcess>;
  59031. /**
  59032. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  59033. */
  59034. lensFlareFinalPostProcess: Nullable<PostProcess>;
  59035. /**
  59036. * Post-process used to merge the final HDR post-process and the real scene color
  59037. */
  59038. hdrFinalPostProcess: Nullable<PostProcess>;
  59039. /**
  59040. * Post-process used to create a lens flare effect
  59041. */
  59042. lensFlarePostProcess: Nullable<PostProcess>;
  59043. /**
  59044. * Post-process that merges the result of the lens flare post-process and the real scene color
  59045. */
  59046. lensFlareComposePostProcess: Nullable<PostProcess>;
  59047. /**
  59048. * Post-process used to create a motion blur effect
  59049. */
  59050. motionBlurPostProcess: Nullable<PostProcess>;
  59051. /**
  59052. * Post-process used to create a depth of field effect
  59053. */
  59054. depthOfFieldPostProcess: Nullable<PostProcess>;
  59055. /**
  59056. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  59057. */
  59058. fxaaPostProcess: Nullable<FxaaPostProcess>;
  59059. /**
  59060. * Represents the brightness threshold in order to configure the illuminated surfaces
  59061. */
  59062. brightThreshold: number;
  59063. /**
  59064. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  59065. */
  59066. blurWidth: number;
  59067. /**
  59068. * Sets if the blur for highlighted surfaces must be only horizontal
  59069. */
  59070. horizontalBlur: boolean;
  59071. /**
  59072. * Gets the overall exposure used by the pipeline
  59073. */
  59074. /**
  59075. * Sets the overall exposure used by the pipeline
  59076. */
  59077. exposure: number;
  59078. /**
  59079. * Texture used typically to simulate "dirty" on camera lens
  59080. */
  59081. lensTexture: Nullable<Texture>;
  59082. /**
  59083. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  59084. */
  59085. volumetricLightCoefficient: number;
  59086. /**
  59087. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  59088. */
  59089. volumetricLightPower: number;
  59090. /**
  59091. * Used the set the blur intensity to smooth the volumetric lights
  59092. */
  59093. volumetricLightBlurScale: number;
  59094. /**
  59095. * Light (spot or directional) used to generate the volumetric lights rays
  59096. * The source light must have a shadow generate so the pipeline can get its
  59097. * depth map
  59098. */
  59099. sourceLight: Nullable<SpotLight | DirectionalLight>;
  59100. /**
  59101. * For eye adaptation, represents the minimum luminance the eye can see
  59102. */
  59103. hdrMinimumLuminance: number;
  59104. /**
  59105. * For eye adaptation, represents the decrease luminance speed
  59106. */
  59107. hdrDecreaseRate: number;
  59108. /**
  59109. * For eye adaptation, represents the increase luminance speed
  59110. */
  59111. hdrIncreaseRate: number;
  59112. /**
  59113. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59114. */
  59115. /**
  59116. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  59117. */
  59118. hdrAutoExposure: boolean;
  59119. /**
  59120. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  59121. */
  59122. lensColorTexture: Nullable<Texture>;
  59123. /**
  59124. * The overall strengh for the lens flare effect
  59125. */
  59126. lensFlareStrength: number;
  59127. /**
  59128. * Dispersion coefficient for lens flare ghosts
  59129. */
  59130. lensFlareGhostDispersal: number;
  59131. /**
  59132. * Main lens flare halo width
  59133. */
  59134. lensFlareHaloWidth: number;
  59135. /**
  59136. * Based on the lens distortion effect, defines how much the lens flare result
  59137. * is distorted
  59138. */
  59139. lensFlareDistortionStrength: number;
  59140. /**
  59141. * Lens star texture must be used to simulate rays on the flares and is available
  59142. * in the documentation
  59143. */
  59144. lensStarTexture: Nullable<Texture>;
  59145. /**
  59146. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  59147. * flare effect by taking account of the dirt texture
  59148. */
  59149. lensFlareDirtTexture: Nullable<Texture>;
  59150. /**
  59151. * Represents the focal length for the depth of field effect
  59152. */
  59153. depthOfFieldDistance: number;
  59154. /**
  59155. * Represents the blur intensity for the blurred part of the depth of field effect
  59156. */
  59157. depthOfFieldBlurWidth: number;
  59158. /**
  59159. * Gets how much the image is blurred by the movement while using the motion blur post-process
  59160. */
  59161. /**
  59162. * Sets how much the image is blurred by the movement while using the motion blur post-process
  59163. */
  59164. motionStrength: number;
  59165. /**
  59166. * Gets wether or not the motion blur post-process is object based or screen based.
  59167. */
  59168. /**
  59169. * Sets wether or not the motion blur post-process should be object based or screen based
  59170. */
  59171. objectBasedMotionBlur: boolean;
  59172. /**
  59173. * List of animations for the pipeline (IAnimatable implementation)
  59174. */
  59175. animations: Animation[];
  59176. /**
  59177. * Private members
  59178. */
  59179. private _scene;
  59180. private _currentDepthOfFieldSource;
  59181. private _basePostProcess;
  59182. private _fixedExposure;
  59183. private _currentExposure;
  59184. private _hdrAutoExposure;
  59185. private _hdrCurrentLuminance;
  59186. private _motionStrength;
  59187. private _isObjectBasedMotionBlur;
  59188. private _floatTextureType;
  59189. private _ratio;
  59190. private _bloomEnabled;
  59191. private _depthOfFieldEnabled;
  59192. private _vlsEnabled;
  59193. private _lensFlareEnabled;
  59194. private _hdrEnabled;
  59195. private _motionBlurEnabled;
  59196. private _fxaaEnabled;
  59197. private _motionBlurSamples;
  59198. private _volumetricLightStepsCount;
  59199. private _samples;
  59200. /**
  59201. * @ignore
  59202. * Specifies if the bloom pipeline is enabled
  59203. */
  59204. BloomEnabled: boolean;
  59205. /**
  59206. * @ignore
  59207. * Specifies if the depth of field pipeline is enabed
  59208. */
  59209. DepthOfFieldEnabled: boolean;
  59210. /**
  59211. * @ignore
  59212. * Specifies if the lens flare pipeline is enabed
  59213. */
  59214. LensFlareEnabled: boolean;
  59215. /**
  59216. * @ignore
  59217. * Specifies if the HDR pipeline is enabled
  59218. */
  59219. HDREnabled: boolean;
  59220. /**
  59221. * @ignore
  59222. * Specifies if the volumetric lights scattering effect is enabled
  59223. */
  59224. VLSEnabled: boolean;
  59225. /**
  59226. * @ignore
  59227. * Specifies if the motion blur effect is enabled
  59228. */
  59229. MotionBlurEnabled: boolean;
  59230. /**
  59231. * Specifies if anti-aliasing is enabled
  59232. */
  59233. fxaaEnabled: boolean;
  59234. /**
  59235. * Specifies the number of steps used to calculate the volumetric lights
  59236. * Typically in interval [50, 200]
  59237. */
  59238. volumetricLightStepsCount: number;
  59239. /**
  59240. * Specifies the number of samples used for the motion blur effect
  59241. * Typically in interval [16, 64]
  59242. */
  59243. motionBlurSamples: number;
  59244. /**
  59245. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  59246. */
  59247. samples: number;
  59248. /**
  59249. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  59250. * @constructor
  59251. * @param name The rendering pipeline name
  59252. * @param scene The scene linked to this pipeline
  59253. * @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)
  59254. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  59255. * @param cameras The array of cameras that the rendering pipeline will be attached to
  59256. */
  59257. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  59258. private _buildPipeline;
  59259. private _createDownSampleX4PostProcess;
  59260. private _createBrightPassPostProcess;
  59261. private _createBlurPostProcesses;
  59262. private _createTextureAdderPostProcess;
  59263. private _createVolumetricLightPostProcess;
  59264. private _createLuminancePostProcesses;
  59265. private _createHdrPostProcess;
  59266. private _createLensFlarePostProcess;
  59267. private _createDepthOfFieldPostProcess;
  59268. private _createMotionBlurPostProcess;
  59269. private _getDepthTexture;
  59270. private _disposePostProcesses;
  59271. /**
  59272. * Dispose of the pipeline and stop all post processes
  59273. */
  59274. dispose(): void;
  59275. /**
  59276. * Serialize the rendering pipeline (Used when exporting)
  59277. * @returns the serialized object
  59278. */
  59279. serialize(): any;
  59280. /**
  59281. * Parse the serialized pipeline
  59282. * @param source Source pipeline.
  59283. * @param scene The scene to load the pipeline to.
  59284. * @param rootUrl The URL of the serialized pipeline.
  59285. * @returns An instantiated pipeline from the serialized object.
  59286. */
  59287. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  59288. /**
  59289. * Luminance steps
  59290. */
  59291. static LuminanceSteps: number;
  59292. }
  59293. }
  59294. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  59295. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  59296. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  59297. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  59298. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  59299. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  59300. }
  59301. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  59302. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  59303. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  59304. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  59305. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  59306. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  59307. }
  59308. declare module "babylonjs/Shaders/tonemap.fragment" {
  59309. /** @hidden */
  59310. export var tonemapPixelShader: {
  59311. name: string;
  59312. shader: string;
  59313. };
  59314. }
  59315. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  59316. import { Camera } from "babylonjs/Cameras/camera";
  59317. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59318. import "babylonjs/Shaders/tonemap.fragment";
  59319. import { Engine } from "babylonjs/Engines/engine";
  59320. /** Defines operator used for tonemapping */
  59321. export enum TonemappingOperator {
  59322. /** Hable */
  59323. Hable = 0,
  59324. /** Reinhard */
  59325. Reinhard = 1,
  59326. /** HejiDawson */
  59327. HejiDawson = 2,
  59328. /** Photographic */
  59329. Photographic = 3
  59330. }
  59331. /**
  59332. * Defines a post process to apply tone mapping
  59333. */
  59334. export class TonemapPostProcess extends PostProcess {
  59335. private _operator;
  59336. /** Defines the required exposure adjustement */
  59337. exposureAdjustment: number;
  59338. /**
  59339. * Creates a new TonemapPostProcess
  59340. * @param name defines the name of the postprocess
  59341. * @param _operator defines the operator to use
  59342. * @param exposureAdjustment defines the required exposure adjustement
  59343. * @param camera defines the camera to use (can be null)
  59344. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  59345. * @param engine defines the hosting engine (can be ignore if camera is set)
  59346. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59347. */
  59348. constructor(name: string, _operator: TonemappingOperator,
  59349. /** Defines the required exposure adjustement */
  59350. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  59351. }
  59352. }
  59353. declare module "babylonjs/Shaders/depth.vertex" {
  59354. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59355. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59356. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59357. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59358. /** @hidden */
  59359. export var depthVertexShader: {
  59360. name: string;
  59361. shader: string;
  59362. };
  59363. }
  59364. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  59365. /** @hidden */
  59366. export var volumetricLightScatteringPixelShader: {
  59367. name: string;
  59368. shader: string;
  59369. };
  59370. }
  59371. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  59372. /** @hidden */
  59373. export var volumetricLightScatteringPassPixelShader: {
  59374. name: string;
  59375. shader: string;
  59376. };
  59377. }
  59378. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  59379. import { Vector3 } from "babylonjs/Maths/math";
  59380. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59381. import { Mesh } from "babylonjs/Meshes/mesh";
  59382. import { Camera } from "babylonjs/Cameras/camera";
  59383. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59384. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  59385. import { Scene } from "babylonjs/scene";
  59386. import "babylonjs/Meshes/Builders/planeBuilder";
  59387. import "babylonjs/Shaders/depth.vertex";
  59388. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  59389. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  59390. import { Engine } from "babylonjs/Engines/engine";
  59391. /**
  59392. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  59393. */
  59394. export class VolumetricLightScatteringPostProcess extends PostProcess {
  59395. private _volumetricLightScatteringPass;
  59396. private _volumetricLightScatteringRTT;
  59397. private _viewPort;
  59398. private _screenCoordinates;
  59399. private _cachedDefines;
  59400. /**
  59401. * If not undefined, the mesh position is computed from the attached node position
  59402. */
  59403. attachedNode: {
  59404. position: Vector3;
  59405. };
  59406. /**
  59407. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  59408. */
  59409. customMeshPosition: Vector3;
  59410. /**
  59411. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  59412. */
  59413. useCustomMeshPosition: boolean;
  59414. /**
  59415. * If the post-process should inverse the light scattering direction
  59416. */
  59417. invert: boolean;
  59418. /**
  59419. * The internal mesh used by the post-process
  59420. */
  59421. mesh: Mesh;
  59422. /**
  59423. * @hidden
  59424. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  59425. */
  59426. useDiffuseColor: boolean;
  59427. /**
  59428. * Array containing the excluded meshes not rendered in the internal pass
  59429. */
  59430. excludedMeshes: AbstractMesh[];
  59431. /**
  59432. * Controls the overall intensity of the post-process
  59433. */
  59434. exposure: number;
  59435. /**
  59436. * Dissipates each sample's contribution in range [0, 1]
  59437. */
  59438. decay: number;
  59439. /**
  59440. * Controls the overall intensity of each sample
  59441. */
  59442. weight: number;
  59443. /**
  59444. * Controls the density of each sample
  59445. */
  59446. density: number;
  59447. /**
  59448. * @constructor
  59449. * @param name The post-process name
  59450. * @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)
  59451. * @param camera The camera that the post-process will be attached to
  59452. * @param mesh The mesh used to create the light scattering
  59453. * @param samples The post-process quality, default 100
  59454. * @param samplingModeThe post-process filtering mode
  59455. * @param engine The babylon engine
  59456. * @param reusable If the post-process is reusable
  59457. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  59458. */
  59459. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  59460. /**
  59461. * Returns the string "VolumetricLightScatteringPostProcess"
  59462. * @returns "VolumetricLightScatteringPostProcess"
  59463. */
  59464. getClassName(): string;
  59465. private _isReady;
  59466. /**
  59467. * Sets the new light position for light scattering effect
  59468. * @param position The new custom light position
  59469. */
  59470. setCustomMeshPosition(position: Vector3): void;
  59471. /**
  59472. * Returns the light position for light scattering effect
  59473. * @return Vector3 The custom light position
  59474. */
  59475. getCustomMeshPosition(): Vector3;
  59476. /**
  59477. * Disposes the internal assets and detaches the post-process from the camera
  59478. */
  59479. dispose(camera: Camera): void;
  59480. /**
  59481. * Returns the render target texture used by the post-process
  59482. * @return the render target texture used by the post-process
  59483. */
  59484. getPass(): RenderTargetTexture;
  59485. private _meshExcluded;
  59486. private _createPass;
  59487. private _updateMeshScreenCoordinates;
  59488. /**
  59489. * Creates a default mesh for the Volumeric Light Scattering post-process
  59490. * @param name The mesh name
  59491. * @param scene The scene where to create the mesh
  59492. * @return the default mesh
  59493. */
  59494. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  59495. }
  59496. }
  59497. declare module "babylonjs/PostProcesses/index" {
  59498. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  59499. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  59500. export * from "babylonjs/PostProcesses/bloomEffect";
  59501. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  59502. export * from "babylonjs/PostProcesses/blurPostProcess";
  59503. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  59504. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  59505. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  59506. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  59507. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  59508. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  59509. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  59510. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  59511. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  59512. export * from "babylonjs/PostProcesses/filterPostProcess";
  59513. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  59514. export * from "babylonjs/PostProcesses/grainPostProcess";
  59515. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  59516. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  59517. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  59518. export * from "babylonjs/PostProcesses/passPostProcess";
  59519. export * from "babylonjs/PostProcesses/postProcess";
  59520. export * from "babylonjs/PostProcesses/postProcessManager";
  59521. export * from "babylonjs/PostProcesses/refractionPostProcess";
  59522. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  59523. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  59524. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  59525. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  59526. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  59527. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  59528. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  59529. }
  59530. declare module "babylonjs/Probes/index" {
  59531. export * from "babylonjs/Probes/reflectionProbe";
  59532. }
  59533. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  59534. import { Scene } from "babylonjs/scene";
  59535. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59536. import { Color3 } from "babylonjs/Maths/math";
  59537. import { SmartArray } from "babylonjs/Misc/smartArray";
  59538. import { ISceneComponent } from "babylonjs/sceneComponent";
  59539. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  59540. import "babylonjs/Meshes/Builders/boxBuilder";
  59541. import "babylonjs/Shaders/color.fragment";
  59542. import "babylonjs/Shaders/color.vertex";
  59543. module "babylonjs/scene" {
  59544. interface Scene {
  59545. /** @hidden (Backing field) */
  59546. _boundingBoxRenderer: BoundingBoxRenderer;
  59547. /** @hidden (Backing field) */
  59548. _forceShowBoundingBoxes: boolean;
  59549. /**
  59550. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  59551. */
  59552. forceShowBoundingBoxes: boolean;
  59553. /**
  59554. * Gets the bounding box renderer associated with the scene
  59555. * @returns a BoundingBoxRenderer
  59556. */
  59557. getBoundingBoxRenderer(): BoundingBoxRenderer;
  59558. }
  59559. }
  59560. module "babylonjs/Meshes/abstractMesh" {
  59561. interface AbstractMesh {
  59562. /** @hidden (Backing field) */
  59563. _showBoundingBox: boolean;
  59564. /**
  59565. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  59566. */
  59567. showBoundingBox: boolean;
  59568. }
  59569. }
  59570. /**
  59571. * Component responsible of rendering the bounding box of the meshes in a scene.
  59572. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  59573. */
  59574. export class BoundingBoxRenderer implements ISceneComponent {
  59575. /**
  59576. * The component name helpfull to identify the component in the list of scene components.
  59577. */
  59578. readonly name: string;
  59579. /**
  59580. * The scene the component belongs to.
  59581. */
  59582. scene: Scene;
  59583. /**
  59584. * Color of the bounding box lines placed in front of an object
  59585. */
  59586. frontColor: Color3;
  59587. /**
  59588. * Color of the bounding box lines placed behind an object
  59589. */
  59590. backColor: Color3;
  59591. /**
  59592. * Defines if the renderer should show the back lines or not
  59593. */
  59594. showBackLines: boolean;
  59595. /**
  59596. * @hidden
  59597. */
  59598. renderList: SmartArray<BoundingBox>;
  59599. private _colorShader;
  59600. private _vertexBuffers;
  59601. private _indexBuffer;
  59602. /**
  59603. * Instantiates a new bounding box renderer in a scene.
  59604. * @param scene the scene the renderer renders in
  59605. */
  59606. constructor(scene: Scene);
  59607. /**
  59608. * Registers the component in a given scene
  59609. */
  59610. register(): void;
  59611. private _evaluateSubMesh;
  59612. private _activeMesh;
  59613. private _prepareRessources;
  59614. private _createIndexBuffer;
  59615. /**
  59616. * Rebuilds the elements related to this component in case of
  59617. * context lost for instance.
  59618. */
  59619. rebuild(): void;
  59620. /**
  59621. * @hidden
  59622. */
  59623. reset(): void;
  59624. /**
  59625. * Render the bounding boxes of a specific rendering group
  59626. * @param renderingGroupId defines the rendering group to render
  59627. */
  59628. render(renderingGroupId: number): void;
  59629. /**
  59630. * In case of occlusion queries, we can render the occlusion bounding box through this method
  59631. * @param mesh Define the mesh to render the occlusion bounding box for
  59632. */
  59633. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  59634. /**
  59635. * Dispose and release the resources attached to this renderer.
  59636. */
  59637. dispose(): void;
  59638. }
  59639. }
  59640. declare module "babylonjs/Shaders/depth.fragment" {
  59641. /** @hidden */
  59642. export var depthPixelShader: {
  59643. name: string;
  59644. shader: string;
  59645. };
  59646. }
  59647. declare module "babylonjs/Rendering/depthRenderer" {
  59648. import { Nullable } from "babylonjs/types";
  59649. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59650. import { Scene } from "babylonjs/scene";
  59651. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59652. import { Camera } from "babylonjs/Cameras/camera";
  59653. import "babylonjs/Shaders/depth.fragment";
  59654. import "babylonjs/Shaders/depth.vertex";
  59655. /**
  59656. * This represents a depth renderer in Babylon.
  59657. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  59658. */
  59659. export class DepthRenderer {
  59660. private _scene;
  59661. private _depthMap;
  59662. private _effect;
  59663. private _cachedDefines;
  59664. private _camera;
  59665. /**
  59666. * Specifiess that the depth renderer will only be used within
  59667. * the camera it is created for.
  59668. * This can help forcing its rendering during the camera processing.
  59669. */
  59670. useOnlyInActiveCamera: boolean;
  59671. /** @hidden */
  59672. static _SceneComponentInitialization: (scene: Scene) => void;
  59673. /**
  59674. * Instantiates a depth renderer
  59675. * @param scene The scene the renderer belongs to
  59676. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  59677. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  59678. */
  59679. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  59680. /**
  59681. * Creates the depth rendering effect and checks if the effect is ready.
  59682. * @param subMesh The submesh to be used to render the depth map of
  59683. * @param useInstances If multiple world instances should be used
  59684. * @returns if the depth renderer is ready to render the depth map
  59685. */
  59686. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59687. /**
  59688. * Gets the texture which the depth map will be written to.
  59689. * @returns The depth map texture
  59690. */
  59691. getDepthMap(): RenderTargetTexture;
  59692. /**
  59693. * Disposes of the depth renderer.
  59694. */
  59695. dispose(): void;
  59696. }
  59697. }
  59698. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  59699. import { Nullable } from "babylonjs/types";
  59700. import { Scene } from "babylonjs/scene";
  59701. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  59702. import { Camera } from "babylonjs/Cameras/camera";
  59703. import { ISceneComponent } from "babylonjs/sceneComponent";
  59704. module "babylonjs/scene" {
  59705. interface Scene {
  59706. /** @hidden (Backing field) */
  59707. _depthRenderer: {
  59708. [id: string]: DepthRenderer;
  59709. };
  59710. /**
  59711. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  59712. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  59713. * @returns the created depth renderer
  59714. */
  59715. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  59716. /**
  59717. * Disables a depth renderer for a given camera
  59718. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  59719. */
  59720. disableDepthRenderer(camera?: Nullable<Camera>): void;
  59721. }
  59722. }
  59723. /**
  59724. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  59725. * in several rendering techniques.
  59726. */
  59727. export class DepthRendererSceneComponent implements ISceneComponent {
  59728. /**
  59729. * The component name helpfull to identify the component in the list of scene components.
  59730. */
  59731. readonly name: string;
  59732. /**
  59733. * The scene the component belongs to.
  59734. */
  59735. scene: Scene;
  59736. /**
  59737. * Creates a new instance of the component for the given scene
  59738. * @param scene Defines the scene to register the component in
  59739. */
  59740. constructor(scene: Scene);
  59741. /**
  59742. * Registers the component in a given scene
  59743. */
  59744. register(): void;
  59745. /**
  59746. * Rebuilds the elements related to this component in case of
  59747. * context lost for instance.
  59748. */
  59749. rebuild(): void;
  59750. /**
  59751. * Disposes the component and the associated ressources
  59752. */
  59753. dispose(): void;
  59754. private _gatherRenderTargets;
  59755. private _gatherActiveCameraRenderTargets;
  59756. }
  59757. }
  59758. declare module "babylonjs/Shaders/outline.fragment" {
  59759. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59760. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  59761. /** @hidden */
  59762. export var outlinePixelShader: {
  59763. name: string;
  59764. shader: string;
  59765. };
  59766. }
  59767. declare module "babylonjs/Shaders/outline.vertex" {
  59768. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59769. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59770. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59771. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59772. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59773. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59774. /** @hidden */
  59775. export var outlineVertexShader: {
  59776. name: string;
  59777. shader: string;
  59778. };
  59779. }
  59780. declare module "babylonjs/Rendering/outlineRenderer" {
  59781. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59782. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  59783. import { Scene } from "babylonjs/scene";
  59784. import { ISceneComponent } from "babylonjs/sceneComponent";
  59785. import "babylonjs/Shaders/outline.fragment";
  59786. import "babylonjs/Shaders/outline.vertex";
  59787. module "babylonjs/scene" {
  59788. interface Scene {
  59789. /** @hidden */
  59790. _outlineRenderer: OutlineRenderer;
  59791. /**
  59792. * Gets the outline renderer associated with the scene
  59793. * @returns a OutlineRenderer
  59794. */
  59795. getOutlineRenderer(): OutlineRenderer;
  59796. }
  59797. }
  59798. module "babylonjs/Meshes/abstractMesh" {
  59799. interface AbstractMesh {
  59800. /** @hidden (Backing field) */
  59801. _renderOutline: boolean;
  59802. /**
  59803. * Gets or sets a boolean indicating if the outline must be rendered as well
  59804. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  59805. */
  59806. renderOutline: boolean;
  59807. /** @hidden (Backing field) */
  59808. _renderOverlay: boolean;
  59809. /**
  59810. * Gets or sets a boolean indicating if the overlay must be rendered as well
  59811. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  59812. */
  59813. renderOverlay: boolean;
  59814. }
  59815. }
  59816. /**
  59817. * This class is responsible to draw bothe outline/overlay of meshes.
  59818. * It should not be used directly but through the available method on mesh.
  59819. */
  59820. export class OutlineRenderer implements ISceneComponent {
  59821. /**
  59822. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  59823. */
  59824. private static _StencilReference;
  59825. /**
  59826. * The name of the component. Each component must have a unique name.
  59827. */
  59828. name: string;
  59829. /**
  59830. * The scene the component belongs to.
  59831. */
  59832. scene: Scene;
  59833. /**
  59834. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  59835. */
  59836. zOffset: number;
  59837. private _engine;
  59838. private _effect;
  59839. private _cachedDefines;
  59840. private _savedDepthWrite;
  59841. /**
  59842. * Instantiates a new outline renderer. (There could be only one per scene).
  59843. * @param scene Defines the scene it belongs to
  59844. */
  59845. constructor(scene: Scene);
  59846. /**
  59847. * Register the component to one instance of a scene.
  59848. */
  59849. register(): void;
  59850. /**
  59851. * Rebuilds the elements related to this component in case of
  59852. * context lost for instance.
  59853. */
  59854. rebuild(): void;
  59855. /**
  59856. * Disposes the component and the associated ressources.
  59857. */
  59858. dispose(): void;
  59859. /**
  59860. * Renders the outline in the canvas.
  59861. * @param subMesh Defines the sumesh to render
  59862. * @param batch Defines the batch of meshes in case of instances
  59863. * @param useOverlay Defines if the rendering is for the overlay or the outline
  59864. */
  59865. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  59866. /**
  59867. * Returns whether or not the outline renderer is ready for a given submesh.
  59868. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  59869. * @param subMesh Defines the submesh to check readyness for
  59870. * @param useInstances Defines wheter wee are trying to render instances or not
  59871. * @returns true if ready otherwise false
  59872. */
  59873. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  59874. private _beforeRenderingMesh;
  59875. private _afterRenderingMesh;
  59876. }
  59877. }
  59878. declare module "babylonjs/Rendering/index" {
  59879. export * from "babylonjs/Rendering/boundingBoxRenderer";
  59880. export * from "babylonjs/Rendering/depthRenderer";
  59881. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  59882. export * from "babylonjs/Rendering/edgesRenderer";
  59883. export * from "babylonjs/Rendering/geometryBufferRenderer";
  59884. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  59885. export * from "babylonjs/Rendering/outlineRenderer";
  59886. export * from "babylonjs/Rendering/renderingGroup";
  59887. export * from "babylonjs/Rendering/renderingManager";
  59888. export * from "babylonjs/Rendering/utilityLayerRenderer";
  59889. }
  59890. declare module "babylonjs/Sprites/index" {
  59891. export * from "babylonjs/Sprites/sprite";
  59892. export * from "babylonjs/Sprites/spriteManager";
  59893. export * from "babylonjs/Sprites/spriteSceneComponent";
  59894. }
  59895. declare module "babylonjs/Misc/assetsManager" {
  59896. import { Scene } from "babylonjs/scene";
  59897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59898. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  59899. import { Skeleton } from "babylonjs/Bones/skeleton";
  59900. import { Observable } from "babylonjs/Misc/observable";
  59901. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59902. import { Texture } from "babylonjs/Materials/Textures/texture";
  59903. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59904. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  59905. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59906. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  59907. /**
  59908. * Defines the list of states available for a task inside a AssetsManager
  59909. */
  59910. export enum AssetTaskState {
  59911. /**
  59912. * Initialization
  59913. */
  59914. INIT = 0,
  59915. /**
  59916. * Running
  59917. */
  59918. RUNNING = 1,
  59919. /**
  59920. * Done
  59921. */
  59922. DONE = 2,
  59923. /**
  59924. * Error
  59925. */
  59926. ERROR = 3
  59927. }
  59928. /**
  59929. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  59930. */
  59931. export abstract class AbstractAssetTask {
  59932. /**
  59933. * Task name
  59934. */ name: string;
  59935. /**
  59936. * Callback called when the task is successful
  59937. */
  59938. onSuccess: (task: any) => void;
  59939. /**
  59940. * Callback called when the task is not successful
  59941. */
  59942. onError: (task: any, message?: string, exception?: any) => void;
  59943. /**
  59944. * Creates a new AssetsManager
  59945. * @param name defines the name of the task
  59946. */
  59947. constructor(
  59948. /**
  59949. * Task name
  59950. */ name: string);
  59951. private _isCompleted;
  59952. private _taskState;
  59953. private _errorObject;
  59954. /**
  59955. * Get if the task is completed
  59956. */
  59957. readonly isCompleted: boolean;
  59958. /**
  59959. * Gets the current state of the task
  59960. */
  59961. readonly taskState: AssetTaskState;
  59962. /**
  59963. * Gets the current error object (if task is in error)
  59964. */
  59965. readonly errorObject: {
  59966. message?: string;
  59967. exception?: any;
  59968. };
  59969. /**
  59970. * Internal only
  59971. * @hidden
  59972. */
  59973. _setErrorObject(message?: string, exception?: any): void;
  59974. /**
  59975. * Execute the current task
  59976. * @param scene defines the scene where you want your assets to be loaded
  59977. * @param onSuccess is a callback called when the task is successfully executed
  59978. * @param onError is a callback called if an error occurs
  59979. */
  59980. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59981. /**
  59982. * Execute the current task
  59983. * @param scene defines the scene where you want your assets to be loaded
  59984. * @param onSuccess is a callback called when the task is successfully executed
  59985. * @param onError is a callback called if an error occurs
  59986. */
  59987. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59988. /**
  59989. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  59990. * This can be used with failed tasks that have the reason for failure fixed.
  59991. */
  59992. reset(): void;
  59993. private onErrorCallback;
  59994. private onDoneCallback;
  59995. }
  59996. /**
  59997. * Define the interface used by progress events raised during assets loading
  59998. */
  59999. export interface IAssetsProgressEvent {
  60000. /**
  60001. * Defines the number of remaining tasks to process
  60002. */
  60003. remainingCount: number;
  60004. /**
  60005. * Defines the total number of tasks
  60006. */
  60007. totalCount: number;
  60008. /**
  60009. * Defines the task that was just processed
  60010. */
  60011. task: AbstractAssetTask;
  60012. }
  60013. /**
  60014. * Class used to share progress information about assets loading
  60015. */
  60016. export class AssetsProgressEvent implements IAssetsProgressEvent {
  60017. /**
  60018. * Defines the number of remaining tasks to process
  60019. */
  60020. remainingCount: number;
  60021. /**
  60022. * Defines the total number of tasks
  60023. */
  60024. totalCount: number;
  60025. /**
  60026. * Defines the task that was just processed
  60027. */
  60028. task: AbstractAssetTask;
  60029. /**
  60030. * Creates a AssetsProgressEvent
  60031. * @param remainingCount defines the number of remaining tasks to process
  60032. * @param totalCount defines the total number of tasks
  60033. * @param task defines the task that was just processed
  60034. */
  60035. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  60036. }
  60037. /**
  60038. * Define a task used by AssetsManager to load meshes
  60039. */
  60040. export class MeshAssetTask extends AbstractAssetTask {
  60041. /**
  60042. * Defines the name of the task
  60043. */
  60044. name: string;
  60045. /**
  60046. * Defines the list of mesh's names you want to load
  60047. */
  60048. meshesNames: any;
  60049. /**
  60050. * Defines the root url to use as a base to load your meshes and associated resources
  60051. */
  60052. rootUrl: string;
  60053. /**
  60054. * Defines the filename of the scene to load from
  60055. */
  60056. sceneFilename: string;
  60057. /**
  60058. * Gets the list of loaded meshes
  60059. */
  60060. loadedMeshes: Array<AbstractMesh>;
  60061. /**
  60062. * Gets the list of loaded particle systems
  60063. */
  60064. loadedParticleSystems: Array<IParticleSystem>;
  60065. /**
  60066. * Gets the list of loaded skeletons
  60067. */
  60068. loadedSkeletons: Array<Skeleton>;
  60069. /**
  60070. * Gets the list of loaded animation groups
  60071. */
  60072. loadedAnimationGroups: Array<AnimationGroup>;
  60073. /**
  60074. * Callback called when the task is successful
  60075. */
  60076. onSuccess: (task: MeshAssetTask) => void;
  60077. /**
  60078. * Callback called when the task is successful
  60079. */
  60080. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  60081. /**
  60082. * Creates a new MeshAssetTask
  60083. * @param name defines the name of the task
  60084. * @param meshesNames defines the list of mesh's names you want to load
  60085. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  60086. * @param sceneFilename defines the filename of the scene to load from
  60087. */
  60088. constructor(
  60089. /**
  60090. * Defines the name of the task
  60091. */
  60092. name: string,
  60093. /**
  60094. * Defines the list of mesh's names you want to load
  60095. */
  60096. meshesNames: any,
  60097. /**
  60098. * Defines the root url to use as a base to load your meshes and associated resources
  60099. */
  60100. rootUrl: string,
  60101. /**
  60102. * Defines the filename of the scene to load from
  60103. */
  60104. sceneFilename: string);
  60105. /**
  60106. * Execute the current task
  60107. * @param scene defines the scene where you want your assets to be loaded
  60108. * @param onSuccess is a callback called when the task is successfully executed
  60109. * @param onError is a callback called if an error occurs
  60110. */
  60111. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60112. }
  60113. /**
  60114. * Define a task used by AssetsManager to load text content
  60115. */
  60116. export class TextFileAssetTask extends AbstractAssetTask {
  60117. /**
  60118. * Defines the name of the task
  60119. */
  60120. name: string;
  60121. /**
  60122. * Defines the location of the file to load
  60123. */
  60124. url: string;
  60125. /**
  60126. * Gets the loaded text string
  60127. */
  60128. text: string;
  60129. /**
  60130. * Callback called when the task is successful
  60131. */
  60132. onSuccess: (task: TextFileAssetTask) => void;
  60133. /**
  60134. * Callback called when the task is successful
  60135. */
  60136. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  60137. /**
  60138. * Creates a new TextFileAssetTask object
  60139. * @param name defines the name of the task
  60140. * @param url defines the location of the file to load
  60141. */
  60142. constructor(
  60143. /**
  60144. * Defines the name of the task
  60145. */
  60146. name: string,
  60147. /**
  60148. * Defines the location of the file to load
  60149. */
  60150. url: string);
  60151. /**
  60152. * Execute the current task
  60153. * @param scene defines the scene where you want your assets to be loaded
  60154. * @param onSuccess is a callback called when the task is successfully executed
  60155. * @param onError is a callback called if an error occurs
  60156. */
  60157. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60158. }
  60159. /**
  60160. * Define a task used by AssetsManager to load binary data
  60161. */
  60162. export class BinaryFileAssetTask extends AbstractAssetTask {
  60163. /**
  60164. * Defines the name of the task
  60165. */
  60166. name: string;
  60167. /**
  60168. * Defines the location of the file to load
  60169. */
  60170. url: string;
  60171. /**
  60172. * Gets the lodaded data (as an array buffer)
  60173. */
  60174. data: ArrayBuffer;
  60175. /**
  60176. * Callback called when the task is successful
  60177. */
  60178. onSuccess: (task: BinaryFileAssetTask) => void;
  60179. /**
  60180. * Callback called when the task is successful
  60181. */
  60182. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  60183. /**
  60184. * Creates a new BinaryFileAssetTask object
  60185. * @param name defines the name of the new task
  60186. * @param url defines the location of the file to load
  60187. */
  60188. constructor(
  60189. /**
  60190. * Defines the name of the task
  60191. */
  60192. name: string,
  60193. /**
  60194. * Defines the location of the file to load
  60195. */
  60196. url: string);
  60197. /**
  60198. * Execute the current task
  60199. * @param scene defines the scene where you want your assets to be loaded
  60200. * @param onSuccess is a callback called when the task is successfully executed
  60201. * @param onError is a callback called if an error occurs
  60202. */
  60203. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60204. }
  60205. /**
  60206. * Define a task used by AssetsManager to load images
  60207. */
  60208. export class ImageAssetTask extends AbstractAssetTask {
  60209. /**
  60210. * Defines the name of the task
  60211. */
  60212. name: string;
  60213. /**
  60214. * Defines the location of the image to load
  60215. */
  60216. url: string;
  60217. /**
  60218. * Gets the loaded images
  60219. */
  60220. image: HTMLImageElement;
  60221. /**
  60222. * Callback called when the task is successful
  60223. */
  60224. onSuccess: (task: ImageAssetTask) => void;
  60225. /**
  60226. * Callback called when the task is successful
  60227. */
  60228. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  60229. /**
  60230. * Creates a new ImageAssetTask
  60231. * @param name defines the name of the task
  60232. * @param url defines the location of the image to load
  60233. */
  60234. constructor(
  60235. /**
  60236. * Defines the name of the task
  60237. */
  60238. name: string,
  60239. /**
  60240. * Defines the location of the image to load
  60241. */
  60242. url: string);
  60243. /**
  60244. * Execute the current task
  60245. * @param scene defines the scene where you want your assets to be loaded
  60246. * @param onSuccess is a callback called when the task is successfully executed
  60247. * @param onError is a callback called if an error occurs
  60248. */
  60249. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60250. }
  60251. /**
  60252. * Defines the interface used by texture loading tasks
  60253. */
  60254. export interface ITextureAssetTask<TEX extends BaseTexture> {
  60255. /**
  60256. * Gets the loaded texture
  60257. */
  60258. texture: TEX;
  60259. }
  60260. /**
  60261. * Define a task used by AssetsManager to load 2D textures
  60262. */
  60263. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  60264. /**
  60265. * Defines the name of the task
  60266. */
  60267. name: string;
  60268. /**
  60269. * Defines the location of the file to load
  60270. */
  60271. url: string;
  60272. /**
  60273. * Defines if mipmap should not be generated (default is false)
  60274. */
  60275. noMipmap?: boolean | undefined;
  60276. /**
  60277. * Defines if texture must be inverted on Y axis (default is false)
  60278. */
  60279. invertY?: boolean | undefined;
  60280. /**
  60281. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60282. */
  60283. samplingMode: number;
  60284. /**
  60285. * Gets the loaded texture
  60286. */
  60287. texture: Texture;
  60288. /**
  60289. * Callback called when the task is successful
  60290. */
  60291. onSuccess: (task: TextureAssetTask) => void;
  60292. /**
  60293. * Callback called when the task is successful
  60294. */
  60295. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  60296. /**
  60297. * Creates a new TextureAssetTask object
  60298. * @param name defines the name of the task
  60299. * @param url defines the location of the file to load
  60300. * @param noMipmap defines if mipmap should not be generated (default is false)
  60301. * @param invertY defines if texture must be inverted on Y axis (default is false)
  60302. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60303. */
  60304. constructor(
  60305. /**
  60306. * Defines the name of the task
  60307. */
  60308. name: string,
  60309. /**
  60310. * Defines the location of the file to load
  60311. */
  60312. url: string,
  60313. /**
  60314. * Defines if mipmap should not be generated (default is false)
  60315. */
  60316. noMipmap?: boolean | undefined,
  60317. /**
  60318. * Defines if texture must be inverted on Y axis (default is false)
  60319. */
  60320. invertY?: boolean | undefined,
  60321. /**
  60322. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  60323. */
  60324. samplingMode?: number);
  60325. /**
  60326. * Execute the current task
  60327. * @param scene defines the scene where you want your assets to be loaded
  60328. * @param onSuccess is a callback called when the task is successfully executed
  60329. * @param onError is a callback called if an error occurs
  60330. */
  60331. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60332. }
  60333. /**
  60334. * Define a task used by AssetsManager to load cube textures
  60335. */
  60336. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  60337. /**
  60338. * Defines the name of the task
  60339. */
  60340. name: string;
  60341. /**
  60342. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60343. */
  60344. url: string;
  60345. /**
  60346. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60347. */
  60348. extensions?: string[] | undefined;
  60349. /**
  60350. * Defines if mipmaps should not be generated (default is false)
  60351. */
  60352. noMipmap?: boolean | undefined;
  60353. /**
  60354. * Defines the explicit list of files (undefined by default)
  60355. */
  60356. files?: string[] | undefined;
  60357. /**
  60358. * Gets the loaded texture
  60359. */
  60360. texture: CubeTexture;
  60361. /**
  60362. * Callback called when the task is successful
  60363. */
  60364. onSuccess: (task: CubeTextureAssetTask) => void;
  60365. /**
  60366. * Callback called when the task is successful
  60367. */
  60368. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  60369. /**
  60370. * Creates a new CubeTextureAssetTask
  60371. * @param name defines the name of the task
  60372. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60373. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60374. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60375. * @param files defines the explicit list of files (undefined by default)
  60376. */
  60377. constructor(
  60378. /**
  60379. * Defines the name of the task
  60380. */
  60381. name: string,
  60382. /**
  60383. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  60384. */
  60385. url: string,
  60386. /**
  60387. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  60388. */
  60389. extensions?: string[] | undefined,
  60390. /**
  60391. * Defines if mipmaps should not be generated (default is false)
  60392. */
  60393. noMipmap?: boolean | undefined,
  60394. /**
  60395. * Defines the explicit list of files (undefined by default)
  60396. */
  60397. files?: string[] | undefined);
  60398. /**
  60399. * Execute the current task
  60400. * @param scene defines the scene where you want your assets to be loaded
  60401. * @param onSuccess is a callback called when the task is successfully executed
  60402. * @param onError is a callback called if an error occurs
  60403. */
  60404. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60405. }
  60406. /**
  60407. * Define a task used by AssetsManager to load HDR cube textures
  60408. */
  60409. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  60410. /**
  60411. * Defines the name of the task
  60412. */
  60413. name: string;
  60414. /**
  60415. * Defines the location of the file to load
  60416. */
  60417. url: string;
  60418. /**
  60419. * Defines the desired size (the more it increases the longer the generation will be)
  60420. */
  60421. size: number;
  60422. /**
  60423. * Defines if mipmaps should not be generated (default is false)
  60424. */
  60425. noMipmap: boolean;
  60426. /**
  60427. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60428. */
  60429. generateHarmonics: boolean;
  60430. /**
  60431. * 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)
  60432. */
  60433. gammaSpace: boolean;
  60434. /**
  60435. * Internal Use Only
  60436. */
  60437. reserved: boolean;
  60438. /**
  60439. * Gets the loaded texture
  60440. */
  60441. texture: HDRCubeTexture;
  60442. /**
  60443. * Callback called when the task is successful
  60444. */
  60445. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  60446. /**
  60447. * Callback called when the task is successful
  60448. */
  60449. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  60450. /**
  60451. * Creates a new HDRCubeTextureAssetTask object
  60452. * @param name defines the name of the task
  60453. * @param url defines the location of the file to load
  60454. * @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.
  60455. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60456. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60457. * @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)
  60458. * @param reserved Internal use only
  60459. */
  60460. constructor(
  60461. /**
  60462. * Defines the name of the task
  60463. */
  60464. name: string,
  60465. /**
  60466. * Defines the location of the file to load
  60467. */
  60468. url: string,
  60469. /**
  60470. * Defines the desired size (the more it increases the longer the generation will be)
  60471. */
  60472. size: number,
  60473. /**
  60474. * Defines if mipmaps should not be generated (default is false)
  60475. */
  60476. noMipmap?: boolean,
  60477. /**
  60478. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  60479. */
  60480. generateHarmonics?: boolean,
  60481. /**
  60482. * 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)
  60483. */
  60484. gammaSpace?: boolean,
  60485. /**
  60486. * Internal Use Only
  60487. */
  60488. reserved?: boolean);
  60489. /**
  60490. * Execute the current task
  60491. * @param scene defines the scene where you want your assets to be loaded
  60492. * @param onSuccess is a callback called when the task is successfully executed
  60493. * @param onError is a callback called if an error occurs
  60494. */
  60495. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60496. }
  60497. /**
  60498. * Define a task used by AssetsManager to load Equirectangular cube textures
  60499. */
  60500. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  60501. /**
  60502. * Defines the name of the task
  60503. */
  60504. name: string;
  60505. /**
  60506. * Defines the location of the file to load
  60507. */
  60508. url: string;
  60509. /**
  60510. * Defines the desired size (the more it increases the longer the generation will be)
  60511. */
  60512. size: number;
  60513. /**
  60514. * Defines if mipmaps should not be generated (default is false)
  60515. */
  60516. noMipmap: boolean;
  60517. /**
  60518. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60519. * but the standard material would require them in Gamma space) (default is true)
  60520. */
  60521. gammaSpace: boolean;
  60522. /**
  60523. * Gets the loaded texture
  60524. */
  60525. texture: EquiRectangularCubeTexture;
  60526. /**
  60527. * Callback called when the task is successful
  60528. */
  60529. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  60530. /**
  60531. * Callback called when the task is successful
  60532. */
  60533. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  60534. /**
  60535. * Creates a new EquiRectangularCubeTextureAssetTask object
  60536. * @param name defines the name of the task
  60537. * @param url defines the location of the file to load
  60538. * @param size defines the desired size (the more it increases the longer the generation will be)
  60539. * If the size is omitted this implies you are using a preprocessed cubemap.
  60540. * @param noMipmap defines if mipmaps should not be generated (default is false)
  60541. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  60542. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  60543. * (default is true)
  60544. */
  60545. constructor(
  60546. /**
  60547. * Defines the name of the task
  60548. */
  60549. name: string,
  60550. /**
  60551. * Defines the location of the file to load
  60552. */
  60553. url: string,
  60554. /**
  60555. * Defines the desired size (the more it increases the longer the generation will be)
  60556. */
  60557. size: number,
  60558. /**
  60559. * Defines if mipmaps should not be generated (default is false)
  60560. */
  60561. noMipmap?: boolean,
  60562. /**
  60563. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  60564. * but the standard material would require them in Gamma space) (default is true)
  60565. */
  60566. gammaSpace?: boolean);
  60567. /**
  60568. * Execute the current task
  60569. * @param scene defines the scene where you want your assets to be loaded
  60570. * @param onSuccess is a callback called when the task is successfully executed
  60571. * @param onError is a callback called if an error occurs
  60572. */
  60573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  60574. }
  60575. /**
  60576. * This class can be used to easily import assets into a scene
  60577. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  60578. */
  60579. export class AssetsManager {
  60580. private _scene;
  60581. private _isLoading;
  60582. protected _tasks: AbstractAssetTask[];
  60583. protected _waitingTasksCount: number;
  60584. protected _totalTasksCount: number;
  60585. /**
  60586. * Callback called when all tasks are processed
  60587. */
  60588. onFinish: (tasks: AbstractAssetTask[]) => void;
  60589. /**
  60590. * Callback called when a task is successful
  60591. */
  60592. onTaskSuccess: (task: AbstractAssetTask) => void;
  60593. /**
  60594. * Callback called when a task had an error
  60595. */
  60596. onTaskError: (task: AbstractAssetTask) => void;
  60597. /**
  60598. * Callback called when a task is done (whatever the result is)
  60599. */
  60600. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  60601. /**
  60602. * Observable called when all tasks are processed
  60603. */
  60604. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  60605. /**
  60606. * Observable called when a task had an error
  60607. */
  60608. onTaskErrorObservable: Observable<AbstractAssetTask>;
  60609. /**
  60610. * Observable called when all tasks were executed
  60611. */
  60612. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  60613. /**
  60614. * Observable called when a task is done (whatever the result is)
  60615. */
  60616. onProgressObservable: Observable<IAssetsProgressEvent>;
  60617. /**
  60618. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  60619. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  60620. */
  60621. useDefaultLoadingScreen: boolean;
  60622. /**
  60623. * Creates a new AssetsManager
  60624. * @param scene defines the scene to work on
  60625. */
  60626. constructor(scene: Scene);
  60627. /**
  60628. * Add a MeshAssetTask to the list of active tasks
  60629. * @param taskName defines the name of the new task
  60630. * @param meshesNames defines the name of meshes to load
  60631. * @param rootUrl defines the root url to use to locate files
  60632. * @param sceneFilename defines the filename of the scene file
  60633. * @returns a new MeshAssetTask object
  60634. */
  60635. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  60636. /**
  60637. * Add a TextFileAssetTask to the list of active tasks
  60638. * @param taskName defines the name of the new task
  60639. * @param url defines the url of the file to load
  60640. * @returns a new TextFileAssetTask object
  60641. */
  60642. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  60643. /**
  60644. * Add a BinaryFileAssetTask to the list of active tasks
  60645. * @param taskName defines the name of the new task
  60646. * @param url defines the url of the file to load
  60647. * @returns a new BinaryFileAssetTask object
  60648. */
  60649. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  60650. /**
  60651. * Add a ImageAssetTask to the list of active tasks
  60652. * @param taskName defines the name of the new task
  60653. * @param url defines the url of the file to load
  60654. * @returns a new ImageAssetTask object
  60655. */
  60656. addImageTask(taskName: string, url: string): ImageAssetTask;
  60657. /**
  60658. * Add a TextureAssetTask to the list of active tasks
  60659. * @param taskName defines the name of the new task
  60660. * @param url defines the url of the file to load
  60661. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60662. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  60663. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  60664. * @returns a new TextureAssetTask object
  60665. */
  60666. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  60667. /**
  60668. * Add a CubeTextureAssetTask to the list of active tasks
  60669. * @param taskName defines the name of the new task
  60670. * @param url defines the url of the file to load
  60671. * @param extensions defines the extension to use to load the cube map (can be null)
  60672. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60673. * @param files defines the list of files to load (can be null)
  60674. * @returns a new CubeTextureAssetTask object
  60675. */
  60676. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  60677. /**
  60678. *
  60679. * Add a HDRCubeTextureAssetTask to the list of active tasks
  60680. * @param taskName defines the name of the new task
  60681. * @param url defines the url of the file to load
  60682. * @param size defines the size you want for the cubemap (can be null)
  60683. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60684. * @param generateHarmonics defines if you want to automatically generate (true by default)
  60685. * @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)
  60686. * @param reserved Internal use only
  60687. * @returns a new HDRCubeTextureAssetTask object
  60688. */
  60689. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  60690. /**
  60691. *
  60692. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  60693. * @param taskName defines the name of the new task
  60694. * @param url defines the url of the file to load
  60695. * @param size defines the size you want for the cubemap (can be null)
  60696. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  60697. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  60698. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  60699. * @returns a new EquiRectangularCubeTextureAssetTask object
  60700. */
  60701. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  60702. /**
  60703. * Remove a task from the assets manager.
  60704. * @param task the task to remove
  60705. */
  60706. removeTask(task: AbstractAssetTask): void;
  60707. private _decreaseWaitingTasksCount;
  60708. private _runTask;
  60709. /**
  60710. * Reset the AssetsManager and remove all tasks
  60711. * @return the current instance of the AssetsManager
  60712. */
  60713. reset(): AssetsManager;
  60714. /**
  60715. * Start the loading process
  60716. * @return the current instance of the AssetsManager
  60717. */
  60718. load(): AssetsManager;
  60719. /**
  60720. * Start the loading process as an async operation
  60721. * @return a promise returning the list of failed tasks
  60722. */
  60723. loadAsync(): Promise<void>;
  60724. }
  60725. }
  60726. declare module "babylonjs/Misc/deferred" {
  60727. /**
  60728. * Wrapper class for promise with external resolve and reject.
  60729. */
  60730. export class Deferred<T> {
  60731. /**
  60732. * The promise associated with this deferred object.
  60733. */
  60734. readonly promise: Promise<T>;
  60735. private _resolve;
  60736. private _reject;
  60737. /**
  60738. * The resolve method of the promise associated with this deferred object.
  60739. */
  60740. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  60741. /**
  60742. * The reject method of the promise associated with this deferred object.
  60743. */
  60744. readonly reject: (reason?: any) => void;
  60745. /**
  60746. * Constructor for this deferred object.
  60747. */
  60748. constructor();
  60749. }
  60750. }
  60751. declare module "babylonjs/Misc/meshExploder" {
  60752. import { Mesh } from "babylonjs/Meshes/mesh";
  60753. /**
  60754. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  60755. */
  60756. export class MeshExploder {
  60757. private _centerMesh;
  60758. private _meshes;
  60759. private _meshesOrigins;
  60760. private _toCenterVectors;
  60761. private _scaledDirection;
  60762. private _newPosition;
  60763. private _centerPosition;
  60764. /**
  60765. * Explodes meshes from a center mesh.
  60766. * @param meshes The meshes to explode.
  60767. * @param centerMesh The mesh to be center of explosion.
  60768. */
  60769. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  60770. private _setCenterMesh;
  60771. /**
  60772. * Get class name
  60773. * @returns "MeshExploder"
  60774. */
  60775. getClassName(): string;
  60776. /**
  60777. * "Exploded meshes"
  60778. * @returns Array of meshes with the centerMesh at index 0.
  60779. */
  60780. getMeshes(): Array<Mesh>;
  60781. /**
  60782. * Explodes meshes giving a specific direction
  60783. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  60784. */
  60785. explode(direction?: number): void;
  60786. }
  60787. }
  60788. declare module "babylonjs/Misc/filesInput" {
  60789. import { Engine } from "babylonjs/Engines/engine";
  60790. import { Scene } from "babylonjs/scene";
  60791. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  60792. /**
  60793. * Class used to help managing file picking and drag'n'drop
  60794. */
  60795. export class FilesInput {
  60796. /**
  60797. * List of files ready to be loaded
  60798. */
  60799. static readonly FilesToLoad: {
  60800. [key: string]: File;
  60801. };
  60802. /**
  60803. * Callback called when a file is processed
  60804. */
  60805. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  60806. private _engine;
  60807. private _currentScene;
  60808. private _sceneLoadedCallback;
  60809. private _progressCallback;
  60810. private _additionalRenderLoopLogicCallback;
  60811. private _textureLoadingCallback;
  60812. private _startingProcessingFilesCallback;
  60813. private _onReloadCallback;
  60814. private _errorCallback;
  60815. private _elementToMonitor;
  60816. private _sceneFileToLoad;
  60817. private _filesToLoad;
  60818. /**
  60819. * Creates a new FilesInput
  60820. * @param engine defines the rendering engine
  60821. * @param scene defines the hosting scene
  60822. * @param sceneLoadedCallback callback called when scene is loaded
  60823. * @param progressCallback callback called to track progress
  60824. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  60825. * @param textureLoadingCallback callback called when a texture is loading
  60826. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  60827. * @param onReloadCallback callback called when a reload is requested
  60828. * @param errorCallback callback call if an error occurs
  60829. */
  60830. 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);
  60831. private _dragEnterHandler;
  60832. private _dragOverHandler;
  60833. private _dropHandler;
  60834. /**
  60835. * Calls this function to listen to drag'n'drop events on a specific DOM element
  60836. * @param elementToMonitor defines the DOM element to track
  60837. */
  60838. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  60839. /**
  60840. * Release all associated resources
  60841. */
  60842. dispose(): void;
  60843. private renderFunction;
  60844. private drag;
  60845. private drop;
  60846. private _traverseFolder;
  60847. private _processFiles;
  60848. /**
  60849. * Load files from a drop event
  60850. * @param event defines the drop event to use as source
  60851. */
  60852. loadFiles(event: any): void;
  60853. private _processReload;
  60854. /**
  60855. * Reload the current scene from the loaded files
  60856. */
  60857. reload(): void;
  60858. }
  60859. }
  60860. declare module "babylonjs/Misc/HighDynamicRange/index" {
  60861. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  60862. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  60863. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  60864. }
  60865. declare module "babylonjs/Misc/sceneOptimizer" {
  60866. import { Scene, IDisposable } from "babylonjs/scene";
  60867. import { Observable } from "babylonjs/Misc/observable";
  60868. /**
  60869. * Defines the root class used to create scene optimization to use with SceneOptimizer
  60870. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60871. */
  60872. export class SceneOptimization {
  60873. /**
  60874. * Defines the priority of this optimization (0 by default which means first in the list)
  60875. */
  60876. priority: number;
  60877. /**
  60878. * Gets a string describing the action executed by the current optimization
  60879. * @returns description string
  60880. */
  60881. getDescription(): string;
  60882. /**
  60883. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60884. * @param scene defines the current scene where to apply this optimization
  60885. * @param optimizer defines the current optimizer
  60886. * @returns true if everything that can be done was applied
  60887. */
  60888. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60889. /**
  60890. * Creates the SceneOptimization object
  60891. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60892. * @param desc defines the description associated with the optimization
  60893. */
  60894. constructor(
  60895. /**
  60896. * Defines the priority of this optimization (0 by default which means first in the list)
  60897. */
  60898. priority?: number);
  60899. }
  60900. /**
  60901. * Defines an optimization used to reduce the size of render target textures
  60902. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60903. */
  60904. export class TextureOptimization extends SceneOptimization {
  60905. /**
  60906. * Defines the priority of this optimization (0 by default which means first in the list)
  60907. */
  60908. priority: number;
  60909. /**
  60910. * 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
  60911. */
  60912. maximumSize: number;
  60913. /**
  60914. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60915. */
  60916. step: number;
  60917. /**
  60918. * Gets a string describing the action executed by the current optimization
  60919. * @returns description string
  60920. */
  60921. getDescription(): string;
  60922. /**
  60923. * Creates the TextureOptimization object
  60924. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60925. * @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
  60926. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60927. */
  60928. constructor(
  60929. /**
  60930. * Defines the priority of this optimization (0 by default which means first in the list)
  60931. */
  60932. priority?: number,
  60933. /**
  60934. * 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
  60935. */
  60936. maximumSize?: number,
  60937. /**
  60938. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  60939. */
  60940. step?: number);
  60941. /**
  60942. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60943. * @param scene defines the current scene where to apply this optimization
  60944. * @param optimizer defines the current optimizer
  60945. * @returns true if everything that can be done was applied
  60946. */
  60947. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60948. }
  60949. /**
  60950. * Defines an optimization used to increase or decrease the rendering resolution
  60951. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  60952. */
  60953. export class HardwareScalingOptimization extends SceneOptimization {
  60954. /**
  60955. * Defines the priority of this optimization (0 by default which means first in the list)
  60956. */
  60957. priority: number;
  60958. /**
  60959. * Defines the maximum scale to use (2 by default)
  60960. */
  60961. maximumScale: number;
  60962. /**
  60963. * Defines the step to use between two passes (0.5 by default)
  60964. */
  60965. step: number;
  60966. private _currentScale;
  60967. private _directionOffset;
  60968. /**
  60969. * Gets a string describing the action executed by the current optimization
  60970. * @return description string
  60971. */
  60972. getDescription(): string;
  60973. /**
  60974. * Creates the HardwareScalingOptimization object
  60975. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  60976. * @param maximumScale defines the maximum scale to use (2 by default)
  60977. * @param step defines the step to use between two passes (0.5 by default)
  60978. */
  60979. constructor(
  60980. /**
  60981. * Defines the priority of this optimization (0 by default which means first in the list)
  60982. */
  60983. priority?: number,
  60984. /**
  60985. * Defines the maximum scale to use (2 by default)
  60986. */
  60987. maximumScale?: number,
  60988. /**
  60989. * Defines the step to use between two passes (0.5 by default)
  60990. */
  60991. step?: number);
  60992. /**
  60993. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  60994. * @param scene defines the current scene where to apply this optimization
  60995. * @param optimizer defines the current optimizer
  60996. * @returns true if everything that can be done was applied
  60997. */
  60998. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  60999. }
  61000. /**
  61001. * Defines an optimization used to remove shadows
  61002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61003. */
  61004. export class ShadowsOptimization extends SceneOptimization {
  61005. /**
  61006. * Gets a string describing the action executed by the current optimization
  61007. * @return description string
  61008. */
  61009. getDescription(): string;
  61010. /**
  61011. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61012. * @param scene defines the current scene where to apply this optimization
  61013. * @param optimizer defines the current optimizer
  61014. * @returns true if everything that can be done was applied
  61015. */
  61016. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61017. }
  61018. /**
  61019. * Defines an optimization used to turn post-processes off
  61020. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61021. */
  61022. export class PostProcessesOptimization extends SceneOptimization {
  61023. /**
  61024. * Gets a string describing the action executed by the current optimization
  61025. * @return description string
  61026. */
  61027. getDescription(): string;
  61028. /**
  61029. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61030. * @param scene defines the current scene where to apply this optimization
  61031. * @param optimizer defines the current optimizer
  61032. * @returns true if everything that can be done was applied
  61033. */
  61034. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61035. }
  61036. /**
  61037. * Defines an optimization used to turn lens flares off
  61038. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61039. */
  61040. export class LensFlaresOptimization extends SceneOptimization {
  61041. /**
  61042. * Gets a string describing the action executed by the current optimization
  61043. * @return description string
  61044. */
  61045. getDescription(): string;
  61046. /**
  61047. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61048. * @param scene defines the current scene where to apply this optimization
  61049. * @param optimizer defines the current optimizer
  61050. * @returns true if everything that can be done was applied
  61051. */
  61052. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61053. }
  61054. /**
  61055. * Defines an optimization based on user defined callback.
  61056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61057. */
  61058. export class CustomOptimization extends SceneOptimization {
  61059. /**
  61060. * Callback called to apply the custom optimization.
  61061. */
  61062. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  61063. /**
  61064. * Callback called to get custom description
  61065. */
  61066. onGetDescription: () => string;
  61067. /**
  61068. * Gets a string describing the action executed by the current optimization
  61069. * @returns description string
  61070. */
  61071. getDescription(): string;
  61072. /**
  61073. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61074. * @param scene defines the current scene where to apply this optimization
  61075. * @param optimizer defines the current optimizer
  61076. * @returns true if everything that can be done was applied
  61077. */
  61078. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61079. }
  61080. /**
  61081. * Defines an optimization used to turn particles off
  61082. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61083. */
  61084. export class ParticlesOptimization extends SceneOptimization {
  61085. /**
  61086. * Gets a string describing the action executed by the current optimization
  61087. * @return description string
  61088. */
  61089. getDescription(): string;
  61090. /**
  61091. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61092. * @param scene defines the current scene where to apply this optimization
  61093. * @param optimizer defines the current optimizer
  61094. * @returns true if everything that can be done was applied
  61095. */
  61096. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61097. }
  61098. /**
  61099. * Defines an optimization used to turn render targets off
  61100. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61101. */
  61102. export class RenderTargetsOptimization extends SceneOptimization {
  61103. /**
  61104. * Gets a string describing the action executed by the current optimization
  61105. * @return description string
  61106. */
  61107. getDescription(): string;
  61108. /**
  61109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61110. * @param scene defines the current scene where to apply this optimization
  61111. * @param optimizer defines the current optimizer
  61112. * @returns true if everything that can be done was applied
  61113. */
  61114. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  61115. }
  61116. /**
  61117. * Defines an optimization used to merge meshes with compatible materials
  61118. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61119. */
  61120. export class MergeMeshesOptimization extends SceneOptimization {
  61121. private static _UpdateSelectionTree;
  61122. /**
  61123. * Gets or sets a boolean which defines if optimization octree has to be updated
  61124. */
  61125. /**
  61126. * Gets or sets a boolean which defines if optimization octree has to be updated
  61127. */
  61128. static UpdateSelectionTree: boolean;
  61129. /**
  61130. * Gets a string describing the action executed by the current optimization
  61131. * @return description string
  61132. */
  61133. getDescription(): string;
  61134. private _canBeMerged;
  61135. /**
  61136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  61137. * @param scene defines the current scene where to apply this optimization
  61138. * @param optimizer defines the current optimizer
  61139. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  61140. * @returns true if everything that can be done was applied
  61141. */
  61142. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  61143. }
  61144. /**
  61145. * Defines a list of options used by SceneOptimizer
  61146. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61147. */
  61148. export class SceneOptimizerOptions {
  61149. /**
  61150. * Defines the target frame rate to reach (60 by default)
  61151. */
  61152. targetFrameRate: number;
  61153. /**
  61154. * Defines the interval between two checkes (2000ms by default)
  61155. */
  61156. trackerDuration: number;
  61157. /**
  61158. * Gets the list of optimizations to apply
  61159. */
  61160. optimizations: SceneOptimization[];
  61161. /**
  61162. * Creates a new list of options used by SceneOptimizer
  61163. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  61164. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  61165. */
  61166. constructor(
  61167. /**
  61168. * Defines the target frame rate to reach (60 by default)
  61169. */
  61170. targetFrameRate?: number,
  61171. /**
  61172. * Defines the interval between two checkes (2000ms by default)
  61173. */
  61174. trackerDuration?: number);
  61175. /**
  61176. * Add a new optimization
  61177. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  61178. * @returns the current SceneOptimizerOptions
  61179. */
  61180. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  61181. /**
  61182. * Add a new custom optimization
  61183. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  61184. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  61185. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  61186. * @returns the current SceneOptimizerOptions
  61187. */
  61188. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  61189. /**
  61190. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  61191. * @param targetFrameRate defines the target frame rate (60 by default)
  61192. * @returns a SceneOptimizerOptions object
  61193. */
  61194. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61195. /**
  61196. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  61197. * @param targetFrameRate defines the target frame rate (60 by default)
  61198. * @returns a SceneOptimizerOptions object
  61199. */
  61200. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61201. /**
  61202. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  61203. * @param targetFrameRate defines the target frame rate (60 by default)
  61204. * @returns a SceneOptimizerOptions object
  61205. */
  61206. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  61207. }
  61208. /**
  61209. * Class used to run optimizations in order to reach a target frame rate
  61210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  61211. */
  61212. export class SceneOptimizer implements IDisposable {
  61213. private _isRunning;
  61214. private _options;
  61215. private _scene;
  61216. private _currentPriorityLevel;
  61217. private _targetFrameRate;
  61218. private _trackerDuration;
  61219. private _currentFrameRate;
  61220. private _sceneDisposeObserver;
  61221. private _improvementMode;
  61222. /**
  61223. * Defines an observable called when the optimizer reaches the target frame rate
  61224. */
  61225. onSuccessObservable: Observable<SceneOptimizer>;
  61226. /**
  61227. * Defines an observable called when the optimizer enables an optimization
  61228. */
  61229. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  61230. /**
  61231. * Defines an observable called when the optimizer is not able to reach the target frame rate
  61232. */
  61233. onFailureObservable: Observable<SceneOptimizer>;
  61234. /**
  61235. * Gets a boolean indicating if the optimizer is in improvement mode
  61236. */
  61237. readonly isInImprovementMode: boolean;
  61238. /**
  61239. * Gets the current priority level (0 at start)
  61240. */
  61241. readonly currentPriorityLevel: number;
  61242. /**
  61243. * Gets the current frame rate checked by the SceneOptimizer
  61244. */
  61245. readonly currentFrameRate: number;
  61246. /**
  61247. * Gets or sets the current target frame rate (60 by default)
  61248. */
  61249. /**
  61250. * Gets or sets the current target frame rate (60 by default)
  61251. */
  61252. targetFrameRate: number;
  61253. /**
  61254. * Gets or sets the current interval between two checks (every 2000ms by default)
  61255. */
  61256. /**
  61257. * Gets or sets the current interval between two checks (every 2000ms by default)
  61258. */
  61259. trackerDuration: number;
  61260. /**
  61261. * Gets the list of active optimizations
  61262. */
  61263. readonly optimizations: SceneOptimization[];
  61264. /**
  61265. * Creates a new SceneOptimizer
  61266. * @param scene defines the scene to work on
  61267. * @param options defines the options to use with the SceneOptimizer
  61268. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  61269. * @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)
  61270. */
  61271. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  61272. /**
  61273. * Stops the current optimizer
  61274. */
  61275. stop(): void;
  61276. /**
  61277. * Reset the optimizer to initial step (current priority level = 0)
  61278. */
  61279. reset(): void;
  61280. /**
  61281. * Start the optimizer. By default it will try to reach a specific framerate
  61282. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  61283. */
  61284. start(): void;
  61285. private _checkCurrentState;
  61286. /**
  61287. * Release all resources
  61288. */
  61289. dispose(): void;
  61290. /**
  61291. * Helper function to create a SceneOptimizer with one single line of code
  61292. * @param scene defines the scene to work on
  61293. * @param options defines the options to use with the SceneOptimizer
  61294. * @param onSuccess defines a callback to call on success
  61295. * @param onFailure defines a callback to call on failure
  61296. * @returns the new SceneOptimizer object
  61297. */
  61298. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  61299. }
  61300. }
  61301. declare module "babylonjs/Misc/sceneSerializer" {
  61302. import { Scene } from "babylonjs/scene";
  61303. /**
  61304. * Class used to serialize a scene into a string
  61305. */
  61306. export class SceneSerializer {
  61307. /**
  61308. * Clear cache used by a previous serialization
  61309. */
  61310. static ClearCache(): void;
  61311. /**
  61312. * Serialize a scene into a JSON compatible object
  61313. * @param scene defines the scene to serialize
  61314. * @returns a JSON compatible object
  61315. */
  61316. static Serialize(scene: Scene): any;
  61317. /**
  61318. * Serialize a mesh into a JSON compatible object
  61319. * @param toSerialize defines the mesh to serialize
  61320. * @param withParents defines if parents must be serialized as well
  61321. * @param withChildren defines if children must be serialized as well
  61322. * @returns a JSON compatible object
  61323. */
  61324. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  61325. }
  61326. }
  61327. declare module "babylonjs/Misc/textureTools" {
  61328. import { Texture } from "babylonjs/Materials/Textures/texture";
  61329. /**
  61330. * Class used to host texture specific utilities
  61331. */
  61332. export class TextureTools {
  61333. /**
  61334. * Uses the GPU to create a copy texture rescaled at a given size
  61335. * @param texture Texture to copy from
  61336. * @param width defines the desired width
  61337. * @param height defines the desired height
  61338. * @param useBilinearMode defines if bilinear mode has to be used
  61339. * @return the generated texture
  61340. */
  61341. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  61342. }
  61343. }
  61344. declare module "babylonjs/Misc/videoRecorder" {
  61345. import { Nullable } from "babylonjs/types";
  61346. import { Engine } from "babylonjs/Engines/engine";
  61347. /**
  61348. * This represents the different options avilable for the video capture.
  61349. */
  61350. export interface VideoRecorderOptions {
  61351. /** Defines the mime type of the video */
  61352. mimeType: string;
  61353. /** Defines the video the video should be recorded at */
  61354. fps: number;
  61355. /** Defines the chunk size for the recording data */
  61356. recordChunckSize: number;
  61357. /** The audio tracks to attach to the record */
  61358. audioTracks?: MediaStreamTrack[];
  61359. }
  61360. /**
  61361. * This can helps recording videos from BabylonJS.
  61362. * This is based on the available WebRTC functionalities of the browser.
  61363. *
  61364. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  61365. */
  61366. export class VideoRecorder {
  61367. private static readonly _defaultOptions;
  61368. /**
  61369. * Returns wehther or not the VideoRecorder is available in your browser.
  61370. * @param engine Defines the Babylon Engine to check the support for
  61371. * @returns true if supported otherwise false
  61372. */
  61373. static IsSupported(engine: Engine): boolean;
  61374. private readonly _options;
  61375. private _canvas;
  61376. private _mediaRecorder;
  61377. private _recordedChunks;
  61378. private _fileName;
  61379. private _resolve;
  61380. private _reject;
  61381. /**
  61382. * True wether a recording is already in progress.
  61383. */
  61384. readonly isRecording: boolean;
  61385. /**
  61386. * Create a new VideoCapture object which can help converting what you see in Babylon to
  61387. * a video file.
  61388. * @param engine Defines the BabylonJS Engine you wish to record
  61389. * @param options Defines options that can be used to customized the capture
  61390. */
  61391. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  61392. /**
  61393. * Stops the current recording before the default capture timeout passed in the startRecording
  61394. * functions.
  61395. */
  61396. stopRecording(): void;
  61397. /**
  61398. * Starts recording the canvas for a max duration specified in parameters.
  61399. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  61400. * @param maxDuration Defines the maximum recording time in seconds.
  61401. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  61402. * @return a promise callback at the end of the recording with the video data in Blob.
  61403. */
  61404. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  61405. /**
  61406. * Releases internal resources used during the recording.
  61407. */
  61408. dispose(): void;
  61409. private _handleDataAvailable;
  61410. private _handleError;
  61411. private _handleStop;
  61412. }
  61413. }
  61414. declare module "babylonjs/Misc/screenshotTools" {
  61415. import { Camera } from "babylonjs/Cameras/camera";
  61416. import { Engine } from "babylonjs/Engines/engine";
  61417. /**
  61418. * Class containing a set of static utilities functions for screenshots
  61419. */
  61420. export class ScreenshotTools {
  61421. /**
  61422. * Captures a screenshot of the current rendering
  61423. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61424. * @param engine defines the rendering engine
  61425. * @param camera defines the source camera
  61426. * @param size This parameter can be set to a single number or to an object with the
  61427. * following (optional) properties: precision, width, height. If a single number is passed,
  61428. * it will be used for both width and height. If an object is passed, the screenshot size
  61429. * will be derived from the parameters. The precision property is a multiplier allowing
  61430. * rendering at a higher or lower resolution
  61431. * @param successCallback defines the callback receives a single parameter which contains the
  61432. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61433. * src parameter of an <img> to display it
  61434. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  61435. * Check your browser for supported MIME types
  61436. */
  61437. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  61438. /**
  61439. * Generates an image screenshot from the specified camera.
  61440. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  61441. * @param engine The engine to use for rendering
  61442. * @param camera The camera to use for rendering
  61443. * @param size This parameter can be set to a single number or to an object with the
  61444. * following (optional) properties: precision, width, height. If a single number is passed,
  61445. * it will be used for both width and height. If an object is passed, the screenshot size
  61446. * will be derived from the parameters. The precision property is a multiplier allowing
  61447. * rendering at a higher or lower resolution
  61448. * @param successCallback The callback receives a single parameter which contains the
  61449. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  61450. * src parameter of an <img> to display it
  61451. * @param mimeType The MIME type of the screenshot image (default: image/png).
  61452. * Check your browser for supported MIME types
  61453. * @param samples Texture samples (default: 1)
  61454. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  61455. * @param fileName A name for for the downloaded file.
  61456. */
  61457. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  61458. }
  61459. }
  61460. declare module "babylonjs/Misc/index" {
  61461. export * from "babylonjs/Misc/andOrNotEvaluator";
  61462. export * from "babylonjs/Misc/assetsManager";
  61463. export * from "babylonjs/Misc/dds";
  61464. export * from "babylonjs/Misc/decorators";
  61465. export * from "babylonjs/Misc/deferred";
  61466. export * from "babylonjs/Misc/environmentTextureTools";
  61467. export * from "babylonjs/Misc/meshExploder";
  61468. export * from "babylonjs/Misc/filesInput";
  61469. export * from "babylonjs/Misc/HighDynamicRange/index";
  61470. export * from "babylonjs/Misc/khronosTextureContainer";
  61471. export * from "babylonjs/Misc/observable";
  61472. export * from "babylonjs/Misc/performanceMonitor";
  61473. export * from "babylonjs/Misc/promise";
  61474. export * from "babylonjs/Misc/sceneOptimizer";
  61475. export * from "babylonjs/Misc/sceneSerializer";
  61476. export * from "babylonjs/Misc/smartArray";
  61477. export * from "babylonjs/Misc/stringDictionary";
  61478. export * from "babylonjs/Misc/tags";
  61479. export * from "babylonjs/Misc/textureTools";
  61480. export * from "babylonjs/Misc/tga";
  61481. export * from "babylonjs/Misc/tools";
  61482. export * from "babylonjs/Misc/videoRecorder";
  61483. export * from "babylonjs/Misc/virtualJoystick";
  61484. export * from "babylonjs/Misc/workerPool";
  61485. export * from "babylonjs/Misc/logger";
  61486. export * from "babylonjs/Misc/typeStore";
  61487. export * from "babylonjs/Misc/filesInputStore";
  61488. export * from "babylonjs/Misc/deepCopier";
  61489. export * from "babylonjs/Misc/pivotTools";
  61490. export * from "babylonjs/Misc/precisionDate";
  61491. export * from "babylonjs/Misc/screenshotTools";
  61492. export * from "babylonjs/Misc/typeStore";
  61493. export * from "babylonjs/Misc/webRequest";
  61494. export * from "babylonjs/Misc/iInspectable";
  61495. }
  61496. declare module "babylonjs/index" {
  61497. export * from "babylonjs/abstractScene";
  61498. export * from "babylonjs/Actions/index";
  61499. export * from "babylonjs/Animations/index";
  61500. export * from "babylonjs/assetContainer";
  61501. export * from "babylonjs/Audio/index";
  61502. export * from "babylonjs/Behaviors/index";
  61503. export * from "babylonjs/Bones/index";
  61504. export * from "babylonjs/Cameras/index";
  61505. export * from "babylonjs/Collisions/index";
  61506. export * from "babylonjs/Culling/index";
  61507. export * from "babylonjs/Debug/index";
  61508. export * from "babylonjs/Engines/index";
  61509. export * from "babylonjs/Events/index";
  61510. export * from "babylonjs/Gamepads/index";
  61511. export * from "babylonjs/Gizmos/index";
  61512. export * from "babylonjs/Helpers/index";
  61513. export * from "babylonjs/Instrumentation/index";
  61514. export * from "babylonjs/Layers/index";
  61515. export * from "babylonjs/LensFlares/index";
  61516. export * from "babylonjs/Lights/index";
  61517. export * from "babylonjs/Loading/index";
  61518. export * from "babylonjs/Materials/index";
  61519. export * from "babylonjs/Maths/index";
  61520. export * from "babylonjs/Meshes/index";
  61521. export * from "babylonjs/Morph/index";
  61522. export * from "babylonjs/node";
  61523. export * from "babylonjs/Offline/index";
  61524. export * from "babylonjs/Particles/index";
  61525. export * from "babylonjs/Physics/index";
  61526. export * from "babylonjs/PostProcesses/index";
  61527. export * from "babylonjs/Probes/index";
  61528. export * from "babylonjs/Rendering/index";
  61529. export * from "babylonjs/scene";
  61530. export * from "babylonjs/sceneComponent";
  61531. export * from "babylonjs/Sprites/index";
  61532. export * from "babylonjs/States/index";
  61533. export * from "babylonjs/Misc/index";
  61534. export * from "babylonjs/types";
  61535. }
  61536. declare module "babylonjs/Animations/pathCursor" {
  61537. import { Path2, Vector3 } from "babylonjs/Maths/math";
  61538. /**
  61539. * A cursor which tracks a point on a path
  61540. */
  61541. export class PathCursor {
  61542. private path;
  61543. /**
  61544. * Stores path cursor callbacks for when an onchange event is triggered
  61545. */
  61546. private _onchange;
  61547. /**
  61548. * The value of the path cursor
  61549. */
  61550. value: number;
  61551. /**
  61552. * The animation array of the path cursor
  61553. */
  61554. animations: Animation[];
  61555. /**
  61556. * Initializes the path cursor
  61557. * @param path The path to track
  61558. */
  61559. constructor(path: Path2);
  61560. /**
  61561. * Gets the cursor point on the path
  61562. * @returns A point on the path cursor at the cursor location
  61563. */
  61564. getPoint(): Vector3;
  61565. /**
  61566. * Moves the cursor ahead by the step amount
  61567. * @param step The amount to move the cursor forward
  61568. * @returns This path cursor
  61569. */
  61570. moveAhead(step?: number): PathCursor;
  61571. /**
  61572. * Moves the cursor behind by the step amount
  61573. * @param step The amount to move the cursor back
  61574. * @returns This path cursor
  61575. */
  61576. moveBack(step?: number): PathCursor;
  61577. /**
  61578. * Moves the cursor by the step amount
  61579. * If the step amount is greater than one, an exception is thrown
  61580. * @param step The amount to move the cursor
  61581. * @returns This path cursor
  61582. */
  61583. move(step: number): PathCursor;
  61584. /**
  61585. * Ensures that the value is limited between zero and one
  61586. * @returns This path cursor
  61587. */
  61588. private ensureLimits;
  61589. /**
  61590. * Runs onchange callbacks on change (used by the animation engine)
  61591. * @returns This path cursor
  61592. */
  61593. private raiseOnChange;
  61594. /**
  61595. * Executes a function on change
  61596. * @param f A path cursor onchange callback
  61597. * @returns This path cursor
  61598. */
  61599. onchange(f: (cursor: PathCursor) => void): PathCursor;
  61600. }
  61601. }
  61602. declare module "babylonjs/Legacy/legacy" {
  61603. import * as Babylon from "babylonjs/index";
  61604. export * from "babylonjs/index";
  61605. }
  61606. declare module "babylonjs/Shaders/blur.fragment" {
  61607. /** @hidden */
  61608. export var blurPixelShader: {
  61609. name: string;
  61610. shader: string;
  61611. };
  61612. }
  61613. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  61614. /** @hidden */
  61615. export var bones300Declaration: {
  61616. name: string;
  61617. shader: string;
  61618. };
  61619. }
  61620. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  61621. /** @hidden */
  61622. export var instances300Declaration: {
  61623. name: string;
  61624. shader: string;
  61625. };
  61626. }
  61627. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  61628. /** @hidden */
  61629. export var pointCloudVertexDeclaration: {
  61630. name: string;
  61631. shader: string;
  61632. };
  61633. }
  61634. // Mixins
  61635. interface Window {
  61636. mozIndexedDB: IDBFactory;
  61637. webkitIndexedDB: IDBFactory;
  61638. msIndexedDB: IDBFactory;
  61639. webkitURL: typeof URL;
  61640. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  61641. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  61642. WebGLRenderingContext: WebGLRenderingContext;
  61643. MSGesture: MSGesture;
  61644. CANNON: any;
  61645. AudioContext: AudioContext;
  61646. webkitAudioContext: AudioContext;
  61647. PointerEvent: any;
  61648. Math: Math;
  61649. Uint8Array: Uint8ArrayConstructor;
  61650. Float32Array: Float32ArrayConstructor;
  61651. mozURL: typeof URL;
  61652. msURL: typeof URL;
  61653. VRFrameData: any; // WebVR, from specs 1.1
  61654. DracoDecoderModule: any;
  61655. setImmediate(handler: (...args: any[]) => void): number;
  61656. }
  61657. interface HTMLCanvasElement {
  61658. requestPointerLock(): void;
  61659. msRequestPointerLock?(): void;
  61660. mozRequestPointerLock?(): void;
  61661. webkitRequestPointerLock?(): void;
  61662. /** Track wether a record is in progress */
  61663. isRecording: boolean;
  61664. /** Capture Stream method defined by some browsers */
  61665. captureStream(fps?: number): MediaStream;
  61666. }
  61667. interface CanvasRenderingContext2D {
  61668. msImageSmoothingEnabled: boolean;
  61669. }
  61670. interface MouseEvent {
  61671. mozMovementX: number;
  61672. mozMovementY: number;
  61673. webkitMovementX: number;
  61674. webkitMovementY: number;
  61675. msMovementX: number;
  61676. msMovementY: number;
  61677. }
  61678. interface Navigator {
  61679. mozGetVRDevices: (any: any) => any;
  61680. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61681. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61682. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  61683. webkitGetGamepads(): Gamepad[];
  61684. msGetGamepads(): Gamepad[];
  61685. webkitGamepads(): Gamepad[];
  61686. }
  61687. interface HTMLVideoElement {
  61688. mozSrcObject: any;
  61689. }
  61690. interface Math {
  61691. fround(x: number): number;
  61692. imul(a: number, b: number): number;
  61693. }
  61694. interface WebGLRenderingContext {
  61695. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  61696. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  61697. vertexAttribDivisor(index: number, divisor: number): void;
  61698. createVertexArray(): any;
  61699. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  61700. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  61701. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  61702. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  61703. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  61704. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  61705. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  61706. // Queries
  61707. createQuery(): WebGLQuery;
  61708. deleteQuery(query: WebGLQuery): void;
  61709. beginQuery(target: number, query: WebGLQuery): void;
  61710. endQuery(target: number): void;
  61711. getQueryParameter(query: WebGLQuery, pname: number): any;
  61712. getQuery(target: number, pname: number): any;
  61713. MAX_SAMPLES: number;
  61714. RGBA8: number;
  61715. READ_FRAMEBUFFER: number;
  61716. DRAW_FRAMEBUFFER: number;
  61717. UNIFORM_BUFFER: number;
  61718. HALF_FLOAT_OES: number;
  61719. RGBA16F: number;
  61720. RGBA32F: number;
  61721. R32F: number;
  61722. RG32F: number;
  61723. RGB32F: number;
  61724. R16F: number;
  61725. RG16F: number;
  61726. RGB16F: number;
  61727. RED: number;
  61728. RG: number;
  61729. R8: number;
  61730. RG8: number;
  61731. UNSIGNED_INT_24_8: number;
  61732. DEPTH24_STENCIL8: number;
  61733. /* Multiple Render Targets */
  61734. drawBuffers(buffers: number[]): void;
  61735. readBuffer(src: number): void;
  61736. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  61737. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  61738. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  61739. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  61740. // Occlusion Query
  61741. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  61742. ANY_SAMPLES_PASSED: number;
  61743. QUERY_RESULT_AVAILABLE: number;
  61744. QUERY_RESULT: number;
  61745. }
  61746. interface WebGLProgram {
  61747. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  61748. }
  61749. interface EXT_disjoint_timer_query {
  61750. QUERY_COUNTER_BITS_EXT: number;
  61751. TIME_ELAPSED_EXT: number;
  61752. TIMESTAMP_EXT: number;
  61753. GPU_DISJOINT_EXT: number;
  61754. QUERY_RESULT_EXT: number;
  61755. QUERY_RESULT_AVAILABLE_EXT: number;
  61756. queryCounterEXT(query: WebGLQuery, target: number): void;
  61757. createQueryEXT(): WebGLQuery;
  61758. beginQueryEXT(target: number, query: WebGLQuery): void;
  61759. endQueryEXT(target: number): void;
  61760. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  61761. deleteQueryEXT(query: WebGLQuery): void;
  61762. }
  61763. interface WebGLUniformLocation {
  61764. _currentState: any;
  61765. }
  61766. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  61767. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  61768. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  61769. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61770. interface WebGLRenderingContext {
  61771. readonly RASTERIZER_DISCARD: number;
  61772. readonly DEPTH_COMPONENT24: number;
  61773. readonly TEXTURE_3D: number;
  61774. readonly TEXTURE_2D_ARRAY: number;
  61775. readonly TEXTURE_COMPARE_FUNC: number;
  61776. readonly TEXTURE_COMPARE_MODE: number;
  61777. readonly COMPARE_REF_TO_TEXTURE: number;
  61778. readonly TEXTURE_WRAP_R: number;
  61779. readonly HALF_FLOAT: number;
  61780. readonly RGB8: number;
  61781. readonly RED_INTEGER: number;
  61782. readonly RG_INTEGER: number;
  61783. readonly RGB_INTEGER: number;
  61784. readonly RGBA_INTEGER: number;
  61785. readonly R8_SNORM: number;
  61786. readonly RG8_SNORM: number;
  61787. readonly RGB8_SNORM: number;
  61788. readonly RGBA8_SNORM: number;
  61789. readonly R8I: number;
  61790. readonly RG8I: number;
  61791. readonly RGB8I: number;
  61792. readonly RGBA8I: number;
  61793. readonly R8UI: number;
  61794. readonly RG8UI: number;
  61795. readonly RGB8UI: number;
  61796. readonly RGBA8UI: number;
  61797. readonly R16I: number;
  61798. readonly RG16I: number;
  61799. readonly RGB16I: number;
  61800. readonly RGBA16I: number;
  61801. readonly R16UI: number;
  61802. readonly RG16UI: number;
  61803. readonly RGB16UI: number;
  61804. readonly RGBA16UI: number;
  61805. readonly R32I: number;
  61806. readonly RG32I: number;
  61807. readonly RGB32I: number;
  61808. readonly RGBA32I: number;
  61809. readonly R32UI: number;
  61810. readonly RG32UI: number;
  61811. readonly RGB32UI: number;
  61812. readonly RGBA32UI: number;
  61813. readonly RGB10_A2UI: number;
  61814. readonly R11F_G11F_B10F: number;
  61815. readonly RGB9_E5: number;
  61816. readonly RGB10_A2: number;
  61817. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  61818. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  61819. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  61820. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  61821. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  61822. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  61823. 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;
  61824. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  61825. readonly TRANSFORM_FEEDBACK: number;
  61826. readonly INTERLEAVED_ATTRIBS: number;
  61827. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  61828. createTransformFeedback(): WebGLTransformFeedback;
  61829. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  61830. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  61831. beginTransformFeedback(primitiveMode: number): void;
  61832. endTransformFeedback(): void;
  61833. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  61834. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61835. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61836. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  61837. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  61838. }
  61839. interface ImageBitmap {
  61840. readonly width: number;
  61841. readonly height: number;
  61842. close(): void;
  61843. }
  61844. interface WebGLQuery extends WebGLObject {
  61845. }
  61846. declare var WebGLQuery: {
  61847. prototype: WebGLQuery;
  61848. new(): WebGLQuery;
  61849. };
  61850. interface WebGLSampler extends WebGLObject {
  61851. }
  61852. declare var WebGLSampler: {
  61853. prototype: WebGLSampler;
  61854. new(): WebGLSampler;
  61855. };
  61856. interface WebGLSync extends WebGLObject {
  61857. }
  61858. declare var WebGLSync: {
  61859. prototype: WebGLSync;
  61860. new(): WebGLSync;
  61861. };
  61862. interface WebGLTransformFeedback extends WebGLObject {
  61863. }
  61864. declare var WebGLTransformFeedback: {
  61865. prototype: WebGLTransformFeedback;
  61866. new(): WebGLTransformFeedback;
  61867. };
  61868. interface WebGLVertexArrayObject extends WebGLObject {
  61869. }
  61870. declare var WebGLVertexArrayObject: {
  61871. prototype: WebGLVertexArrayObject;
  61872. new(): WebGLVertexArrayObject;
  61873. };
  61874. // Type definitions for WebVR API
  61875. // Project: https://w3c.github.io/webvr/
  61876. // Definitions by: six a <https://github.com/lostfictions>
  61877. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  61878. interface VRDisplay extends EventTarget {
  61879. /**
  61880. * Dictionary of capabilities describing the VRDisplay.
  61881. */
  61882. readonly capabilities: VRDisplayCapabilities;
  61883. /**
  61884. * z-depth defining the far plane of the eye view frustum
  61885. * enables mapping of values in the render target depth
  61886. * attachment to scene coordinates. Initially set to 10000.0.
  61887. */
  61888. depthFar: number;
  61889. /**
  61890. * z-depth defining the near plane of the eye view frustum
  61891. * enables mapping of values in the render target depth
  61892. * attachment to scene coordinates. Initially set to 0.01.
  61893. */
  61894. depthNear: number;
  61895. /**
  61896. * An identifier for this distinct VRDisplay. Used as an
  61897. * association point in the Gamepad API.
  61898. */
  61899. readonly displayId: number;
  61900. /**
  61901. * A display name, a user-readable name identifying it.
  61902. */
  61903. readonly displayName: string;
  61904. readonly isConnected: boolean;
  61905. readonly isPresenting: boolean;
  61906. /**
  61907. * If this VRDisplay supports room-scale experiences, the optional
  61908. * stage attribute contains details on the room-scale parameters.
  61909. */
  61910. readonly stageParameters: VRStageParameters | null;
  61911. /**
  61912. * Passing the value returned by `requestAnimationFrame` to
  61913. * `cancelAnimationFrame` will unregister the callback.
  61914. * @param handle Define the hanle of the request to cancel
  61915. */
  61916. cancelAnimationFrame(handle: number): void;
  61917. /**
  61918. * Stops presenting to the VRDisplay.
  61919. * @returns a promise to know when it stopped
  61920. */
  61921. exitPresent(): Promise<void>;
  61922. /**
  61923. * Return the current VREyeParameters for the given eye.
  61924. * @param whichEye Define the eye we want the parameter for
  61925. * @returns the eye parameters
  61926. */
  61927. getEyeParameters(whichEye: string): VREyeParameters;
  61928. /**
  61929. * Populates the passed VRFrameData with the information required to render
  61930. * the current frame.
  61931. * @param frameData Define the data structure to populate
  61932. * @returns true if ok otherwise false
  61933. */
  61934. getFrameData(frameData: VRFrameData): boolean;
  61935. /**
  61936. * Get the layers currently being presented.
  61937. * @returns the list of VR layers
  61938. */
  61939. getLayers(): VRLayer[];
  61940. /**
  61941. * Return a VRPose containing the future predicted pose of the VRDisplay
  61942. * when the current frame will be presented. The value returned will not
  61943. * change until JavaScript has returned control to the browser.
  61944. *
  61945. * The VRPose will contain the position, orientation, velocity,
  61946. * and acceleration of each of these properties.
  61947. * @returns the pose object
  61948. */
  61949. getPose(): VRPose;
  61950. /**
  61951. * Return the current instantaneous pose of the VRDisplay, with no
  61952. * prediction applied.
  61953. * @returns the current instantaneous pose
  61954. */
  61955. getImmediatePose(): VRPose;
  61956. /**
  61957. * The callback passed to `requestAnimationFrame` will be called
  61958. * any time a new frame should be rendered. When the VRDisplay is
  61959. * presenting the callback will be called at the native refresh
  61960. * rate of the HMD. When not presenting this function acts
  61961. * identically to how window.requestAnimationFrame acts. Content should
  61962. * make no assumptions of frame rate or vsync behavior as the HMD runs
  61963. * asynchronously from other displays and at differing refresh rates.
  61964. * @param callback Define the eaction to run next frame
  61965. * @returns the request handle it
  61966. */
  61967. requestAnimationFrame(callback: FrameRequestCallback): number;
  61968. /**
  61969. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  61970. * Repeat calls while already presenting will update the VRLayers being displayed.
  61971. * @param layers Define the list of layer to present
  61972. * @returns a promise to know when the request has been fulfilled
  61973. */
  61974. requestPresent(layers: VRLayer[]): Promise<void>;
  61975. /**
  61976. * Reset the pose for this display, treating its current position and
  61977. * orientation as the "origin/zero" values. VRPose.position,
  61978. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  61979. * updated when calling resetPose(). This should be called in only
  61980. * sitting-space experiences.
  61981. */
  61982. resetPose(): void;
  61983. /**
  61984. * The VRLayer provided to the VRDisplay will be captured and presented
  61985. * in the HMD. Calling this function has the same effect on the source
  61986. * canvas as any other operation that uses its source image, and canvases
  61987. * created without preserveDrawingBuffer set to true will be cleared.
  61988. * @param pose Define the pose to submit
  61989. */
  61990. submitFrame(pose?: VRPose): void;
  61991. }
  61992. declare var VRDisplay: {
  61993. prototype: VRDisplay;
  61994. new(): VRDisplay;
  61995. };
  61996. interface VRLayer {
  61997. leftBounds?: number[] | Float32Array | null;
  61998. rightBounds?: number[] | Float32Array | null;
  61999. source?: HTMLCanvasElement | null;
  62000. }
  62001. interface VRDisplayCapabilities {
  62002. readonly canPresent: boolean;
  62003. readonly hasExternalDisplay: boolean;
  62004. readonly hasOrientation: boolean;
  62005. readonly hasPosition: boolean;
  62006. readonly maxLayers: number;
  62007. }
  62008. interface VREyeParameters {
  62009. /** @deprecated */
  62010. readonly fieldOfView: VRFieldOfView;
  62011. readonly offset: Float32Array;
  62012. readonly renderHeight: number;
  62013. readonly renderWidth: number;
  62014. }
  62015. interface VRFieldOfView {
  62016. readonly downDegrees: number;
  62017. readonly leftDegrees: number;
  62018. readonly rightDegrees: number;
  62019. readonly upDegrees: number;
  62020. }
  62021. interface VRFrameData {
  62022. readonly leftProjectionMatrix: Float32Array;
  62023. readonly leftViewMatrix: Float32Array;
  62024. readonly pose: VRPose;
  62025. readonly rightProjectionMatrix: Float32Array;
  62026. readonly rightViewMatrix: Float32Array;
  62027. readonly timestamp: number;
  62028. }
  62029. interface VRPose {
  62030. readonly angularAcceleration: Float32Array | null;
  62031. readonly angularVelocity: Float32Array | null;
  62032. readonly linearAcceleration: Float32Array | null;
  62033. readonly linearVelocity: Float32Array | null;
  62034. readonly orientation: Float32Array | null;
  62035. readonly position: Float32Array | null;
  62036. readonly timestamp: number;
  62037. }
  62038. interface VRStageParameters {
  62039. sittingToStandingTransform?: Float32Array;
  62040. sizeX?: number;
  62041. sizeY?: number;
  62042. }
  62043. interface Navigator {
  62044. getVRDisplays(): Promise<VRDisplay[]>;
  62045. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  62046. }
  62047. interface Window {
  62048. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  62049. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  62050. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  62051. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62052. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  62053. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  62054. }
  62055. interface Gamepad {
  62056. readonly displayId: number;
  62057. }
  62058. interface XRDevice {
  62059. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  62060. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  62061. }
  62062. interface XRSession {
  62063. getInputSources(): Array<any>;
  62064. baseLayer: XRWebGLLayer;
  62065. requestFrameOfReference(type: string): Promise<void>;
  62066. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  62067. end(): Promise<void>;
  62068. requestAnimationFrame: Function;
  62069. addEventListener: Function;
  62070. }
  62071. interface XRSessionCreationOptions {
  62072. outputContext?: WebGLRenderingContext | null;
  62073. immersive?: boolean;
  62074. environmentIntegration?: boolean;
  62075. }
  62076. interface XRLayer {
  62077. getViewport: Function;
  62078. framebufferWidth: number;
  62079. framebufferHeight: number;
  62080. }
  62081. interface XRView {
  62082. projectionMatrix: Float32Array;
  62083. }
  62084. interface XRFrame {
  62085. getDevicePose: Function;
  62086. getInputPose: Function;
  62087. views: Array<XRView>;
  62088. baseLayer: XRLayer;
  62089. }
  62090. interface XRFrameOfReference {
  62091. }
  62092. interface XRWebGLLayer extends XRLayer {
  62093. framebuffer: WebGLFramebuffer;
  62094. }
  62095. declare var XRWebGLLayer: {
  62096. prototype: XRWebGLLayer;
  62097. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  62098. };
  62099. declare module "babylonjs" {
  62100. export * from "babylonjs/Legacy/legacy";
  62101. }
  62102. declare module BABYLON {
  62103. /** Alias type for value that can be null */
  62104. export type Nullable<T> = T | null;
  62105. /**
  62106. * Alias type for number that are floats
  62107. * @ignorenaming
  62108. */
  62109. export type float = number;
  62110. /**
  62111. * Alias type for number that are doubles.
  62112. * @ignorenaming
  62113. */
  62114. export type double = number;
  62115. /**
  62116. * Alias type for number that are integer
  62117. * @ignorenaming
  62118. */
  62119. export type int = number;
  62120. /** Alias type for number array or Float32Array */
  62121. export type FloatArray = number[] | Float32Array;
  62122. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  62123. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  62124. /**
  62125. * Alias for types that can be used by a Buffer or VertexBuffer.
  62126. */
  62127. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  62128. /**
  62129. * Alias type for primitive types
  62130. * @ignorenaming
  62131. */
  62132. type Primitive = undefined | null | boolean | string | number | Function;
  62133. /**
  62134. * Type modifier to make all the properties of an object Readonly
  62135. */
  62136. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  62137. /**
  62138. * Type modifier to make all the properties of an object Readonly recursively
  62139. */
  62140. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  62141. /** @hidden */
  62142. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  62143. }
  62144. /** @hidden */
  62145. /** @hidden */
  62146. type DeepImmutableObject<T> = {
  62147. readonly [K in keyof T]: DeepImmutable<T[K]>;
  62148. };
  62149. }
  62150. declare module BABYLON {
  62151. /**
  62152. * Class containing a set of static utilities functions for arrays.
  62153. */
  62154. export class ArrayTools {
  62155. /**
  62156. * Returns an array of the given size filled with element built from the given constructor and the paramters
  62157. * @param size the number of element to construct and put in the array
  62158. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  62159. * @returns a new array filled with new objects
  62160. */
  62161. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  62162. }
  62163. }
  62164. declare module BABYLON {
  62165. /**
  62166. * Scalar computation library
  62167. */
  62168. export class Scalar {
  62169. /**
  62170. * Two pi constants convenient for computation.
  62171. */
  62172. static TwoPi: number;
  62173. /**
  62174. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62175. * @param a number
  62176. * @param b number
  62177. * @param epsilon (default = 1.401298E-45)
  62178. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  62179. */
  62180. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  62181. /**
  62182. * Returns a string : the upper case translation of the number i to hexadecimal.
  62183. * @param i number
  62184. * @returns the upper case translation of the number i to hexadecimal.
  62185. */
  62186. static ToHex(i: number): string;
  62187. /**
  62188. * Returns -1 if value is negative and +1 is value is positive.
  62189. * @param value the value
  62190. * @returns the value itself if it's equal to zero.
  62191. */
  62192. static Sign(value: number): number;
  62193. /**
  62194. * Returns the value itself if it's between min and max.
  62195. * Returns min if the value is lower than min.
  62196. * Returns max if the value is greater than max.
  62197. * @param value the value to clmap
  62198. * @param min the min value to clamp to (default: 0)
  62199. * @param max the max value to clamp to (default: 1)
  62200. * @returns the clamped value
  62201. */
  62202. static Clamp(value: number, min?: number, max?: number): number;
  62203. /**
  62204. * the log2 of value.
  62205. * @param value the value to compute log2 of
  62206. * @returns the log2 of value.
  62207. */
  62208. static Log2(value: number): number;
  62209. /**
  62210. * Loops the value, so that it is never larger than length and never smaller than 0.
  62211. *
  62212. * This is similar to the modulo operator but it works with floating point numbers.
  62213. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  62214. * With t = 5 and length = 2.5, the result would be 0.0.
  62215. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  62216. * @param value the value
  62217. * @param length the length
  62218. * @returns the looped value
  62219. */
  62220. static Repeat(value: number, length: number): number;
  62221. /**
  62222. * Normalize the value between 0.0 and 1.0 using min and max values
  62223. * @param value value to normalize
  62224. * @param min max to normalize between
  62225. * @param max min to normalize between
  62226. * @returns the normalized value
  62227. */
  62228. static Normalize(value: number, min: number, max: number): number;
  62229. /**
  62230. * Denormalize the value from 0.0 and 1.0 using min and max values
  62231. * @param normalized value to denormalize
  62232. * @param min max to denormalize between
  62233. * @param max min to denormalize between
  62234. * @returns the denormalized value
  62235. */
  62236. static Denormalize(normalized: number, min: number, max: number): number;
  62237. /**
  62238. * Calculates the shortest difference between two given angles given in degrees.
  62239. * @param current current angle in degrees
  62240. * @param target target angle in degrees
  62241. * @returns the delta
  62242. */
  62243. static DeltaAngle(current: number, target: number): number;
  62244. /**
  62245. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  62246. * @param tx value
  62247. * @param length length
  62248. * @returns The returned value will move back and forth between 0 and length
  62249. */
  62250. static PingPong(tx: number, length: number): number;
  62251. /**
  62252. * Interpolates between min and max with smoothing at the limits.
  62253. *
  62254. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  62255. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  62256. * @param from from
  62257. * @param to to
  62258. * @param tx value
  62259. * @returns the smooth stepped value
  62260. */
  62261. static SmoothStep(from: number, to: number, tx: number): number;
  62262. /**
  62263. * Moves a value current towards target.
  62264. *
  62265. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  62266. * Negative values of maxDelta pushes the value away from target.
  62267. * @param current current value
  62268. * @param target target value
  62269. * @param maxDelta max distance to move
  62270. * @returns resulting value
  62271. */
  62272. static MoveTowards(current: number, target: number, maxDelta: number): number;
  62273. /**
  62274. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62275. *
  62276. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  62277. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  62278. * @param current current value
  62279. * @param target target value
  62280. * @param maxDelta max distance to move
  62281. * @returns resulting angle
  62282. */
  62283. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  62284. /**
  62285. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  62286. * @param start start value
  62287. * @param end target value
  62288. * @param amount amount to lerp between
  62289. * @returns the lerped value
  62290. */
  62291. static Lerp(start: number, end: number, amount: number): number;
  62292. /**
  62293. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  62294. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  62295. * @param start start value
  62296. * @param end target value
  62297. * @param amount amount to lerp between
  62298. * @returns the lerped value
  62299. */
  62300. static LerpAngle(start: number, end: number, amount: number): number;
  62301. /**
  62302. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  62303. * @param a start value
  62304. * @param b target value
  62305. * @param value value between a and b
  62306. * @returns the inverseLerp value
  62307. */
  62308. static InverseLerp(a: number, b: number, value: number): number;
  62309. /**
  62310. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  62311. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  62312. * @param value1 spline value
  62313. * @param tangent1 spline value
  62314. * @param value2 spline value
  62315. * @param tangent2 spline value
  62316. * @param amount input value
  62317. * @returns hermite result
  62318. */
  62319. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  62320. /**
  62321. * Returns a random float number between and min and max values
  62322. * @param min min value of random
  62323. * @param max max value of random
  62324. * @returns random value
  62325. */
  62326. static RandomRange(min: number, max: number): number;
  62327. /**
  62328. * This function returns percentage of a number in a given range.
  62329. *
  62330. * RangeToPercent(40,20,60) will return 0.5 (50%)
  62331. * RangeToPercent(34,0,100) will return 0.34 (34%)
  62332. * @param number to convert to percentage
  62333. * @param min min range
  62334. * @param max max range
  62335. * @returns the percentage
  62336. */
  62337. static RangeToPercent(number: number, min: number, max: number): number;
  62338. /**
  62339. * This function returns number that corresponds to the percentage in a given range.
  62340. *
  62341. * PercentToRange(0.34,0,100) will return 34.
  62342. * @param percent to convert to number
  62343. * @param min min range
  62344. * @param max max range
  62345. * @returns the number
  62346. */
  62347. static PercentToRange(percent: number, min: number, max: number): number;
  62348. /**
  62349. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  62350. * @param angle The angle to normalize in radian.
  62351. * @return The converted angle.
  62352. */
  62353. static NormalizeRadians(angle: number): number;
  62354. }
  62355. }
  62356. declare module BABYLON {
  62357. /**
  62358. * Constant used to convert a value to gamma space
  62359. * @ignorenaming
  62360. */
  62361. export const ToGammaSpace: number;
  62362. /**
  62363. * Constant used to convert a value to linear space
  62364. * @ignorenaming
  62365. */
  62366. export const ToLinearSpace = 2.2;
  62367. /**
  62368. * Constant used to define the minimal number value in Babylon.js
  62369. * @ignorenaming
  62370. */
  62371. let Epsilon: number;
  62372. /**
  62373. * Class used to hold a RBG color
  62374. */
  62375. export class Color3 {
  62376. /**
  62377. * Defines the red component (between 0 and 1, default is 0)
  62378. */
  62379. r: number;
  62380. /**
  62381. * Defines the green component (between 0 and 1, default is 0)
  62382. */
  62383. g: number;
  62384. /**
  62385. * Defines the blue component (between 0 and 1, default is 0)
  62386. */
  62387. b: number;
  62388. /**
  62389. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  62390. * @param r defines the red component (between 0 and 1, default is 0)
  62391. * @param g defines the green component (between 0 and 1, default is 0)
  62392. * @param b defines the blue component (between 0 and 1, default is 0)
  62393. */
  62394. constructor(
  62395. /**
  62396. * Defines the red component (between 0 and 1, default is 0)
  62397. */
  62398. r?: number,
  62399. /**
  62400. * Defines the green component (between 0 and 1, default is 0)
  62401. */
  62402. g?: number,
  62403. /**
  62404. * Defines the blue component (between 0 and 1, default is 0)
  62405. */
  62406. b?: number);
  62407. /**
  62408. * Creates a string with the Color3 current values
  62409. * @returns the string representation of the Color3 object
  62410. */
  62411. toString(): string;
  62412. /**
  62413. * Returns the string "Color3"
  62414. * @returns "Color3"
  62415. */
  62416. getClassName(): string;
  62417. /**
  62418. * Compute the Color3 hash code
  62419. * @returns an unique number that can be used to hash Color3 objects
  62420. */
  62421. getHashCode(): number;
  62422. /**
  62423. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  62424. * @param array defines the array where to store the r,g,b components
  62425. * @param index defines an optional index in the target array to define where to start storing values
  62426. * @returns the current Color3 object
  62427. */
  62428. toArray(array: FloatArray, index?: number): Color3;
  62429. /**
  62430. * Returns a new Color4 object from the current Color3 and the given alpha
  62431. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  62432. * @returns a new Color4 object
  62433. */
  62434. toColor4(alpha?: number): Color4;
  62435. /**
  62436. * Returns a new array populated with 3 numeric elements : red, green and blue values
  62437. * @returns the new array
  62438. */
  62439. asArray(): number[];
  62440. /**
  62441. * Returns the luminance value
  62442. * @returns a float value
  62443. */
  62444. toLuminance(): number;
  62445. /**
  62446. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  62447. * @param otherColor defines the second operand
  62448. * @returns the new Color3 object
  62449. */
  62450. multiply(otherColor: DeepImmutable<Color3>): Color3;
  62451. /**
  62452. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  62453. * @param otherColor defines the second operand
  62454. * @param result defines the Color3 object where to store the result
  62455. * @returns the current Color3
  62456. */
  62457. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62458. /**
  62459. * Determines equality between Color3 objects
  62460. * @param otherColor defines the second operand
  62461. * @returns true if the rgb values are equal to the given ones
  62462. */
  62463. equals(otherColor: DeepImmutable<Color3>): boolean;
  62464. /**
  62465. * Determines equality between the current Color3 object and a set of r,b,g values
  62466. * @param r defines the red component to check
  62467. * @param g defines the green component to check
  62468. * @param b defines the blue component to check
  62469. * @returns true if the rgb values are equal to the given ones
  62470. */
  62471. equalsFloats(r: number, g: number, b: number): boolean;
  62472. /**
  62473. * Multiplies in place each rgb value by scale
  62474. * @param scale defines the scaling factor
  62475. * @returns the updated Color3
  62476. */
  62477. scale(scale: number): Color3;
  62478. /**
  62479. * Multiplies the rgb values by scale and stores the result into "result"
  62480. * @param scale defines the scaling factor
  62481. * @param result defines the Color3 object where to store the result
  62482. * @returns the unmodified current Color3
  62483. */
  62484. scaleToRef(scale: number, result: Color3): Color3;
  62485. /**
  62486. * Scale the current Color3 values by a factor and add the result to a given Color3
  62487. * @param scale defines the scale factor
  62488. * @param result defines color to store the result into
  62489. * @returns the unmodified current Color3
  62490. */
  62491. scaleAndAddToRef(scale: number, result: Color3): Color3;
  62492. /**
  62493. * Clamps the rgb values by the min and max values and stores the result into "result"
  62494. * @param min defines minimum clamping value (default is 0)
  62495. * @param max defines maximum clamping value (default is 1)
  62496. * @param result defines color to store the result into
  62497. * @returns the original Color3
  62498. */
  62499. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  62500. /**
  62501. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  62502. * @param otherColor defines the second operand
  62503. * @returns the new Color3
  62504. */
  62505. add(otherColor: DeepImmutable<Color3>): Color3;
  62506. /**
  62507. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  62508. * @param otherColor defines the second operand
  62509. * @param result defines Color3 object to store the result into
  62510. * @returns the unmodified current Color3
  62511. */
  62512. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62513. /**
  62514. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  62515. * @param otherColor defines the second operand
  62516. * @returns the new Color3
  62517. */
  62518. subtract(otherColor: DeepImmutable<Color3>): Color3;
  62519. /**
  62520. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  62521. * @param otherColor defines the second operand
  62522. * @param result defines Color3 object to store the result into
  62523. * @returns the unmodified current Color3
  62524. */
  62525. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  62526. /**
  62527. * Copy the current object
  62528. * @returns a new Color3 copied the current one
  62529. */
  62530. clone(): Color3;
  62531. /**
  62532. * Copies the rgb values from the source in the current Color3
  62533. * @param source defines the source Color3 object
  62534. * @returns the updated Color3 object
  62535. */
  62536. copyFrom(source: DeepImmutable<Color3>): Color3;
  62537. /**
  62538. * Updates the Color3 rgb values from the given floats
  62539. * @param r defines the red component to read from
  62540. * @param g defines the green component to read from
  62541. * @param b defines the blue component to read from
  62542. * @returns the current Color3 object
  62543. */
  62544. copyFromFloats(r: number, g: number, b: number): Color3;
  62545. /**
  62546. * Updates the Color3 rgb values from the given floats
  62547. * @param r defines the red component to read from
  62548. * @param g defines the green component to read from
  62549. * @param b defines the blue component to read from
  62550. * @returns the current Color3 object
  62551. */
  62552. set(r: number, g: number, b: number): Color3;
  62553. /**
  62554. * Compute the Color3 hexadecimal code as a string
  62555. * @returns a string containing the hexadecimal representation of the Color3 object
  62556. */
  62557. toHexString(): string;
  62558. /**
  62559. * Computes a new Color3 converted from the current one to linear space
  62560. * @returns a new Color3 object
  62561. */
  62562. toLinearSpace(): Color3;
  62563. /**
  62564. * Converts current color in rgb space to HSV values
  62565. * @returns a new color3 representing the HSV values
  62566. */
  62567. toHSV(): Color3;
  62568. /**
  62569. * Converts current color in rgb space to HSV values
  62570. * @param result defines the Color3 where to store the HSV values
  62571. */
  62572. toHSVToRef(result: Color3): void;
  62573. /**
  62574. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  62575. * @param convertedColor defines the Color3 object where to store the linear space version
  62576. * @returns the unmodified Color3
  62577. */
  62578. toLinearSpaceToRef(convertedColor: Color3): Color3;
  62579. /**
  62580. * Computes a new Color3 converted from the current one to gamma space
  62581. * @returns a new Color3 object
  62582. */
  62583. toGammaSpace(): Color3;
  62584. /**
  62585. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  62586. * @param convertedColor defines the Color3 object where to store the gamma space version
  62587. * @returns the unmodified Color3
  62588. */
  62589. toGammaSpaceToRef(convertedColor: Color3): Color3;
  62590. private static _BlackReadOnly;
  62591. /**
  62592. * Convert Hue, saturation and value to a Color3 (RGB)
  62593. * @param hue defines the hue
  62594. * @param saturation defines the saturation
  62595. * @param value defines the value
  62596. * @param result defines the Color3 where to store the RGB values
  62597. */
  62598. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  62599. /**
  62600. * Creates a new Color3 from the string containing valid hexadecimal values
  62601. * @param hex defines a string containing valid hexadecimal values
  62602. * @returns a new Color3 object
  62603. */
  62604. static FromHexString(hex: string): Color3;
  62605. /**
  62606. * Creates a new Color3 from the starting index of the given array
  62607. * @param array defines the source array
  62608. * @param offset defines an offset in the source array
  62609. * @returns a new Color3 object
  62610. */
  62611. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  62612. /**
  62613. * Creates a new Color3 from integer values (< 256)
  62614. * @param r defines the red component to read from (value between 0 and 255)
  62615. * @param g defines the green component to read from (value between 0 and 255)
  62616. * @param b defines the blue component to read from (value between 0 and 255)
  62617. * @returns a new Color3 object
  62618. */
  62619. static FromInts(r: number, g: number, b: number): Color3;
  62620. /**
  62621. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62622. * @param start defines the start Color3 value
  62623. * @param end defines the end Color3 value
  62624. * @param amount defines the gradient value between start and end
  62625. * @returns a new Color3 object
  62626. */
  62627. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  62628. /**
  62629. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  62630. * @param left defines the start value
  62631. * @param right defines the end value
  62632. * @param amount defines the gradient factor
  62633. * @param result defines the Color3 object where to store the result
  62634. */
  62635. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  62636. /**
  62637. * Returns a Color3 value containing a red color
  62638. * @returns a new Color3 object
  62639. */
  62640. static Red(): Color3;
  62641. /**
  62642. * Returns a Color3 value containing a green color
  62643. * @returns a new Color3 object
  62644. */
  62645. static Green(): Color3;
  62646. /**
  62647. * Returns a Color3 value containing a blue color
  62648. * @returns a new Color3 object
  62649. */
  62650. static Blue(): Color3;
  62651. /**
  62652. * Returns a Color3 value containing a black color
  62653. * @returns a new Color3 object
  62654. */
  62655. static Black(): Color3;
  62656. /**
  62657. * Gets a Color3 value containing a black color that must not be updated
  62658. */
  62659. static readonly BlackReadOnly: DeepImmutable<Color3>;
  62660. /**
  62661. * Returns a Color3 value containing a white color
  62662. * @returns a new Color3 object
  62663. */
  62664. static White(): Color3;
  62665. /**
  62666. * Returns a Color3 value containing a purple color
  62667. * @returns a new Color3 object
  62668. */
  62669. static Purple(): Color3;
  62670. /**
  62671. * Returns a Color3 value containing a magenta color
  62672. * @returns a new Color3 object
  62673. */
  62674. static Magenta(): Color3;
  62675. /**
  62676. * Returns a Color3 value containing a yellow color
  62677. * @returns a new Color3 object
  62678. */
  62679. static Yellow(): Color3;
  62680. /**
  62681. * Returns a Color3 value containing a gray color
  62682. * @returns a new Color3 object
  62683. */
  62684. static Gray(): Color3;
  62685. /**
  62686. * Returns a Color3 value containing a teal color
  62687. * @returns a new Color3 object
  62688. */
  62689. static Teal(): Color3;
  62690. /**
  62691. * Returns a Color3 value containing a random color
  62692. * @returns a new Color3 object
  62693. */
  62694. static Random(): Color3;
  62695. }
  62696. /**
  62697. * Class used to hold a RBGA color
  62698. */
  62699. export class Color4 {
  62700. /**
  62701. * Defines the red component (between 0 and 1, default is 0)
  62702. */
  62703. r: number;
  62704. /**
  62705. * Defines the green component (between 0 and 1, default is 0)
  62706. */
  62707. g: number;
  62708. /**
  62709. * Defines the blue component (between 0 and 1, default is 0)
  62710. */
  62711. b: number;
  62712. /**
  62713. * Defines the alpha component (between 0 and 1, default is 1)
  62714. */
  62715. a: number;
  62716. /**
  62717. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  62718. * @param r defines the red component (between 0 and 1, default is 0)
  62719. * @param g defines the green component (between 0 and 1, default is 0)
  62720. * @param b defines the blue component (between 0 and 1, default is 0)
  62721. * @param a defines the alpha component (between 0 and 1, default is 1)
  62722. */
  62723. constructor(
  62724. /**
  62725. * Defines the red component (between 0 and 1, default is 0)
  62726. */
  62727. r?: number,
  62728. /**
  62729. * Defines the green component (between 0 and 1, default is 0)
  62730. */
  62731. g?: number,
  62732. /**
  62733. * Defines the blue component (between 0 and 1, default is 0)
  62734. */
  62735. b?: number,
  62736. /**
  62737. * Defines the alpha component (between 0 and 1, default is 1)
  62738. */
  62739. a?: number);
  62740. /**
  62741. * Adds in place the given Color4 values to the current Color4 object
  62742. * @param right defines the second operand
  62743. * @returns the current updated Color4 object
  62744. */
  62745. addInPlace(right: DeepImmutable<Color4>): Color4;
  62746. /**
  62747. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  62748. * @returns the new array
  62749. */
  62750. asArray(): number[];
  62751. /**
  62752. * Stores from the starting index in the given array the Color4 successive values
  62753. * @param array defines the array where to store the r,g,b components
  62754. * @param index defines an optional index in the target array to define where to start storing values
  62755. * @returns the current Color4 object
  62756. */
  62757. toArray(array: number[], index?: number): Color4;
  62758. /**
  62759. * Determines equality between Color4 objects
  62760. * @param otherColor defines the second operand
  62761. * @returns true if the rgba values are equal to the given ones
  62762. */
  62763. equals(otherColor: DeepImmutable<Color4>): boolean;
  62764. /**
  62765. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  62766. * @param right defines the second operand
  62767. * @returns a new Color4 object
  62768. */
  62769. add(right: DeepImmutable<Color4>): Color4;
  62770. /**
  62771. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  62772. * @param right defines the second operand
  62773. * @returns a new Color4 object
  62774. */
  62775. subtract(right: DeepImmutable<Color4>): Color4;
  62776. /**
  62777. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  62778. * @param right defines the second operand
  62779. * @param result defines the Color4 object where to store the result
  62780. * @returns the current Color4 object
  62781. */
  62782. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  62783. /**
  62784. * Creates a new Color4 with the current Color4 values multiplied by scale
  62785. * @param scale defines the scaling factor to apply
  62786. * @returns a new Color4 object
  62787. */
  62788. scale(scale: number): Color4;
  62789. /**
  62790. * Multiplies the current Color4 values by scale and stores the result in "result"
  62791. * @param scale defines the scaling factor to apply
  62792. * @param result defines the Color4 object where to store the result
  62793. * @returns the current unmodified Color4
  62794. */
  62795. scaleToRef(scale: number, result: Color4): Color4;
  62796. /**
  62797. * Scale the current Color4 values by a factor and add the result to a given Color4
  62798. * @param scale defines the scale factor
  62799. * @param result defines the Color4 object where to store the result
  62800. * @returns the unmodified current Color4
  62801. */
  62802. scaleAndAddToRef(scale: number, result: Color4): Color4;
  62803. /**
  62804. * Clamps the rgb values by the min and max values and stores the result into "result"
  62805. * @param min defines minimum clamping value (default is 0)
  62806. * @param max defines maximum clamping value (default is 1)
  62807. * @param result defines color to store the result into.
  62808. * @returns the cuurent Color4
  62809. */
  62810. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  62811. /**
  62812. * Multipy an Color4 value by another and return a new Color4 object
  62813. * @param color defines the Color4 value to multiply by
  62814. * @returns a new Color4 object
  62815. */
  62816. multiply(color: Color4): Color4;
  62817. /**
  62818. * Multipy a Color4 value by another and push the result in a reference value
  62819. * @param color defines the Color4 value to multiply by
  62820. * @param result defines the Color4 to fill the result in
  62821. * @returns the result Color4
  62822. */
  62823. multiplyToRef(color: Color4, result: Color4): Color4;
  62824. /**
  62825. * Creates a string with the Color4 current values
  62826. * @returns the string representation of the Color4 object
  62827. */
  62828. toString(): string;
  62829. /**
  62830. * Returns the string "Color4"
  62831. * @returns "Color4"
  62832. */
  62833. getClassName(): string;
  62834. /**
  62835. * Compute the Color4 hash code
  62836. * @returns an unique number that can be used to hash Color4 objects
  62837. */
  62838. getHashCode(): number;
  62839. /**
  62840. * Creates a new Color4 copied from the current one
  62841. * @returns a new Color4 object
  62842. */
  62843. clone(): Color4;
  62844. /**
  62845. * Copies the given Color4 values into the current one
  62846. * @param source defines the source Color4 object
  62847. * @returns the current updated Color4 object
  62848. */
  62849. copyFrom(source: Color4): Color4;
  62850. /**
  62851. * Copies the given float values into the current one
  62852. * @param r defines the red component to read from
  62853. * @param g defines the green component to read from
  62854. * @param b defines the blue component to read from
  62855. * @param a defines the alpha component to read from
  62856. * @returns the current updated Color4 object
  62857. */
  62858. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  62859. /**
  62860. * Copies the given float values into the current one
  62861. * @param r defines the red component to read from
  62862. * @param g defines the green component to read from
  62863. * @param b defines the blue component to read from
  62864. * @param a defines the alpha component to read from
  62865. * @returns the current updated Color4 object
  62866. */
  62867. set(r: number, g: number, b: number, a: number): Color4;
  62868. /**
  62869. * Compute the Color4 hexadecimal code as a string
  62870. * @returns a string containing the hexadecimal representation of the Color4 object
  62871. */
  62872. toHexString(): string;
  62873. /**
  62874. * Computes a new Color4 converted from the current one to linear space
  62875. * @returns a new Color4 object
  62876. */
  62877. toLinearSpace(): Color4;
  62878. /**
  62879. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  62880. * @param convertedColor defines the Color4 object where to store the linear space version
  62881. * @returns the unmodified Color4
  62882. */
  62883. toLinearSpaceToRef(convertedColor: Color4): Color4;
  62884. /**
  62885. * Computes a new Color4 converted from the current one to gamma space
  62886. * @returns a new Color4 object
  62887. */
  62888. toGammaSpace(): Color4;
  62889. /**
  62890. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  62891. * @param convertedColor defines the Color4 object where to store the gamma space version
  62892. * @returns the unmodified Color4
  62893. */
  62894. toGammaSpaceToRef(convertedColor: Color4): Color4;
  62895. /**
  62896. * Creates a new Color4 from the string containing valid hexadecimal values
  62897. * @param hex defines a string containing valid hexadecimal values
  62898. * @returns a new Color4 object
  62899. */
  62900. static FromHexString(hex: string): Color4;
  62901. /**
  62902. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  62903. * @param left defines the start value
  62904. * @param right defines the end value
  62905. * @param amount defines the gradient factor
  62906. * @returns a new Color4 object
  62907. */
  62908. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  62909. /**
  62910. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  62911. * @param left defines the start value
  62912. * @param right defines the end value
  62913. * @param amount defines the gradient factor
  62914. * @param result defines the Color4 object where to store data
  62915. */
  62916. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  62917. /**
  62918. * Creates a new Color4 from a Color3 and an alpha value
  62919. * @param color3 defines the source Color3 to read from
  62920. * @param alpha defines the alpha component (1.0 by default)
  62921. * @returns a new Color4 object
  62922. */
  62923. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  62924. /**
  62925. * Creates a new Color4 from the starting index element of the given array
  62926. * @param array defines the source array to read from
  62927. * @param offset defines the offset in the source array
  62928. * @returns a new Color4 object
  62929. */
  62930. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  62931. /**
  62932. * Creates a new Color3 from integer values (< 256)
  62933. * @param r defines the red component to read from (value between 0 and 255)
  62934. * @param g defines the green component to read from (value between 0 and 255)
  62935. * @param b defines the blue component to read from (value between 0 and 255)
  62936. * @param a defines the alpha component to read from (value between 0 and 255)
  62937. * @returns a new Color3 object
  62938. */
  62939. static FromInts(r: number, g: number, b: number, a: number): Color4;
  62940. /**
  62941. * Check the content of a given array and convert it to an array containing RGBA data
  62942. * If the original array was already containing count * 4 values then it is returned directly
  62943. * @param colors defines the array to check
  62944. * @param count defines the number of RGBA data to expect
  62945. * @returns an array containing count * 4 values (RGBA)
  62946. */
  62947. static CheckColors4(colors: number[], count: number): number[];
  62948. }
  62949. /**
  62950. * Class representing a vector containing 2 coordinates
  62951. */
  62952. export class Vector2 {
  62953. /** defines the first coordinate */
  62954. x: number;
  62955. /** defines the second coordinate */
  62956. y: number;
  62957. /**
  62958. * Creates a new Vector2 from the given x and y coordinates
  62959. * @param x defines the first coordinate
  62960. * @param y defines the second coordinate
  62961. */
  62962. constructor(
  62963. /** defines the first coordinate */
  62964. x?: number,
  62965. /** defines the second coordinate */
  62966. y?: number);
  62967. /**
  62968. * Gets a string with the Vector2 coordinates
  62969. * @returns a string with the Vector2 coordinates
  62970. */
  62971. toString(): string;
  62972. /**
  62973. * Gets class name
  62974. * @returns the string "Vector2"
  62975. */
  62976. getClassName(): string;
  62977. /**
  62978. * Gets current vector hash code
  62979. * @returns the Vector2 hash code as a number
  62980. */
  62981. getHashCode(): number;
  62982. /**
  62983. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  62984. * @param array defines the source array
  62985. * @param index defines the offset in source array
  62986. * @returns the current Vector2
  62987. */
  62988. toArray(array: FloatArray, index?: number): Vector2;
  62989. /**
  62990. * Copy the current vector to an array
  62991. * @returns a new array with 2 elements: the Vector2 coordinates.
  62992. */
  62993. asArray(): number[];
  62994. /**
  62995. * Sets the Vector2 coordinates with the given Vector2 coordinates
  62996. * @param source defines the source Vector2
  62997. * @returns the current updated Vector2
  62998. */
  62999. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  63000. /**
  63001. * Sets the Vector2 coordinates with the given floats
  63002. * @param x defines the first coordinate
  63003. * @param y defines the second coordinate
  63004. * @returns the current updated Vector2
  63005. */
  63006. copyFromFloats(x: number, y: number): Vector2;
  63007. /**
  63008. * Sets the Vector2 coordinates with the given floats
  63009. * @param x defines the first coordinate
  63010. * @param y defines the second coordinate
  63011. * @returns the current updated Vector2
  63012. */
  63013. set(x: number, y: number): Vector2;
  63014. /**
  63015. * Add another vector with the current one
  63016. * @param otherVector defines the other vector
  63017. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  63018. */
  63019. add(otherVector: DeepImmutable<Vector2>): Vector2;
  63020. /**
  63021. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  63022. * @param otherVector defines the other vector
  63023. * @param result defines the target vector
  63024. * @returns the unmodified current Vector2
  63025. */
  63026. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63027. /**
  63028. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  63029. * @param otherVector defines the other vector
  63030. * @returns the current updated Vector2
  63031. */
  63032. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63033. /**
  63034. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  63035. * @param otherVector defines the other vector
  63036. * @returns a new Vector2
  63037. */
  63038. addVector3(otherVector: Vector3): Vector2;
  63039. /**
  63040. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  63041. * @param otherVector defines the other vector
  63042. * @returns a new Vector2
  63043. */
  63044. subtract(otherVector: Vector2): Vector2;
  63045. /**
  63046. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  63047. * @param otherVector defines the other vector
  63048. * @param result defines the target vector
  63049. * @returns the unmodified current Vector2
  63050. */
  63051. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63052. /**
  63053. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  63054. * @param otherVector defines the other vector
  63055. * @returns the current updated Vector2
  63056. */
  63057. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63058. /**
  63059. * Multiplies in place the current Vector2 coordinates by the given ones
  63060. * @param otherVector defines the other vector
  63061. * @returns the current updated Vector2
  63062. */
  63063. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63064. /**
  63065. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  63066. * @param otherVector defines the other vector
  63067. * @returns a new Vector2
  63068. */
  63069. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  63070. /**
  63071. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  63072. * @param otherVector defines the other vector
  63073. * @param result defines the target vector
  63074. * @returns the unmodified current Vector2
  63075. */
  63076. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63077. /**
  63078. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  63079. * @param x defines the first coordinate
  63080. * @param y defines the second coordinate
  63081. * @returns a new Vector2
  63082. */
  63083. multiplyByFloats(x: number, y: number): Vector2;
  63084. /**
  63085. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  63086. * @param otherVector defines the other vector
  63087. * @returns a new Vector2
  63088. */
  63089. divide(otherVector: Vector2): Vector2;
  63090. /**
  63091. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  63092. * @param otherVector defines the other vector
  63093. * @param result defines the target vector
  63094. * @returns the unmodified current Vector2
  63095. */
  63096. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  63097. /**
  63098. * Divides the current Vector2 coordinates by the given ones
  63099. * @param otherVector defines the other vector
  63100. * @returns the current updated Vector2
  63101. */
  63102. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  63103. /**
  63104. * Gets a new Vector2 with current Vector2 negated coordinates
  63105. * @returns a new Vector2
  63106. */
  63107. negate(): Vector2;
  63108. /**
  63109. * Multiply the Vector2 coordinates by scale
  63110. * @param scale defines the scaling factor
  63111. * @returns the current updated Vector2
  63112. */
  63113. scaleInPlace(scale: number): Vector2;
  63114. /**
  63115. * Returns a new Vector2 scaled by "scale" from the current Vector2
  63116. * @param scale defines the scaling factor
  63117. * @returns a new Vector2
  63118. */
  63119. scale(scale: number): Vector2;
  63120. /**
  63121. * Scale the current Vector2 values by a factor to a given Vector2
  63122. * @param scale defines the scale factor
  63123. * @param result defines the Vector2 object where to store the result
  63124. * @returns the unmodified current Vector2
  63125. */
  63126. scaleToRef(scale: number, result: Vector2): Vector2;
  63127. /**
  63128. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  63129. * @param scale defines the scale factor
  63130. * @param result defines the Vector2 object where to store the result
  63131. * @returns the unmodified current Vector2
  63132. */
  63133. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  63134. /**
  63135. * Gets a boolean if two vectors are equals
  63136. * @param otherVector defines the other vector
  63137. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  63138. */
  63139. equals(otherVector: DeepImmutable<Vector2>): boolean;
  63140. /**
  63141. * Gets a boolean if two vectors are equals (using an epsilon value)
  63142. * @param otherVector defines the other vector
  63143. * @param epsilon defines the minimal distance to consider equality
  63144. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  63145. */
  63146. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  63147. /**
  63148. * Gets a new Vector2 from current Vector2 floored values
  63149. * @returns a new Vector2
  63150. */
  63151. floor(): Vector2;
  63152. /**
  63153. * Gets a new Vector2 from current Vector2 floored values
  63154. * @returns a new Vector2
  63155. */
  63156. fract(): Vector2;
  63157. /**
  63158. * Gets the length of the vector
  63159. * @returns the vector length (float)
  63160. */
  63161. length(): number;
  63162. /**
  63163. * Gets the vector squared length
  63164. * @returns the vector squared length (float)
  63165. */
  63166. lengthSquared(): number;
  63167. /**
  63168. * Normalize the vector
  63169. * @returns the current updated Vector2
  63170. */
  63171. normalize(): Vector2;
  63172. /**
  63173. * Gets a new Vector2 copied from the Vector2
  63174. * @returns a new Vector2
  63175. */
  63176. clone(): Vector2;
  63177. /**
  63178. * Gets a new Vector2(0, 0)
  63179. * @returns a new Vector2
  63180. */
  63181. static Zero(): Vector2;
  63182. /**
  63183. * Gets a new Vector2(1, 1)
  63184. * @returns a new Vector2
  63185. */
  63186. static One(): Vector2;
  63187. /**
  63188. * Gets a new Vector2 set from the given index element of the given array
  63189. * @param array defines the data source
  63190. * @param offset defines the offset in the data source
  63191. * @returns a new Vector2
  63192. */
  63193. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  63194. /**
  63195. * Sets "result" from the given index element of the given array
  63196. * @param array defines the data source
  63197. * @param offset defines the offset in the data source
  63198. * @param result defines the target vector
  63199. */
  63200. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  63201. /**
  63202. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  63203. * @param value1 defines 1st point of control
  63204. * @param value2 defines 2nd point of control
  63205. * @param value3 defines 3rd point of control
  63206. * @param value4 defines 4th point of control
  63207. * @param amount defines the interpolation factor
  63208. * @returns a new Vector2
  63209. */
  63210. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  63211. /**
  63212. * 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".
  63213. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  63214. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  63215. * @param value defines the value to clamp
  63216. * @param min defines the lower limit
  63217. * @param max defines the upper limit
  63218. * @returns a new Vector2
  63219. */
  63220. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  63221. /**
  63222. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  63223. * @param value1 defines the 1st control point
  63224. * @param tangent1 defines the outgoing tangent
  63225. * @param value2 defines the 2nd control point
  63226. * @param tangent2 defines the incoming tangent
  63227. * @param amount defines the interpolation factor
  63228. * @returns a new Vector2
  63229. */
  63230. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  63231. /**
  63232. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  63233. * @param start defines the start vector
  63234. * @param end defines the end vector
  63235. * @param amount defines the interpolation factor
  63236. * @returns a new Vector2
  63237. */
  63238. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  63239. /**
  63240. * Gets the dot product of the vector "left" and the vector "right"
  63241. * @param left defines first vector
  63242. * @param right defines second vector
  63243. * @returns the dot product (float)
  63244. */
  63245. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  63246. /**
  63247. * Returns a new Vector2 equal to the normalized given vector
  63248. * @param vector defines the vector to normalize
  63249. * @returns a new Vector2
  63250. */
  63251. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  63252. /**
  63253. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  63254. * @param left defines 1st vector
  63255. * @param right defines 2nd vector
  63256. * @returns a new Vector2
  63257. */
  63258. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63259. /**
  63260. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  63261. * @param left defines 1st vector
  63262. * @param right defines 2nd vector
  63263. * @returns a new Vector2
  63264. */
  63265. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  63266. /**
  63267. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  63268. * @param vector defines the vector to transform
  63269. * @param transformation defines the matrix to apply
  63270. * @returns a new Vector2
  63271. */
  63272. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  63273. /**
  63274. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  63275. * @param vector defines the vector to transform
  63276. * @param transformation defines the matrix to apply
  63277. * @param result defines the target vector
  63278. */
  63279. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  63280. /**
  63281. * Determines if a given vector is included in a triangle
  63282. * @param p defines the vector to test
  63283. * @param p0 defines 1st triangle point
  63284. * @param p1 defines 2nd triangle point
  63285. * @param p2 defines 3rd triangle point
  63286. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  63287. */
  63288. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  63289. /**
  63290. * Gets the distance between the vectors "value1" and "value2"
  63291. * @param value1 defines first vector
  63292. * @param value2 defines second vector
  63293. * @returns the distance between vectors
  63294. */
  63295. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63296. /**
  63297. * Returns the squared distance between the vectors "value1" and "value2"
  63298. * @param value1 defines first vector
  63299. * @param value2 defines second vector
  63300. * @returns the squared distance between vectors
  63301. */
  63302. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  63303. /**
  63304. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  63305. * @param value1 defines first vector
  63306. * @param value2 defines second vector
  63307. * @returns a new Vector2
  63308. */
  63309. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  63310. /**
  63311. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  63312. * @param p defines the middle point
  63313. * @param segA defines one point of the segment
  63314. * @param segB defines the other point of the segment
  63315. * @returns the shortest distance
  63316. */
  63317. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  63318. }
  63319. /**
  63320. * Classed used to store (x,y,z) vector representation
  63321. * A Vector3 is the main object used in 3D geometry
  63322. * It can represent etiher the coordinates of a point the space, either a direction
  63323. * Reminder: js uses a left handed forward facing system
  63324. */
  63325. export class Vector3 {
  63326. /**
  63327. * Defines the first coordinates (on X axis)
  63328. */
  63329. x: number;
  63330. /**
  63331. * Defines the second coordinates (on Y axis)
  63332. */
  63333. y: number;
  63334. /**
  63335. * Defines the third coordinates (on Z axis)
  63336. */
  63337. z: number;
  63338. private static _UpReadOnly;
  63339. private static _ZeroReadOnly;
  63340. /**
  63341. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  63342. * @param x defines the first coordinates (on X axis)
  63343. * @param y defines the second coordinates (on Y axis)
  63344. * @param z defines the third coordinates (on Z axis)
  63345. */
  63346. constructor(
  63347. /**
  63348. * Defines the first coordinates (on X axis)
  63349. */
  63350. x?: number,
  63351. /**
  63352. * Defines the second coordinates (on Y axis)
  63353. */
  63354. y?: number,
  63355. /**
  63356. * Defines the third coordinates (on Z axis)
  63357. */
  63358. z?: number);
  63359. /**
  63360. * Creates a string representation of the Vector3
  63361. * @returns a string with the Vector3 coordinates.
  63362. */
  63363. toString(): string;
  63364. /**
  63365. * Gets the class name
  63366. * @returns the string "Vector3"
  63367. */
  63368. getClassName(): string;
  63369. /**
  63370. * Creates the Vector3 hash code
  63371. * @returns a number which tends to be unique between Vector3 instances
  63372. */
  63373. getHashCode(): number;
  63374. /**
  63375. * Creates an array containing three elements : the coordinates of the Vector3
  63376. * @returns a new array of numbers
  63377. */
  63378. asArray(): number[];
  63379. /**
  63380. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  63381. * @param array defines the destination array
  63382. * @param index defines the offset in the destination array
  63383. * @returns the current Vector3
  63384. */
  63385. toArray(array: FloatArray, index?: number): Vector3;
  63386. /**
  63387. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  63388. * @returns a new Quaternion object, computed from the Vector3 coordinates
  63389. */
  63390. toQuaternion(): Quaternion;
  63391. /**
  63392. * Adds the given vector to the current Vector3
  63393. * @param otherVector defines the second operand
  63394. * @returns the current updated Vector3
  63395. */
  63396. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63397. /**
  63398. * Adds the given coordinates to the current Vector3
  63399. * @param x defines the x coordinate of the operand
  63400. * @param y defines the y coordinate of the operand
  63401. * @param z defines the z coordinate of the operand
  63402. * @returns the current updated Vector3
  63403. */
  63404. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63405. /**
  63406. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  63407. * @param otherVector defines the second operand
  63408. * @returns the resulting Vector3
  63409. */
  63410. add(otherVector: DeepImmutable<Vector3>): Vector3;
  63411. /**
  63412. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  63413. * @param otherVector defines the second operand
  63414. * @param result defines the Vector3 object where to store the result
  63415. * @returns the current Vector3
  63416. */
  63417. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63418. /**
  63419. * Subtract the given vector from the current Vector3
  63420. * @param otherVector defines the second operand
  63421. * @returns the current updated Vector3
  63422. */
  63423. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63424. /**
  63425. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  63426. * @param otherVector defines the second operand
  63427. * @returns the resulting Vector3
  63428. */
  63429. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  63430. /**
  63431. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  63432. * @param otherVector defines the second operand
  63433. * @param result defines the Vector3 object where to store the result
  63434. * @returns the current Vector3
  63435. */
  63436. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63437. /**
  63438. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  63439. * @param x defines the x coordinate of the operand
  63440. * @param y defines the y coordinate of the operand
  63441. * @param z defines the z coordinate of the operand
  63442. * @returns the resulting Vector3
  63443. */
  63444. subtractFromFloats(x: number, y: number, z: number): Vector3;
  63445. /**
  63446. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  63447. * @param x defines the x coordinate of the operand
  63448. * @param y defines the y coordinate of the operand
  63449. * @param z defines the z coordinate of the operand
  63450. * @param result defines the Vector3 object where to store the result
  63451. * @returns the current Vector3
  63452. */
  63453. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  63454. /**
  63455. * Gets a new Vector3 set with the current Vector3 negated coordinates
  63456. * @returns a new Vector3
  63457. */
  63458. negate(): Vector3;
  63459. /**
  63460. * Multiplies the Vector3 coordinates by the float "scale"
  63461. * @param scale defines the multiplier factor
  63462. * @returns the current updated Vector3
  63463. */
  63464. scaleInPlace(scale: number): Vector3;
  63465. /**
  63466. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  63467. * @param scale defines the multiplier factor
  63468. * @returns a new Vector3
  63469. */
  63470. scale(scale: number): Vector3;
  63471. /**
  63472. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  63473. * @param scale defines the multiplier factor
  63474. * @param result defines the Vector3 object where to store the result
  63475. * @returns the current Vector3
  63476. */
  63477. scaleToRef(scale: number, result: Vector3): Vector3;
  63478. /**
  63479. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  63480. * @param scale defines the scale factor
  63481. * @param result defines the Vector3 object where to store the result
  63482. * @returns the unmodified current Vector3
  63483. */
  63484. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  63485. /**
  63486. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  63487. * @param otherVector defines the second operand
  63488. * @returns true if both vectors are equals
  63489. */
  63490. equals(otherVector: DeepImmutable<Vector3>): boolean;
  63491. /**
  63492. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  63493. * @param otherVector defines the second operand
  63494. * @param epsilon defines the minimal distance to define values as equals
  63495. * @returns true if both vectors are distant less than epsilon
  63496. */
  63497. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  63498. /**
  63499. * Returns true if the current Vector3 coordinates equals the given floats
  63500. * @param x defines the x coordinate of the operand
  63501. * @param y defines the y coordinate of the operand
  63502. * @param z defines the z coordinate of the operand
  63503. * @returns true if both vectors are equals
  63504. */
  63505. equalsToFloats(x: number, y: number, z: number): boolean;
  63506. /**
  63507. * Multiplies the current Vector3 coordinates by the given ones
  63508. * @param otherVector defines the second operand
  63509. * @returns the current updated Vector3
  63510. */
  63511. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  63512. /**
  63513. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  63514. * @param otherVector defines the second operand
  63515. * @returns the new Vector3
  63516. */
  63517. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  63518. /**
  63519. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  63520. * @param otherVector defines the second operand
  63521. * @param result defines the Vector3 object where to store the result
  63522. * @returns the current Vector3
  63523. */
  63524. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63525. /**
  63526. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  63527. * @param x defines the x coordinate of the operand
  63528. * @param y defines the y coordinate of the operand
  63529. * @param z defines the z coordinate of the operand
  63530. * @returns the new Vector3
  63531. */
  63532. multiplyByFloats(x: number, y: number, z: number): Vector3;
  63533. /**
  63534. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  63535. * @param otherVector defines the second operand
  63536. * @returns the new Vector3
  63537. */
  63538. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  63539. /**
  63540. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  63541. * @param otherVector defines the second operand
  63542. * @param result defines the Vector3 object where to store the result
  63543. * @returns the current Vector3
  63544. */
  63545. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  63546. /**
  63547. * Divides the current Vector3 coordinates by the given ones.
  63548. * @param otherVector defines the second operand
  63549. * @returns the current updated Vector3
  63550. */
  63551. divideInPlace(otherVector: Vector3): Vector3;
  63552. /**
  63553. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  63554. * @param other defines the second operand
  63555. * @returns the current updated Vector3
  63556. */
  63557. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63558. /**
  63559. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  63560. * @param other defines the second operand
  63561. * @returns the current updated Vector3
  63562. */
  63563. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  63564. /**
  63565. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  63566. * @param x defines the x coordinate of the operand
  63567. * @param y defines the y coordinate of the operand
  63568. * @param z defines the z coordinate of the operand
  63569. * @returns the current updated Vector3
  63570. */
  63571. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63572. /**
  63573. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  63574. * @param x defines the x coordinate of the operand
  63575. * @param y defines the y coordinate of the operand
  63576. * @param z defines the z coordinate of the operand
  63577. * @returns the current updated Vector3
  63578. */
  63579. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  63580. /**
  63581. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  63582. * Check if is non uniform within a certain amount of decimal places to account for this
  63583. * @param epsilon the amount the values can differ
  63584. * @returns if the the vector is non uniform to a certain number of decimal places
  63585. */
  63586. isNonUniformWithinEpsilon(epsilon: number): boolean;
  63587. /**
  63588. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  63589. */
  63590. readonly isNonUniform: boolean;
  63591. /**
  63592. * Gets a new Vector3 from current Vector3 floored values
  63593. * @returns a new Vector3
  63594. */
  63595. floor(): Vector3;
  63596. /**
  63597. * Gets a new Vector3 from current Vector3 floored values
  63598. * @returns a new Vector3
  63599. */
  63600. fract(): Vector3;
  63601. /**
  63602. * Gets the length of the Vector3
  63603. * @returns the length of the Vecto3
  63604. */
  63605. length(): number;
  63606. /**
  63607. * Gets the squared length of the Vector3
  63608. * @returns squared length of the Vector3
  63609. */
  63610. lengthSquared(): number;
  63611. /**
  63612. * Normalize the current Vector3.
  63613. * Please note that this is an in place operation.
  63614. * @returns the current updated Vector3
  63615. */
  63616. normalize(): Vector3;
  63617. /**
  63618. * Reorders the x y z properties of the vector in place
  63619. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  63620. * @returns the current updated vector
  63621. */
  63622. reorderInPlace(order: string): this;
  63623. /**
  63624. * Rotates the vector around 0,0,0 by a quaternion
  63625. * @param quaternion the rotation quaternion
  63626. * @param result vector to store the result
  63627. * @returns the resulting vector
  63628. */
  63629. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  63630. /**
  63631. * Rotates a vector around a given point
  63632. * @param quaternion the rotation quaternion
  63633. * @param point the point to rotate around
  63634. * @param result vector to store the result
  63635. * @returns the resulting vector
  63636. */
  63637. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  63638. /**
  63639. * Normalize the current Vector3 with the given input length.
  63640. * Please note that this is an in place operation.
  63641. * @param len the length of the vector
  63642. * @returns the current updated Vector3
  63643. */
  63644. normalizeFromLength(len: number): Vector3;
  63645. /**
  63646. * Normalize the current Vector3 to a new vector
  63647. * @returns the new Vector3
  63648. */
  63649. normalizeToNew(): Vector3;
  63650. /**
  63651. * Normalize the current Vector3 to the reference
  63652. * @param reference define the Vector3 to update
  63653. * @returns the updated Vector3
  63654. */
  63655. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  63656. /**
  63657. * Creates a new Vector3 copied from the current Vector3
  63658. * @returns the new Vector3
  63659. */
  63660. clone(): Vector3;
  63661. /**
  63662. * Copies the given vector coordinates to the current Vector3 ones
  63663. * @param source defines the source Vector3
  63664. * @returns the current updated Vector3
  63665. */
  63666. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  63667. /**
  63668. * Copies the given floats to the current Vector3 coordinates
  63669. * @param x defines the x coordinate of the operand
  63670. * @param y defines the y coordinate of the operand
  63671. * @param z defines the z coordinate of the operand
  63672. * @returns the current updated Vector3
  63673. */
  63674. copyFromFloats(x: number, y: number, z: number): Vector3;
  63675. /**
  63676. * Copies the given floats to the current Vector3 coordinates
  63677. * @param x defines the x coordinate of the operand
  63678. * @param y defines the y coordinate of the operand
  63679. * @param z defines the z coordinate of the operand
  63680. * @returns the current updated Vector3
  63681. */
  63682. set(x: number, y: number, z: number): Vector3;
  63683. /**
  63684. * Copies the given float to the current Vector3 coordinates
  63685. * @param v defines the x, y and z coordinates of the operand
  63686. * @returns the current updated Vector3
  63687. */
  63688. setAll(v: number): Vector3;
  63689. /**
  63690. * Get the clip factor between two vectors
  63691. * @param vector0 defines the first operand
  63692. * @param vector1 defines the second operand
  63693. * @param axis defines the axis to use
  63694. * @param size defines the size along the axis
  63695. * @returns the clip factor
  63696. */
  63697. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  63698. /**
  63699. * Get angle between two vectors
  63700. * @param vector0 angle between vector0 and vector1
  63701. * @param vector1 angle between vector0 and vector1
  63702. * @param normal direction of the normal
  63703. * @return the angle between vector0 and vector1
  63704. */
  63705. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  63706. /**
  63707. * Returns a new Vector3 set from the index "offset" of the given array
  63708. * @param array defines the source array
  63709. * @param offset defines the offset in the source array
  63710. * @returns the new Vector3
  63711. */
  63712. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  63713. /**
  63714. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  63715. * This function is deprecated. Use FromArray instead
  63716. * @param array defines the source array
  63717. * @param offset defines the offset in the source array
  63718. * @returns the new Vector3
  63719. */
  63720. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  63721. /**
  63722. * Sets the given vector "result" with the element values from the index "offset" of the given array
  63723. * @param array defines the source array
  63724. * @param offset defines the offset in the source array
  63725. * @param result defines the Vector3 where to store the result
  63726. */
  63727. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  63728. /**
  63729. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  63730. * This function is deprecated. Use FromArrayToRef instead.
  63731. * @param array defines the source array
  63732. * @param offset defines the offset in the source array
  63733. * @param result defines the Vector3 where to store the result
  63734. */
  63735. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  63736. /**
  63737. * Sets the given vector "result" with the given floats.
  63738. * @param x defines the x coordinate of the source
  63739. * @param y defines the y coordinate of the source
  63740. * @param z defines the z coordinate of the source
  63741. * @param result defines the Vector3 where to store the result
  63742. */
  63743. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  63744. /**
  63745. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  63746. * @returns a new empty Vector3
  63747. */
  63748. static Zero(): Vector3;
  63749. /**
  63750. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  63751. * @returns a new unit Vector3
  63752. */
  63753. static One(): Vector3;
  63754. /**
  63755. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  63756. * @returns a new up Vector3
  63757. */
  63758. static Up(): Vector3;
  63759. /**
  63760. * Gets a up Vector3 that must not be updated
  63761. */
  63762. static readonly UpReadOnly: DeepImmutable<Vector3>;
  63763. /**
  63764. * Gets a zero Vector3 that must not be updated
  63765. */
  63766. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  63767. /**
  63768. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  63769. * @returns a new down Vector3
  63770. */
  63771. static Down(): Vector3;
  63772. /**
  63773. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  63774. * @returns a new forward Vector3
  63775. */
  63776. static Forward(): Vector3;
  63777. /**
  63778. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  63779. * @returns a new forward Vector3
  63780. */
  63781. static Backward(): Vector3;
  63782. /**
  63783. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  63784. * @returns a new right Vector3
  63785. */
  63786. static Right(): Vector3;
  63787. /**
  63788. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  63789. * @returns a new left Vector3
  63790. */
  63791. static Left(): Vector3;
  63792. /**
  63793. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  63794. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  63795. * @param vector defines the Vector3 to transform
  63796. * @param transformation defines the transformation matrix
  63797. * @returns the transformed Vector3
  63798. */
  63799. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  63800. /**
  63801. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  63802. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  63803. * @param vector defines the Vector3 to transform
  63804. * @param transformation defines the transformation matrix
  63805. * @param result defines the Vector3 where to store the result
  63806. */
  63807. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  63808. /**
  63809. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  63810. * This method computes tranformed coordinates only, not transformed direction vectors
  63811. * @param x define the x coordinate of the source vector
  63812. * @param y define the y coordinate of the source vector
  63813. * @param z define the z coordinate of the source vector
  63814. * @param transformation defines the transformation matrix
  63815. * @param result defines the Vector3 where to store the result
  63816. */
  63817. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  63818. /**
  63819. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  63820. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  63821. * @param vector defines the Vector3 to transform
  63822. * @param transformation defines the transformation matrix
  63823. * @returns the new Vector3
  63824. */
  63825. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  63826. /**
  63827. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  63828. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  63829. * @param vector defines the Vector3 to transform
  63830. * @param transformation defines the transformation matrix
  63831. * @param result defines the Vector3 where to store the result
  63832. */
  63833. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  63834. /**
  63835. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  63836. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  63837. * @param x define the x coordinate of the source vector
  63838. * @param y define the y coordinate of the source vector
  63839. * @param z define the z coordinate of the source vector
  63840. * @param transformation defines the transformation matrix
  63841. * @param result defines the Vector3 where to store the result
  63842. */
  63843. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  63844. /**
  63845. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  63846. * @param value1 defines the first control point
  63847. * @param value2 defines the second control point
  63848. * @param value3 defines the third control point
  63849. * @param value4 defines the fourth control point
  63850. * @param amount defines the amount on the spline to use
  63851. * @returns the new Vector3
  63852. */
  63853. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  63854. /**
  63855. * 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"
  63856. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  63857. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  63858. * @param value defines the current value
  63859. * @param min defines the lower range value
  63860. * @param max defines the upper range value
  63861. * @returns the new Vector3
  63862. */
  63863. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  63864. /**
  63865. * 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"
  63866. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  63867. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  63868. * @param value defines the current value
  63869. * @param min defines the lower range value
  63870. * @param max defines the upper range value
  63871. * @param result defines the Vector3 where to store the result
  63872. */
  63873. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  63874. /**
  63875. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  63876. * @param value1 defines the first control point
  63877. * @param tangent1 defines the first tangent vector
  63878. * @param value2 defines the second control point
  63879. * @param tangent2 defines the second tangent vector
  63880. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  63881. * @returns the new Vector3
  63882. */
  63883. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  63884. /**
  63885. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  63886. * @param start defines the start value
  63887. * @param end defines the end value
  63888. * @param amount max defines amount between both (between 0 and 1)
  63889. * @returns the new Vector3
  63890. */
  63891. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  63892. /**
  63893. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  63894. * @param start defines the start value
  63895. * @param end defines the end value
  63896. * @param amount max defines amount between both (between 0 and 1)
  63897. * @param result defines the Vector3 where to store the result
  63898. */
  63899. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  63900. /**
  63901. * Returns the dot product (float) between the vectors "left" and "right"
  63902. * @param left defines the left operand
  63903. * @param right defines the right operand
  63904. * @returns the dot product
  63905. */
  63906. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  63907. /**
  63908. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  63909. * The cross product is then orthogonal to both "left" and "right"
  63910. * @param left defines the left operand
  63911. * @param right defines the right operand
  63912. * @returns the cross product
  63913. */
  63914. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  63915. /**
  63916. * Sets the given vector "result" with the cross product of "left" and "right"
  63917. * The cross product is then orthogonal to both "left" and "right"
  63918. * @param left defines the left operand
  63919. * @param right defines the right operand
  63920. * @param result defines the Vector3 where to store the result
  63921. */
  63922. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  63923. /**
  63924. * Returns a new Vector3 as the normalization of the given vector
  63925. * @param vector defines the Vector3 to normalize
  63926. * @returns the new Vector3
  63927. */
  63928. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  63929. /**
  63930. * Sets the given vector "result" with the normalization of the given first vector
  63931. * @param vector defines the Vector3 to normalize
  63932. * @param result defines the Vector3 where to store the result
  63933. */
  63934. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  63935. /**
  63936. * Project a Vector3 onto screen space
  63937. * @param vector defines the Vector3 to project
  63938. * @param world defines the world matrix to use
  63939. * @param transform defines the transform (view x projection) matrix to use
  63940. * @param viewport defines the screen viewport to use
  63941. * @returns the new Vector3
  63942. */
  63943. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  63944. /** @hidden */
  63945. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  63946. /**
  63947. * Unproject from screen space to object space
  63948. * @param source defines the screen space Vector3 to use
  63949. * @param viewportWidth defines the current width of the viewport
  63950. * @param viewportHeight defines the current height of the viewport
  63951. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  63952. * @param transform defines the transform (view x projection) matrix to use
  63953. * @returns the new Vector3
  63954. */
  63955. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  63956. /**
  63957. * Unproject from screen space to object space
  63958. * @param source defines the screen space Vector3 to use
  63959. * @param viewportWidth defines the current width of the viewport
  63960. * @param viewportHeight defines the current height of the viewport
  63961. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  63962. * @param view defines the view matrix to use
  63963. * @param projection defines the projection matrix to use
  63964. * @returns the new Vector3
  63965. */
  63966. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  63967. /**
  63968. * Unproject from screen space to object space
  63969. * @param source defines the screen space Vector3 to use
  63970. * @param viewportWidth defines the current width of the viewport
  63971. * @param viewportHeight defines the current height of the viewport
  63972. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  63973. * @param view defines the view matrix to use
  63974. * @param projection defines the projection matrix to use
  63975. * @param result defines the Vector3 where to store the result
  63976. */
  63977. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  63978. /**
  63979. * Unproject from screen space to object space
  63980. * @param sourceX defines the screen space x coordinate to use
  63981. * @param sourceY defines the screen space y coordinate to use
  63982. * @param sourceZ defines the screen space z coordinate to use
  63983. * @param viewportWidth defines the current width of the viewport
  63984. * @param viewportHeight defines the current height of the viewport
  63985. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  63986. * @param view defines the view matrix to use
  63987. * @param projection defines the projection matrix to use
  63988. * @param result defines the Vector3 where to store the result
  63989. */
  63990. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  63991. /**
  63992. * Gets the minimal coordinate values between two Vector3
  63993. * @param left defines the first operand
  63994. * @param right defines the second operand
  63995. * @returns the new Vector3
  63996. */
  63997. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  63998. /**
  63999. * Gets the maximal coordinate values between two Vector3
  64000. * @param left defines the first operand
  64001. * @param right defines the second operand
  64002. * @returns the new Vector3
  64003. */
  64004. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  64005. /**
  64006. * Returns the distance between the vectors "value1" and "value2"
  64007. * @param value1 defines the first operand
  64008. * @param value2 defines the second operand
  64009. * @returns the distance
  64010. */
  64011. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64012. /**
  64013. * Returns the squared distance between the vectors "value1" and "value2"
  64014. * @param value1 defines the first operand
  64015. * @param value2 defines the second operand
  64016. * @returns the squared distance
  64017. */
  64018. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  64019. /**
  64020. * Returns a new Vector3 located at the center between "value1" and "value2"
  64021. * @param value1 defines the first operand
  64022. * @param value2 defines the second operand
  64023. * @returns the new Vector3
  64024. */
  64025. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  64026. /**
  64027. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  64028. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  64029. * to something in order to rotate it from its local system to the given target system
  64030. * Note: axis1, axis2 and axis3 are normalized during this operation
  64031. * @param axis1 defines the first axis
  64032. * @param axis2 defines the second axis
  64033. * @param axis3 defines the third axis
  64034. * @returns a new Vector3
  64035. */
  64036. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  64037. /**
  64038. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  64039. * @param axis1 defines the first axis
  64040. * @param axis2 defines the second axis
  64041. * @param axis3 defines the third axis
  64042. * @param ref defines the Vector3 where to store the result
  64043. */
  64044. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  64045. }
  64046. /**
  64047. * Vector4 class created for EulerAngle class conversion to Quaternion
  64048. */
  64049. export class Vector4 {
  64050. /** x value of the vector */
  64051. x: number;
  64052. /** y value of the vector */
  64053. y: number;
  64054. /** z value of the vector */
  64055. z: number;
  64056. /** w value of the vector */
  64057. w: number;
  64058. /**
  64059. * Creates a Vector4 object from the given floats.
  64060. * @param x x value of the vector
  64061. * @param y y value of the vector
  64062. * @param z z value of the vector
  64063. * @param w w value of the vector
  64064. */
  64065. constructor(
  64066. /** x value of the vector */
  64067. x: number,
  64068. /** y value of the vector */
  64069. y: number,
  64070. /** z value of the vector */
  64071. z: number,
  64072. /** w value of the vector */
  64073. w: number);
  64074. /**
  64075. * Returns the string with the Vector4 coordinates.
  64076. * @returns a string containing all the vector values
  64077. */
  64078. toString(): string;
  64079. /**
  64080. * Returns the string "Vector4".
  64081. * @returns "Vector4"
  64082. */
  64083. getClassName(): string;
  64084. /**
  64085. * Returns the Vector4 hash code.
  64086. * @returns a unique hash code
  64087. */
  64088. getHashCode(): number;
  64089. /**
  64090. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  64091. * @returns the resulting array
  64092. */
  64093. asArray(): number[];
  64094. /**
  64095. * Populates the given array from the given index with the Vector4 coordinates.
  64096. * @param array array to populate
  64097. * @param index index of the array to start at (default: 0)
  64098. * @returns the Vector4.
  64099. */
  64100. toArray(array: FloatArray, index?: number): Vector4;
  64101. /**
  64102. * Adds the given vector to the current Vector4.
  64103. * @param otherVector the vector to add
  64104. * @returns the updated Vector4.
  64105. */
  64106. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64107. /**
  64108. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  64109. * @param otherVector the vector to add
  64110. * @returns the resulting vector
  64111. */
  64112. add(otherVector: DeepImmutable<Vector4>): Vector4;
  64113. /**
  64114. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  64115. * @param otherVector the vector to add
  64116. * @param result the vector to store the result
  64117. * @returns the current Vector4.
  64118. */
  64119. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64120. /**
  64121. * Subtract in place the given vector from the current Vector4.
  64122. * @param otherVector the vector to subtract
  64123. * @returns the updated Vector4.
  64124. */
  64125. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64126. /**
  64127. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  64128. * @param otherVector the vector to add
  64129. * @returns the new vector with the result
  64130. */
  64131. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  64132. /**
  64133. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  64134. * @param otherVector the vector to subtract
  64135. * @param result the vector to store the result
  64136. * @returns the current Vector4.
  64137. */
  64138. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64139. /**
  64140. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64141. */
  64142. /**
  64143. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64144. * @param x value to subtract
  64145. * @param y value to subtract
  64146. * @param z value to subtract
  64147. * @param w value to subtract
  64148. * @returns new vector containing the result
  64149. */
  64150. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64151. /**
  64152. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  64153. * @param x value to subtract
  64154. * @param y value to subtract
  64155. * @param z value to subtract
  64156. * @param w value to subtract
  64157. * @param result the vector to store the result in
  64158. * @returns the current Vector4.
  64159. */
  64160. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  64161. /**
  64162. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  64163. * @returns a new vector with the negated values
  64164. */
  64165. negate(): Vector4;
  64166. /**
  64167. * Multiplies the current Vector4 coordinates by scale (float).
  64168. * @param scale the number to scale with
  64169. * @returns the updated Vector4.
  64170. */
  64171. scaleInPlace(scale: number): Vector4;
  64172. /**
  64173. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  64174. * @param scale the number to scale with
  64175. * @returns a new vector with the result
  64176. */
  64177. scale(scale: number): Vector4;
  64178. /**
  64179. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  64180. * @param scale the number to scale with
  64181. * @param result a vector to store the result in
  64182. * @returns the current Vector4.
  64183. */
  64184. scaleToRef(scale: number, result: Vector4): Vector4;
  64185. /**
  64186. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  64187. * @param scale defines the scale factor
  64188. * @param result defines the Vector4 object where to store the result
  64189. * @returns the unmodified current Vector4
  64190. */
  64191. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  64192. /**
  64193. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  64194. * @param otherVector the vector to compare against
  64195. * @returns true if they are equal
  64196. */
  64197. equals(otherVector: DeepImmutable<Vector4>): boolean;
  64198. /**
  64199. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  64200. * @param otherVector vector to compare against
  64201. * @param epsilon (Default: very small number)
  64202. * @returns true if they are equal
  64203. */
  64204. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  64205. /**
  64206. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  64207. * @param x x value to compare against
  64208. * @param y y value to compare against
  64209. * @param z z value to compare against
  64210. * @param w w value to compare against
  64211. * @returns true if equal
  64212. */
  64213. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  64214. /**
  64215. * Multiplies in place the current Vector4 by the given one.
  64216. * @param otherVector vector to multiple with
  64217. * @returns the updated Vector4.
  64218. */
  64219. multiplyInPlace(otherVector: Vector4): Vector4;
  64220. /**
  64221. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  64222. * @param otherVector vector to multiple with
  64223. * @returns resulting new vector
  64224. */
  64225. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  64226. /**
  64227. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  64228. * @param otherVector vector to multiple with
  64229. * @param result vector to store the result
  64230. * @returns the current Vector4.
  64231. */
  64232. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64233. /**
  64234. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  64235. * @param x x value multiply with
  64236. * @param y y value multiply with
  64237. * @param z z value multiply with
  64238. * @param w w value multiply with
  64239. * @returns resulting new vector
  64240. */
  64241. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  64242. /**
  64243. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  64244. * @param otherVector vector to devide with
  64245. * @returns resulting new vector
  64246. */
  64247. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  64248. /**
  64249. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  64250. * @param otherVector vector to devide with
  64251. * @param result vector to store the result
  64252. * @returns the current Vector4.
  64253. */
  64254. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  64255. /**
  64256. * Divides the current Vector3 coordinates by the given ones.
  64257. * @param otherVector vector to devide with
  64258. * @returns the updated Vector3.
  64259. */
  64260. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  64261. /**
  64262. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  64263. * @param other defines the second operand
  64264. * @returns the current updated Vector4
  64265. */
  64266. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64267. /**
  64268. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  64269. * @param other defines the second operand
  64270. * @returns the current updated Vector4
  64271. */
  64272. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  64273. /**
  64274. * Gets a new Vector4 from current Vector4 floored values
  64275. * @returns a new Vector4
  64276. */
  64277. floor(): Vector4;
  64278. /**
  64279. * Gets a new Vector4 from current Vector3 floored values
  64280. * @returns a new Vector4
  64281. */
  64282. fract(): Vector4;
  64283. /**
  64284. * Returns the Vector4 length (float).
  64285. * @returns the length
  64286. */
  64287. length(): number;
  64288. /**
  64289. * Returns the Vector4 squared length (float).
  64290. * @returns the length squared
  64291. */
  64292. lengthSquared(): number;
  64293. /**
  64294. * Normalizes in place the Vector4.
  64295. * @returns the updated Vector4.
  64296. */
  64297. normalize(): Vector4;
  64298. /**
  64299. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  64300. * @returns this converted to a new vector3
  64301. */
  64302. toVector3(): Vector3;
  64303. /**
  64304. * Returns a new Vector4 copied from the current one.
  64305. * @returns the new cloned vector
  64306. */
  64307. clone(): Vector4;
  64308. /**
  64309. * Updates the current Vector4 with the given one coordinates.
  64310. * @param source the source vector to copy from
  64311. * @returns the updated Vector4.
  64312. */
  64313. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  64314. /**
  64315. * Updates the current Vector4 coordinates with the given floats.
  64316. * @param x float to copy from
  64317. * @param y float to copy from
  64318. * @param z float to copy from
  64319. * @param w float to copy from
  64320. * @returns the updated Vector4.
  64321. */
  64322. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  64323. /**
  64324. * Updates the current Vector4 coordinates with the given floats.
  64325. * @param x float to set from
  64326. * @param y float to set from
  64327. * @param z float to set from
  64328. * @param w float to set from
  64329. * @returns the updated Vector4.
  64330. */
  64331. set(x: number, y: number, z: number, w: number): Vector4;
  64332. /**
  64333. * Copies the given float to the current Vector3 coordinates
  64334. * @param v defines the x, y, z and w coordinates of the operand
  64335. * @returns the current updated Vector3
  64336. */
  64337. setAll(v: number): Vector4;
  64338. /**
  64339. * Returns a new Vector4 set from the starting index of the given array.
  64340. * @param array the array to pull values from
  64341. * @param offset the offset into the array to start at
  64342. * @returns the new vector
  64343. */
  64344. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  64345. /**
  64346. * Updates the given vector "result" from the starting index of the given array.
  64347. * @param array the array to pull values from
  64348. * @param offset the offset into the array to start at
  64349. * @param result the vector to store the result in
  64350. */
  64351. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  64352. /**
  64353. * Updates the given vector "result" from the starting index of the given Float32Array.
  64354. * @param array the array to pull values from
  64355. * @param offset the offset into the array to start at
  64356. * @param result the vector to store the result in
  64357. */
  64358. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  64359. /**
  64360. * Updates the given vector "result" coordinates from the given floats.
  64361. * @param x float to set from
  64362. * @param y float to set from
  64363. * @param z float to set from
  64364. * @param w float to set from
  64365. * @param result the vector to the floats in
  64366. */
  64367. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  64368. /**
  64369. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  64370. * @returns the new vector
  64371. */
  64372. static Zero(): Vector4;
  64373. /**
  64374. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  64375. * @returns the new vector
  64376. */
  64377. static One(): Vector4;
  64378. /**
  64379. * Returns a new normalized Vector4 from the given one.
  64380. * @param vector the vector to normalize
  64381. * @returns the vector
  64382. */
  64383. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  64384. /**
  64385. * Updates the given vector "result" from the normalization of the given one.
  64386. * @param vector the vector to normalize
  64387. * @param result the vector to store the result in
  64388. */
  64389. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  64390. /**
  64391. * Returns a vector with the minimum values from the left and right vectors
  64392. * @param left left vector to minimize
  64393. * @param right right vector to minimize
  64394. * @returns a new vector with the minimum of the left and right vector values
  64395. */
  64396. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64397. /**
  64398. * Returns a vector with the maximum values from the left and right vectors
  64399. * @param left left vector to maximize
  64400. * @param right right vector to maximize
  64401. * @returns a new vector with the maximum of the left and right vector values
  64402. */
  64403. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  64404. /**
  64405. * Returns the distance (float) between the vectors "value1" and "value2".
  64406. * @param value1 value to calulate the distance between
  64407. * @param value2 value to calulate the distance between
  64408. * @return the distance between the two vectors
  64409. */
  64410. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64411. /**
  64412. * Returns the squared distance (float) between the vectors "value1" and "value2".
  64413. * @param value1 value to calulate the distance between
  64414. * @param value2 value to calulate the distance between
  64415. * @return the distance between the two vectors squared
  64416. */
  64417. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  64418. /**
  64419. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  64420. * @param value1 value to calulate the center between
  64421. * @param value2 value to calulate the center between
  64422. * @return the center between the two vectors
  64423. */
  64424. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  64425. /**
  64426. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  64427. * This methods computes transformed normalized direction vectors only.
  64428. * @param vector the vector to transform
  64429. * @param transformation the transformation matrix to apply
  64430. * @returns the new vector
  64431. */
  64432. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  64433. /**
  64434. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  64435. * This methods computes transformed normalized direction vectors only.
  64436. * @param vector the vector to transform
  64437. * @param transformation the transformation matrix to apply
  64438. * @param result the vector to store the result in
  64439. */
  64440. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64441. /**
  64442. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  64443. * This methods computes transformed normalized direction vectors only.
  64444. * @param x value to transform
  64445. * @param y value to transform
  64446. * @param z value to transform
  64447. * @param w value to transform
  64448. * @param transformation the transformation matrix to apply
  64449. * @param result the vector to store the results in
  64450. */
  64451. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  64452. /**
  64453. * Creates a new Vector4 from a Vector3
  64454. * @param source defines the source data
  64455. * @param w defines the 4th component (default is 0)
  64456. * @returns a new Vector4
  64457. */
  64458. static FromVector3(source: Vector3, w?: number): Vector4;
  64459. }
  64460. /**
  64461. * Interface for the size containing width and height
  64462. */
  64463. export interface ISize {
  64464. /**
  64465. * Width
  64466. */
  64467. width: number;
  64468. /**
  64469. * Heighht
  64470. */
  64471. height: number;
  64472. }
  64473. /**
  64474. * Size containing widht and height
  64475. */
  64476. export class Size implements ISize {
  64477. /**
  64478. * Width
  64479. */
  64480. width: number;
  64481. /**
  64482. * Height
  64483. */
  64484. height: number;
  64485. /**
  64486. * Creates a Size object from the given width and height (floats).
  64487. * @param width width of the new size
  64488. * @param height height of the new size
  64489. */
  64490. constructor(width: number, height: number);
  64491. /**
  64492. * Returns a string with the Size width and height
  64493. * @returns a string with the Size width and height
  64494. */
  64495. toString(): string;
  64496. /**
  64497. * "Size"
  64498. * @returns the string "Size"
  64499. */
  64500. getClassName(): string;
  64501. /**
  64502. * Returns the Size hash code.
  64503. * @returns a hash code for a unique width and height
  64504. */
  64505. getHashCode(): number;
  64506. /**
  64507. * Updates the current size from the given one.
  64508. * @param src the given size
  64509. */
  64510. copyFrom(src: Size): void;
  64511. /**
  64512. * Updates in place the current Size from the given floats.
  64513. * @param width width of the new size
  64514. * @param height height of the new size
  64515. * @returns the updated Size.
  64516. */
  64517. copyFromFloats(width: number, height: number): Size;
  64518. /**
  64519. * Updates in place the current Size from the given floats.
  64520. * @param width width to set
  64521. * @param height height to set
  64522. * @returns the updated Size.
  64523. */
  64524. set(width: number, height: number): Size;
  64525. /**
  64526. * Multiplies the width and height by numbers
  64527. * @param w factor to multiple the width by
  64528. * @param h factor to multiple the height by
  64529. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  64530. */
  64531. multiplyByFloats(w: number, h: number): Size;
  64532. /**
  64533. * Clones the size
  64534. * @returns a new Size copied from the given one.
  64535. */
  64536. clone(): Size;
  64537. /**
  64538. * True if the current Size and the given one width and height are strictly equal.
  64539. * @param other the other size to compare against
  64540. * @returns True if the current Size and the given one width and height are strictly equal.
  64541. */
  64542. equals(other: Size): boolean;
  64543. /**
  64544. * The surface of the Size : width * height (float).
  64545. */
  64546. readonly surface: number;
  64547. /**
  64548. * Create a new size of zero
  64549. * @returns a new Size set to (0.0, 0.0)
  64550. */
  64551. static Zero(): Size;
  64552. /**
  64553. * Sums the width and height of two sizes
  64554. * @param otherSize size to add to this size
  64555. * @returns a new Size set as the addition result of the current Size and the given one.
  64556. */
  64557. add(otherSize: Size): Size;
  64558. /**
  64559. * Subtracts the width and height of two
  64560. * @param otherSize size to subtract to this size
  64561. * @returns a new Size set as the subtraction result of the given one from the current Size.
  64562. */
  64563. subtract(otherSize: Size): Size;
  64564. /**
  64565. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  64566. * @param start starting size to lerp between
  64567. * @param end end size to lerp between
  64568. * @param amount amount to lerp between the start and end values
  64569. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  64570. */
  64571. static Lerp(start: Size, end: Size, amount: number): Size;
  64572. }
  64573. /**
  64574. * Class used to store quaternion data
  64575. * @see https://en.wikipedia.org/wiki/Quaternion
  64576. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  64577. */
  64578. export class Quaternion {
  64579. /** defines the first component (0 by default) */
  64580. x: number;
  64581. /** defines the second component (0 by default) */
  64582. y: number;
  64583. /** defines the third component (0 by default) */
  64584. z: number;
  64585. /** defines the fourth component (1.0 by default) */
  64586. w: number;
  64587. /**
  64588. * Creates a new Quaternion from the given floats
  64589. * @param x defines the first component (0 by default)
  64590. * @param y defines the second component (0 by default)
  64591. * @param z defines the third component (0 by default)
  64592. * @param w defines the fourth component (1.0 by default)
  64593. */
  64594. constructor(
  64595. /** defines the first component (0 by default) */
  64596. x?: number,
  64597. /** defines the second component (0 by default) */
  64598. y?: number,
  64599. /** defines the third component (0 by default) */
  64600. z?: number,
  64601. /** defines the fourth component (1.0 by default) */
  64602. w?: number);
  64603. /**
  64604. * Gets a string representation for the current quaternion
  64605. * @returns a string with the Quaternion coordinates
  64606. */
  64607. toString(): string;
  64608. /**
  64609. * Gets the class name of the quaternion
  64610. * @returns the string "Quaternion"
  64611. */
  64612. getClassName(): string;
  64613. /**
  64614. * Gets a hash code for this quaternion
  64615. * @returns the quaternion hash code
  64616. */
  64617. getHashCode(): number;
  64618. /**
  64619. * Copy the quaternion to an array
  64620. * @returns a new array populated with 4 elements from the quaternion coordinates
  64621. */
  64622. asArray(): number[];
  64623. /**
  64624. * Check if two quaternions are equals
  64625. * @param otherQuaternion defines the second operand
  64626. * @return true if the current quaternion and the given one coordinates are strictly equals
  64627. */
  64628. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  64629. /**
  64630. * Clone the current quaternion
  64631. * @returns a new quaternion copied from the current one
  64632. */
  64633. clone(): Quaternion;
  64634. /**
  64635. * Copy a quaternion to the current one
  64636. * @param other defines the other quaternion
  64637. * @returns the updated current quaternion
  64638. */
  64639. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  64640. /**
  64641. * Updates the current quaternion with the given float coordinates
  64642. * @param x defines the x coordinate
  64643. * @param y defines the y coordinate
  64644. * @param z defines the z coordinate
  64645. * @param w defines the w coordinate
  64646. * @returns the updated current quaternion
  64647. */
  64648. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  64649. /**
  64650. * Updates the current quaternion from the given float coordinates
  64651. * @param x defines the x coordinate
  64652. * @param y defines the y coordinate
  64653. * @param z defines the z coordinate
  64654. * @param w defines the w coordinate
  64655. * @returns the updated current quaternion
  64656. */
  64657. set(x: number, y: number, z: number, w: number): Quaternion;
  64658. /**
  64659. * Adds two quaternions
  64660. * @param other defines the second operand
  64661. * @returns a new quaternion as the addition result of the given one and the current quaternion
  64662. */
  64663. add(other: DeepImmutable<Quaternion>): Quaternion;
  64664. /**
  64665. * Add a quaternion to the current one
  64666. * @param other defines the quaternion to add
  64667. * @returns the current quaternion
  64668. */
  64669. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  64670. /**
  64671. * Subtract two quaternions
  64672. * @param other defines the second operand
  64673. * @returns a new quaternion as the subtraction result of the given one from the current one
  64674. */
  64675. subtract(other: Quaternion): Quaternion;
  64676. /**
  64677. * Multiplies the current quaternion by a scale factor
  64678. * @param value defines the scale factor
  64679. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  64680. */
  64681. scale(value: number): Quaternion;
  64682. /**
  64683. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  64684. * @param scale defines the scale factor
  64685. * @param result defines the Quaternion object where to store the result
  64686. * @returns the unmodified current quaternion
  64687. */
  64688. scaleToRef(scale: number, result: Quaternion): Quaternion;
  64689. /**
  64690. * Multiplies in place the current quaternion by a scale factor
  64691. * @param value defines the scale factor
  64692. * @returns the current modified quaternion
  64693. */
  64694. scaleInPlace(value: number): Quaternion;
  64695. /**
  64696. * Scale the current quaternion values by a factor and add the result to a given quaternion
  64697. * @param scale defines the scale factor
  64698. * @param result defines the Quaternion object where to store the result
  64699. * @returns the unmodified current quaternion
  64700. */
  64701. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  64702. /**
  64703. * Multiplies two quaternions
  64704. * @param q1 defines the second operand
  64705. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  64706. */
  64707. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  64708. /**
  64709. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  64710. * @param q1 defines the second operand
  64711. * @param result defines the target quaternion
  64712. * @returns the current quaternion
  64713. */
  64714. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  64715. /**
  64716. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  64717. * @param q1 defines the second operand
  64718. * @returns the currentupdated quaternion
  64719. */
  64720. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  64721. /**
  64722. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  64723. * @param ref defines the target quaternion
  64724. * @returns the current quaternion
  64725. */
  64726. conjugateToRef(ref: Quaternion): Quaternion;
  64727. /**
  64728. * Conjugates in place (1-q) the current quaternion
  64729. * @returns the current updated quaternion
  64730. */
  64731. conjugateInPlace(): Quaternion;
  64732. /**
  64733. * Conjugates in place (1-q) the current quaternion
  64734. * @returns a new quaternion
  64735. */
  64736. conjugate(): Quaternion;
  64737. /**
  64738. * Gets length of current quaternion
  64739. * @returns the quaternion length (float)
  64740. */
  64741. length(): number;
  64742. /**
  64743. * Normalize in place the current quaternion
  64744. * @returns the current updated quaternion
  64745. */
  64746. normalize(): Quaternion;
  64747. /**
  64748. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  64749. * @param order is a reserved parameter and is ignore for now
  64750. * @returns a new Vector3 containing the Euler angles
  64751. */
  64752. toEulerAngles(order?: string): Vector3;
  64753. /**
  64754. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  64755. * @param result defines the vector which will be filled with the Euler angles
  64756. * @param order is a reserved parameter and is ignore for now
  64757. * @returns the current unchanged quaternion
  64758. */
  64759. toEulerAnglesToRef(result: Vector3): Quaternion;
  64760. /**
  64761. * Updates the given rotation matrix with the current quaternion values
  64762. * @param result defines the target matrix
  64763. * @returns the current unchanged quaternion
  64764. */
  64765. toRotationMatrix(result: Matrix): Quaternion;
  64766. /**
  64767. * Updates the current quaternion from the given rotation matrix values
  64768. * @param matrix defines the source matrix
  64769. * @returns the current updated quaternion
  64770. */
  64771. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  64772. /**
  64773. * Creates a new quaternion from a rotation matrix
  64774. * @param matrix defines the source matrix
  64775. * @returns a new quaternion created from the given rotation matrix values
  64776. */
  64777. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  64778. /**
  64779. * Updates the given quaternion with the given rotation matrix values
  64780. * @param matrix defines the source matrix
  64781. * @param result defines the target quaternion
  64782. */
  64783. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  64784. /**
  64785. * Returns the dot product (float) between the quaternions "left" and "right"
  64786. * @param left defines the left operand
  64787. * @param right defines the right operand
  64788. * @returns the dot product
  64789. */
  64790. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  64791. /**
  64792. * Checks if the two quaternions are close to each other
  64793. * @param quat0 defines the first quaternion to check
  64794. * @param quat1 defines the second quaternion to check
  64795. * @returns true if the two quaternions are close to each other
  64796. */
  64797. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  64798. /**
  64799. * Creates an empty quaternion
  64800. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  64801. */
  64802. static Zero(): Quaternion;
  64803. /**
  64804. * Inverse a given quaternion
  64805. * @param q defines the source quaternion
  64806. * @returns a new quaternion as the inverted current quaternion
  64807. */
  64808. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  64809. /**
  64810. * Inverse a given quaternion
  64811. * @param q defines the source quaternion
  64812. * @param result the quaternion the result will be stored in
  64813. * @returns the result quaternion
  64814. */
  64815. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  64816. /**
  64817. * Creates an identity quaternion
  64818. * @returns the identity quaternion
  64819. */
  64820. static Identity(): Quaternion;
  64821. /**
  64822. * Gets a boolean indicating if the given quaternion is identity
  64823. * @param quaternion defines the quaternion to check
  64824. * @returns true if the quaternion is identity
  64825. */
  64826. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  64827. /**
  64828. * Creates a quaternion from a rotation around an axis
  64829. * @param axis defines the axis to use
  64830. * @param angle defines the angle to use
  64831. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  64832. */
  64833. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  64834. /**
  64835. * Creates a rotation around an axis and stores it into the given quaternion
  64836. * @param axis defines the axis to use
  64837. * @param angle defines the angle to use
  64838. * @param result defines the target quaternion
  64839. * @returns the target quaternion
  64840. */
  64841. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  64842. /**
  64843. * Creates a new quaternion from data stored into an array
  64844. * @param array defines the data source
  64845. * @param offset defines the offset in the source array where the data starts
  64846. * @returns a new quaternion
  64847. */
  64848. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  64849. /**
  64850. * Create a quaternion from Euler rotation angles
  64851. * @param x Pitch
  64852. * @param y Yaw
  64853. * @param z Roll
  64854. * @returns the new Quaternion
  64855. */
  64856. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  64857. /**
  64858. * Updates a quaternion from Euler rotation angles
  64859. * @param x Pitch
  64860. * @param y Yaw
  64861. * @param z Roll
  64862. * @param result the quaternion to store the result
  64863. * @returns the updated quaternion
  64864. */
  64865. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  64866. /**
  64867. * Create a quaternion from Euler rotation vector
  64868. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  64869. * @returns the new Quaternion
  64870. */
  64871. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  64872. /**
  64873. * Updates a quaternion from Euler rotation vector
  64874. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  64875. * @param result the quaternion to store the result
  64876. * @returns the updated quaternion
  64877. */
  64878. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  64879. /**
  64880. * Creates a new quaternion from the given Euler float angles (y, x, z)
  64881. * @param yaw defines the rotation around Y axis
  64882. * @param pitch defines the rotation around X axis
  64883. * @param roll defines the rotation around Z axis
  64884. * @returns the new quaternion
  64885. */
  64886. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  64887. /**
  64888. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  64889. * @param yaw defines the rotation around Y axis
  64890. * @param pitch defines the rotation around X axis
  64891. * @param roll defines the rotation around Z axis
  64892. * @param result defines the target quaternion
  64893. */
  64894. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  64895. /**
  64896. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  64897. * @param alpha defines the rotation around first axis
  64898. * @param beta defines the rotation around second axis
  64899. * @param gamma defines the rotation around third axis
  64900. * @returns the new quaternion
  64901. */
  64902. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  64903. /**
  64904. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  64905. * @param alpha defines the rotation around first axis
  64906. * @param beta defines the rotation around second axis
  64907. * @param gamma defines the rotation around third axis
  64908. * @param result defines the target quaternion
  64909. */
  64910. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  64911. /**
  64912. * 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)
  64913. * @param axis1 defines the first axis
  64914. * @param axis2 defines the second axis
  64915. * @param axis3 defines the third axis
  64916. * @returns the new quaternion
  64917. */
  64918. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  64919. /**
  64920. * 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
  64921. * @param axis1 defines the first axis
  64922. * @param axis2 defines the second axis
  64923. * @param axis3 defines the third axis
  64924. * @param ref defines the target quaternion
  64925. */
  64926. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  64927. /**
  64928. * Interpolates between two quaternions
  64929. * @param left defines first quaternion
  64930. * @param right defines second quaternion
  64931. * @param amount defines the gradient to use
  64932. * @returns the new interpolated quaternion
  64933. */
  64934. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  64935. /**
  64936. * Interpolates between two quaternions and stores it into a target quaternion
  64937. * @param left defines first quaternion
  64938. * @param right defines second quaternion
  64939. * @param amount defines the gradient to use
  64940. * @param result defines the target quaternion
  64941. */
  64942. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  64943. /**
  64944. * Interpolate between two quaternions using Hermite interpolation
  64945. * @param value1 defines first quaternion
  64946. * @param tangent1 defines the incoming tangent
  64947. * @param value2 defines second quaternion
  64948. * @param tangent2 defines the outgoing tangent
  64949. * @param amount defines the target quaternion
  64950. * @returns the new interpolated quaternion
  64951. */
  64952. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  64953. }
  64954. /**
  64955. * Class used to store matrix data (4x4)
  64956. */
  64957. export class Matrix {
  64958. private static _updateFlagSeed;
  64959. private static _identityReadOnly;
  64960. private _isIdentity;
  64961. private _isIdentityDirty;
  64962. private _isIdentity3x2;
  64963. private _isIdentity3x2Dirty;
  64964. /**
  64965. * Gets the update flag of the matrix which is an unique number for the matrix.
  64966. * It will be incremented every time the matrix data change.
  64967. * You can use it to speed the comparison between two versions of the same matrix.
  64968. */
  64969. updateFlag: number;
  64970. private readonly _m;
  64971. /**
  64972. * Gets the internal data of the matrix
  64973. */
  64974. readonly m: DeepImmutable<Float32Array>;
  64975. /** @hidden */
  64976. _markAsUpdated(): void;
  64977. /** @hidden */
  64978. private _updateIdentityStatus;
  64979. /**
  64980. * Creates an empty matrix (filled with zeros)
  64981. */
  64982. constructor();
  64983. /**
  64984. * Check if the current matrix is identity
  64985. * @returns true is the matrix is the identity matrix
  64986. */
  64987. isIdentity(): boolean;
  64988. /**
  64989. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  64990. * @returns true is the matrix is the identity matrix
  64991. */
  64992. isIdentityAs3x2(): boolean;
  64993. /**
  64994. * Gets the determinant of the matrix
  64995. * @returns the matrix determinant
  64996. */
  64997. determinant(): number;
  64998. /**
  64999. * Returns the matrix as a Float32Array
  65000. * @returns the matrix underlying array
  65001. */
  65002. toArray(): DeepImmutable<Float32Array>;
  65003. /**
  65004. * Returns the matrix as a Float32Array
  65005. * @returns the matrix underlying array.
  65006. */
  65007. asArray(): DeepImmutable<Float32Array>;
  65008. /**
  65009. * Inverts the current matrix in place
  65010. * @returns the current inverted matrix
  65011. */
  65012. invert(): Matrix;
  65013. /**
  65014. * Sets all the matrix elements to zero
  65015. * @returns the current matrix
  65016. */
  65017. reset(): Matrix;
  65018. /**
  65019. * Adds the current matrix with a second one
  65020. * @param other defines the matrix to add
  65021. * @returns a new matrix as the addition of the current matrix and the given one
  65022. */
  65023. add(other: DeepImmutable<Matrix>): Matrix;
  65024. /**
  65025. * Sets the given matrix "result" to the addition of the current matrix and the given one
  65026. * @param other defines the matrix to add
  65027. * @param result defines the target matrix
  65028. * @returns the current matrix
  65029. */
  65030. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65031. /**
  65032. * Adds in place the given matrix to the current matrix
  65033. * @param other defines the second operand
  65034. * @returns the current updated matrix
  65035. */
  65036. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  65037. /**
  65038. * Sets the given matrix to the current inverted Matrix
  65039. * @param other defines the target matrix
  65040. * @returns the unmodified current matrix
  65041. */
  65042. invertToRef(other: Matrix): Matrix;
  65043. /**
  65044. * add a value at the specified position in the current Matrix
  65045. * @param index the index of the value within the matrix. between 0 and 15.
  65046. * @param value the value to be added
  65047. * @returns the current updated matrix
  65048. */
  65049. addAtIndex(index: number, value: number): Matrix;
  65050. /**
  65051. * mutiply the specified position in the current Matrix by a value
  65052. * @param index the index of the value within the matrix. between 0 and 15.
  65053. * @param value the value to be added
  65054. * @returns the current updated matrix
  65055. */
  65056. multiplyAtIndex(index: number, value: number): Matrix;
  65057. /**
  65058. * Inserts the translation vector (using 3 floats) in the current matrix
  65059. * @param x defines the 1st component of the translation
  65060. * @param y defines the 2nd component of the translation
  65061. * @param z defines the 3rd component of the translation
  65062. * @returns the current updated matrix
  65063. */
  65064. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65065. /**
  65066. * Adds the translation vector (using 3 floats) in the current matrix
  65067. * @param x defines the 1st component of the translation
  65068. * @param y defines the 2nd component of the translation
  65069. * @param z defines the 3rd component of the translation
  65070. * @returns the current updated matrix
  65071. */
  65072. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  65073. /**
  65074. * Inserts the translation vector in the current matrix
  65075. * @param vector3 defines the translation to insert
  65076. * @returns the current updated matrix
  65077. */
  65078. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  65079. /**
  65080. * Gets the translation value of the current matrix
  65081. * @returns a new Vector3 as the extracted translation from the matrix
  65082. */
  65083. getTranslation(): Vector3;
  65084. /**
  65085. * Fill a Vector3 with the extracted translation from the matrix
  65086. * @param result defines the Vector3 where to store the translation
  65087. * @returns the current matrix
  65088. */
  65089. getTranslationToRef(result: Vector3): Matrix;
  65090. /**
  65091. * Remove rotation and scaling part from the matrix
  65092. * @returns the updated matrix
  65093. */
  65094. removeRotationAndScaling(): Matrix;
  65095. /**
  65096. * Multiply two matrices
  65097. * @param other defines the second operand
  65098. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  65099. */
  65100. multiply(other: DeepImmutable<Matrix>): Matrix;
  65101. /**
  65102. * Copy the current matrix from the given one
  65103. * @param other defines the source matrix
  65104. * @returns the current updated matrix
  65105. */
  65106. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  65107. /**
  65108. * Populates the given array from the starting index with the current matrix values
  65109. * @param array defines the target array
  65110. * @param offset defines the offset in the target array where to start storing values
  65111. * @returns the current matrix
  65112. */
  65113. copyToArray(array: Float32Array, offset?: number): Matrix;
  65114. /**
  65115. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  65116. * @param other defines the second operand
  65117. * @param result defines the matrix where to store the multiplication
  65118. * @returns the current matrix
  65119. */
  65120. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  65121. /**
  65122. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  65123. * @param other defines the second operand
  65124. * @param result defines the array where to store the multiplication
  65125. * @param offset defines the offset in the target array where to start storing values
  65126. * @returns the current matrix
  65127. */
  65128. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  65129. /**
  65130. * Check equality between this matrix and a second one
  65131. * @param value defines the second matrix to compare
  65132. * @returns true is the current matrix and the given one values are strictly equal
  65133. */
  65134. equals(value: DeepImmutable<Matrix>): boolean;
  65135. /**
  65136. * Clone the current matrix
  65137. * @returns a new matrix from the current matrix
  65138. */
  65139. clone(): Matrix;
  65140. /**
  65141. * Returns the name of the current matrix class
  65142. * @returns the string "Matrix"
  65143. */
  65144. getClassName(): string;
  65145. /**
  65146. * Gets the hash code of the current matrix
  65147. * @returns the hash code
  65148. */
  65149. getHashCode(): number;
  65150. /**
  65151. * Decomposes the current Matrix into a translation, rotation and scaling components
  65152. * @param scale defines the scale vector3 given as a reference to update
  65153. * @param rotation defines the rotation quaternion given as a reference to update
  65154. * @param translation defines the translation vector3 given as a reference to update
  65155. * @returns true if operation was successful
  65156. */
  65157. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  65158. /**
  65159. * Gets specific row of the matrix
  65160. * @param index defines the number of the row to get
  65161. * @returns the index-th row of the current matrix as a new Vector4
  65162. */
  65163. getRow(index: number): Nullable<Vector4>;
  65164. /**
  65165. * Sets the index-th row of the current matrix to the vector4 values
  65166. * @param index defines the number of the row to set
  65167. * @param row defines the target vector4
  65168. * @returns the updated current matrix
  65169. */
  65170. setRow(index: number, row: Vector4): Matrix;
  65171. /**
  65172. * Compute the transpose of the matrix
  65173. * @returns the new transposed matrix
  65174. */
  65175. transpose(): Matrix;
  65176. /**
  65177. * Compute the transpose of the matrix and store it in a given matrix
  65178. * @param result defines the target matrix
  65179. * @returns the current matrix
  65180. */
  65181. transposeToRef(result: Matrix): Matrix;
  65182. /**
  65183. * Sets the index-th row of the current matrix with the given 4 x float values
  65184. * @param index defines the row index
  65185. * @param x defines the x component to set
  65186. * @param y defines the y component to set
  65187. * @param z defines the z component to set
  65188. * @param w defines the w component to set
  65189. * @returns the updated current matrix
  65190. */
  65191. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  65192. /**
  65193. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  65194. * @param scale defines the scale factor
  65195. * @returns a new matrix
  65196. */
  65197. scale(scale: number): Matrix;
  65198. /**
  65199. * Scale the current matrix values by a factor to a given result matrix
  65200. * @param scale defines the scale factor
  65201. * @param result defines the matrix to store the result
  65202. * @returns the current matrix
  65203. */
  65204. scaleToRef(scale: number, result: Matrix): Matrix;
  65205. /**
  65206. * Scale the current matrix values by a factor and add the result to a given matrix
  65207. * @param scale defines the scale factor
  65208. * @param result defines the Matrix to store the result
  65209. * @returns the current matrix
  65210. */
  65211. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  65212. /**
  65213. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  65214. * @param ref matrix to store the result
  65215. */
  65216. toNormalMatrix(ref: Matrix): void;
  65217. /**
  65218. * Gets only rotation part of the current matrix
  65219. * @returns a new matrix sets to the extracted rotation matrix from the current one
  65220. */
  65221. getRotationMatrix(): Matrix;
  65222. /**
  65223. * Extracts the rotation matrix from the current one and sets it as the given "result"
  65224. * @param result defines the target matrix to store data to
  65225. * @returns the current matrix
  65226. */
  65227. getRotationMatrixToRef(result: Matrix): Matrix;
  65228. /**
  65229. * Toggles model matrix from being right handed to left handed in place and vice versa
  65230. */
  65231. toggleModelMatrixHandInPlace(): void;
  65232. /**
  65233. * Toggles projection matrix from being right handed to left handed in place and vice versa
  65234. */
  65235. toggleProjectionMatrixHandInPlace(): void;
  65236. /**
  65237. * Creates a matrix from an array
  65238. * @param array defines the source array
  65239. * @param offset defines an offset in the source array
  65240. * @returns a new Matrix set from the starting index of the given array
  65241. */
  65242. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  65243. /**
  65244. * Copy the content of an array into a given matrix
  65245. * @param array defines the source array
  65246. * @param offset defines an offset in the source array
  65247. * @param result defines the target matrix
  65248. */
  65249. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  65250. /**
  65251. * Stores an array into a matrix after having multiplied each component by a given factor
  65252. * @param array defines the source array
  65253. * @param offset defines the offset in the source array
  65254. * @param scale defines the scaling factor
  65255. * @param result defines the target matrix
  65256. */
  65257. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  65258. /**
  65259. * Gets an identity matrix that must not be updated
  65260. */
  65261. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  65262. /**
  65263. * Stores a list of values (16) inside a given matrix
  65264. * @param initialM11 defines 1st value of 1st row
  65265. * @param initialM12 defines 2nd value of 1st row
  65266. * @param initialM13 defines 3rd value of 1st row
  65267. * @param initialM14 defines 4th value of 1st row
  65268. * @param initialM21 defines 1st value of 2nd row
  65269. * @param initialM22 defines 2nd value of 2nd row
  65270. * @param initialM23 defines 3rd value of 2nd row
  65271. * @param initialM24 defines 4th value of 2nd row
  65272. * @param initialM31 defines 1st value of 3rd row
  65273. * @param initialM32 defines 2nd value of 3rd row
  65274. * @param initialM33 defines 3rd value of 3rd row
  65275. * @param initialM34 defines 4th value of 3rd row
  65276. * @param initialM41 defines 1st value of 4th row
  65277. * @param initialM42 defines 2nd value of 4th row
  65278. * @param initialM43 defines 3rd value of 4th row
  65279. * @param initialM44 defines 4th value of 4th row
  65280. * @param result defines the target matrix
  65281. */
  65282. 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;
  65283. /**
  65284. * Creates new matrix from a list of values (16)
  65285. * @param initialM11 defines 1st value of 1st row
  65286. * @param initialM12 defines 2nd value of 1st row
  65287. * @param initialM13 defines 3rd value of 1st row
  65288. * @param initialM14 defines 4th value of 1st row
  65289. * @param initialM21 defines 1st value of 2nd row
  65290. * @param initialM22 defines 2nd value of 2nd row
  65291. * @param initialM23 defines 3rd value of 2nd row
  65292. * @param initialM24 defines 4th value of 2nd row
  65293. * @param initialM31 defines 1st value of 3rd row
  65294. * @param initialM32 defines 2nd value of 3rd row
  65295. * @param initialM33 defines 3rd value of 3rd row
  65296. * @param initialM34 defines 4th value of 3rd row
  65297. * @param initialM41 defines 1st value of 4th row
  65298. * @param initialM42 defines 2nd value of 4th row
  65299. * @param initialM43 defines 3rd value of 4th row
  65300. * @param initialM44 defines 4th value of 4th row
  65301. * @returns the new matrix
  65302. */
  65303. 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;
  65304. /**
  65305. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65306. * @param scale defines the scale vector3
  65307. * @param rotation defines the rotation quaternion
  65308. * @param translation defines the translation vector3
  65309. * @returns a new matrix
  65310. */
  65311. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  65312. /**
  65313. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  65314. * @param scale defines the scale vector3
  65315. * @param rotation defines the rotation quaternion
  65316. * @param translation defines the translation vector3
  65317. * @param result defines the target matrix
  65318. */
  65319. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  65320. /**
  65321. * Creates a new identity matrix
  65322. * @returns a new identity matrix
  65323. */
  65324. static Identity(): Matrix;
  65325. /**
  65326. * Creates a new identity matrix and stores the result in a given matrix
  65327. * @param result defines the target matrix
  65328. */
  65329. static IdentityToRef(result: Matrix): void;
  65330. /**
  65331. * Creates a new zero matrix
  65332. * @returns a new zero matrix
  65333. */
  65334. static Zero(): Matrix;
  65335. /**
  65336. * Creates a new rotation matrix for "angle" radians around the X axis
  65337. * @param angle defines the angle (in radians) to use
  65338. * @return the new matrix
  65339. */
  65340. static RotationX(angle: number): Matrix;
  65341. /**
  65342. * Creates a new matrix as the invert of a given matrix
  65343. * @param source defines the source matrix
  65344. * @returns the new matrix
  65345. */
  65346. static Invert(source: DeepImmutable<Matrix>): Matrix;
  65347. /**
  65348. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  65349. * @param angle defines the angle (in radians) to use
  65350. * @param result defines the target matrix
  65351. */
  65352. static RotationXToRef(angle: number, result: Matrix): void;
  65353. /**
  65354. * Creates a new rotation matrix for "angle" radians around the Y axis
  65355. * @param angle defines the angle (in radians) to use
  65356. * @return the new matrix
  65357. */
  65358. static RotationY(angle: number): Matrix;
  65359. /**
  65360. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  65361. * @param angle defines the angle (in radians) to use
  65362. * @param result defines the target matrix
  65363. */
  65364. static RotationYToRef(angle: number, result: Matrix): void;
  65365. /**
  65366. * Creates a new rotation matrix for "angle" radians around the Z axis
  65367. * @param angle defines the angle (in radians) to use
  65368. * @return the new matrix
  65369. */
  65370. static RotationZ(angle: number): Matrix;
  65371. /**
  65372. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  65373. * @param angle defines the angle (in radians) to use
  65374. * @param result defines the target matrix
  65375. */
  65376. static RotationZToRef(angle: number, result: Matrix): void;
  65377. /**
  65378. * Creates a new rotation matrix for "angle" radians around the given axis
  65379. * @param axis defines the axis to use
  65380. * @param angle defines the angle (in radians) to use
  65381. * @return the new matrix
  65382. */
  65383. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  65384. /**
  65385. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  65386. * @param axis defines the axis to use
  65387. * @param angle defines the angle (in radians) to use
  65388. * @param result defines the target matrix
  65389. */
  65390. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  65391. /**
  65392. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  65393. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  65394. * @param from defines the vector to align
  65395. * @param to defines the vector to align to
  65396. * @param result defines the target matrix
  65397. */
  65398. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  65399. /**
  65400. * Creates a rotation matrix
  65401. * @param yaw defines the yaw angle in radians (Y axis)
  65402. * @param pitch defines the pitch angle in radians (X axis)
  65403. * @param roll defines the roll angle in radians (X axis)
  65404. * @returns the new rotation matrix
  65405. */
  65406. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  65407. /**
  65408. * Creates a rotation matrix and stores it in a given matrix
  65409. * @param yaw defines the yaw angle in radians (Y axis)
  65410. * @param pitch defines the pitch angle in radians (X axis)
  65411. * @param roll defines the roll angle in radians (X axis)
  65412. * @param result defines the target matrix
  65413. */
  65414. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  65415. /**
  65416. * Creates a scaling matrix
  65417. * @param x defines the scale factor on X axis
  65418. * @param y defines the scale factor on Y axis
  65419. * @param z defines the scale factor on Z axis
  65420. * @returns the new matrix
  65421. */
  65422. static Scaling(x: number, y: number, z: number): Matrix;
  65423. /**
  65424. * Creates a scaling matrix and stores it in a given matrix
  65425. * @param x defines the scale factor on X axis
  65426. * @param y defines the scale factor on Y axis
  65427. * @param z defines the scale factor on Z axis
  65428. * @param result defines the target matrix
  65429. */
  65430. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  65431. /**
  65432. * Creates a translation matrix
  65433. * @param x defines the translation on X axis
  65434. * @param y defines the translation on Y axis
  65435. * @param z defines the translationon Z axis
  65436. * @returns the new matrix
  65437. */
  65438. static Translation(x: number, y: number, z: number): Matrix;
  65439. /**
  65440. * Creates a translation matrix and stores it in a given matrix
  65441. * @param x defines the translation on X axis
  65442. * @param y defines the translation on Y axis
  65443. * @param z defines the translationon Z axis
  65444. * @param result defines the target matrix
  65445. */
  65446. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  65447. /**
  65448. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65449. * @param startValue defines the start value
  65450. * @param endValue defines the end value
  65451. * @param gradient defines the gradient factor
  65452. * @returns the new matrix
  65453. */
  65454. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65455. /**
  65456. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  65457. * @param startValue defines the start value
  65458. * @param endValue defines the end value
  65459. * @param gradient defines the gradient factor
  65460. * @param result defines the Matrix object where to store data
  65461. */
  65462. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65463. /**
  65464. * Builds a new matrix whose values are computed by:
  65465. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65466. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65467. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65468. * @param startValue defines the first matrix
  65469. * @param endValue defines the second matrix
  65470. * @param gradient defines the gradient between the two matrices
  65471. * @returns the new matrix
  65472. */
  65473. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  65474. /**
  65475. * Update a matrix to values which are computed by:
  65476. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  65477. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  65478. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  65479. * @param startValue defines the first matrix
  65480. * @param endValue defines the second matrix
  65481. * @param gradient defines the gradient between the two matrices
  65482. * @param result defines the target matrix
  65483. */
  65484. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  65485. /**
  65486. * 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"
  65487. * This function works in left handed mode
  65488. * @param eye defines the final position of the entity
  65489. * @param target defines where the entity should look at
  65490. * @param up defines the up vector for the entity
  65491. * @returns the new matrix
  65492. */
  65493. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65494. /**
  65495. * 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".
  65496. * This function works in left handed mode
  65497. * @param eye defines the final position of the entity
  65498. * @param target defines where the entity should look at
  65499. * @param up defines the up vector for the entity
  65500. * @param result defines the target matrix
  65501. */
  65502. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65503. /**
  65504. * 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"
  65505. * This function works in right handed mode
  65506. * @param eye defines the final position of the entity
  65507. * @param target defines where the entity should look at
  65508. * @param up defines the up vector for the entity
  65509. * @returns the new matrix
  65510. */
  65511. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  65512. /**
  65513. * 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".
  65514. * This function works in right handed mode
  65515. * @param eye defines the final position of the entity
  65516. * @param target defines where the entity should look at
  65517. * @param up defines the up vector for the entity
  65518. * @param result defines the target matrix
  65519. */
  65520. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  65521. /**
  65522. * Create a left-handed orthographic projection matrix
  65523. * @param width defines the viewport width
  65524. * @param height defines the viewport height
  65525. * @param znear defines the near clip plane
  65526. * @param zfar defines the far clip plane
  65527. * @returns a new matrix as a left-handed orthographic projection matrix
  65528. */
  65529. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65530. /**
  65531. * Store a left-handed orthographic projection to a given matrix
  65532. * @param width defines the viewport width
  65533. * @param height defines the viewport height
  65534. * @param znear defines the near clip plane
  65535. * @param zfar defines the far clip plane
  65536. * @param result defines the target matrix
  65537. */
  65538. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  65539. /**
  65540. * Create a left-handed orthographic projection matrix
  65541. * @param left defines the viewport left coordinate
  65542. * @param right defines the viewport right coordinate
  65543. * @param bottom defines the viewport bottom coordinate
  65544. * @param top defines the viewport top coordinate
  65545. * @param znear defines the near clip plane
  65546. * @param zfar defines the far clip plane
  65547. * @returns a new matrix as a left-handed orthographic projection matrix
  65548. */
  65549. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65550. /**
  65551. * Stores a left-handed orthographic projection into a given matrix
  65552. * @param left defines the viewport left coordinate
  65553. * @param right defines the viewport right coordinate
  65554. * @param bottom defines the viewport bottom coordinate
  65555. * @param top defines the viewport top coordinate
  65556. * @param znear defines the near clip plane
  65557. * @param zfar defines the far clip plane
  65558. * @param result defines the target matrix
  65559. */
  65560. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65561. /**
  65562. * Creates a right-handed orthographic projection matrix
  65563. * @param left defines the viewport left coordinate
  65564. * @param right defines the viewport right coordinate
  65565. * @param bottom defines the viewport bottom coordinate
  65566. * @param top defines the viewport top coordinate
  65567. * @param znear defines the near clip plane
  65568. * @param zfar defines the far clip plane
  65569. * @returns a new matrix as a right-handed orthographic projection matrix
  65570. */
  65571. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  65572. /**
  65573. * Stores a right-handed orthographic projection into a given matrix
  65574. * @param left defines the viewport left coordinate
  65575. * @param right defines the viewport right coordinate
  65576. * @param bottom defines the viewport bottom coordinate
  65577. * @param top defines the viewport top coordinate
  65578. * @param znear defines the near clip plane
  65579. * @param zfar defines the far clip plane
  65580. * @param result defines the target matrix
  65581. */
  65582. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  65583. /**
  65584. * Creates a left-handed perspective projection matrix
  65585. * @param width defines the viewport width
  65586. * @param height defines the viewport height
  65587. * @param znear defines the near clip plane
  65588. * @param zfar defines the far clip plane
  65589. * @returns a new matrix as a left-handed perspective projection matrix
  65590. */
  65591. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  65592. /**
  65593. * Creates a left-handed perspective projection matrix
  65594. * @param fov defines the horizontal field of view
  65595. * @param aspect defines the aspect ratio
  65596. * @param znear defines the near clip plane
  65597. * @param zfar defines the far clip plane
  65598. * @returns a new matrix as a left-handed perspective projection matrix
  65599. */
  65600. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65601. /**
  65602. * Stores a left-handed perspective projection into a given matrix
  65603. * @param fov defines the horizontal field of view
  65604. * @param aspect defines the aspect ratio
  65605. * @param znear defines the near clip plane
  65606. * @param zfar defines the far clip plane
  65607. * @param result defines the target matrix
  65608. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65609. */
  65610. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65611. /**
  65612. * Creates a right-handed perspective projection matrix
  65613. * @param fov defines the horizontal field of view
  65614. * @param aspect defines the aspect ratio
  65615. * @param znear defines the near clip plane
  65616. * @param zfar defines the far clip plane
  65617. * @returns a new matrix as a right-handed perspective projection matrix
  65618. */
  65619. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  65620. /**
  65621. * Stores a right-handed perspective projection into a given matrix
  65622. * @param fov defines the horizontal field of view
  65623. * @param aspect defines the aspect ratio
  65624. * @param znear defines the near clip plane
  65625. * @param zfar defines the far clip plane
  65626. * @param result defines the target matrix
  65627. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  65628. */
  65629. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  65630. /**
  65631. * Stores a perspective projection for WebVR info a given matrix
  65632. * @param fov defines the field of view
  65633. * @param znear defines the near clip plane
  65634. * @param zfar defines the far clip plane
  65635. * @param result defines the target matrix
  65636. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  65637. */
  65638. static PerspectiveFovWebVRToRef(fov: {
  65639. upDegrees: number;
  65640. downDegrees: number;
  65641. leftDegrees: number;
  65642. rightDegrees: number;
  65643. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  65644. /**
  65645. * Computes a complete transformation matrix
  65646. * @param viewport defines the viewport to use
  65647. * @param world defines the world matrix
  65648. * @param view defines the view matrix
  65649. * @param projection defines the projection matrix
  65650. * @param zmin defines the near clip plane
  65651. * @param zmax defines the far clip plane
  65652. * @returns the transformation matrix
  65653. */
  65654. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  65655. /**
  65656. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  65657. * @param matrix defines the matrix to use
  65658. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  65659. */
  65660. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  65661. /**
  65662. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  65663. * @param matrix defines the matrix to use
  65664. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  65665. */
  65666. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  65667. /**
  65668. * Compute the transpose of a given matrix
  65669. * @param matrix defines the matrix to transpose
  65670. * @returns the new matrix
  65671. */
  65672. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  65673. /**
  65674. * Compute the transpose of a matrix and store it in a target matrix
  65675. * @param matrix defines the matrix to transpose
  65676. * @param result defines the target matrix
  65677. */
  65678. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  65679. /**
  65680. * Computes a reflection matrix from a plane
  65681. * @param plane defines the reflection plane
  65682. * @returns a new matrix
  65683. */
  65684. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  65685. /**
  65686. * Computes a reflection matrix from a plane
  65687. * @param plane defines the reflection plane
  65688. * @param result defines the target matrix
  65689. */
  65690. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  65691. /**
  65692. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  65693. * @param xaxis defines the value of the 1st axis
  65694. * @param yaxis defines the value of the 2nd axis
  65695. * @param zaxis defines the value of the 3rd axis
  65696. * @param result defines the target matrix
  65697. */
  65698. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  65699. /**
  65700. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  65701. * @param quat defines the quaternion to use
  65702. * @param result defines the target matrix
  65703. */
  65704. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  65705. }
  65706. /**
  65707. * Represens a plane by the equation ax + by + cz + d = 0
  65708. */
  65709. export class Plane {
  65710. /**
  65711. * Normal of the plane (a,b,c)
  65712. */
  65713. normal: Vector3;
  65714. /**
  65715. * d component of the plane
  65716. */
  65717. d: number;
  65718. /**
  65719. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  65720. * @param a a component of the plane
  65721. * @param b b component of the plane
  65722. * @param c c component of the plane
  65723. * @param d d component of the plane
  65724. */
  65725. constructor(a: number, b: number, c: number, d: number);
  65726. /**
  65727. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  65728. */
  65729. asArray(): number[];
  65730. /**
  65731. * @returns a new plane copied from the current Plane.
  65732. */
  65733. clone(): Plane;
  65734. /**
  65735. * @returns the string "Plane".
  65736. */
  65737. getClassName(): string;
  65738. /**
  65739. * @returns the Plane hash code.
  65740. */
  65741. getHashCode(): number;
  65742. /**
  65743. * Normalize the current Plane in place.
  65744. * @returns the updated Plane.
  65745. */
  65746. normalize(): Plane;
  65747. /**
  65748. * Applies a transformation the plane and returns the result
  65749. * @param transformation the transformation matrix to be applied to the plane
  65750. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  65751. */
  65752. transform(transformation: DeepImmutable<Matrix>): Plane;
  65753. /**
  65754. * Calcualtte the dot product between the point and the plane normal
  65755. * @param point point to calculate the dot product with
  65756. * @returns the dot product (float) of the point coordinates and the plane normal.
  65757. */
  65758. dotCoordinate(point: DeepImmutable<Vector3>): number;
  65759. /**
  65760. * Updates the current Plane from the plane defined by the three given points.
  65761. * @param point1 one of the points used to contruct the plane
  65762. * @param point2 one of the points used to contruct the plane
  65763. * @param point3 one of the points used to contruct the plane
  65764. * @returns the updated Plane.
  65765. */
  65766. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  65767. /**
  65768. * Checks if the plane is facing a given direction
  65769. * @param direction the direction to check if the plane is facing
  65770. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  65771. * @returns True is the vector "direction" is the same side than the plane normal.
  65772. */
  65773. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  65774. /**
  65775. * Calculates the distance to a point
  65776. * @param point point to calculate distance to
  65777. * @returns the signed distance (float) from the given point to the Plane.
  65778. */
  65779. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  65780. /**
  65781. * Creates a plane from an array
  65782. * @param array the array to create a plane from
  65783. * @returns a new Plane from the given array.
  65784. */
  65785. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  65786. /**
  65787. * Creates a plane from three points
  65788. * @param point1 point used to create the plane
  65789. * @param point2 point used to create the plane
  65790. * @param point3 point used to create the plane
  65791. * @returns a new Plane defined by the three given points.
  65792. */
  65793. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  65794. /**
  65795. * Creates a plane from an origin point and a normal
  65796. * @param origin origin of the plane to be constructed
  65797. * @param normal normal of the plane to be constructed
  65798. * @returns a new Plane the normal vector to this plane at the given origin point.
  65799. * Note : the vector "normal" is updated because normalized.
  65800. */
  65801. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  65802. /**
  65803. * Calculates the distance from a plane and a point
  65804. * @param origin origin of the plane to be constructed
  65805. * @param normal normal of the plane to be constructed
  65806. * @param point point to calculate distance to
  65807. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  65808. */
  65809. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  65810. }
  65811. /**
  65812. * Class used to represent a viewport on screen
  65813. */
  65814. export class Viewport {
  65815. /** viewport left coordinate */
  65816. x: number;
  65817. /** viewport top coordinate */
  65818. y: number;
  65819. /**viewport width */
  65820. width: number;
  65821. /** viewport height */
  65822. height: number;
  65823. /**
  65824. * Creates a Viewport object located at (x, y) and sized (width, height)
  65825. * @param x defines viewport left coordinate
  65826. * @param y defines viewport top coordinate
  65827. * @param width defines the viewport width
  65828. * @param height defines the viewport height
  65829. */
  65830. constructor(
  65831. /** viewport left coordinate */
  65832. x: number,
  65833. /** viewport top coordinate */
  65834. y: number,
  65835. /**viewport width */
  65836. width: number,
  65837. /** viewport height */
  65838. height: number);
  65839. /**
  65840. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  65841. * @param renderWidth defines the rendering width
  65842. * @param renderHeight defines the rendering height
  65843. * @returns a new Viewport
  65844. */
  65845. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  65846. /**
  65847. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  65848. * @param renderWidth defines the rendering width
  65849. * @param renderHeight defines the rendering height
  65850. * @param ref defines the target viewport
  65851. * @returns the current viewport
  65852. */
  65853. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  65854. /**
  65855. * Returns a new Viewport copied from the current one
  65856. * @returns a new Viewport
  65857. */
  65858. clone(): Viewport;
  65859. }
  65860. /**
  65861. * Reprasents a camera frustum
  65862. */
  65863. export class Frustum {
  65864. /**
  65865. * Gets the planes representing the frustum
  65866. * @param transform matrix to be applied to the returned planes
  65867. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  65868. */
  65869. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  65870. /**
  65871. * Gets the near frustum plane transformed by the transform matrix
  65872. * @param transform transformation matrix to be applied to the resulting frustum plane
  65873. * @param frustumPlane the resuling frustum plane
  65874. */
  65875. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65876. /**
  65877. * Gets the far frustum plane transformed by the transform matrix
  65878. * @param transform transformation matrix to be applied to the resulting frustum plane
  65879. * @param frustumPlane the resuling frustum plane
  65880. */
  65881. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65882. /**
  65883. * Gets the left frustum plane transformed by the transform matrix
  65884. * @param transform transformation matrix to be applied to the resulting frustum plane
  65885. * @param frustumPlane the resuling frustum plane
  65886. */
  65887. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65888. /**
  65889. * Gets the right frustum plane transformed by the transform matrix
  65890. * @param transform transformation matrix to be applied to the resulting frustum plane
  65891. * @param frustumPlane the resuling frustum plane
  65892. */
  65893. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65894. /**
  65895. * Gets the top frustum plane transformed by the transform matrix
  65896. * @param transform transformation matrix to be applied to the resulting frustum plane
  65897. * @param frustumPlane the resuling frustum plane
  65898. */
  65899. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65900. /**
  65901. * Gets the bottom frustum plane transformed by the transform matrix
  65902. * @param transform transformation matrix to be applied to the resulting frustum plane
  65903. * @param frustumPlane the resuling frustum plane
  65904. */
  65905. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  65906. /**
  65907. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  65908. * @param transform transformation matrix to be applied to the resulting frustum planes
  65909. * @param frustumPlanes the resuling frustum planes
  65910. */
  65911. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  65912. }
  65913. /** Defines supported spaces */
  65914. export enum Space {
  65915. /** Local (object) space */
  65916. LOCAL = 0,
  65917. /** World space */
  65918. WORLD = 1,
  65919. /** Bone space */
  65920. BONE = 2
  65921. }
  65922. /** Defines the 3 main axes */
  65923. export class Axis {
  65924. /** X axis */
  65925. static X: Vector3;
  65926. /** Y axis */
  65927. static Y: Vector3;
  65928. /** Z axis */
  65929. static Z: Vector3;
  65930. }
  65931. /** Class used to represent a Bezier curve */
  65932. export class BezierCurve {
  65933. /**
  65934. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  65935. * @param t defines the time
  65936. * @param x1 defines the left coordinate on X axis
  65937. * @param y1 defines the left coordinate on Y axis
  65938. * @param x2 defines the right coordinate on X axis
  65939. * @param y2 defines the right coordinate on Y axis
  65940. * @returns the interpolated value
  65941. */
  65942. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  65943. }
  65944. /**
  65945. * Defines potential orientation for back face culling
  65946. */
  65947. export enum Orientation {
  65948. /**
  65949. * Clockwise
  65950. */
  65951. CW = 0,
  65952. /** Counter clockwise */
  65953. CCW = 1
  65954. }
  65955. /**
  65956. * Defines angle representation
  65957. */
  65958. export class Angle {
  65959. private _radians;
  65960. /**
  65961. * Creates an Angle object of "radians" radians (float).
  65962. * @param radians the angle in radians
  65963. */
  65964. constructor(radians: number);
  65965. /**
  65966. * Get value in degrees
  65967. * @returns the Angle value in degrees (float)
  65968. */
  65969. degrees(): number;
  65970. /**
  65971. * Get value in radians
  65972. * @returns the Angle value in radians (float)
  65973. */
  65974. radians(): number;
  65975. /**
  65976. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  65977. * @param a defines first vector
  65978. * @param b defines second vector
  65979. * @returns a new Angle
  65980. */
  65981. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  65982. /**
  65983. * Gets a new Angle object from the given float in radians
  65984. * @param radians defines the angle value in radians
  65985. * @returns a new Angle
  65986. */
  65987. static FromRadians(radians: number): Angle;
  65988. /**
  65989. * Gets a new Angle object from the given float in degrees
  65990. * @param degrees defines the angle value in degrees
  65991. * @returns a new Angle
  65992. */
  65993. static FromDegrees(degrees: number): Angle;
  65994. }
  65995. /**
  65996. * This represents an arc in a 2d space.
  65997. */
  65998. export class Arc2 {
  65999. /** Defines the start point of the arc */
  66000. startPoint: Vector2;
  66001. /** Defines the mid point of the arc */
  66002. midPoint: Vector2;
  66003. /** Defines the end point of the arc */
  66004. endPoint: Vector2;
  66005. /**
  66006. * Defines the center point of the arc.
  66007. */
  66008. centerPoint: Vector2;
  66009. /**
  66010. * Defines the radius of the arc.
  66011. */
  66012. radius: number;
  66013. /**
  66014. * Defines the angle of the arc (from mid point to end point).
  66015. */
  66016. angle: Angle;
  66017. /**
  66018. * Defines the start angle of the arc (from start point to middle point).
  66019. */
  66020. startAngle: Angle;
  66021. /**
  66022. * Defines the orientation of the arc (clock wise/counter clock wise).
  66023. */
  66024. orientation: Orientation;
  66025. /**
  66026. * Creates an Arc object from the three given points : start, middle and end.
  66027. * @param startPoint Defines the start point of the arc
  66028. * @param midPoint Defines the midlle point of the arc
  66029. * @param endPoint Defines the end point of the arc
  66030. */
  66031. constructor(
  66032. /** Defines the start point of the arc */
  66033. startPoint: Vector2,
  66034. /** Defines the mid point of the arc */
  66035. midPoint: Vector2,
  66036. /** Defines the end point of the arc */
  66037. endPoint: Vector2);
  66038. }
  66039. /**
  66040. * Represents a 2D path made up of multiple 2D points
  66041. */
  66042. export class Path2 {
  66043. private _points;
  66044. private _length;
  66045. /**
  66046. * If the path start and end point are the same
  66047. */
  66048. closed: boolean;
  66049. /**
  66050. * Creates a Path2 object from the starting 2D coordinates x and y.
  66051. * @param x the starting points x value
  66052. * @param y the starting points y value
  66053. */
  66054. constructor(x: number, y: number);
  66055. /**
  66056. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  66057. * @param x the added points x value
  66058. * @param y the added points y value
  66059. * @returns the updated Path2.
  66060. */
  66061. addLineTo(x: number, y: number): Path2;
  66062. /**
  66063. * 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.
  66064. * @param midX middle point x value
  66065. * @param midY middle point y value
  66066. * @param endX end point x value
  66067. * @param endY end point y value
  66068. * @param numberOfSegments (default: 36)
  66069. * @returns the updated Path2.
  66070. */
  66071. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  66072. /**
  66073. * Closes the Path2.
  66074. * @returns the Path2.
  66075. */
  66076. close(): Path2;
  66077. /**
  66078. * Gets the sum of the distance between each sequential point in the path
  66079. * @returns the Path2 total length (float).
  66080. */
  66081. length(): number;
  66082. /**
  66083. * Gets the points which construct the path
  66084. * @returns the Path2 internal array of points.
  66085. */
  66086. getPoints(): Vector2[];
  66087. /**
  66088. * Retreives the point at the distance aways from the starting point
  66089. * @param normalizedLengthPosition the length along the path to retreive the point from
  66090. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  66091. */
  66092. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  66093. /**
  66094. * Creates a new path starting from an x and y position
  66095. * @param x starting x value
  66096. * @param y starting y value
  66097. * @returns a new Path2 starting at the coordinates (x, y).
  66098. */
  66099. static StartingAt(x: number, y: number): Path2;
  66100. }
  66101. /**
  66102. * Represents a 3D path made up of multiple 3D points
  66103. */
  66104. export class Path3D {
  66105. /**
  66106. * an array of Vector3, the curve axis of the Path3D
  66107. */
  66108. path: Vector3[];
  66109. private _curve;
  66110. private _distances;
  66111. private _tangents;
  66112. private _normals;
  66113. private _binormals;
  66114. private _raw;
  66115. /**
  66116. * new Path3D(path, normal, raw)
  66117. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  66118. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  66119. * @param path an array of Vector3, the curve axis of the Path3D
  66120. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  66121. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  66122. */
  66123. constructor(
  66124. /**
  66125. * an array of Vector3, the curve axis of the Path3D
  66126. */
  66127. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  66128. /**
  66129. * Returns the Path3D array of successive Vector3 designing its curve.
  66130. * @returns the Path3D array of successive Vector3 designing its curve.
  66131. */
  66132. getCurve(): Vector3[];
  66133. /**
  66134. * Returns an array populated with tangent vectors on each Path3D curve point.
  66135. * @returns an array populated with tangent vectors on each Path3D curve point.
  66136. */
  66137. getTangents(): Vector3[];
  66138. /**
  66139. * Returns an array populated with normal vectors on each Path3D curve point.
  66140. * @returns an array populated with normal vectors on each Path3D curve point.
  66141. */
  66142. getNormals(): Vector3[];
  66143. /**
  66144. * Returns an array populated with binormal vectors on each Path3D curve point.
  66145. * @returns an array populated with binormal vectors on each Path3D curve point.
  66146. */
  66147. getBinormals(): Vector3[];
  66148. /**
  66149. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  66150. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  66151. */
  66152. getDistances(): number[];
  66153. /**
  66154. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  66155. * @param path path which all values are copied into the curves points
  66156. * @param firstNormal which should be projected onto the curve
  66157. * @returns the same object updated.
  66158. */
  66159. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  66160. private _compute;
  66161. private _getFirstNonNullVector;
  66162. private _getLastNonNullVector;
  66163. private _normalVector;
  66164. }
  66165. /**
  66166. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66167. * A Curve3 is designed from a series of successive Vector3.
  66168. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  66169. */
  66170. export class Curve3 {
  66171. private _points;
  66172. private _length;
  66173. /**
  66174. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  66175. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  66176. * @param v1 (Vector3) the control point
  66177. * @param v2 (Vector3) the end point of the Quadratic Bezier
  66178. * @param nbPoints (integer) the wanted number of points in the curve
  66179. * @returns the created Curve3
  66180. */
  66181. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66182. /**
  66183. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  66184. * @param v0 (Vector3) the origin point of the Cubic Bezier
  66185. * @param v1 (Vector3) the first control point
  66186. * @param v2 (Vector3) the second control point
  66187. * @param v3 (Vector3) the end point of the Cubic Bezier
  66188. * @param nbPoints (integer) the wanted number of points in the curve
  66189. * @returns the created Curve3
  66190. */
  66191. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66192. /**
  66193. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  66194. * @param p1 (Vector3) the origin point of the Hermite Spline
  66195. * @param t1 (Vector3) the tangent vector at the origin point
  66196. * @param p2 (Vector3) the end point of the Hermite Spline
  66197. * @param t2 (Vector3) the tangent vector at the end point
  66198. * @param nbPoints (integer) the wanted number of points in the curve
  66199. * @returns the created Curve3
  66200. */
  66201. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  66202. /**
  66203. * Returns a Curve3 object along a CatmullRom Spline curve :
  66204. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  66205. * @param nbPoints (integer) the wanted number of points between each curve control points
  66206. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  66207. * @returns the created Curve3
  66208. */
  66209. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  66210. /**
  66211. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  66212. * A Curve3 is designed from a series of successive Vector3.
  66213. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  66214. * @param points points which make up the curve
  66215. */
  66216. constructor(points: Vector3[]);
  66217. /**
  66218. * @returns the Curve3 stored array of successive Vector3
  66219. */
  66220. getPoints(): Vector3[];
  66221. /**
  66222. * @returns the computed length (float) of the curve.
  66223. */
  66224. length(): number;
  66225. /**
  66226. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  66227. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  66228. * curveA and curveB keep unchanged.
  66229. * @param curve the curve to continue from this curve
  66230. * @returns the newly constructed curve
  66231. */
  66232. continue(curve: DeepImmutable<Curve3>): Curve3;
  66233. private _computeLength;
  66234. }
  66235. /**
  66236. * Contains position and normal vectors for a vertex
  66237. */
  66238. export class PositionNormalVertex {
  66239. /** the position of the vertex (defaut: 0,0,0) */
  66240. position: Vector3;
  66241. /** the normal of the vertex (defaut: 0,1,0) */
  66242. normal: Vector3;
  66243. /**
  66244. * Creates a PositionNormalVertex
  66245. * @param position the position of the vertex (defaut: 0,0,0)
  66246. * @param normal the normal of the vertex (defaut: 0,1,0)
  66247. */
  66248. constructor(
  66249. /** the position of the vertex (defaut: 0,0,0) */
  66250. position?: Vector3,
  66251. /** the normal of the vertex (defaut: 0,1,0) */
  66252. normal?: Vector3);
  66253. /**
  66254. * Clones the PositionNormalVertex
  66255. * @returns the cloned PositionNormalVertex
  66256. */
  66257. clone(): PositionNormalVertex;
  66258. }
  66259. /**
  66260. * Contains position, normal and uv vectors for a vertex
  66261. */
  66262. export class PositionNormalTextureVertex {
  66263. /** the position of the vertex (defaut: 0,0,0) */
  66264. position: Vector3;
  66265. /** the normal of the vertex (defaut: 0,1,0) */
  66266. normal: Vector3;
  66267. /** the uv of the vertex (default: 0,0) */
  66268. uv: Vector2;
  66269. /**
  66270. * Creates a PositionNormalTextureVertex
  66271. * @param position the position of the vertex (defaut: 0,0,0)
  66272. * @param normal the normal of the vertex (defaut: 0,1,0)
  66273. * @param uv the uv of the vertex (default: 0,0)
  66274. */
  66275. constructor(
  66276. /** the position of the vertex (defaut: 0,0,0) */
  66277. position?: Vector3,
  66278. /** the normal of the vertex (defaut: 0,1,0) */
  66279. normal?: Vector3,
  66280. /** the uv of the vertex (default: 0,0) */
  66281. uv?: Vector2);
  66282. /**
  66283. * Clones the PositionNormalTextureVertex
  66284. * @returns the cloned PositionNormalTextureVertex
  66285. */
  66286. clone(): PositionNormalTextureVertex;
  66287. }
  66288. /**
  66289. * @hidden
  66290. */
  66291. export class Tmp {
  66292. static Color3: Color3[];
  66293. static Color4: Color4[];
  66294. static Vector2: Vector2[];
  66295. static Vector3: Vector3[];
  66296. static Vector4: Vector4[];
  66297. static Quaternion: Quaternion[];
  66298. static Matrix: Matrix[];
  66299. }
  66300. }
  66301. declare module BABYLON {
  66302. /**
  66303. * Class used to enable access to offline support
  66304. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66305. */
  66306. export interface IOfflineProvider {
  66307. /**
  66308. * Gets a boolean indicating if scene must be saved in the database
  66309. */
  66310. enableSceneOffline: boolean;
  66311. /**
  66312. * Gets a boolean indicating if textures must be saved in the database
  66313. */
  66314. enableTexturesOffline: boolean;
  66315. /**
  66316. * Open the offline support and make it available
  66317. * @param successCallback defines the callback to call on success
  66318. * @param errorCallback defines the callback to call on error
  66319. */
  66320. open(successCallback: () => void, errorCallback: () => void): void;
  66321. /**
  66322. * Loads an image from the offline support
  66323. * @param url defines the url to load from
  66324. * @param image defines the target DOM image
  66325. */
  66326. loadImage(url: string, image: HTMLImageElement): void;
  66327. /**
  66328. * Loads a file from offline support
  66329. * @param url defines the URL to load from
  66330. * @param sceneLoaded defines a callback to call on success
  66331. * @param progressCallBack defines a callback to call when progress changed
  66332. * @param errorCallback defines a callback to call on error
  66333. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66334. */
  66335. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66336. }
  66337. }
  66338. declare module BABYLON {
  66339. /**
  66340. * A class serves as a medium between the observable and its observers
  66341. */
  66342. export class EventState {
  66343. /**
  66344. * Create a new EventState
  66345. * @param mask defines the mask associated with this state
  66346. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66347. * @param target defines the original target of the state
  66348. * @param currentTarget defines the current target of the state
  66349. */
  66350. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66351. /**
  66352. * Initialize the current event state
  66353. * @param mask defines the mask associated with this state
  66354. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66355. * @param target defines the original target of the state
  66356. * @param currentTarget defines the current target of the state
  66357. * @returns the current event state
  66358. */
  66359. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66360. /**
  66361. * An Observer can set this property to true to prevent subsequent observers of being notified
  66362. */
  66363. skipNextObservers: boolean;
  66364. /**
  66365. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66366. */
  66367. mask: number;
  66368. /**
  66369. * The object that originally notified the event
  66370. */
  66371. target?: any;
  66372. /**
  66373. * The current object in the bubbling phase
  66374. */
  66375. currentTarget?: any;
  66376. /**
  66377. * This will be populated with the return value of the last function that was executed.
  66378. * If it is the first function in the callback chain it will be the event data.
  66379. */
  66380. lastReturnValue?: any;
  66381. }
  66382. /**
  66383. * Represent an Observer registered to a given Observable object.
  66384. */
  66385. export class Observer<T> {
  66386. /**
  66387. * Defines the callback to call when the observer is notified
  66388. */
  66389. callback: (eventData: T, eventState: EventState) => void;
  66390. /**
  66391. * Defines the mask of the observer (used to filter notifications)
  66392. */
  66393. mask: number;
  66394. /**
  66395. * Defines the current scope used to restore the JS context
  66396. */
  66397. scope: any;
  66398. /** @hidden */
  66399. _willBeUnregistered: boolean;
  66400. /**
  66401. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66402. */
  66403. unregisterOnNextCall: boolean;
  66404. /**
  66405. * Creates a new observer
  66406. * @param callback defines the callback to call when the observer is notified
  66407. * @param mask defines the mask of the observer (used to filter notifications)
  66408. * @param scope defines the current scope used to restore the JS context
  66409. */
  66410. constructor(
  66411. /**
  66412. * Defines the callback to call when the observer is notified
  66413. */
  66414. callback: (eventData: T, eventState: EventState) => void,
  66415. /**
  66416. * Defines the mask of the observer (used to filter notifications)
  66417. */
  66418. mask: number,
  66419. /**
  66420. * Defines the current scope used to restore the JS context
  66421. */
  66422. scope?: any);
  66423. }
  66424. /**
  66425. * Represent a list of observers registered to multiple Observables object.
  66426. */
  66427. export class MultiObserver<T> {
  66428. private _observers;
  66429. private _observables;
  66430. /**
  66431. * Release associated resources
  66432. */
  66433. dispose(): void;
  66434. /**
  66435. * Raise a callback when one of the observable will notify
  66436. * @param observables defines a list of observables to watch
  66437. * @param callback defines the callback to call on notification
  66438. * @param mask defines the mask used to filter notifications
  66439. * @param scope defines the current scope used to restore the JS context
  66440. * @returns the new MultiObserver
  66441. */
  66442. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66443. }
  66444. /**
  66445. * The Observable class is a simple implementation of the Observable pattern.
  66446. *
  66447. * 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.
  66448. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66449. * 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).
  66450. * 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.
  66451. */
  66452. export class Observable<T> {
  66453. private _observers;
  66454. private _eventState;
  66455. private _onObserverAdded;
  66456. /**
  66457. * Creates a new observable
  66458. * @param onObserverAdded defines a callback to call when a new observer is added
  66459. */
  66460. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66461. /**
  66462. * Create a new Observer with the specified callback
  66463. * @param callback the callback that will be executed for that Observer
  66464. * @param mask the mask used to filter observers
  66465. * @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.
  66466. * @param scope optional scope for the callback to be called from
  66467. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66468. * @returns the new observer created for the callback
  66469. */
  66470. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66471. /**
  66472. * Create a new Observer with the specified callback and unregisters after the next notification
  66473. * @param callback the callback that will be executed for that Observer
  66474. * @returns the new observer created for the callback
  66475. */
  66476. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66477. /**
  66478. * Remove an Observer from the Observable object
  66479. * @param observer the instance of the Observer to remove
  66480. * @returns false if it doesn't belong to this Observable
  66481. */
  66482. remove(observer: Nullable<Observer<T>>): boolean;
  66483. /**
  66484. * Remove a callback from the Observable object
  66485. * @param callback the callback to remove
  66486. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66487. * @returns false if it doesn't belong to this Observable
  66488. */
  66489. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66490. private _deferUnregister;
  66491. private _remove;
  66492. /**
  66493. * Moves the observable to the top of the observer list making it get called first when notified
  66494. * @param observer the observer to move
  66495. */
  66496. makeObserverTopPriority(observer: Observer<T>): void;
  66497. /**
  66498. * Moves the observable to the bottom of the observer list making it get called last when notified
  66499. * @param observer the observer to move
  66500. */
  66501. makeObserverBottomPriority(observer: Observer<T>): void;
  66502. /**
  66503. * Notify all Observers by calling their respective callback with the given data
  66504. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66505. * @param eventData defines the data to send to all observers
  66506. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66507. * @param target defines the original target of the state
  66508. * @param currentTarget defines the current target of the state
  66509. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  66510. */
  66511. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  66512. /**
  66513. * Calling this will execute each callback, expecting it to be a promise or return a value.
  66514. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  66515. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  66516. * and it is crucial that all callbacks will be executed.
  66517. * The order of the callbacks is kept, callbacks are not executed parallel.
  66518. *
  66519. * @param eventData The data to be sent to each callback
  66520. * @param mask is used to filter observers defaults to -1
  66521. * @param target defines the callback target (see EventState)
  66522. * @param currentTarget defines he current object in the bubbling phase
  66523. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  66524. */
  66525. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  66526. /**
  66527. * Notify a specific observer
  66528. * @param observer defines the observer to notify
  66529. * @param eventData defines the data to be sent to each callback
  66530. * @param mask is used to filter observers defaults to -1
  66531. */
  66532. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  66533. /**
  66534. * Gets a boolean indicating if the observable has at least one observer
  66535. * @returns true is the Observable has at least one Observer registered
  66536. */
  66537. hasObservers(): boolean;
  66538. /**
  66539. * Clear the list of observers
  66540. */
  66541. clear(): void;
  66542. /**
  66543. * Clone the current observable
  66544. * @returns a new observable
  66545. */
  66546. clone(): Observable<T>;
  66547. /**
  66548. * Does this observable handles observer registered with a given mask
  66549. * @param mask defines the mask to be tested
  66550. * @return whether or not one observer registered with the given mask is handeled
  66551. **/
  66552. hasSpecificMask(mask?: number): boolean;
  66553. }
  66554. }
  66555. declare module BABYLON {
  66556. /**
  66557. * Class used to help managing file picking and drag'n'drop
  66558. * File Storage
  66559. */
  66560. export class FilesInputStore {
  66561. /**
  66562. * List of files ready to be loaded
  66563. */
  66564. static FilesToLoad: {
  66565. [key: string]: File;
  66566. };
  66567. }
  66568. }
  66569. declare module BABYLON {
  66570. /** Defines the cross module used constants to avoid circular dependncies */
  66571. export class Constants {
  66572. /** Defines that alpha blending is disabled */
  66573. static readonly ALPHA_DISABLE: number;
  66574. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  66575. static readonly ALPHA_ADD: number;
  66576. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  66577. static readonly ALPHA_COMBINE: number;
  66578. /** Defines that alpha blending to DEST - SRC * DEST */
  66579. static readonly ALPHA_SUBTRACT: number;
  66580. /** Defines that alpha blending to SRC * DEST */
  66581. static readonly ALPHA_MULTIPLY: number;
  66582. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  66583. static readonly ALPHA_MAXIMIZED: number;
  66584. /** Defines that alpha blending to SRC + DEST */
  66585. static readonly ALPHA_ONEONE: number;
  66586. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  66587. static readonly ALPHA_PREMULTIPLIED: number;
  66588. /**
  66589. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  66590. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  66591. */
  66592. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  66593. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  66594. static readonly ALPHA_INTERPOLATE: number;
  66595. /**
  66596. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  66597. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  66598. */
  66599. static readonly ALPHA_SCREENMODE: number;
  66600. /** Defines that the ressource is not delayed*/
  66601. static readonly DELAYLOADSTATE_NONE: number;
  66602. /** Defines that the ressource was successfully delay loaded */
  66603. static readonly DELAYLOADSTATE_LOADED: number;
  66604. /** Defines that the ressource is currently delay loading */
  66605. static readonly DELAYLOADSTATE_LOADING: number;
  66606. /** Defines that the ressource is delayed and has not started loading */
  66607. static readonly DELAYLOADSTATE_NOTLOADED: number;
  66608. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  66609. static readonly NEVER: number;
  66610. /** 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 */
  66611. static readonly ALWAYS: number;
  66612. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  66613. static readonly LESS: number;
  66614. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  66615. static readonly EQUAL: number;
  66616. /** 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 */
  66617. static readonly LEQUAL: number;
  66618. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  66619. static readonly GREATER: number;
  66620. /** 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 */
  66621. static readonly GEQUAL: number;
  66622. /** 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 */
  66623. static readonly NOTEQUAL: number;
  66624. /** Passed to stencilOperation to specify that stencil value must be kept */
  66625. static readonly KEEP: number;
  66626. /** Passed to stencilOperation to specify that stencil value must be replaced */
  66627. static readonly REPLACE: number;
  66628. /** Passed to stencilOperation to specify that stencil value must be incremented */
  66629. static readonly INCR: number;
  66630. /** Passed to stencilOperation to specify that stencil value must be decremented */
  66631. static readonly DECR: number;
  66632. /** Passed to stencilOperation to specify that stencil value must be inverted */
  66633. static readonly INVERT: number;
  66634. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  66635. static readonly INCR_WRAP: number;
  66636. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  66637. static readonly DECR_WRAP: number;
  66638. /** Texture is not repeating outside of 0..1 UVs */
  66639. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  66640. /** Texture is repeating outside of 0..1 UVs */
  66641. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  66642. /** Texture is repeating and mirrored */
  66643. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  66644. /** ALPHA */
  66645. static readonly TEXTUREFORMAT_ALPHA: number;
  66646. /** LUMINANCE */
  66647. static readonly TEXTUREFORMAT_LUMINANCE: number;
  66648. /** LUMINANCE_ALPHA */
  66649. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  66650. /** RGB */
  66651. static readonly TEXTUREFORMAT_RGB: number;
  66652. /** RGBA */
  66653. static readonly TEXTUREFORMAT_RGBA: number;
  66654. /** RED */
  66655. static readonly TEXTUREFORMAT_RED: number;
  66656. /** RED (2nd reference) */
  66657. static readonly TEXTUREFORMAT_R: number;
  66658. /** RG */
  66659. static readonly TEXTUREFORMAT_RG: number;
  66660. /** RED_INTEGER */
  66661. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  66662. /** RED_INTEGER (2nd reference) */
  66663. static readonly TEXTUREFORMAT_R_INTEGER: number;
  66664. /** RG_INTEGER */
  66665. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  66666. /** RGB_INTEGER */
  66667. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  66668. /** RGBA_INTEGER */
  66669. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  66670. /** UNSIGNED_BYTE */
  66671. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  66672. /** UNSIGNED_BYTE (2nd reference) */
  66673. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  66674. /** FLOAT */
  66675. static readonly TEXTURETYPE_FLOAT: number;
  66676. /** HALF_FLOAT */
  66677. static readonly TEXTURETYPE_HALF_FLOAT: number;
  66678. /** BYTE */
  66679. static readonly TEXTURETYPE_BYTE: number;
  66680. /** SHORT */
  66681. static readonly TEXTURETYPE_SHORT: number;
  66682. /** UNSIGNED_SHORT */
  66683. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  66684. /** INT */
  66685. static readonly TEXTURETYPE_INT: number;
  66686. /** UNSIGNED_INT */
  66687. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  66688. /** UNSIGNED_SHORT_4_4_4_4 */
  66689. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  66690. /** UNSIGNED_SHORT_5_5_5_1 */
  66691. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  66692. /** UNSIGNED_SHORT_5_6_5 */
  66693. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  66694. /** UNSIGNED_INT_2_10_10_10_REV */
  66695. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  66696. /** UNSIGNED_INT_24_8 */
  66697. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  66698. /** UNSIGNED_INT_10F_11F_11F_REV */
  66699. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  66700. /** UNSIGNED_INT_5_9_9_9_REV */
  66701. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  66702. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  66703. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  66704. /** nearest is mag = nearest and min = nearest and mip = linear */
  66705. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  66706. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66707. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  66708. /** Trilinear is mag = linear and min = linear and mip = linear */
  66709. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  66710. /** nearest is mag = nearest and min = nearest and mip = linear */
  66711. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  66712. /** Bilinear is mag = linear and min = linear and mip = nearest */
  66713. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  66714. /** Trilinear is mag = linear and min = linear and mip = linear */
  66715. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  66716. /** mag = nearest and min = nearest and mip = nearest */
  66717. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  66718. /** mag = nearest and min = linear and mip = nearest */
  66719. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  66720. /** mag = nearest and min = linear and mip = linear */
  66721. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  66722. /** mag = nearest and min = linear and mip = none */
  66723. static readonly TEXTURE_NEAREST_LINEAR: number;
  66724. /** mag = nearest and min = nearest and mip = none */
  66725. static readonly TEXTURE_NEAREST_NEAREST: number;
  66726. /** mag = linear and min = nearest and mip = nearest */
  66727. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  66728. /** mag = linear and min = nearest and mip = linear */
  66729. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  66730. /** mag = linear and min = linear and mip = none */
  66731. static readonly TEXTURE_LINEAR_LINEAR: number;
  66732. /** mag = linear and min = nearest and mip = none */
  66733. static readonly TEXTURE_LINEAR_NEAREST: number;
  66734. /** Explicit coordinates mode */
  66735. static readonly TEXTURE_EXPLICIT_MODE: number;
  66736. /** Spherical coordinates mode */
  66737. static readonly TEXTURE_SPHERICAL_MODE: number;
  66738. /** Planar coordinates mode */
  66739. static readonly TEXTURE_PLANAR_MODE: number;
  66740. /** Cubic coordinates mode */
  66741. static readonly TEXTURE_CUBIC_MODE: number;
  66742. /** Projection coordinates mode */
  66743. static readonly TEXTURE_PROJECTION_MODE: number;
  66744. /** Skybox coordinates mode */
  66745. static readonly TEXTURE_SKYBOX_MODE: number;
  66746. /** Inverse Cubic coordinates mode */
  66747. static readonly TEXTURE_INVCUBIC_MODE: number;
  66748. /** Equirectangular coordinates mode */
  66749. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  66750. /** Equirectangular Fixed coordinates mode */
  66751. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  66752. /** Equirectangular Fixed Mirrored coordinates mode */
  66753. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  66754. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  66755. static readonly SCALEMODE_FLOOR: number;
  66756. /** Defines that texture rescaling will look for the nearest power of 2 size */
  66757. static readonly SCALEMODE_NEAREST: number;
  66758. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  66759. static readonly SCALEMODE_CEILING: number;
  66760. /**
  66761. * The dirty texture flag value
  66762. */
  66763. static readonly MATERIAL_TextureDirtyFlag: number;
  66764. /**
  66765. * The dirty light flag value
  66766. */
  66767. static readonly MATERIAL_LightDirtyFlag: number;
  66768. /**
  66769. * The dirty fresnel flag value
  66770. */
  66771. static readonly MATERIAL_FresnelDirtyFlag: number;
  66772. /**
  66773. * The dirty attribute flag value
  66774. */
  66775. static readonly MATERIAL_AttributesDirtyFlag: number;
  66776. /**
  66777. * The dirty misc flag value
  66778. */
  66779. static readonly MATERIAL_MiscDirtyFlag: number;
  66780. /**
  66781. * The all dirty flag value
  66782. */
  66783. static readonly MATERIAL_AllDirtyFlag: number;
  66784. /**
  66785. * Returns the triangle fill mode
  66786. */
  66787. static readonly MATERIAL_TriangleFillMode: number;
  66788. /**
  66789. * Returns the wireframe mode
  66790. */
  66791. static readonly MATERIAL_WireFrameFillMode: number;
  66792. /**
  66793. * Returns the point fill mode
  66794. */
  66795. static readonly MATERIAL_PointFillMode: number;
  66796. /**
  66797. * Returns the point list draw mode
  66798. */
  66799. static readonly MATERIAL_PointListDrawMode: number;
  66800. /**
  66801. * Returns the line list draw mode
  66802. */
  66803. static readonly MATERIAL_LineListDrawMode: number;
  66804. /**
  66805. * Returns the line loop draw mode
  66806. */
  66807. static readonly MATERIAL_LineLoopDrawMode: number;
  66808. /**
  66809. * Returns the line strip draw mode
  66810. */
  66811. static readonly MATERIAL_LineStripDrawMode: number;
  66812. /**
  66813. * Returns the triangle strip draw mode
  66814. */
  66815. static readonly MATERIAL_TriangleStripDrawMode: number;
  66816. /**
  66817. * Returns the triangle fan draw mode
  66818. */
  66819. static readonly MATERIAL_TriangleFanDrawMode: number;
  66820. /**
  66821. * Stores the clock-wise side orientation
  66822. */
  66823. static readonly MATERIAL_ClockWiseSideOrientation: number;
  66824. /**
  66825. * Stores the counter clock-wise side orientation
  66826. */
  66827. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  66828. /**
  66829. * Nothing
  66830. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66831. */
  66832. static readonly ACTION_NothingTrigger: number;
  66833. /**
  66834. * On pick
  66835. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66836. */
  66837. static readonly ACTION_OnPickTrigger: number;
  66838. /**
  66839. * On left pick
  66840. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66841. */
  66842. static readonly ACTION_OnLeftPickTrigger: number;
  66843. /**
  66844. * On right pick
  66845. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66846. */
  66847. static readonly ACTION_OnRightPickTrigger: number;
  66848. /**
  66849. * On center pick
  66850. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66851. */
  66852. static readonly ACTION_OnCenterPickTrigger: number;
  66853. /**
  66854. * On pick down
  66855. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66856. */
  66857. static readonly ACTION_OnPickDownTrigger: number;
  66858. /**
  66859. * On double pick
  66860. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66861. */
  66862. static readonly ACTION_OnDoublePickTrigger: number;
  66863. /**
  66864. * On pick up
  66865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66866. */
  66867. static readonly ACTION_OnPickUpTrigger: number;
  66868. /**
  66869. * On pick out.
  66870. * This trigger will only be raised if you also declared a OnPickDown
  66871. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66872. */
  66873. static readonly ACTION_OnPickOutTrigger: number;
  66874. /**
  66875. * On long press
  66876. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66877. */
  66878. static readonly ACTION_OnLongPressTrigger: number;
  66879. /**
  66880. * On pointer over
  66881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66882. */
  66883. static readonly ACTION_OnPointerOverTrigger: number;
  66884. /**
  66885. * On pointer out
  66886. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66887. */
  66888. static readonly ACTION_OnPointerOutTrigger: number;
  66889. /**
  66890. * On every frame
  66891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66892. */
  66893. static readonly ACTION_OnEveryFrameTrigger: number;
  66894. /**
  66895. * On intersection enter
  66896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66897. */
  66898. static readonly ACTION_OnIntersectionEnterTrigger: number;
  66899. /**
  66900. * On intersection exit
  66901. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66902. */
  66903. static readonly ACTION_OnIntersectionExitTrigger: number;
  66904. /**
  66905. * On key down
  66906. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66907. */
  66908. static readonly ACTION_OnKeyDownTrigger: number;
  66909. /**
  66910. * On key up
  66911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  66912. */
  66913. static readonly ACTION_OnKeyUpTrigger: number;
  66914. /**
  66915. * Billboard mode will only apply to Y axis
  66916. */
  66917. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  66918. /**
  66919. * Billboard mode will apply to all axes
  66920. */
  66921. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  66922. /**
  66923. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  66924. */
  66925. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  66926. /**
  66927. * Gets or sets base Assets URL
  66928. */
  66929. static readonly PARTICLES_BaseAssetsUrl: string;
  66930. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  66931. * Test order :
  66932. * Is the bounding sphere outside the frustum ?
  66933. * If not, are the bounding box vertices outside the frustum ?
  66934. * It not, then the cullable object is in the frustum.
  66935. */
  66936. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  66937. /** Culling strategy : Bounding Sphere Only.
  66938. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  66939. * It's also less accurate than the standard because some not visible objects can still be selected.
  66940. * Test : is the bounding sphere outside the frustum ?
  66941. * If not, then the cullable object is in the frustum.
  66942. */
  66943. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  66944. /** Culling strategy : Optimistic Inclusion.
  66945. * This in an inclusion test first, then the standard exclusion test.
  66946. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  66947. * 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.
  66948. * Anyway, it's as accurate as the standard strategy.
  66949. * Test :
  66950. * Is the cullable object bounding sphere center in the frustum ?
  66951. * If not, apply the default culling strategy.
  66952. */
  66953. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  66954. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  66955. * This in an inclusion test first, then the bounding sphere only exclusion test.
  66956. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  66957. * 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.
  66958. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  66959. * Test :
  66960. * Is the cullable object bounding sphere center in the frustum ?
  66961. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  66962. */
  66963. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  66964. /**
  66965. * No logging while loading
  66966. */
  66967. static readonly SCENELOADER_NO_LOGGING: number;
  66968. /**
  66969. * Minimal logging while loading
  66970. */
  66971. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  66972. /**
  66973. * Summary logging while loading
  66974. */
  66975. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  66976. /**
  66977. * Detailled logging while loading
  66978. */
  66979. static readonly SCENELOADER_DETAILED_LOGGING: number;
  66980. }
  66981. }
  66982. declare module BABYLON {
  66983. /**
  66984. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  66985. * Babylon.js
  66986. */
  66987. export class DomManagement {
  66988. /**
  66989. * Checks if the window object exists
  66990. * @returns true if the window object exists
  66991. */
  66992. static IsWindowObjectExist(): boolean;
  66993. /**
  66994. * Extracts text content from a DOM element hierarchy
  66995. * @param element defines the root element
  66996. * @returns a string
  66997. */
  66998. static GetDOMTextContent(element: HTMLElement): string;
  66999. }
  67000. }
  67001. declare module BABYLON {
  67002. /**
  67003. * Logger used througouht the application to allow configuration of
  67004. * the log level required for the messages.
  67005. */
  67006. export class Logger {
  67007. /**
  67008. * No log
  67009. */
  67010. static readonly NoneLogLevel: number;
  67011. /**
  67012. * Only message logs
  67013. */
  67014. static readonly MessageLogLevel: number;
  67015. /**
  67016. * Only warning logs
  67017. */
  67018. static readonly WarningLogLevel: number;
  67019. /**
  67020. * Only error logs
  67021. */
  67022. static readonly ErrorLogLevel: number;
  67023. /**
  67024. * All logs
  67025. */
  67026. static readonly AllLogLevel: number;
  67027. private static _LogCache;
  67028. /**
  67029. * Gets a value indicating the number of loading errors
  67030. * @ignorenaming
  67031. */
  67032. static errorsCount: number;
  67033. /**
  67034. * Callback called when a new log is added
  67035. */
  67036. static OnNewCacheEntry: (entry: string) => void;
  67037. private static _AddLogEntry;
  67038. private static _FormatMessage;
  67039. private static _LogDisabled;
  67040. private static _LogEnabled;
  67041. private static _WarnDisabled;
  67042. private static _WarnEnabled;
  67043. private static _ErrorDisabled;
  67044. private static _ErrorEnabled;
  67045. /**
  67046. * Log a message to the console
  67047. */
  67048. static Log: (message: string) => void;
  67049. /**
  67050. * Write a warning message to the console
  67051. */
  67052. static Warn: (message: string) => void;
  67053. /**
  67054. * Write an error message to the console
  67055. */
  67056. static Error: (message: string) => void;
  67057. /**
  67058. * Gets current log cache (list of logs)
  67059. */
  67060. static readonly LogCache: string;
  67061. /**
  67062. * Clears the log cache
  67063. */
  67064. static ClearLogCache(): void;
  67065. /**
  67066. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67067. */
  67068. static LogLevels: number;
  67069. }
  67070. }
  67071. declare module BABYLON {
  67072. /** @hidden */
  67073. export class _TypeStore {
  67074. /** @hidden */
  67075. static RegisteredTypes: {
  67076. [key: string]: Object;
  67077. };
  67078. /** @hidden */
  67079. static GetClass(fqdn: string): any;
  67080. }
  67081. }
  67082. declare module BABYLON {
  67083. /**
  67084. * Class containing a set of static utilities functions for deep copy.
  67085. */
  67086. export class DeepCopier {
  67087. /**
  67088. * Tries to copy an object by duplicating every property
  67089. * @param source defines the source object
  67090. * @param destination defines the target object
  67091. * @param doNotCopyList defines a list of properties to avoid
  67092. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67093. */
  67094. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67095. }
  67096. }
  67097. declare module BABYLON {
  67098. /**
  67099. * Class containing a set of static utilities functions for precision date
  67100. */
  67101. export class PrecisionDate {
  67102. /**
  67103. * Gets either window.performance.now() if supported or Date.now() else
  67104. */
  67105. static readonly Now: number;
  67106. }
  67107. }
  67108. declare module BABYLON {
  67109. /** @hidden */
  67110. export class _DevTools {
  67111. static WarnImport(name: string): string;
  67112. }
  67113. }
  67114. declare module BABYLON {
  67115. /**
  67116. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67117. */
  67118. export class WebRequest {
  67119. private _xhr;
  67120. /**
  67121. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67122. * i.e. when loading files, where the server/service expects an Authorization header
  67123. */
  67124. static CustomRequestHeaders: {
  67125. [key: string]: string;
  67126. };
  67127. /**
  67128. * Add callback functions in this array to update all the requests before they get sent to the network
  67129. */
  67130. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  67131. private _injectCustomRequestHeaders;
  67132. /**
  67133. * Gets or sets a function to be called when loading progress changes
  67134. */
  67135. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67136. /**
  67137. * Returns client's state
  67138. */
  67139. readonly readyState: number;
  67140. /**
  67141. * Returns client's status
  67142. */
  67143. readonly status: number;
  67144. /**
  67145. * Returns client's status as a text
  67146. */
  67147. readonly statusText: string;
  67148. /**
  67149. * Returns client's response
  67150. */
  67151. readonly response: any;
  67152. /**
  67153. * Returns client's response url
  67154. */
  67155. readonly responseURL: string;
  67156. /**
  67157. * Returns client's response as text
  67158. */
  67159. readonly responseText: string;
  67160. /**
  67161. * Gets or sets the expected response type
  67162. */
  67163. responseType: XMLHttpRequestResponseType;
  67164. /** @hidden */
  67165. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67166. /** @hidden */
  67167. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67168. /**
  67169. * Cancels any network activity
  67170. */
  67171. abort(): void;
  67172. /**
  67173. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67174. * @param body defines an optional request body
  67175. */
  67176. send(body?: Document | BodyInit | null): void;
  67177. /**
  67178. * Sets the request method, request URL
  67179. * @param method defines the method to use (GET, POST, etc..)
  67180. * @param url defines the url to connect with
  67181. */
  67182. open(method: string, url: string): void;
  67183. }
  67184. }
  67185. declare module BABYLON {
  67186. /**
  67187. * Class used to evalaute queries containing `and` and `or` operators
  67188. */
  67189. export class AndOrNotEvaluator {
  67190. /**
  67191. * Evaluate a query
  67192. * @param query defines the query to evaluate
  67193. * @param evaluateCallback defines the callback used to filter result
  67194. * @returns true if the query matches
  67195. */
  67196. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  67197. private static _HandleParenthesisContent;
  67198. private static _SimplifyNegation;
  67199. }
  67200. }
  67201. declare module BABYLON {
  67202. /**
  67203. * Class used to store custom tags
  67204. */
  67205. export class Tags {
  67206. /**
  67207. * Adds support for tags on the given object
  67208. * @param obj defines the object to use
  67209. */
  67210. static EnableFor(obj: any): void;
  67211. /**
  67212. * Removes tags support
  67213. * @param obj defines the object to use
  67214. */
  67215. static DisableFor(obj: any): void;
  67216. /**
  67217. * Gets a boolean indicating if the given object has tags
  67218. * @param obj defines the object to use
  67219. * @returns a boolean
  67220. */
  67221. static HasTags(obj: any): boolean;
  67222. /**
  67223. * Gets the tags available on a given object
  67224. * @param obj defines the object to use
  67225. * @param asString defines if the tags must be returned as a string instead of an array of strings
  67226. * @returns the tags
  67227. */
  67228. static GetTags(obj: any, asString?: boolean): any;
  67229. /**
  67230. * Adds tags to an object
  67231. * @param obj defines the object to use
  67232. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  67233. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  67234. */
  67235. static AddTagsTo(obj: any, tagsString: string): void;
  67236. /**
  67237. * @hidden
  67238. */
  67239. static _AddTagTo(obj: any, tag: string): void;
  67240. /**
  67241. * Removes specific tags from a specific object
  67242. * @param obj defines the object to use
  67243. * @param tagsString defines the tags to remove
  67244. */
  67245. static RemoveTagsFrom(obj: any, tagsString: string): void;
  67246. /**
  67247. * @hidden
  67248. */
  67249. static _RemoveTagFrom(obj: any, tag: string): void;
  67250. /**
  67251. * Defines if tags hosted on an object match a given query
  67252. * @param obj defines the object to use
  67253. * @param tagsQuery defines the tag query
  67254. * @returns a boolean
  67255. */
  67256. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  67257. }
  67258. }
  67259. declare module BABYLON {
  67260. /**
  67261. * Manages the defines for the Material
  67262. */
  67263. export class MaterialDefines {
  67264. /** @hidden */
  67265. protected _keys: string[];
  67266. private _isDirty;
  67267. /** @hidden */
  67268. _renderId: number;
  67269. /** @hidden */
  67270. _areLightsDirty: boolean;
  67271. /** @hidden */
  67272. _areAttributesDirty: boolean;
  67273. /** @hidden */
  67274. _areTexturesDirty: boolean;
  67275. /** @hidden */
  67276. _areFresnelDirty: boolean;
  67277. /** @hidden */
  67278. _areMiscDirty: boolean;
  67279. /** @hidden */
  67280. _areImageProcessingDirty: boolean;
  67281. /** @hidden */
  67282. _normals: boolean;
  67283. /** @hidden */
  67284. _uvs: boolean;
  67285. /** @hidden */
  67286. _needNormals: boolean;
  67287. /** @hidden */
  67288. _needUVs: boolean;
  67289. [id: string]: any;
  67290. /**
  67291. * Specifies if the material needs to be re-calculated
  67292. */
  67293. readonly isDirty: boolean;
  67294. /**
  67295. * Marks the material to indicate that it has been re-calculated
  67296. */
  67297. markAsProcessed(): void;
  67298. /**
  67299. * Marks the material to indicate that it needs to be re-calculated
  67300. */
  67301. markAsUnprocessed(): void;
  67302. /**
  67303. * Marks the material to indicate all of its defines need to be re-calculated
  67304. */
  67305. markAllAsDirty(): void;
  67306. /**
  67307. * Marks the material to indicate that image processing needs to be re-calculated
  67308. */
  67309. markAsImageProcessingDirty(): void;
  67310. /**
  67311. * Marks the material to indicate the lights need to be re-calculated
  67312. */
  67313. markAsLightDirty(): void;
  67314. /**
  67315. * Marks the attribute state as changed
  67316. */
  67317. markAsAttributesDirty(): void;
  67318. /**
  67319. * Marks the texture state as changed
  67320. */
  67321. markAsTexturesDirty(): void;
  67322. /**
  67323. * Marks the fresnel state as changed
  67324. */
  67325. markAsFresnelDirty(): void;
  67326. /**
  67327. * Marks the misc state as changed
  67328. */
  67329. markAsMiscDirty(): void;
  67330. /**
  67331. * Rebuilds the material defines
  67332. */
  67333. rebuild(): void;
  67334. /**
  67335. * Specifies if two material defines are equal
  67336. * @param other - A material define instance to compare to
  67337. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  67338. */
  67339. isEqual(other: MaterialDefines): boolean;
  67340. /**
  67341. * Clones this instance's defines to another instance
  67342. * @param other - material defines to clone values to
  67343. */
  67344. cloneTo(other: MaterialDefines): void;
  67345. /**
  67346. * Resets the material define values
  67347. */
  67348. reset(): void;
  67349. /**
  67350. * Converts the material define values to a string
  67351. * @returns - String of material define information
  67352. */
  67353. toString(): string;
  67354. }
  67355. }
  67356. declare module BABYLON {
  67357. /**
  67358. * Class used to store and describe the pipeline context associated with an effect
  67359. */
  67360. export interface IPipelineContext {
  67361. /**
  67362. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  67363. */
  67364. isAsync: boolean;
  67365. /**
  67366. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  67367. */
  67368. isReady: boolean;
  67369. /** @hidden */
  67370. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  67371. }
  67372. }
  67373. declare module BABYLON {
  67374. /**
  67375. * Class used to store gfx data (like WebGLBuffer)
  67376. */
  67377. export class DataBuffer {
  67378. /**
  67379. * Gets or sets the number of objects referencing this buffer
  67380. */
  67381. references: number;
  67382. /** Gets or sets the size of the underlying buffer */
  67383. capacity: number;
  67384. /**
  67385. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  67386. */
  67387. is32Bits: boolean;
  67388. /**
  67389. * Gets the underlying buffer
  67390. */
  67391. readonly underlyingResource: any;
  67392. }
  67393. }
  67394. declare module BABYLON {
  67395. /**
  67396. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  67397. */
  67398. export class PerformanceMonitor {
  67399. private _enabled;
  67400. private _rollingFrameTime;
  67401. private _lastFrameTimeMs;
  67402. /**
  67403. * constructor
  67404. * @param frameSampleSize The number of samples required to saturate the sliding window
  67405. */
  67406. constructor(frameSampleSize?: number);
  67407. /**
  67408. * Samples current frame
  67409. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  67410. */
  67411. sampleFrame(timeMs?: number): void;
  67412. /**
  67413. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67414. */
  67415. readonly averageFrameTime: number;
  67416. /**
  67417. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  67418. */
  67419. readonly averageFrameTimeVariance: number;
  67420. /**
  67421. * Returns the frame time of the most recent frame
  67422. */
  67423. readonly instantaneousFrameTime: number;
  67424. /**
  67425. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  67426. */
  67427. readonly averageFPS: number;
  67428. /**
  67429. * Returns the average framerate in frames per second using the most recent frame time
  67430. */
  67431. readonly instantaneousFPS: number;
  67432. /**
  67433. * Returns true if enough samples have been taken to completely fill the sliding window
  67434. */
  67435. readonly isSaturated: boolean;
  67436. /**
  67437. * Enables contributions to the sliding window sample set
  67438. */
  67439. enable(): void;
  67440. /**
  67441. * Disables contributions to the sliding window sample set
  67442. * Samples will not be interpolated over the disabled period
  67443. */
  67444. disable(): void;
  67445. /**
  67446. * Returns true if sampling is enabled
  67447. */
  67448. readonly isEnabled: boolean;
  67449. /**
  67450. * Resets performance monitor
  67451. */
  67452. reset(): void;
  67453. }
  67454. /**
  67455. * RollingAverage
  67456. *
  67457. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  67458. */
  67459. export class RollingAverage {
  67460. /**
  67461. * Current average
  67462. */
  67463. average: number;
  67464. /**
  67465. * Current variance
  67466. */
  67467. variance: number;
  67468. protected _samples: Array<number>;
  67469. protected _sampleCount: number;
  67470. protected _pos: number;
  67471. protected _m2: number;
  67472. /**
  67473. * constructor
  67474. * @param length The number of samples required to saturate the sliding window
  67475. */
  67476. constructor(length: number);
  67477. /**
  67478. * Adds a sample to the sample set
  67479. * @param v The sample value
  67480. */
  67481. add(v: number): void;
  67482. /**
  67483. * Returns previously added values or null if outside of history or outside the sliding window domain
  67484. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  67485. * @return Value previously recorded with add() or null if outside of range
  67486. */
  67487. history(i: number): number;
  67488. /**
  67489. * Returns true if enough samples have been taken to completely fill the sliding window
  67490. * @return true if sample-set saturated
  67491. */
  67492. isSaturated(): boolean;
  67493. /**
  67494. * Resets the rolling average (equivalent to 0 samples taken so far)
  67495. */
  67496. reset(): void;
  67497. /**
  67498. * Wraps a value around the sample range boundaries
  67499. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  67500. * @return Wrapped position in sample range
  67501. */
  67502. protected _wrapPosition(i: number): number;
  67503. }
  67504. }
  67505. declare module BABYLON {
  67506. /**
  67507. * This class implement a typical dictionary using a string as key and the generic type T as value.
  67508. * The underlying implementation relies on an associative array to ensure the best performances.
  67509. * The value can be anything including 'null' but except 'undefined'
  67510. */
  67511. export class StringDictionary<T> {
  67512. /**
  67513. * This will clear this dictionary and copy the content from the 'source' one.
  67514. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  67515. * @param source the dictionary to take the content from and copy to this dictionary
  67516. */
  67517. copyFrom(source: StringDictionary<T>): void;
  67518. /**
  67519. * Get a value based from its key
  67520. * @param key the given key to get the matching value from
  67521. * @return the value if found, otherwise undefined is returned
  67522. */
  67523. get(key: string): T | undefined;
  67524. /**
  67525. * Get a value from its key or add it if it doesn't exist.
  67526. * This method will ensure you that a given key/data will be present in the dictionary.
  67527. * @param key the given key to get the matching value from
  67528. * @param factory the factory that will create the value if the key is not present in the dictionary.
  67529. * The factory will only be invoked if there's no data for the given key.
  67530. * @return the value corresponding to the key.
  67531. */
  67532. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  67533. /**
  67534. * Get a value from its key if present in the dictionary otherwise add it
  67535. * @param key the key to get the value from
  67536. * @param val if there's no such key/value pair in the dictionary add it with this value
  67537. * @return the value corresponding to the key
  67538. */
  67539. getOrAdd(key: string, val: T): T;
  67540. /**
  67541. * Check if there's a given key in the dictionary
  67542. * @param key the key to check for
  67543. * @return true if the key is present, false otherwise
  67544. */
  67545. contains(key: string): boolean;
  67546. /**
  67547. * Add a new key and its corresponding value
  67548. * @param key the key to add
  67549. * @param value the value corresponding to the key
  67550. * @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
  67551. */
  67552. add(key: string, value: T): boolean;
  67553. /**
  67554. * Update a specific value associated to a key
  67555. * @param key defines the key to use
  67556. * @param value defines the value to store
  67557. * @returns true if the value was updated (or false if the key was not found)
  67558. */
  67559. set(key: string, value: T): boolean;
  67560. /**
  67561. * Get the element of the given key and remove it from the dictionary
  67562. * @param key defines the key to search
  67563. * @returns the value associated with the key or null if not found
  67564. */
  67565. getAndRemove(key: string): Nullable<T>;
  67566. /**
  67567. * Remove a key/value from the dictionary.
  67568. * @param key the key to remove
  67569. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  67570. */
  67571. remove(key: string): boolean;
  67572. /**
  67573. * Clear the whole content of the dictionary
  67574. */
  67575. clear(): void;
  67576. /**
  67577. * Gets the current count
  67578. */
  67579. readonly count: number;
  67580. /**
  67581. * Execute a callback on each key/val of the dictionary.
  67582. * Note that you can remove any element in this dictionary in the callback implementation
  67583. * @param callback the callback to execute on a given key/value pair
  67584. */
  67585. forEach(callback: (key: string, val: T) => void): void;
  67586. /**
  67587. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  67588. * If the callback returns null or undefined the method will iterate to the next key/value pair
  67589. * Note that you can remove any element in this dictionary in the callback implementation
  67590. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  67591. * @returns the first item
  67592. */
  67593. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  67594. private _count;
  67595. private _data;
  67596. }
  67597. }
  67598. declare module BABYLON {
  67599. /**
  67600. * Helper class that provides a small promise polyfill
  67601. */
  67602. export class PromisePolyfill {
  67603. /**
  67604. * Static function used to check if the polyfill is required
  67605. * If this is the case then the function will inject the polyfill to window.Promise
  67606. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  67607. */
  67608. static Apply(force?: boolean): void;
  67609. }
  67610. }
  67611. declare module BABYLON {
  67612. /**
  67613. * Class used to store data that will be store in GPU memory
  67614. */
  67615. export class Buffer {
  67616. private _engine;
  67617. private _buffer;
  67618. /** @hidden */
  67619. _data: Nullable<DataArray>;
  67620. private _updatable;
  67621. private _instanced;
  67622. /**
  67623. * Gets the byte stride.
  67624. */
  67625. readonly byteStride: number;
  67626. /**
  67627. * Constructor
  67628. * @param engine the engine
  67629. * @param data the data to use for this buffer
  67630. * @param updatable whether the data is updatable
  67631. * @param stride the stride (optional)
  67632. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  67633. * @param instanced whether the buffer is instanced (optional)
  67634. * @param useBytes set to true if the stride in in bytes (optional)
  67635. */
  67636. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  67637. /**
  67638. * Create a new VertexBuffer based on the current buffer
  67639. * @param kind defines the vertex buffer kind (position, normal, etc.)
  67640. * @param offset defines offset in the buffer (0 by default)
  67641. * @param size defines the size in floats of attributes (position is 3 for instance)
  67642. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  67643. * @param instanced defines if the vertex buffer contains indexed data
  67644. * @param useBytes defines if the offset and stride are in bytes
  67645. * @returns the new vertex buffer
  67646. */
  67647. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  67648. /**
  67649. * Gets a boolean indicating if the Buffer is updatable?
  67650. * @returns true if the buffer is updatable
  67651. */
  67652. isUpdatable(): boolean;
  67653. /**
  67654. * Gets current buffer's data
  67655. * @returns a DataArray or null
  67656. */
  67657. getData(): Nullable<DataArray>;
  67658. /**
  67659. * Gets underlying native buffer
  67660. * @returns underlying native buffer
  67661. */
  67662. getBuffer(): Nullable<DataBuffer>;
  67663. /**
  67664. * Gets the stride in float32 units (i.e. byte stride / 4).
  67665. * May not be an integer if the byte stride is not divisible by 4.
  67666. * DEPRECATED. Use byteStride instead.
  67667. * @returns the stride in float32 units
  67668. */
  67669. getStrideSize(): number;
  67670. /**
  67671. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  67672. * @param data defines the data to store
  67673. */
  67674. create(data?: Nullable<DataArray>): void;
  67675. /** @hidden */
  67676. _rebuild(): void;
  67677. /**
  67678. * Update current buffer data
  67679. * @param data defines the data to store
  67680. */
  67681. update(data: DataArray): void;
  67682. /**
  67683. * Updates the data directly.
  67684. * @param data the new data
  67685. * @param offset the new offset
  67686. * @param vertexCount the vertex count (optional)
  67687. * @param useBytes set to true if the offset is in bytes
  67688. */
  67689. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  67690. /**
  67691. * Release all resources
  67692. */
  67693. dispose(): void;
  67694. }
  67695. /**
  67696. * Specialized buffer used to store vertex data
  67697. */
  67698. export class VertexBuffer {
  67699. /** @hidden */
  67700. _buffer: Buffer;
  67701. private _kind;
  67702. private _size;
  67703. private _ownsBuffer;
  67704. private _instanced;
  67705. private _instanceDivisor;
  67706. /**
  67707. * The byte type.
  67708. */
  67709. static readonly BYTE: number;
  67710. /**
  67711. * The unsigned byte type.
  67712. */
  67713. static readonly UNSIGNED_BYTE: number;
  67714. /**
  67715. * The short type.
  67716. */
  67717. static readonly SHORT: number;
  67718. /**
  67719. * The unsigned short type.
  67720. */
  67721. static readonly UNSIGNED_SHORT: number;
  67722. /**
  67723. * The integer type.
  67724. */
  67725. static readonly INT: number;
  67726. /**
  67727. * The unsigned integer type.
  67728. */
  67729. static readonly UNSIGNED_INT: number;
  67730. /**
  67731. * The float type.
  67732. */
  67733. static readonly FLOAT: number;
  67734. /**
  67735. * Gets or sets the instance divisor when in instanced mode
  67736. */
  67737. instanceDivisor: number;
  67738. /**
  67739. * Gets the byte stride.
  67740. */
  67741. readonly byteStride: number;
  67742. /**
  67743. * Gets the byte offset.
  67744. */
  67745. readonly byteOffset: number;
  67746. /**
  67747. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  67748. */
  67749. readonly normalized: boolean;
  67750. /**
  67751. * Gets the data type of each component in the array.
  67752. */
  67753. readonly type: number;
  67754. /**
  67755. * Constructor
  67756. * @param engine the engine
  67757. * @param data the data to use for this vertex buffer
  67758. * @param kind the vertex buffer kind
  67759. * @param updatable whether the data is updatable
  67760. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  67761. * @param stride the stride (optional)
  67762. * @param instanced whether the buffer is instanced (optional)
  67763. * @param offset the offset of the data (optional)
  67764. * @param size the number of components (optional)
  67765. * @param type the type of the component (optional)
  67766. * @param normalized whether the data contains normalized data (optional)
  67767. * @param useBytes set to true if stride and offset are in bytes (optional)
  67768. */
  67769. 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);
  67770. /** @hidden */
  67771. _rebuild(): void;
  67772. /**
  67773. * Returns the kind of the VertexBuffer (string)
  67774. * @returns a string
  67775. */
  67776. getKind(): string;
  67777. /**
  67778. * Gets a boolean indicating if the VertexBuffer is updatable?
  67779. * @returns true if the buffer is updatable
  67780. */
  67781. isUpdatable(): boolean;
  67782. /**
  67783. * Gets current buffer's data
  67784. * @returns a DataArray or null
  67785. */
  67786. getData(): Nullable<DataArray>;
  67787. /**
  67788. * Gets underlying native buffer
  67789. * @returns underlying native buffer
  67790. */
  67791. getBuffer(): Nullable<DataBuffer>;
  67792. /**
  67793. * Gets the stride in float32 units (i.e. byte stride / 4).
  67794. * May not be an integer if the byte stride is not divisible by 4.
  67795. * DEPRECATED. Use byteStride instead.
  67796. * @returns the stride in float32 units
  67797. */
  67798. getStrideSize(): number;
  67799. /**
  67800. * Returns the offset as a multiple of the type byte length.
  67801. * DEPRECATED. Use byteOffset instead.
  67802. * @returns the offset in bytes
  67803. */
  67804. getOffset(): number;
  67805. /**
  67806. * Returns the number of components per vertex attribute (integer)
  67807. * @returns the size in float
  67808. */
  67809. getSize(): number;
  67810. /**
  67811. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  67812. * @returns true if this buffer is instanced
  67813. */
  67814. getIsInstanced(): boolean;
  67815. /**
  67816. * Returns the instancing divisor, zero for non-instanced (integer).
  67817. * @returns a number
  67818. */
  67819. getInstanceDivisor(): number;
  67820. /**
  67821. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  67822. * @param data defines the data to store
  67823. */
  67824. create(data?: DataArray): void;
  67825. /**
  67826. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  67827. * This function will create a new buffer if the current one is not updatable
  67828. * @param data defines the data to store
  67829. */
  67830. update(data: DataArray): void;
  67831. /**
  67832. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  67833. * Returns the directly updated WebGLBuffer.
  67834. * @param data the new data
  67835. * @param offset the new offset
  67836. * @param useBytes set to true if the offset is in bytes
  67837. */
  67838. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  67839. /**
  67840. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  67841. */
  67842. dispose(): void;
  67843. /**
  67844. * Enumerates each value of this vertex buffer as numbers.
  67845. * @param count the number of values to enumerate
  67846. * @param callback the callback function called for each value
  67847. */
  67848. forEach(count: number, callback: (value: number, index: number) => void): void;
  67849. /**
  67850. * Positions
  67851. */
  67852. static readonly PositionKind: string;
  67853. /**
  67854. * Normals
  67855. */
  67856. static readonly NormalKind: string;
  67857. /**
  67858. * Tangents
  67859. */
  67860. static readonly TangentKind: string;
  67861. /**
  67862. * Texture coordinates
  67863. */
  67864. static readonly UVKind: string;
  67865. /**
  67866. * Texture coordinates 2
  67867. */
  67868. static readonly UV2Kind: string;
  67869. /**
  67870. * Texture coordinates 3
  67871. */
  67872. static readonly UV3Kind: string;
  67873. /**
  67874. * Texture coordinates 4
  67875. */
  67876. static readonly UV4Kind: string;
  67877. /**
  67878. * Texture coordinates 5
  67879. */
  67880. static readonly UV5Kind: string;
  67881. /**
  67882. * Texture coordinates 6
  67883. */
  67884. static readonly UV6Kind: string;
  67885. /**
  67886. * Colors
  67887. */
  67888. static readonly ColorKind: string;
  67889. /**
  67890. * Matrix indices (for bones)
  67891. */
  67892. static readonly MatricesIndicesKind: string;
  67893. /**
  67894. * Matrix weights (for bones)
  67895. */
  67896. static readonly MatricesWeightsKind: string;
  67897. /**
  67898. * Additional matrix indices (for bones)
  67899. */
  67900. static readonly MatricesIndicesExtraKind: string;
  67901. /**
  67902. * Additional matrix weights (for bones)
  67903. */
  67904. static readonly MatricesWeightsExtraKind: string;
  67905. /**
  67906. * Deduces the stride given a kind.
  67907. * @param kind The kind string to deduce
  67908. * @returns The deduced stride
  67909. */
  67910. static DeduceStride(kind: string): number;
  67911. /**
  67912. * Gets the byte length of the given type.
  67913. * @param type the type
  67914. * @returns the number of bytes
  67915. */
  67916. static GetTypeByteLength(type: number): number;
  67917. /**
  67918. * Enumerates each value of the given parameters as numbers.
  67919. * @param data the data to enumerate
  67920. * @param byteOffset the byte offset of the data
  67921. * @param byteStride the byte stride of the data
  67922. * @param componentCount the number of components per element
  67923. * @param componentType the type of the component
  67924. * @param count the total number of components
  67925. * @param normalized whether the data is normalized
  67926. * @param callback the callback function called for each value
  67927. */
  67928. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  67929. private static _GetFloatValue;
  67930. }
  67931. }
  67932. declare module BABYLON {
  67933. /**
  67934. * Class representing spherical harmonics coefficients to the 3rd degree
  67935. */
  67936. export class SphericalHarmonics {
  67937. /**
  67938. * Defines whether or not the harmonics have been prescaled for rendering.
  67939. */
  67940. preScaled: boolean;
  67941. /**
  67942. * The l0,0 coefficients of the spherical harmonics
  67943. */
  67944. l00: Vector3;
  67945. /**
  67946. * The l1,-1 coefficients of the spherical harmonics
  67947. */
  67948. l1_1: Vector3;
  67949. /**
  67950. * The l1,0 coefficients of the spherical harmonics
  67951. */
  67952. l10: Vector3;
  67953. /**
  67954. * The l1,1 coefficients of the spherical harmonics
  67955. */
  67956. l11: Vector3;
  67957. /**
  67958. * The l2,-2 coefficients of the spherical harmonics
  67959. */
  67960. l2_2: Vector3;
  67961. /**
  67962. * The l2,-1 coefficients of the spherical harmonics
  67963. */
  67964. l2_1: Vector3;
  67965. /**
  67966. * The l2,0 coefficients of the spherical harmonics
  67967. */
  67968. l20: Vector3;
  67969. /**
  67970. * The l2,1 coefficients of the spherical harmonics
  67971. */
  67972. l21: Vector3;
  67973. /**
  67974. * The l2,2 coefficients of the spherical harmonics
  67975. */
  67976. l22: Vector3;
  67977. /**
  67978. * Adds a light to the spherical harmonics
  67979. * @param direction the direction of the light
  67980. * @param color the color of the light
  67981. * @param deltaSolidAngle the delta solid angle of the light
  67982. */
  67983. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  67984. /**
  67985. * Scales the spherical harmonics by the given amount
  67986. * @param scale the amount to scale
  67987. */
  67988. scaleInPlace(scale: number): void;
  67989. /**
  67990. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  67991. *
  67992. * ```
  67993. * E_lm = A_l * L_lm
  67994. * ```
  67995. *
  67996. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  67997. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  67998. * the scaling factors are given in equation 9.
  67999. */
  68000. convertIncidentRadianceToIrradiance(): void;
  68001. /**
  68002. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  68003. *
  68004. * ```
  68005. * L = (1/pi) * E * rho
  68006. * ```
  68007. *
  68008. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  68009. */
  68010. convertIrradianceToLambertianRadiance(): void;
  68011. /**
  68012. * Integrates the reconstruction coefficients directly in to the SH preventing further
  68013. * required operations at run time.
  68014. *
  68015. * This is simply done by scaling back the SH with Ylm constants parameter.
  68016. * The trigonometric part being applied by the shader at run time.
  68017. */
  68018. preScaleForRendering(): void;
  68019. /**
  68020. * Constructs a spherical harmonics from an array.
  68021. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  68022. * @returns the spherical harmonics
  68023. */
  68024. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  68025. /**
  68026. * Gets the spherical harmonics from polynomial
  68027. * @param polynomial the spherical polynomial
  68028. * @returns the spherical harmonics
  68029. */
  68030. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  68031. }
  68032. /**
  68033. * Class representing spherical polynomial coefficients to the 3rd degree
  68034. */
  68035. export class SphericalPolynomial {
  68036. private _harmonics;
  68037. /**
  68038. * The spherical harmonics used to create the polynomials.
  68039. */
  68040. readonly preScaledHarmonics: SphericalHarmonics;
  68041. /**
  68042. * The x coefficients of the spherical polynomial
  68043. */
  68044. x: Vector3;
  68045. /**
  68046. * The y coefficients of the spherical polynomial
  68047. */
  68048. y: Vector3;
  68049. /**
  68050. * The z coefficients of the spherical polynomial
  68051. */
  68052. z: Vector3;
  68053. /**
  68054. * The xx coefficients of the spherical polynomial
  68055. */
  68056. xx: Vector3;
  68057. /**
  68058. * The yy coefficients of the spherical polynomial
  68059. */
  68060. yy: Vector3;
  68061. /**
  68062. * The zz coefficients of the spherical polynomial
  68063. */
  68064. zz: Vector3;
  68065. /**
  68066. * The xy coefficients of the spherical polynomial
  68067. */
  68068. xy: Vector3;
  68069. /**
  68070. * The yz coefficients of the spherical polynomial
  68071. */
  68072. yz: Vector3;
  68073. /**
  68074. * The zx coefficients of the spherical polynomial
  68075. */
  68076. zx: Vector3;
  68077. /**
  68078. * Adds an ambient color to the spherical polynomial
  68079. * @param color the color to add
  68080. */
  68081. addAmbient(color: Color3): void;
  68082. /**
  68083. * Scales the spherical polynomial by the given amount
  68084. * @param scale the amount to scale
  68085. */
  68086. scaleInPlace(scale: number): void;
  68087. /**
  68088. * Gets the spherical polynomial from harmonics
  68089. * @param harmonics the spherical harmonics
  68090. * @returns the spherical polynomial
  68091. */
  68092. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  68093. /**
  68094. * Constructs a spherical polynomial from an array.
  68095. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  68096. * @returns the spherical polynomial
  68097. */
  68098. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  68099. }
  68100. }
  68101. declare module BABYLON {
  68102. /**
  68103. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  68104. */
  68105. export interface CubeMapInfo {
  68106. /**
  68107. * The pixel array for the front face.
  68108. * This is stored in format, left to right, up to down format.
  68109. */
  68110. front: Nullable<ArrayBufferView>;
  68111. /**
  68112. * The pixel array for the back face.
  68113. * This is stored in format, left to right, up to down format.
  68114. */
  68115. back: Nullable<ArrayBufferView>;
  68116. /**
  68117. * The pixel array for the left face.
  68118. * This is stored in format, left to right, up to down format.
  68119. */
  68120. left: Nullable<ArrayBufferView>;
  68121. /**
  68122. * The pixel array for the right face.
  68123. * This is stored in format, left to right, up to down format.
  68124. */
  68125. right: Nullable<ArrayBufferView>;
  68126. /**
  68127. * The pixel array for the up face.
  68128. * This is stored in format, left to right, up to down format.
  68129. */
  68130. up: Nullable<ArrayBufferView>;
  68131. /**
  68132. * The pixel array for the down face.
  68133. * This is stored in format, left to right, up to down format.
  68134. */
  68135. down: Nullable<ArrayBufferView>;
  68136. /**
  68137. * The size of the cubemap stored.
  68138. *
  68139. * Each faces will be size * size pixels.
  68140. */
  68141. size: number;
  68142. /**
  68143. * The format of the texture.
  68144. *
  68145. * RGBA, RGB.
  68146. */
  68147. format: number;
  68148. /**
  68149. * The type of the texture data.
  68150. *
  68151. * UNSIGNED_INT, FLOAT.
  68152. */
  68153. type: number;
  68154. /**
  68155. * Specifies whether the texture is in gamma space.
  68156. */
  68157. gammaSpace: boolean;
  68158. }
  68159. /**
  68160. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  68161. */
  68162. export class PanoramaToCubeMapTools {
  68163. private static FACE_FRONT;
  68164. private static FACE_BACK;
  68165. private static FACE_RIGHT;
  68166. private static FACE_LEFT;
  68167. private static FACE_DOWN;
  68168. private static FACE_UP;
  68169. /**
  68170. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  68171. *
  68172. * @param float32Array The source data.
  68173. * @param inputWidth The width of the input panorama.
  68174. * @param inputHeight The height of the input panorama.
  68175. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  68176. * @return The cubemap data
  68177. */
  68178. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  68179. private static CreateCubemapTexture;
  68180. private static CalcProjectionSpherical;
  68181. }
  68182. }
  68183. declare module BABYLON {
  68184. /**
  68185. * Helper class dealing with the extraction of spherical polynomial dataArray
  68186. * from a cube map.
  68187. */
  68188. export class CubeMapToSphericalPolynomialTools {
  68189. private static FileFaces;
  68190. /**
  68191. * Converts a texture to the according Spherical Polynomial data.
  68192. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68193. *
  68194. * @param texture The texture to extract the information from.
  68195. * @return The Spherical Polynomial data.
  68196. */
  68197. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  68198. /**
  68199. * Converts a cubemap to the according Spherical Polynomial data.
  68200. * This extracts the first 3 orders only as they are the only one used in the lighting.
  68201. *
  68202. * @param cubeInfo The Cube map to extract the information from.
  68203. * @return The Spherical Polynomial data.
  68204. */
  68205. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  68206. }
  68207. }
  68208. declare module BABYLON {
  68209. /**
  68210. * The engine store class is responsible to hold all the instances of Engine and Scene created
  68211. * during the life time of the application.
  68212. */
  68213. export class EngineStore {
  68214. /** Gets the list of created engines */
  68215. static Instances: Engine[];
  68216. /** @hidden */
  68217. static _LastCreatedScene: Nullable<Scene>;
  68218. /**
  68219. * Gets the latest created engine
  68220. */
  68221. static readonly LastCreatedEngine: Nullable<Engine>;
  68222. /**
  68223. * Gets the latest created scene
  68224. */
  68225. static readonly LastCreatedScene: Nullable<Scene>;
  68226. }
  68227. }
  68228. declare module BABYLON {
  68229. /**
  68230. * Define options used to create a render target texture
  68231. */
  68232. export class RenderTargetCreationOptions {
  68233. /**
  68234. * Specifies is mipmaps must be generated
  68235. */
  68236. generateMipMaps?: boolean;
  68237. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  68238. generateDepthBuffer?: boolean;
  68239. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  68240. generateStencilBuffer?: boolean;
  68241. /** Defines texture type (int by default) */
  68242. type?: number;
  68243. /** Defines sampling mode (trilinear by default) */
  68244. samplingMode?: number;
  68245. /** Defines format (RGBA by default) */
  68246. format?: number;
  68247. }
  68248. }
  68249. declare module BABYLON {
  68250. /**
  68251. * @hidden
  68252. **/
  68253. export class _AlphaState {
  68254. private _isAlphaBlendDirty;
  68255. private _isBlendFunctionParametersDirty;
  68256. private _isBlendEquationParametersDirty;
  68257. private _isBlendConstantsDirty;
  68258. private _alphaBlend;
  68259. private _blendFunctionParameters;
  68260. private _blendEquationParameters;
  68261. private _blendConstants;
  68262. /**
  68263. * Initializes the state.
  68264. */
  68265. constructor();
  68266. readonly isDirty: boolean;
  68267. alphaBlend: boolean;
  68268. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  68269. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  68270. setAlphaEquationParameters(rgb: number, alpha: number): void;
  68271. reset(): void;
  68272. apply(gl: WebGLRenderingContext): void;
  68273. }
  68274. }
  68275. declare module BABYLON {
  68276. /**
  68277. * @hidden
  68278. **/
  68279. export class _DepthCullingState {
  68280. private _isDepthTestDirty;
  68281. private _isDepthMaskDirty;
  68282. private _isDepthFuncDirty;
  68283. private _isCullFaceDirty;
  68284. private _isCullDirty;
  68285. private _isZOffsetDirty;
  68286. private _isFrontFaceDirty;
  68287. private _depthTest;
  68288. private _depthMask;
  68289. private _depthFunc;
  68290. private _cull;
  68291. private _cullFace;
  68292. private _zOffset;
  68293. private _frontFace;
  68294. /**
  68295. * Initializes the state.
  68296. */
  68297. constructor();
  68298. readonly isDirty: boolean;
  68299. zOffset: number;
  68300. cullFace: Nullable<number>;
  68301. cull: Nullable<boolean>;
  68302. depthFunc: Nullable<number>;
  68303. depthMask: boolean;
  68304. depthTest: boolean;
  68305. frontFace: Nullable<number>;
  68306. reset(): void;
  68307. apply(gl: WebGLRenderingContext): void;
  68308. }
  68309. }
  68310. declare module BABYLON {
  68311. /**
  68312. * @hidden
  68313. **/
  68314. export class _StencilState {
  68315. /** 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 */
  68316. static readonly ALWAYS: number;
  68317. /** Passed to stencilOperation to specify that stencil value must be kept */
  68318. static readonly KEEP: number;
  68319. /** Passed to stencilOperation to specify that stencil value must be replaced */
  68320. static readonly REPLACE: number;
  68321. private _isStencilTestDirty;
  68322. private _isStencilMaskDirty;
  68323. private _isStencilFuncDirty;
  68324. private _isStencilOpDirty;
  68325. private _stencilTest;
  68326. private _stencilMask;
  68327. private _stencilFunc;
  68328. private _stencilFuncRef;
  68329. private _stencilFuncMask;
  68330. private _stencilOpStencilFail;
  68331. private _stencilOpDepthFail;
  68332. private _stencilOpStencilDepthPass;
  68333. readonly isDirty: boolean;
  68334. stencilFunc: number;
  68335. stencilFuncRef: number;
  68336. stencilFuncMask: number;
  68337. stencilOpStencilFail: number;
  68338. stencilOpDepthFail: number;
  68339. stencilOpStencilDepthPass: number;
  68340. stencilMask: number;
  68341. stencilTest: boolean;
  68342. constructor();
  68343. reset(): void;
  68344. apply(gl: WebGLRenderingContext): void;
  68345. }
  68346. }
  68347. declare module BABYLON {
  68348. /**
  68349. * @hidden
  68350. **/
  68351. export class _TimeToken {
  68352. _startTimeQuery: Nullable<WebGLQuery>;
  68353. _endTimeQuery: Nullable<WebGLQuery>;
  68354. _timeElapsedQuery: Nullable<WebGLQuery>;
  68355. _timeElapsedQueryEnded: boolean;
  68356. }
  68357. }
  68358. declare module BABYLON {
  68359. /**
  68360. * Class used to store data associated with WebGL texture data for the engine
  68361. * This class should not be used directly
  68362. */
  68363. export class InternalTexture {
  68364. /** hidden */
  68365. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  68366. /**
  68367. * The source of the texture data is unknown
  68368. */
  68369. static DATASOURCE_UNKNOWN: number;
  68370. /**
  68371. * Texture data comes from an URL
  68372. */
  68373. static DATASOURCE_URL: number;
  68374. /**
  68375. * Texture data is only used for temporary storage
  68376. */
  68377. static DATASOURCE_TEMP: number;
  68378. /**
  68379. * Texture data comes from raw data (ArrayBuffer)
  68380. */
  68381. static DATASOURCE_RAW: number;
  68382. /**
  68383. * Texture content is dynamic (video or dynamic texture)
  68384. */
  68385. static DATASOURCE_DYNAMIC: number;
  68386. /**
  68387. * Texture content is generated by rendering to it
  68388. */
  68389. static DATASOURCE_RENDERTARGET: number;
  68390. /**
  68391. * Texture content is part of a multi render target process
  68392. */
  68393. static DATASOURCE_MULTIRENDERTARGET: number;
  68394. /**
  68395. * Texture data comes from a cube data file
  68396. */
  68397. static DATASOURCE_CUBE: number;
  68398. /**
  68399. * Texture data comes from a raw cube data
  68400. */
  68401. static DATASOURCE_CUBERAW: number;
  68402. /**
  68403. * Texture data come from a prefiltered cube data file
  68404. */
  68405. static DATASOURCE_CUBEPREFILTERED: number;
  68406. /**
  68407. * Texture content is raw 3D data
  68408. */
  68409. static DATASOURCE_RAW3D: number;
  68410. /**
  68411. * Texture content is a depth texture
  68412. */
  68413. static DATASOURCE_DEPTHTEXTURE: number;
  68414. /**
  68415. * Texture data comes from a raw cube data encoded with RGBD
  68416. */
  68417. static DATASOURCE_CUBERAW_RGBD: number;
  68418. /**
  68419. * Defines if the texture is ready
  68420. */
  68421. isReady: boolean;
  68422. /**
  68423. * Defines if the texture is a cube texture
  68424. */
  68425. isCube: boolean;
  68426. /**
  68427. * Defines if the texture contains 3D data
  68428. */
  68429. is3D: boolean;
  68430. /**
  68431. * Defines if the texture contains multiview data
  68432. */
  68433. isMultiview: boolean;
  68434. /**
  68435. * Gets the URL used to load this texture
  68436. */
  68437. url: string;
  68438. /**
  68439. * Gets the sampling mode of the texture
  68440. */
  68441. samplingMode: number;
  68442. /**
  68443. * Gets a boolean indicating if the texture needs mipmaps generation
  68444. */
  68445. generateMipMaps: boolean;
  68446. /**
  68447. * Gets the number of samples used by the texture (WebGL2+ only)
  68448. */
  68449. samples: number;
  68450. /**
  68451. * Gets the type of the texture (int, float...)
  68452. */
  68453. type: number;
  68454. /**
  68455. * Gets the format of the texture (RGB, RGBA...)
  68456. */
  68457. format: number;
  68458. /**
  68459. * Observable called when the texture is loaded
  68460. */
  68461. onLoadedObservable: Observable<InternalTexture>;
  68462. /**
  68463. * Gets the width of the texture
  68464. */
  68465. width: number;
  68466. /**
  68467. * Gets the height of the texture
  68468. */
  68469. height: number;
  68470. /**
  68471. * Gets the depth of the texture
  68472. */
  68473. depth: number;
  68474. /**
  68475. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  68476. */
  68477. baseWidth: number;
  68478. /**
  68479. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  68480. */
  68481. baseHeight: number;
  68482. /**
  68483. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  68484. */
  68485. baseDepth: number;
  68486. /**
  68487. * Gets a boolean indicating if the texture is inverted on Y axis
  68488. */
  68489. invertY: boolean;
  68490. /** @hidden */
  68491. _invertVScale: boolean;
  68492. /** @hidden */
  68493. _associatedChannel: number;
  68494. /** @hidden */
  68495. _dataSource: number;
  68496. /** @hidden */
  68497. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  68498. /** @hidden */
  68499. _bufferView: Nullable<ArrayBufferView>;
  68500. /** @hidden */
  68501. _bufferViewArray: Nullable<ArrayBufferView[]>;
  68502. /** @hidden */
  68503. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  68504. /** @hidden */
  68505. _size: number;
  68506. /** @hidden */
  68507. _extension: string;
  68508. /** @hidden */
  68509. _files: Nullable<string[]>;
  68510. /** @hidden */
  68511. _workingCanvas: Nullable<HTMLCanvasElement>;
  68512. /** @hidden */
  68513. _workingContext: Nullable<CanvasRenderingContext2D>;
  68514. /** @hidden */
  68515. _framebuffer: Nullable<WebGLFramebuffer>;
  68516. /** @hidden */
  68517. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  68518. /** @hidden */
  68519. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  68520. /** @hidden */
  68521. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  68522. /** @hidden */
  68523. _attachments: Nullable<number[]>;
  68524. /** @hidden */
  68525. _cachedCoordinatesMode: Nullable<number>;
  68526. /** @hidden */
  68527. _cachedWrapU: Nullable<number>;
  68528. /** @hidden */
  68529. _cachedWrapV: Nullable<number>;
  68530. /** @hidden */
  68531. _cachedWrapR: Nullable<number>;
  68532. /** @hidden */
  68533. _cachedAnisotropicFilteringLevel: Nullable<number>;
  68534. /** @hidden */
  68535. _isDisabled: boolean;
  68536. /** @hidden */
  68537. _compression: Nullable<string>;
  68538. /** @hidden */
  68539. _generateStencilBuffer: boolean;
  68540. /** @hidden */
  68541. _generateDepthBuffer: boolean;
  68542. /** @hidden */
  68543. _comparisonFunction: number;
  68544. /** @hidden */
  68545. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  68546. /** @hidden */
  68547. _lodGenerationScale: number;
  68548. /** @hidden */
  68549. _lodGenerationOffset: number;
  68550. /** @hidden */
  68551. _colorTextureArray: Nullable<WebGLTexture>;
  68552. /** @hidden */
  68553. _depthStencilTextureArray: Nullable<WebGLTexture>;
  68554. /** @hidden */
  68555. _lodTextureHigh: Nullable<BaseTexture>;
  68556. /** @hidden */
  68557. _lodTextureMid: Nullable<BaseTexture>;
  68558. /** @hidden */
  68559. _lodTextureLow: Nullable<BaseTexture>;
  68560. /** @hidden */
  68561. _isRGBD: boolean;
  68562. /** @hidden */
  68563. _webGLTexture: Nullable<WebGLTexture>;
  68564. /** @hidden */
  68565. _references: number;
  68566. private _engine;
  68567. /**
  68568. * Gets the Engine the texture belongs to.
  68569. * @returns The babylon engine
  68570. */
  68571. getEngine(): Engine;
  68572. /**
  68573. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  68574. */
  68575. readonly dataSource: number;
  68576. /**
  68577. * Creates a new InternalTexture
  68578. * @param engine defines the engine to use
  68579. * @param dataSource defines the type of data that will be used
  68580. * @param delayAllocation if the texture allocation should be delayed (default: false)
  68581. */
  68582. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  68583. /**
  68584. * Increments the number of references (ie. the number of Texture that point to it)
  68585. */
  68586. incrementReferences(): void;
  68587. /**
  68588. * Change the size of the texture (not the size of the content)
  68589. * @param width defines the new width
  68590. * @param height defines the new height
  68591. * @param depth defines the new depth (1 by default)
  68592. */
  68593. updateSize(width: int, height: int, depth?: int): void;
  68594. /** @hidden */
  68595. _rebuild(): void;
  68596. /** @hidden */
  68597. _swapAndDie(target: InternalTexture): void;
  68598. /**
  68599. * Dispose the current allocated resources
  68600. */
  68601. dispose(): void;
  68602. }
  68603. }
  68604. declare module BABYLON {
  68605. /**
  68606. * This represents the main contract an easing function should follow.
  68607. * Easing functions are used throughout the animation system.
  68608. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68609. */
  68610. export interface IEasingFunction {
  68611. /**
  68612. * Given an input gradient between 0 and 1, this returns the corrseponding value
  68613. * of the easing function.
  68614. * The link below provides some of the most common examples of easing functions.
  68615. * @see https://easings.net/
  68616. * @param gradient Defines the value between 0 and 1 we want the easing value for
  68617. * @returns the corresponding value on the curve defined by the easing function
  68618. */
  68619. ease(gradient: number): number;
  68620. }
  68621. /**
  68622. * Base class used for every default easing function.
  68623. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68624. */
  68625. export class EasingFunction implements IEasingFunction {
  68626. /**
  68627. * Interpolation follows the mathematical formula associated with the easing function.
  68628. */
  68629. static readonly EASINGMODE_EASEIN: number;
  68630. /**
  68631. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  68632. */
  68633. static readonly EASINGMODE_EASEOUT: number;
  68634. /**
  68635. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  68636. */
  68637. static readonly EASINGMODE_EASEINOUT: number;
  68638. private _easingMode;
  68639. /**
  68640. * Sets the easing mode of the current function.
  68641. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  68642. */
  68643. setEasingMode(easingMode: number): void;
  68644. /**
  68645. * Gets the current easing mode.
  68646. * @returns the easing mode
  68647. */
  68648. getEasingMode(): number;
  68649. /**
  68650. * @hidden
  68651. */
  68652. easeInCore(gradient: number): number;
  68653. /**
  68654. * Given an input gradient between 0 and 1, this returns the corrseponding value
  68655. * of the easing function.
  68656. * @param gradient Defines the value between 0 and 1 we want the easing value for
  68657. * @returns the corresponding value on the curve defined by the easing function
  68658. */
  68659. ease(gradient: number): number;
  68660. }
  68661. /**
  68662. * Easing function with a circle shape (see link below).
  68663. * @see https://easings.net/#easeInCirc
  68664. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68665. */
  68666. export class CircleEase extends EasingFunction implements IEasingFunction {
  68667. /** @hidden */
  68668. easeInCore(gradient: number): number;
  68669. }
  68670. /**
  68671. * Easing function with a ease back shape (see link below).
  68672. * @see https://easings.net/#easeInBack
  68673. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68674. */
  68675. export class BackEase extends EasingFunction implements IEasingFunction {
  68676. /** Defines the amplitude of the function */
  68677. amplitude: number;
  68678. /**
  68679. * Instantiates a back ease easing
  68680. * @see https://easings.net/#easeInBack
  68681. * @param amplitude Defines the amplitude of the function
  68682. */
  68683. constructor(
  68684. /** Defines the amplitude of the function */
  68685. amplitude?: number);
  68686. /** @hidden */
  68687. easeInCore(gradient: number): number;
  68688. }
  68689. /**
  68690. * Easing function with a bouncing shape (see link below).
  68691. * @see https://easings.net/#easeInBounce
  68692. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68693. */
  68694. export class BounceEase extends EasingFunction implements IEasingFunction {
  68695. /** Defines the number of bounces */
  68696. bounces: number;
  68697. /** Defines the amplitude of the bounce */
  68698. bounciness: number;
  68699. /**
  68700. * Instantiates a bounce easing
  68701. * @see https://easings.net/#easeInBounce
  68702. * @param bounces Defines the number of bounces
  68703. * @param bounciness Defines the amplitude of the bounce
  68704. */
  68705. constructor(
  68706. /** Defines the number of bounces */
  68707. bounces?: number,
  68708. /** Defines the amplitude of the bounce */
  68709. bounciness?: number);
  68710. /** @hidden */
  68711. easeInCore(gradient: number): number;
  68712. }
  68713. /**
  68714. * Easing function with a power of 3 shape (see link below).
  68715. * @see https://easings.net/#easeInCubic
  68716. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68717. */
  68718. export class CubicEase extends EasingFunction implements IEasingFunction {
  68719. /** @hidden */
  68720. easeInCore(gradient: number): number;
  68721. }
  68722. /**
  68723. * Easing function with an elastic shape (see link below).
  68724. * @see https://easings.net/#easeInElastic
  68725. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68726. */
  68727. export class ElasticEase extends EasingFunction implements IEasingFunction {
  68728. /** Defines the number of oscillations*/
  68729. oscillations: number;
  68730. /** Defines the amplitude of the oscillations*/
  68731. springiness: number;
  68732. /**
  68733. * Instantiates an elastic easing function
  68734. * @see https://easings.net/#easeInElastic
  68735. * @param oscillations Defines the number of oscillations
  68736. * @param springiness Defines the amplitude of the oscillations
  68737. */
  68738. constructor(
  68739. /** Defines the number of oscillations*/
  68740. oscillations?: number,
  68741. /** Defines the amplitude of the oscillations*/
  68742. springiness?: number);
  68743. /** @hidden */
  68744. easeInCore(gradient: number): number;
  68745. }
  68746. /**
  68747. * Easing function with an exponential shape (see link below).
  68748. * @see https://easings.net/#easeInExpo
  68749. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68750. */
  68751. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  68752. /** Defines the exponent of the function */
  68753. exponent: number;
  68754. /**
  68755. * Instantiates an exponential easing function
  68756. * @see https://easings.net/#easeInExpo
  68757. * @param exponent Defines the exponent of the function
  68758. */
  68759. constructor(
  68760. /** Defines the exponent of the function */
  68761. exponent?: number);
  68762. /** @hidden */
  68763. easeInCore(gradient: number): number;
  68764. }
  68765. /**
  68766. * Easing function with a power shape (see link below).
  68767. * @see https://easings.net/#easeInQuad
  68768. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68769. */
  68770. export class PowerEase extends EasingFunction implements IEasingFunction {
  68771. /** Defines the power of the function */
  68772. power: number;
  68773. /**
  68774. * Instantiates an power base easing function
  68775. * @see https://easings.net/#easeInQuad
  68776. * @param power Defines the power of the function
  68777. */
  68778. constructor(
  68779. /** Defines the power of the function */
  68780. power?: number);
  68781. /** @hidden */
  68782. easeInCore(gradient: number): number;
  68783. }
  68784. /**
  68785. * Easing function with a power of 2 shape (see link below).
  68786. * @see https://easings.net/#easeInQuad
  68787. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68788. */
  68789. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  68790. /** @hidden */
  68791. easeInCore(gradient: number): number;
  68792. }
  68793. /**
  68794. * Easing function with a power of 4 shape (see link below).
  68795. * @see https://easings.net/#easeInQuart
  68796. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68797. */
  68798. export class QuarticEase extends EasingFunction implements IEasingFunction {
  68799. /** @hidden */
  68800. easeInCore(gradient: number): number;
  68801. }
  68802. /**
  68803. * Easing function with a power of 5 shape (see link below).
  68804. * @see https://easings.net/#easeInQuint
  68805. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68806. */
  68807. export class QuinticEase extends EasingFunction implements IEasingFunction {
  68808. /** @hidden */
  68809. easeInCore(gradient: number): number;
  68810. }
  68811. /**
  68812. * Easing function with a sin shape (see link below).
  68813. * @see https://easings.net/#easeInSine
  68814. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68815. */
  68816. export class SineEase extends EasingFunction implements IEasingFunction {
  68817. /** @hidden */
  68818. easeInCore(gradient: number): number;
  68819. }
  68820. /**
  68821. * Easing function with a bezier shape (see link below).
  68822. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  68823. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  68824. */
  68825. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  68826. /** Defines the x component of the start tangent in the bezier curve */
  68827. x1: number;
  68828. /** Defines the y component of the start tangent in the bezier curve */
  68829. y1: number;
  68830. /** Defines the x component of the end tangent in the bezier curve */
  68831. x2: number;
  68832. /** Defines the y component of the end tangent in the bezier curve */
  68833. y2: number;
  68834. /**
  68835. * Instantiates a bezier function
  68836. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  68837. * @param x1 Defines the x component of the start tangent in the bezier curve
  68838. * @param y1 Defines the y component of the start tangent in the bezier curve
  68839. * @param x2 Defines the x component of the end tangent in the bezier curve
  68840. * @param y2 Defines the y component of the end tangent in the bezier curve
  68841. */
  68842. constructor(
  68843. /** Defines the x component of the start tangent in the bezier curve */
  68844. x1?: number,
  68845. /** Defines the y component of the start tangent in the bezier curve */
  68846. y1?: number,
  68847. /** Defines the x component of the end tangent in the bezier curve */
  68848. x2?: number,
  68849. /** Defines the y component of the end tangent in the bezier curve */
  68850. y2?: number);
  68851. /** @hidden */
  68852. easeInCore(gradient: number): number;
  68853. }
  68854. }
  68855. declare module BABYLON {
  68856. /**
  68857. * Defines an interface which represents an animation key frame
  68858. */
  68859. export interface IAnimationKey {
  68860. /**
  68861. * Frame of the key frame
  68862. */
  68863. frame: number;
  68864. /**
  68865. * Value at the specifies key frame
  68866. */
  68867. value: any;
  68868. /**
  68869. * The input tangent for the cubic hermite spline
  68870. */
  68871. inTangent?: any;
  68872. /**
  68873. * The output tangent for the cubic hermite spline
  68874. */
  68875. outTangent?: any;
  68876. /**
  68877. * The animation interpolation type
  68878. */
  68879. interpolation?: AnimationKeyInterpolation;
  68880. }
  68881. /**
  68882. * Enum for the animation key frame interpolation type
  68883. */
  68884. export enum AnimationKeyInterpolation {
  68885. /**
  68886. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  68887. */
  68888. STEP = 1
  68889. }
  68890. }
  68891. declare module BABYLON {
  68892. /**
  68893. * Represents the range of an animation
  68894. */
  68895. export class AnimationRange {
  68896. /**The name of the animation range**/
  68897. name: string;
  68898. /**The starting frame of the animation */
  68899. from: number;
  68900. /**The ending frame of the animation*/
  68901. to: number;
  68902. /**
  68903. * Initializes the range of an animation
  68904. * @param name The name of the animation range
  68905. * @param from The starting frame of the animation
  68906. * @param to The ending frame of the animation
  68907. */
  68908. constructor(
  68909. /**The name of the animation range**/
  68910. name: string,
  68911. /**The starting frame of the animation */
  68912. from: number,
  68913. /**The ending frame of the animation*/
  68914. to: number);
  68915. /**
  68916. * Makes a copy of the animation range
  68917. * @returns A copy of the animation range
  68918. */
  68919. clone(): AnimationRange;
  68920. }
  68921. }
  68922. declare module BABYLON {
  68923. /**
  68924. * Composed of a frame, and an action function
  68925. */
  68926. export class AnimationEvent {
  68927. /** The frame for which the event is triggered **/
  68928. frame: number;
  68929. /** The event to perform when triggered **/
  68930. action: (currentFrame: number) => void;
  68931. /** Specifies if the event should be triggered only once**/
  68932. onlyOnce?: boolean | undefined;
  68933. /**
  68934. * Specifies if the animation event is done
  68935. */
  68936. isDone: boolean;
  68937. /**
  68938. * Initializes the animation event
  68939. * @param frame The frame for which the event is triggered
  68940. * @param action The event to perform when triggered
  68941. * @param onlyOnce Specifies if the event should be triggered only once
  68942. */
  68943. constructor(
  68944. /** The frame for which the event is triggered **/
  68945. frame: number,
  68946. /** The event to perform when triggered **/
  68947. action: (currentFrame: number) => void,
  68948. /** Specifies if the event should be triggered only once**/
  68949. onlyOnce?: boolean | undefined);
  68950. /** @hidden */
  68951. _clone(): AnimationEvent;
  68952. }
  68953. }
  68954. declare module BABYLON {
  68955. /**
  68956. * Interface used to define a behavior
  68957. */
  68958. export interface Behavior<T> {
  68959. /** gets or sets behavior's name */
  68960. name: string;
  68961. /**
  68962. * Function called when the behavior needs to be initialized (after attaching it to a target)
  68963. */
  68964. init(): void;
  68965. /**
  68966. * Called when the behavior is attached to a target
  68967. * @param target defines the target where the behavior is attached to
  68968. */
  68969. attach(target: T): void;
  68970. /**
  68971. * Called when the behavior is detached from its target
  68972. */
  68973. detach(): void;
  68974. }
  68975. /**
  68976. * Interface implemented by classes supporting behaviors
  68977. */
  68978. export interface IBehaviorAware<T> {
  68979. /**
  68980. * Attach a behavior
  68981. * @param behavior defines the behavior to attach
  68982. * @returns the current host
  68983. */
  68984. addBehavior(behavior: Behavior<T>): T;
  68985. /**
  68986. * Remove a behavior from the current object
  68987. * @param behavior defines the behavior to detach
  68988. * @returns the current host
  68989. */
  68990. removeBehavior(behavior: Behavior<T>): T;
  68991. /**
  68992. * Gets a behavior using its name to search
  68993. * @param name defines the name to search
  68994. * @returns the behavior or null if not found
  68995. */
  68996. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  68997. }
  68998. }
  68999. declare module BABYLON {
  69000. /**
  69001. * @hidden
  69002. */
  69003. export class IntersectionInfo {
  69004. bu: Nullable<number>;
  69005. bv: Nullable<number>;
  69006. distance: number;
  69007. faceId: number;
  69008. subMeshId: number;
  69009. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  69010. }
  69011. }
  69012. declare module BABYLON {
  69013. /**
  69014. * Class used to store bounding sphere information
  69015. */
  69016. export class BoundingSphere {
  69017. /**
  69018. * Gets the center of the bounding sphere in local space
  69019. */
  69020. readonly center: Vector3;
  69021. /**
  69022. * Radius of the bounding sphere in local space
  69023. */
  69024. radius: number;
  69025. /**
  69026. * Gets the center of the bounding sphere in world space
  69027. */
  69028. readonly centerWorld: Vector3;
  69029. /**
  69030. * Radius of the bounding sphere in world space
  69031. */
  69032. radiusWorld: number;
  69033. /**
  69034. * Gets the minimum vector in local space
  69035. */
  69036. readonly minimum: Vector3;
  69037. /**
  69038. * Gets the maximum vector in local space
  69039. */
  69040. readonly maximum: Vector3;
  69041. private _worldMatrix;
  69042. private static readonly TmpVector3;
  69043. /**
  69044. * Creates a new bounding sphere
  69045. * @param min defines the minimum vector (in local space)
  69046. * @param max defines the maximum vector (in local space)
  69047. * @param worldMatrix defines the new world matrix
  69048. */
  69049. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69050. /**
  69051. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  69052. * @param min defines the new minimum vector (in local space)
  69053. * @param max defines the new maximum vector (in local space)
  69054. * @param worldMatrix defines the new world matrix
  69055. */
  69056. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69057. /**
  69058. * Scale the current bounding sphere by applying a scale factor
  69059. * @param factor defines the scale factor to apply
  69060. * @returns the current bounding box
  69061. */
  69062. scale(factor: number): BoundingSphere;
  69063. /**
  69064. * Gets the world matrix of the bounding box
  69065. * @returns a matrix
  69066. */
  69067. getWorldMatrix(): DeepImmutable<Matrix>;
  69068. /** @hidden */
  69069. _update(worldMatrix: DeepImmutable<Matrix>): void;
  69070. /**
  69071. * Tests if the bounding sphere is intersecting the frustum planes
  69072. * @param frustumPlanes defines the frustum planes to test
  69073. * @returns true if there is an intersection
  69074. */
  69075. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69076. /**
  69077. * Tests if the bounding sphere center is in between the frustum planes.
  69078. * Used for optimistic fast inclusion.
  69079. * @param frustumPlanes defines the frustum planes to test
  69080. * @returns true if the sphere center is in between the frustum planes
  69081. */
  69082. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69083. /**
  69084. * Tests if a point is inside the bounding sphere
  69085. * @param point defines the point to test
  69086. * @returns true if the point is inside the bounding sphere
  69087. */
  69088. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69089. /**
  69090. * Checks if two sphere intersct
  69091. * @param sphere0 sphere 0
  69092. * @param sphere1 sphere 1
  69093. * @returns true if the speres intersect
  69094. */
  69095. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  69096. }
  69097. }
  69098. declare module BABYLON {
  69099. /**
  69100. * Class used to store bounding box information
  69101. */
  69102. export class BoundingBox implements ICullable {
  69103. /**
  69104. * Gets the 8 vectors representing the bounding box in local space
  69105. */
  69106. readonly vectors: Vector3[];
  69107. /**
  69108. * Gets the center of the bounding box in local space
  69109. */
  69110. readonly center: Vector3;
  69111. /**
  69112. * Gets the center of the bounding box in world space
  69113. */
  69114. readonly centerWorld: Vector3;
  69115. /**
  69116. * Gets the extend size in local space
  69117. */
  69118. readonly extendSize: Vector3;
  69119. /**
  69120. * Gets the extend size in world space
  69121. */
  69122. readonly extendSizeWorld: Vector3;
  69123. /**
  69124. * Gets the OBB (object bounding box) directions
  69125. */
  69126. readonly directions: Vector3[];
  69127. /**
  69128. * Gets the 8 vectors representing the bounding box in world space
  69129. */
  69130. readonly vectorsWorld: Vector3[];
  69131. /**
  69132. * Gets the minimum vector in world space
  69133. */
  69134. readonly minimumWorld: Vector3;
  69135. /**
  69136. * Gets the maximum vector in world space
  69137. */
  69138. readonly maximumWorld: Vector3;
  69139. /**
  69140. * Gets the minimum vector in local space
  69141. */
  69142. readonly minimum: Vector3;
  69143. /**
  69144. * Gets the maximum vector in local space
  69145. */
  69146. readonly maximum: Vector3;
  69147. private _worldMatrix;
  69148. private static readonly TmpVector3;
  69149. /**
  69150. * @hidden
  69151. */
  69152. _tag: number;
  69153. /**
  69154. * Creates a new bounding box
  69155. * @param min defines the minimum vector (in local space)
  69156. * @param max defines the maximum vector (in local space)
  69157. * @param worldMatrix defines the new world matrix
  69158. */
  69159. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69160. /**
  69161. * Recreates the entire bounding box from scratch as if we call the constructor in place
  69162. * @param min defines the new minimum vector (in local space)
  69163. * @param max defines the new maximum vector (in local space)
  69164. * @param worldMatrix defines the new world matrix
  69165. */
  69166. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69167. /**
  69168. * Scale the current bounding box by applying a scale factor
  69169. * @param factor defines the scale factor to apply
  69170. * @returns the current bounding box
  69171. */
  69172. scale(factor: number): BoundingBox;
  69173. /**
  69174. * Gets the world matrix of the bounding box
  69175. * @returns a matrix
  69176. */
  69177. getWorldMatrix(): DeepImmutable<Matrix>;
  69178. /** @hidden */
  69179. _update(world: DeepImmutable<Matrix>): void;
  69180. /**
  69181. * Tests if the bounding box is intersecting the frustum planes
  69182. * @param frustumPlanes defines the frustum planes to test
  69183. * @returns true if there is an intersection
  69184. */
  69185. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69186. /**
  69187. * Tests if the bounding box is entirely inside the frustum planes
  69188. * @param frustumPlanes defines the frustum planes to test
  69189. * @returns true if there is an inclusion
  69190. */
  69191. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69192. /**
  69193. * Tests if a point is inside the bounding box
  69194. * @param point defines the point to test
  69195. * @returns true if the point is inside the bounding box
  69196. */
  69197. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69198. /**
  69199. * Tests if the bounding box intersects with a bounding sphere
  69200. * @param sphere defines the sphere to test
  69201. * @returns true if there is an intersection
  69202. */
  69203. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  69204. /**
  69205. * Tests if the bounding box intersects with a box defined by a min and max vectors
  69206. * @param min defines the min vector to use
  69207. * @param max defines the max vector to use
  69208. * @returns true if there is an intersection
  69209. */
  69210. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  69211. /**
  69212. * Tests if two bounding boxes are intersections
  69213. * @param box0 defines the first box to test
  69214. * @param box1 defines the second box to test
  69215. * @returns true if there is an intersection
  69216. */
  69217. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  69218. /**
  69219. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  69220. * @param minPoint defines the minimum vector of the bounding box
  69221. * @param maxPoint defines the maximum vector of the bounding box
  69222. * @param sphereCenter defines the sphere center
  69223. * @param sphereRadius defines the sphere radius
  69224. * @returns true if there is an intersection
  69225. */
  69226. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  69227. /**
  69228. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  69229. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69230. * @param frustumPlanes defines the frustum planes to test
  69231. * @return true if there is an inclusion
  69232. */
  69233. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69234. /**
  69235. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  69236. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  69237. * @param frustumPlanes defines the frustum planes to test
  69238. * @return true if there is an intersection
  69239. */
  69240. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69241. }
  69242. }
  69243. declare module BABYLON {
  69244. /** @hidden */
  69245. export class Collider {
  69246. /** Define if a collision was found */
  69247. collisionFound: boolean;
  69248. /**
  69249. * Define last intersection point in local space
  69250. */
  69251. intersectionPoint: Vector3;
  69252. /**
  69253. * Define last collided mesh
  69254. */
  69255. collidedMesh: Nullable<AbstractMesh>;
  69256. private _collisionPoint;
  69257. private _planeIntersectionPoint;
  69258. private _tempVector;
  69259. private _tempVector2;
  69260. private _tempVector3;
  69261. private _tempVector4;
  69262. private _edge;
  69263. private _baseToVertex;
  69264. private _destinationPoint;
  69265. private _slidePlaneNormal;
  69266. private _displacementVector;
  69267. /** @hidden */
  69268. _radius: Vector3;
  69269. /** @hidden */
  69270. _retry: number;
  69271. private _velocity;
  69272. private _basePoint;
  69273. private _epsilon;
  69274. /** @hidden */
  69275. _velocityWorldLength: number;
  69276. /** @hidden */
  69277. _basePointWorld: Vector3;
  69278. private _velocityWorld;
  69279. private _normalizedVelocity;
  69280. /** @hidden */
  69281. _initialVelocity: Vector3;
  69282. /** @hidden */
  69283. _initialPosition: Vector3;
  69284. private _nearestDistance;
  69285. private _collisionMask;
  69286. collisionMask: number;
  69287. /**
  69288. * Gets the plane normal used to compute the sliding response (in local space)
  69289. */
  69290. readonly slidePlaneNormal: Vector3;
  69291. /** @hidden */
  69292. _initialize(source: Vector3, dir: Vector3, e: number): void;
  69293. /** @hidden */
  69294. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  69295. /** @hidden */
  69296. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  69297. /** @hidden */
  69298. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  69299. /** @hidden */
  69300. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  69301. /** @hidden */
  69302. _getResponse(pos: Vector3, vel: Vector3): void;
  69303. }
  69304. }
  69305. declare module BABYLON {
  69306. /**
  69307. * Interface for cullable objects
  69308. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  69309. */
  69310. export interface ICullable {
  69311. /**
  69312. * Checks if the object or part of the object is in the frustum
  69313. * @param frustumPlanes Camera near/planes
  69314. * @returns true if the object is in frustum otherwise false
  69315. */
  69316. isInFrustum(frustumPlanes: Plane[]): boolean;
  69317. /**
  69318. * Checks if a cullable object (mesh...) is in the camera frustum
  69319. * Unlike isInFrustum this cheks the full bounding box
  69320. * @param frustumPlanes Camera near/planes
  69321. * @returns true if the object is in frustum otherwise false
  69322. */
  69323. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  69324. }
  69325. /**
  69326. * Info for a bounding data of a mesh
  69327. */
  69328. export class BoundingInfo implements ICullable {
  69329. /**
  69330. * Bounding box for the mesh
  69331. */
  69332. readonly boundingBox: BoundingBox;
  69333. /**
  69334. * Bounding sphere for the mesh
  69335. */
  69336. readonly boundingSphere: BoundingSphere;
  69337. private _isLocked;
  69338. private static readonly TmpVector3;
  69339. /**
  69340. * Constructs bounding info
  69341. * @param minimum min vector of the bounding box/sphere
  69342. * @param maximum max vector of the bounding box/sphere
  69343. * @param worldMatrix defines the new world matrix
  69344. */
  69345. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  69346. /**
  69347. * Recreates the entire bounding info from scratch as if we call the constructor in place
  69348. * @param min defines the new minimum vector (in local space)
  69349. * @param max defines the new maximum vector (in local space)
  69350. * @param worldMatrix defines the new world matrix
  69351. */
  69352. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  69353. /**
  69354. * min vector of the bounding box/sphere
  69355. */
  69356. readonly minimum: Vector3;
  69357. /**
  69358. * max vector of the bounding box/sphere
  69359. */
  69360. readonly maximum: Vector3;
  69361. /**
  69362. * If the info is locked and won't be updated to avoid perf overhead
  69363. */
  69364. isLocked: boolean;
  69365. /**
  69366. * Updates the bounding sphere and box
  69367. * @param world world matrix to be used to update
  69368. */
  69369. update(world: DeepImmutable<Matrix>): void;
  69370. /**
  69371. * Recreate the bounding info to be centered around a specific point given a specific extend.
  69372. * @param center New center of the bounding info
  69373. * @param extend New extend of the bounding info
  69374. * @returns the current bounding info
  69375. */
  69376. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  69377. /**
  69378. * Scale the current bounding info by applying a scale factor
  69379. * @param factor defines the scale factor to apply
  69380. * @returns the current bounding info
  69381. */
  69382. scale(factor: number): BoundingInfo;
  69383. /**
  69384. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  69385. * @param frustumPlanes defines the frustum to test
  69386. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  69387. * @returns true if the bounding info is in the frustum planes
  69388. */
  69389. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  69390. /**
  69391. * Gets the world distance between the min and max points of the bounding box
  69392. */
  69393. readonly diagonalLength: number;
  69394. /**
  69395. * Checks if a cullable object (mesh...) is in the camera frustum
  69396. * Unlike isInFrustum this cheks the full bounding box
  69397. * @param frustumPlanes Camera near/planes
  69398. * @returns true if the object is in frustum otherwise false
  69399. */
  69400. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  69401. /** @hidden */
  69402. _checkCollision(collider: Collider): boolean;
  69403. /**
  69404. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  69405. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69406. * @param point the point to check intersection with
  69407. * @returns if the point intersects
  69408. */
  69409. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  69410. /**
  69411. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  69412. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  69413. * @param boundingInfo the bounding info to check intersection with
  69414. * @param precise if the intersection should be done using OBB
  69415. * @returns if the bounding info intersects
  69416. */
  69417. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  69418. }
  69419. }
  69420. declare module BABYLON {
  69421. /**
  69422. * Defines an array and its length.
  69423. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  69424. */
  69425. export interface ISmartArrayLike<T> {
  69426. /**
  69427. * The data of the array.
  69428. */
  69429. data: Array<T>;
  69430. /**
  69431. * The active length of the array.
  69432. */
  69433. length: number;
  69434. }
  69435. /**
  69436. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69437. */
  69438. export class SmartArray<T> implements ISmartArrayLike<T> {
  69439. /**
  69440. * The full set of data from the array.
  69441. */
  69442. data: Array<T>;
  69443. /**
  69444. * The active length of the array.
  69445. */
  69446. length: number;
  69447. protected _id: number;
  69448. /**
  69449. * Instantiates a Smart Array.
  69450. * @param capacity defines the default capacity of the array.
  69451. */
  69452. constructor(capacity: number);
  69453. /**
  69454. * Pushes a value at the end of the active data.
  69455. * @param value defines the object to push in the array.
  69456. */
  69457. push(value: T): void;
  69458. /**
  69459. * Iterates over the active data and apply the lambda to them.
  69460. * @param func defines the action to apply on each value.
  69461. */
  69462. forEach(func: (content: T) => void): void;
  69463. /**
  69464. * Sorts the full sets of data.
  69465. * @param compareFn defines the comparison function to apply.
  69466. */
  69467. sort(compareFn: (a: T, b: T) => number): void;
  69468. /**
  69469. * Resets the active data to an empty array.
  69470. */
  69471. reset(): void;
  69472. /**
  69473. * Releases all the data from the array as well as the array.
  69474. */
  69475. dispose(): void;
  69476. /**
  69477. * Concats the active data with a given array.
  69478. * @param array defines the data to concatenate with.
  69479. */
  69480. concat(array: any): void;
  69481. /**
  69482. * Returns the position of a value in the active data.
  69483. * @param value defines the value to find the index for
  69484. * @returns the index if found in the active data otherwise -1
  69485. */
  69486. indexOf(value: T): number;
  69487. /**
  69488. * Returns whether an element is part of the active data.
  69489. * @param value defines the value to look for
  69490. * @returns true if found in the active data otherwise false
  69491. */
  69492. contains(value: T): boolean;
  69493. private static _GlobalId;
  69494. }
  69495. /**
  69496. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  69497. * The data in this array can only be present once
  69498. */
  69499. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  69500. private _duplicateId;
  69501. /**
  69502. * Pushes a value at the end of the active data.
  69503. * THIS DOES NOT PREVENT DUPPLICATE DATA
  69504. * @param value defines the object to push in the array.
  69505. */
  69506. push(value: T): void;
  69507. /**
  69508. * Pushes a value at the end of the active data.
  69509. * If the data is already present, it won t be added again
  69510. * @param value defines the object to push in the array.
  69511. * @returns true if added false if it was already present
  69512. */
  69513. pushNoDuplicate(value: T): boolean;
  69514. /**
  69515. * Resets the active data to an empty array.
  69516. */
  69517. reset(): void;
  69518. /**
  69519. * Concats the active data with a given array.
  69520. * This ensures no dupplicate will be present in the result.
  69521. * @param array defines the data to concatenate with.
  69522. */
  69523. concatWithNoDuplicate(array: any): void;
  69524. }
  69525. }
  69526. declare module BABYLON {
  69527. /**
  69528. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69529. * separate meshes. This can be use to improve performances.
  69530. * @see http://doc.babylonjs.com/how_to/multi_materials
  69531. */
  69532. export class MultiMaterial extends Material {
  69533. private _subMaterials;
  69534. /**
  69535. * Gets or Sets the list of Materials used within the multi material.
  69536. * They need to be ordered according to the submeshes order in the associated mesh
  69537. */
  69538. subMaterials: Nullable<Material>[];
  69539. /**
  69540. * Function used to align with Node.getChildren()
  69541. * @returns the list of Materials used within the multi material
  69542. */
  69543. getChildren(): Nullable<Material>[];
  69544. /**
  69545. * Instantiates a new Multi Material
  69546. * A multi-material is used to apply different materials to different parts of the same object without the need of
  69547. * separate meshes. This can be use to improve performances.
  69548. * @see http://doc.babylonjs.com/how_to/multi_materials
  69549. * @param name Define the name in the scene
  69550. * @param scene Define the scene the material belongs to
  69551. */
  69552. constructor(name: string, scene: Scene);
  69553. private _hookArray;
  69554. /**
  69555. * Get one of the submaterial by its index in the submaterials array
  69556. * @param index The index to look the sub material at
  69557. * @returns The Material if the index has been defined
  69558. */
  69559. getSubMaterial(index: number): Nullable<Material>;
  69560. /**
  69561. * Get the list of active textures for the whole sub materials list.
  69562. * @returns All the textures that will be used during the rendering
  69563. */
  69564. getActiveTextures(): BaseTexture[];
  69565. /**
  69566. * Gets the current class name of the material e.g. "MultiMaterial"
  69567. * Mainly use in serialization.
  69568. * @returns the class name
  69569. */
  69570. getClassName(): string;
  69571. /**
  69572. * Checks if the material is ready to render the requested sub mesh
  69573. * @param mesh Define the mesh the submesh belongs to
  69574. * @param subMesh Define the sub mesh to look readyness for
  69575. * @param useInstances Define whether or not the material is used with instances
  69576. * @returns true if ready, otherwise false
  69577. */
  69578. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  69579. /**
  69580. * Clones the current material and its related sub materials
  69581. * @param name Define the name of the newly cloned material
  69582. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  69583. * @returns the cloned material
  69584. */
  69585. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  69586. /**
  69587. * Serializes the materials into a JSON representation.
  69588. * @returns the JSON representation
  69589. */
  69590. serialize(): any;
  69591. /**
  69592. * Dispose the material and release its associated resources
  69593. * @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)
  69594. * @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)
  69595. * @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)
  69596. */
  69597. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  69598. /**
  69599. * Creates a MultiMaterial from parsed MultiMaterial data.
  69600. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  69601. * @param scene defines the hosting scene
  69602. * @returns a new MultiMaterial
  69603. */
  69604. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  69605. }
  69606. }
  69607. declare module BABYLON {
  69608. /**
  69609. * Class used to represent data loading progression
  69610. */
  69611. export class SceneLoaderFlags {
  69612. private static _ForceFullSceneLoadingForIncremental;
  69613. private static _ShowLoadingScreen;
  69614. private static _CleanBoneMatrixWeights;
  69615. private static _loggingLevel;
  69616. /**
  69617. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  69618. */
  69619. static ForceFullSceneLoadingForIncremental: boolean;
  69620. /**
  69621. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  69622. */
  69623. static ShowLoadingScreen: boolean;
  69624. /**
  69625. * Defines the current logging level (while loading the scene)
  69626. * @ignorenaming
  69627. */
  69628. static loggingLevel: number;
  69629. /**
  69630. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  69631. */
  69632. static CleanBoneMatrixWeights: boolean;
  69633. }
  69634. }
  69635. declare module BABYLON {
  69636. /**
  69637. * 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.
  69638. * @see https://doc.babylonjs.com/how_to/transformnode
  69639. */
  69640. export class TransformNode extends Node {
  69641. /**
  69642. * Object will not rotate to face the camera
  69643. */
  69644. static BILLBOARDMODE_NONE: number;
  69645. /**
  69646. * Object will rotate to face the camera but only on the x axis
  69647. */
  69648. static BILLBOARDMODE_X: number;
  69649. /**
  69650. * Object will rotate to face the camera but only on the y axis
  69651. */
  69652. static BILLBOARDMODE_Y: number;
  69653. /**
  69654. * Object will rotate to face the camera but only on the z axis
  69655. */
  69656. static BILLBOARDMODE_Z: number;
  69657. /**
  69658. * Object will rotate to face the camera
  69659. */
  69660. static BILLBOARDMODE_ALL: number;
  69661. private _forward;
  69662. private _forwardInverted;
  69663. private _up;
  69664. private _right;
  69665. private _rightInverted;
  69666. private _position;
  69667. private _rotation;
  69668. private _rotationQuaternion;
  69669. protected _scaling: Vector3;
  69670. protected _isDirty: boolean;
  69671. private _transformToBoneReferal;
  69672. private _billboardMode;
  69673. /**
  69674. * Gets or sets the billboard mode. Default is 0.
  69675. *
  69676. * | Value | Type | Description |
  69677. * | --- | --- | --- |
  69678. * | 0 | BILLBOARDMODE_NONE | |
  69679. * | 1 | BILLBOARDMODE_X | |
  69680. * | 2 | BILLBOARDMODE_Y | |
  69681. * | 4 | BILLBOARDMODE_Z | |
  69682. * | 7 | BILLBOARDMODE_ALL | |
  69683. *
  69684. */
  69685. billboardMode: number;
  69686. private _preserveParentRotationForBillboard;
  69687. /**
  69688. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  69689. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  69690. */
  69691. preserveParentRotationForBillboard: boolean;
  69692. /**
  69693. * 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
  69694. */
  69695. scalingDeterminant: number;
  69696. private _infiniteDistance;
  69697. /**
  69698. * Gets or sets the distance of the object to max, often used by skybox
  69699. */
  69700. infiniteDistance: boolean;
  69701. /**
  69702. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  69703. * By default the system will update normals to compensate
  69704. */
  69705. ignoreNonUniformScaling: boolean;
  69706. /**
  69707. * 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
  69708. */
  69709. reIntegrateRotationIntoRotationQuaternion: boolean;
  69710. /** @hidden */
  69711. _poseMatrix: Nullable<Matrix>;
  69712. /** @hidden */
  69713. _localMatrix: Matrix;
  69714. private _usePivotMatrix;
  69715. private _absolutePosition;
  69716. private _pivotMatrix;
  69717. private _pivotMatrixInverse;
  69718. protected _postMultiplyPivotMatrix: boolean;
  69719. protected _isWorldMatrixFrozen: boolean;
  69720. /** @hidden */
  69721. _indexInSceneTransformNodesArray: number;
  69722. /**
  69723. * An event triggered after the world matrix is updated
  69724. */
  69725. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  69726. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  69727. /**
  69728. * Gets a string identifying the name of the class
  69729. * @returns "TransformNode" string
  69730. */
  69731. getClassName(): string;
  69732. /**
  69733. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  69734. */
  69735. position: Vector3;
  69736. /**
  69737. * 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)).
  69738. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  69739. */
  69740. rotation: Vector3;
  69741. /**
  69742. * 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)).
  69743. */
  69744. scaling: Vector3;
  69745. /**
  69746. * 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).
  69747. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  69748. */
  69749. rotationQuaternion: Nullable<Quaternion>;
  69750. /**
  69751. * The forward direction of that transform in world space.
  69752. */
  69753. readonly forward: Vector3;
  69754. /**
  69755. * The up direction of that transform in world space.
  69756. */
  69757. readonly up: Vector3;
  69758. /**
  69759. * The right direction of that transform in world space.
  69760. */
  69761. readonly right: Vector3;
  69762. /**
  69763. * Copies the parameter passed Matrix into the mesh Pose matrix.
  69764. * @param matrix the matrix to copy the pose from
  69765. * @returns this TransformNode.
  69766. */
  69767. updatePoseMatrix(matrix: Matrix): TransformNode;
  69768. /**
  69769. * Returns the mesh Pose matrix.
  69770. * @returns the pose matrix
  69771. */
  69772. getPoseMatrix(): Matrix;
  69773. /** @hidden */
  69774. _isSynchronized(): boolean;
  69775. /** @hidden */
  69776. _initCache(): void;
  69777. /**
  69778. * Flag the transform node as dirty (Forcing it to update everything)
  69779. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  69780. * @returns this transform node
  69781. */
  69782. markAsDirty(property: string): TransformNode;
  69783. /**
  69784. * Returns the current mesh absolute position.
  69785. * Returns a Vector3.
  69786. */
  69787. readonly absolutePosition: Vector3;
  69788. /**
  69789. * Sets a new matrix to apply before all other transformation
  69790. * @param matrix defines the transform matrix
  69791. * @returns the current TransformNode
  69792. */
  69793. setPreTransformMatrix(matrix: Matrix): TransformNode;
  69794. /**
  69795. * Sets a new pivot matrix to the current node
  69796. * @param matrix defines the new pivot matrix to use
  69797. * @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
  69798. * @returns the current TransformNode
  69799. */
  69800. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  69801. /**
  69802. * Returns the mesh pivot matrix.
  69803. * Default : Identity.
  69804. * @returns the matrix
  69805. */
  69806. getPivotMatrix(): Matrix;
  69807. /**
  69808. * Prevents the World matrix to be computed any longer.
  69809. * @returns the TransformNode.
  69810. */
  69811. freezeWorldMatrix(): TransformNode;
  69812. /**
  69813. * Allows back the World matrix computation.
  69814. * @returns the TransformNode.
  69815. */
  69816. unfreezeWorldMatrix(): this;
  69817. /**
  69818. * True if the World matrix has been frozen.
  69819. */
  69820. readonly isWorldMatrixFrozen: boolean;
  69821. /**
  69822. * Retuns the mesh absolute position in the World.
  69823. * @returns a Vector3.
  69824. */
  69825. getAbsolutePosition(): Vector3;
  69826. /**
  69827. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  69828. * @param absolutePosition the absolute position to set
  69829. * @returns the TransformNode.
  69830. */
  69831. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  69832. /**
  69833. * Sets the mesh position in its local space.
  69834. * @param vector3 the position to set in localspace
  69835. * @returns the TransformNode.
  69836. */
  69837. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  69838. /**
  69839. * Returns the mesh position in the local space from the current World matrix values.
  69840. * @returns a new Vector3.
  69841. */
  69842. getPositionExpressedInLocalSpace(): Vector3;
  69843. /**
  69844. * Translates the mesh along the passed Vector3 in its local space.
  69845. * @param vector3 the distance to translate in localspace
  69846. * @returns the TransformNode.
  69847. */
  69848. locallyTranslate(vector3: Vector3): TransformNode;
  69849. private static _lookAtVectorCache;
  69850. /**
  69851. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  69852. * @param targetPoint the position (must be in same space as current mesh) to look at
  69853. * @param yawCor optional yaw (y-axis) correction in radians
  69854. * @param pitchCor optional pitch (x-axis) correction in radians
  69855. * @param rollCor optional roll (z-axis) correction in radians
  69856. * @param space the choosen space of the target
  69857. * @returns the TransformNode.
  69858. */
  69859. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  69860. /**
  69861. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  69862. * This Vector3 is expressed in the World space.
  69863. * @param localAxis axis to rotate
  69864. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  69865. */
  69866. getDirection(localAxis: Vector3): Vector3;
  69867. /**
  69868. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  69869. * localAxis is expressed in the mesh local space.
  69870. * result is computed in the Wordl space from the mesh World matrix.
  69871. * @param localAxis axis to rotate
  69872. * @param result the resulting transformnode
  69873. * @returns this TransformNode.
  69874. */
  69875. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  69876. /**
  69877. * Sets this transform node rotation to the given local axis.
  69878. * @param localAxis the axis in local space
  69879. * @param yawCor optional yaw (y-axis) correction in radians
  69880. * @param pitchCor optional pitch (x-axis) correction in radians
  69881. * @param rollCor optional roll (z-axis) correction in radians
  69882. * @returns this TransformNode
  69883. */
  69884. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  69885. /**
  69886. * Sets a new pivot point to the current node
  69887. * @param point defines the new pivot point to use
  69888. * @param space defines if the point is in world or local space (local by default)
  69889. * @returns the current TransformNode
  69890. */
  69891. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  69892. /**
  69893. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  69894. * @returns the pivot point
  69895. */
  69896. getPivotPoint(): Vector3;
  69897. /**
  69898. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  69899. * @param result the vector3 to store the result
  69900. * @returns this TransformNode.
  69901. */
  69902. getPivotPointToRef(result: Vector3): TransformNode;
  69903. /**
  69904. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  69905. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  69906. */
  69907. getAbsolutePivotPoint(): Vector3;
  69908. /**
  69909. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  69910. * @param result vector3 to store the result
  69911. * @returns this TransformNode.
  69912. */
  69913. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  69914. /**
  69915. * Defines the passed node as the parent of the current node.
  69916. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  69917. * @see https://doc.babylonjs.com/how_to/parenting
  69918. * @param node the node ot set as the parent
  69919. * @returns this TransformNode.
  69920. */
  69921. setParent(node: Nullable<Node>): TransformNode;
  69922. private _nonUniformScaling;
  69923. /**
  69924. * True if the scaling property of this object is non uniform eg. (1,2,1)
  69925. */
  69926. readonly nonUniformScaling: boolean;
  69927. /** @hidden */
  69928. _updateNonUniformScalingState(value: boolean): boolean;
  69929. /**
  69930. * Attach the current TransformNode to another TransformNode associated with a bone
  69931. * @param bone Bone affecting the TransformNode
  69932. * @param affectedTransformNode TransformNode associated with the bone
  69933. * @returns this object
  69934. */
  69935. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  69936. /**
  69937. * Detach the transform node if its associated with a bone
  69938. * @returns this object
  69939. */
  69940. detachFromBone(): TransformNode;
  69941. private static _rotationAxisCache;
  69942. /**
  69943. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  69944. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69945. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69946. * The passed axis is also normalized.
  69947. * @param axis the axis to rotate around
  69948. * @param amount the amount to rotate in radians
  69949. * @param space Space to rotate in (Default: local)
  69950. * @returns the TransformNode.
  69951. */
  69952. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  69953. /**
  69954. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  69955. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  69956. * The passed axis is also normalized. .
  69957. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  69958. * @param point the point to rotate around
  69959. * @param axis the axis to rotate around
  69960. * @param amount the amount to rotate in radians
  69961. * @returns the TransformNode
  69962. */
  69963. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  69964. /**
  69965. * Translates the mesh along the axis vector for the passed distance in the given space.
  69966. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  69967. * @param axis the axis to translate in
  69968. * @param distance the distance to translate
  69969. * @param space Space to rotate in (Default: local)
  69970. * @returns the TransformNode.
  69971. */
  69972. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  69973. /**
  69974. * Adds a rotation step to the mesh current rotation.
  69975. * x, y, z are Euler angles expressed in radians.
  69976. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  69977. * This means this rotation is made in the mesh local space only.
  69978. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  69979. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  69980. * ```javascript
  69981. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  69982. * ```
  69983. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  69984. * 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.
  69985. * @param x Rotation to add
  69986. * @param y Rotation to add
  69987. * @param z Rotation to add
  69988. * @returns the TransformNode.
  69989. */
  69990. addRotation(x: number, y: number, z: number): TransformNode;
  69991. /**
  69992. * @hidden
  69993. */
  69994. protected _getEffectiveParent(): Nullable<Node>;
  69995. /**
  69996. * Computes the world matrix of the node
  69997. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  69998. * @returns the world matrix
  69999. */
  70000. computeWorldMatrix(force?: boolean): Matrix;
  70001. protected _afterComputeWorldMatrix(): void;
  70002. /**
  70003. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  70004. * @param func callback function to add
  70005. *
  70006. * @returns the TransformNode.
  70007. */
  70008. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  70009. /**
  70010. * Removes a registered callback function.
  70011. * @param func callback function to remove
  70012. * @returns the TransformNode.
  70013. */
  70014. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  70015. /**
  70016. * Gets the position of the current mesh in camera space
  70017. * @param camera defines the camera to use
  70018. * @returns a position
  70019. */
  70020. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  70021. /**
  70022. * Returns the distance from the mesh to the active camera
  70023. * @param camera defines the camera to use
  70024. * @returns the distance
  70025. */
  70026. getDistanceToCamera(camera?: Nullable<Camera>): number;
  70027. /**
  70028. * Clone the current transform node
  70029. * @param name Name of the new clone
  70030. * @param newParent New parent for the clone
  70031. * @param doNotCloneChildren Do not clone children hierarchy
  70032. * @returns the new transform node
  70033. */
  70034. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  70035. /**
  70036. * Serializes the objects information.
  70037. * @param currentSerializationObject defines the object to serialize in
  70038. * @returns the serialized object
  70039. */
  70040. serialize(currentSerializationObject?: any): any;
  70041. /**
  70042. * Returns a new TransformNode object parsed from the source provided.
  70043. * @param parsedTransformNode is the source.
  70044. * @param scene the scne the object belongs to
  70045. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  70046. * @returns a new TransformNode object parsed from the source provided.
  70047. */
  70048. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  70049. /**
  70050. * Get all child-transformNodes of this node
  70051. * @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
  70052. * @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
  70053. * @returns an array of TransformNode
  70054. */
  70055. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  70056. /**
  70057. * Releases resources associated with this transform node.
  70058. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  70059. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  70060. */
  70061. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  70062. }
  70063. }
  70064. declare module BABYLON {
  70065. /**
  70066. * Class used to override all child animations of a given target
  70067. */
  70068. export class AnimationPropertiesOverride {
  70069. /**
  70070. * Gets or sets a value indicating if animation blending must be used
  70071. */
  70072. enableBlending: boolean;
  70073. /**
  70074. * Gets or sets the blending speed to use when enableBlending is true
  70075. */
  70076. blendingSpeed: number;
  70077. /**
  70078. * Gets or sets the default loop mode to use
  70079. */
  70080. loopMode: number;
  70081. }
  70082. }
  70083. declare module BABYLON {
  70084. /**
  70085. * Class used to store bone information
  70086. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  70087. */
  70088. export class Bone extends Node {
  70089. /**
  70090. * defines the bone name
  70091. */
  70092. name: string;
  70093. private static _tmpVecs;
  70094. private static _tmpQuat;
  70095. private static _tmpMats;
  70096. /**
  70097. * Gets the list of child bones
  70098. */
  70099. children: Bone[];
  70100. /** Gets the animations associated with this bone */
  70101. animations: Animation[];
  70102. /**
  70103. * Gets or sets bone length
  70104. */
  70105. length: number;
  70106. /**
  70107. * @hidden Internal only
  70108. * Set this value to map this bone to a different index in the transform matrices
  70109. * Set this value to -1 to exclude the bone from the transform matrices
  70110. */
  70111. _index: Nullable<number>;
  70112. private _skeleton;
  70113. private _localMatrix;
  70114. private _restPose;
  70115. private _baseMatrix;
  70116. private _absoluteTransform;
  70117. private _invertedAbsoluteTransform;
  70118. private _parent;
  70119. private _scalingDeterminant;
  70120. private _worldTransform;
  70121. private _localScaling;
  70122. private _localRotation;
  70123. private _localPosition;
  70124. private _needToDecompose;
  70125. private _needToCompose;
  70126. /** @hidden */
  70127. _linkedTransformNode: Nullable<TransformNode>;
  70128. /** @hidden */
  70129. _waitingTransformNodeId: Nullable<string>;
  70130. /** @hidden */
  70131. /** @hidden */
  70132. _matrix: Matrix;
  70133. /**
  70134. * Create a new bone
  70135. * @param name defines the bone name
  70136. * @param skeleton defines the parent skeleton
  70137. * @param parentBone defines the parent (can be null if the bone is the root)
  70138. * @param localMatrix defines the local matrix
  70139. * @param restPose defines the rest pose matrix
  70140. * @param baseMatrix defines the base matrix
  70141. * @param index defines index of the bone in the hiearchy
  70142. */
  70143. constructor(
  70144. /**
  70145. * defines the bone name
  70146. */
  70147. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  70148. /**
  70149. * Gets the current object class name.
  70150. * @return the class name
  70151. */
  70152. getClassName(): string;
  70153. /**
  70154. * Gets the parent skeleton
  70155. * @returns a skeleton
  70156. */
  70157. getSkeleton(): Skeleton;
  70158. /**
  70159. * Gets parent bone
  70160. * @returns a bone or null if the bone is the root of the bone hierarchy
  70161. */
  70162. getParent(): Nullable<Bone>;
  70163. /**
  70164. * Returns an array containing the root bones
  70165. * @returns an array containing the root bones
  70166. */
  70167. getChildren(): Array<Bone>;
  70168. /**
  70169. * Sets the parent bone
  70170. * @param parent defines the parent (can be null if the bone is the root)
  70171. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70172. */
  70173. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  70174. /**
  70175. * Gets the local matrix
  70176. * @returns a matrix
  70177. */
  70178. getLocalMatrix(): Matrix;
  70179. /**
  70180. * Gets the base matrix (initial matrix which remains unchanged)
  70181. * @returns a matrix
  70182. */
  70183. getBaseMatrix(): Matrix;
  70184. /**
  70185. * Gets the rest pose matrix
  70186. * @returns a matrix
  70187. */
  70188. getRestPose(): Matrix;
  70189. /**
  70190. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  70191. */
  70192. getWorldMatrix(): Matrix;
  70193. /**
  70194. * Sets the local matrix to rest pose matrix
  70195. */
  70196. returnToRest(): void;
  70197. /**
  70198. * Gets the inverse of the absolute transform matrix.
  70199. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  70200. * @returns a matrix
  70201. */
  70202. getInvertedAbsoluteTransform(): Matrix;
  70203. /**
  70204. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  70205. * @returns a matrix
  70206. */
  70207. getAbsoluteTransform(): Matrix;
  70208. /**
  70209. * Links with the given transform node.
  70210. * The local matrix of this bone is copied from the transform node every frame.
  70211. * @param transformNode defines the transform node to link to
  70212. */
  70213. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  70214. /** Gets or sets current position (in local space) */
  70215. position: Vector3;
  70216. /** Gets or sets current rotation (in local space) */
  70217. rotation: Vector3;
  70218. /** Gets or sets current rotation quaternion (in local space) */
  70219. rotationQuaternion: Quaternion;
  70220. /** Gets or sets current scaling (in local space) */
  70221. scaling: Vector3;
  70222. /**
  70223. * Gets the animation properties override
  70224. */
  70225. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  70226. private _decompose;
  70227. private _compose;
  70228. /**
  70229. * Update the base and local matrices
  70230. * @param matrix defines the new base or local matrix
  70231. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  70232. * @param updateLocalMatrix defines if the local matrix should be updated
  70233. */
  70234. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  70235. /** @hidden */
  70236. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  70237. /**
  70238. * Flag the bone as dirty (Forcing it to update everything)
  70239. */
  70240. markAsDirty(): void;
  70241. private _markAsDirtyAndCompose;
  70242. private _markAsDirtyAndDecompose;
  70243. /**
  70244. * Translate the bone in local or world space
  70245. * @param vec The amount to translate the bone
  70246. * @param space The space that the translation is in
  70247. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70248. */
  70249. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70250. /**
  70251. * Set the postion of the bone in local or world space
  70252. * @param position The position to set the bone
  70253. * @param space The space that the position is in
  70254. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70255. */
  70256. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70257. /**
  70258. * Set the absolute position of the bone (world space)
  70259. * @param position The position to set the bone
  70260. * @param mesh The mesh that this bone is attached to
  70261. */
  70262. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  70263. /**
  70264. * Scale the bone on the x, y and z axes (in local space)
  70265. * @param x The amount to scale the bone on the x axis
  70266. * @param y The amount to scale the bone on the y axis
  70267. * @param z The amount to scale the bone on the z axis
  70268. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  70269. */
  70270. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  70271. /**
  70272. * Set the bone scaling in local space
  70273. * @param scale defines the scaling vector
  70274. */
  70275. setScale(scale: Vector3): void;
  70276. /**
  70277. * Gets the current scaling in local space
  70278. * @returns the current scaling vector
  70279. */
  70280. getScale(): Vector3;
  70281. /**
  70282. * Gets the current scaling in local space and stores it in a target vector
  70283. * @param result defines the target vector
  70284. */
  70285. getScaleToRef(result: Vector3): void;
  70286. /**
  70287. * Set the yaw, pitch, and roll of the bone in local or world space
  70288. * @param yaw The rotation of the bone on the y axis
  70289. * @param pitch The rotation of the bone on the x axis
  70290. * @param roll The rotation of the bone on the z axis
  70291. * @param space The space that the axes of rotation are in
  70292. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70293. */
  70294. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  70295. /**
  70296. * Add a rotation to the bone on an axis in local or world space
  70297. * @param axis The axis to rotate the bone on
  70298. * @param amount The amount to rotate the bone
  70299. * @param space The space that the axis is in
  70300. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70301. */
  70302. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  70303. /**
  70304. * Set the rotation of the bone to a particular axis angle in local or world space
  70305. * @param axis The axis to rotate the bone on
  70306. * @param angle The angle that the bone should be rotated to
  70307. * @param space The space that the axis is in
  70308. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70309. */
  70310. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  70311. /**
  70312. * Set the euler rotation of the bone in local of world space
  70313. * @param rotation The euler rotation that the bone should be set to
  70314. * @param space The space that the rotation is in
  70315. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70316. */
  70317. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  70318. /**
  70319. * Set the quaternion rotation of the bone in local of world space
  70320. * @param quat The quaternion rotation that the bone should be set to
  70321. * @param space The space that the rotation is in
  70322. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70323. */
  70324. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  70325. /**
  70326. * Set the rotation matrix of the bone in local of world space
  70327. * @param rotMat The rotation matrix that the bone should be set to
  70328. * @param space The space that the rotation is in
  70329. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70330. */
  70331. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  70332. private _rotateWithMatrix;
  70333. private _getNegativeRotationToRef;
  70334. /**
  70335. * Get the position of the bone in local or world space
  70336. * @param space The space that the returned position is in
  70337. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70338. * @returns The position of the bone
  70339. */
  70340. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70341. /**
  70342. * Copy the position of the bone to a vector3 in local or world space
  70343. * @param space The space that the returned position is in
  70344. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70345. * @param result The vector3 to copy the position to
  70346. */
  70347. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  70348. /**
  70349. * Get the absolute position of the bone (world space)
  70350. * @param mesh The mesh that this bone is attached to
  70351. * @returns The absolute position of the bone
  70352. */
  70353. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  70354. /**
  70355. * Copy the absolute position of the bone (world space) to the result param
  70356. * @param mesh The mesh that this bone is attached to
  70357. * @param result The vector3 to copy the absolute position to
  70358. */
  70359. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  70360. /**
  70361. * Compute the absolute transforms of this bone and its children
  70362. */
  70363. computeAbsoluteTransforms(): void;
  70364. /**
  70365. * Get the world direction from an axis that is in the local space of the bone
  70366. * @param localAxis The local direction that is used to compute the world direction
  70367. * @param mesh The mesh that this bone is attached to
  70368. * @returns The world direction
  70369. */
  70370. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70371. /**
  70372. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  70373. * @param localAxis The local direction that is used to compute the world direction
  70374. * @param mesh The mesh that this bone is attached to
  70375. * @param result The vector3 that the world direction will be copied to
  70376. */
  70377. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70378. /**
  70379. * Get the euler rotation of the bone in local or world space
  70380. * @param space The space that the rotation should be in
  70381. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70382. * @returns The euler rotation
  70383. */
  70384. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  70385. /**
  70386. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  70387. * @param space The space that the rotation should be in
  70388. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70389. * @param result The vector3 that the rotation should be copied to
  70390. */
  70391. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70392. /**
  70393. * Get the quaternion rotation of the bone in either local or world space
  70394. * @param space The space that the rotation should be in
  70395. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70396. * @returns The quaternion rotation
  70397. */
  70398. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  70399. /**
  70400. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  70401. * @param space The space that the rotation should be in
  70402. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70403. * @param result The quaternion that the rotation should be copied to
  70404. */
  70405. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  70406. /**
  70407. * Get the rotation matrix of the bone in local or world space
  70408. * @param space The space that the rotation should be in
  70409. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70410. * @returns The rotation matrix
  70411. */
  70412. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  70413. /**
  70414. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  70415. * @param space The space that the rotation should be in
  70416. * @param mesh The mesh that this bone is attached to. This is only used in world space
  70417. * @param result The quaternion that the rotation should be copied to
  70418. */
  70419. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  70420. /**
  70421. * Get the world position of a point that is in the local space of the bone
  70422. * @param position The local position
  70423. * @param mesh The mesh that this bone is attached to
  70424. * @returns The world position
  70425. */
  70426. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70427. /**
  70428. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  70429. * @param position The local position
  70430. * @param mesh The mesh that this bone is attached to
  70431. * @param result The vector3 that the world position should be copied to
  70432. */
  70433. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70434. /**
  70435. * Get the local position of a point that is in world space
  70436. * @param position The world position
  70437. * @param mesh The mesh that this bone is attached to
  70438. * @returns The local position
  70439. */
  70440. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  70441. /**
  70442. * Get the local position of a point that is in world space and copy it to the result param
  70443. * @param position The world position
  70444. * @param mesh The mesh that this bone is attached to
  70445. * @param result The vector3 that the local position should be copied to
  70446. */
  70447. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  70448. }
  70449. }
  70450. declare module BABYLON {
  70451. /**
  70452. * Enum that determines the text-wrapping mode to use.
  70453. */
  70454. export enum InspectableType {
  70455. /**
  70456. * Checkbox for booleans
  70457. */
  70458. Checkbox = 0,
  70459. /**
  70460. * Sliders for numbers
  70461. */
  70462. Slider = 1,
  70463. /**
  70464. * Vector3
  70465. */
  70466. Vector3 = 2,
  70467. /**
  70468. * Quaternions
  70469. */
  70470. Quaternion = 3,
  70471. /**
  70472. * Color3
  70473. */
  70474. Color3 = 4
  70475. }
  70476. /**
  70477. * Interface used to define custom inspectable properties.
  70478. * This interface is used by the inspector to display custom property grids
  70479. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  70480. */
  70481. export interface IInspectable {
  70482. /**
  70483. * Gets the label to display
  70484. */
  70485. label: string;
  70486. /**
  70487. * Gets the name of the property to edit
  70488. */
  70489. propertyName: string;
  70490. /**
  70491. * Gets the type of the editor to use
  70492. */
  70493. type: InspectableType;
  70494. /**
  70495. * Gets the minimum value of the property when using in "slider" mode
  70496. */
  70497. min?: number;
  70498. /**
  70499. * Gets the maximum value of the property when using in "slider" mode
  70500. */
  70501. max?: number;
  70502. /**
  70503. * Gets the setp to use when using in "slider" mode
  70504. */
  70505. step?: number;
  70506. }
  70507. }
  70508. declare module BABYLON {
  70509. /**
  70510. * This represents the required contract to create a new type of texture loader.
  70511. */
  70512. export interface IInternalTextureLoader {
  70513. /**
  70514. * Defines wether the loader supports cascade loading the different faces.
  70515. */
  70516. supportCascades: boolean;
  70517. /**
  70518. * This returns if the loader support the current file information.
  70519. * @param extension defines the file extension of the file being loaded
  70520. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70521. * @param fallback defines the fallback internal texture if any
  70522. * @param isBase64 defines whether the texture is encoded as a base64
  70523. * @param isBuffer defines whether the texture data are stored as a buffer
  70524. * @returns true if the loader can load the specified file
  70525. */
  70526. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  70527. /**
  70528. * Transform the url before loading if required.
  70529. * @param rootUrl the url of the texture
  70530. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70531. * @returns the transformed texture
  70532. */
  70533. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  70534. /**
  70535. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  70536. * @param rootUrl the url of the texture
  70537. * @param textureFormatInUse defines the current compressed format in use iun the engine
  70538. * @returns the fallback texture
  70539. */
  70540. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  70541. /**
  70542. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  70543. * @param data contains the texture data
  70544. * @param texture defines the BabylonJS internal texture
  70545. * @param createPolynomials will be true if polynomials have been requested
  70546. * @param onLoad defines the callback to trigger once the texture is ready
  70547. * @param onError defines the callback to trigger in case of error
  70548. */
  70549. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  70550. /**
  70551. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  70552. * @param data contains the texture data
  70553. * @param texture defines the BabylonJS internal texture
  70554. * @param callback defines the method to call once ready to upload
  70555. */
  70556. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  70557. }
  70558. }
  70559. declare module BABYLON {
  70560. interface Engine {
  70561. /**
  70562. * Creates a depth stencil cube texture.
  70563. * This is only available in WebGL 2.
  70564. * @param size The size of face edge in the cube texture.
  70565. * @param options The options defining the cube texture.
  70566. * @returns The cube texture
  70567. */
  70568. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  70569. /**
  70570. * Creates a cube texture
  70571. * @param rootUrl defines the url where the files to load is located
  70572. * @param scene defines the current scene
  70573. * @param files defines the list of files to load (1 per face)
  70574. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70575. * @param onLoad defines an optional callback raised when the texture is loaded
  70576. * @param onError defines an optional callback raised if there is an issue to load the texture
  70577. * @param format defines the format of the data
  70578. * @param forcedExtension defines the extension to use to pick the right loader
  70579. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70580. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70581. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70582. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  70583. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  70584. * @returns the cube texture as an InternalTexture
  70585. */
  70586. 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;
  70587. /**
  70588. * Creates a cube texture
  70589. * @param rootUrl defines the url where the files to load is located
  70590. * @param scene defines the current scene
  70591. * @param files defines the list of files to load (1 per face)
  70592. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70593. * @param onLoad defines an optional callback raised when the texture is loaded
  70594. * @param onError defines an optional callback raised if there is an issue to load the texture
  70595. * @param format defines the format of the data
  70596. * @param forcedExtension defines the extension to use to pick the right loader
  70597. * @returns the cube texture as an InternalTexture
  70598. */
  70599. 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;
  70600. /**
  70601. * Creates a cube texture
  70602. * @param rootUrl defines the url where the files to load is located
  70603. * @param scene defines the current scene
  70604. * @param files defines the list of files to load (1 per face)
  70605. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  70606. * @param onLoad defines an optional callback raised when the texture is loaded
  70607. * @param onError defines an optional callback raised if there is an issue to load the texture
  70608. * @param format defines the format of the data
  70609. * @param forcedExtension defines the extension to use to pick the right loader
  70610. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  70611. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70612. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70613. * @returns the cube texture as an InternalTexture
  70614. */
  70615. 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;
  70616. /** @hidden */
  70617. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70618. /** @hidden */
  70619. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70620. /** @hidden */
  70621. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  70622. /** @hidden */
  70623. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  70624. }
  70625. }
  70626. declare module BABYLON {
  70627. /**
  70628. * Class for creating a cube texture
  70629. */
  70630. export class CubeTexture extends BaseTexture {
  70631. private _delayedOnLoad;
  70632. /**
  70633. * The url of the texture
  70634. */
  70635. url: string;
  70636. /**
  70637. * Gets or sets the center of the bounding box associated with the cube texture.
  70638. * It must define where the camera used to render the texture was set
  70639. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70640. */
  70641. boundingBoxPosition: Vector3;
  70642. private _boundingBoxSize;
  70643. /**
  70644. * Gets or sets the size of the bounding box associated with the cube texture
  70645. * When defined, the cubemap will switch to local mode
  70646. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  70647. * @example https://www.babylonjs-playground.com/#RNASML
  70648. */
  70649. /**
  70650. * Returns the bounding box size
  70651. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  70652. */
  70653. boundingBoxSize: Vector3;
  70654. protected _rotationY: number;
  70655. /**
  70656. * Sets texture matrix rotation angle around Y axis in radians.
  70657. */
  70658. /**
  70659. * Gets texture matrix rotation angle around Y axis radians.
  70660. */
  70661. rotationY: number;
  70662. /**
  70663. * Are mip maps generated for this texture or not.
  70664. */
  70665. readonly noMipmap: boolean;
  70666. private _noMipmap;
  70667. private _files;
  70668. private _extensions;
  70669. private _textureMatrix;
  70670. private _format;
  70671. private _createPolynomials;
  70672. /** @hidden */
  70673. _prefiltered: boolean;
  70674. /**
  70675. * Creates a cube texture from an array of image urls
  70676. * @param files defines an array of image urls
  70677. * @param scene defines the hosting scene
  70678. * @param noMipmap specifies if mip maps are not used
  70679. * @returns a cube texture
  70680. */
  70681. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  70682. /**
  70683. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  70684. * @param url defines the url of the prefiltered texture
  70685. * @param scene defines the scene the texture is attached to
  70686. * @param forcedExtension defines the extension of the file if different from the url
  70687. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70688. * @return the prefiltered texture
  70689. */
  70690. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  70691. /**
  70692. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  70693. * as prefiltered data.
  70694. * @param rootUrl defines the url of the texture or the root name of the six images
  70695. * @param scene defines the scene the texture is attached to
  70696. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  70697. * @param noMipmap defines if mipmaps should be created or not
  70698. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  70699. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  70700. * @param onError defines a callback triggered in case of error during load
  70701. * @param format defines the internal format to use for the texture once loaded
  70702. * @param prefiltered defines whether or not the texture is created from prefiltered data
  70703. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  70704. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  70705. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  70706. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  70707. * @return the cube texture
  70708. */
  70709. 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);
  70710. /**
  70711. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  70712. */
  70713. readonly isPrefiltered: boolean;
  70714. /**
  70715. * Get the current class name of the texture useful for serialization or dynamic coding.
  70716. * @returns "CubeTexture"
  70717. */
  70718. getClassName(): string;
  70719. /**
  70720. * Update the url (and optional buffer) of this texture if url was null during construction.
  70721. * @param url the url of the texture
  70722. * @param forcedExtension defines the extension to use
  70723. * @param onLoad callback called when the texture is loaded (defaults to null)
  70724. */
  70725. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  70726. /**
  70727. * Delays loading of the cube texture
  70728. * @param forcedExtension defines the extension to use
  70729. */
  70730. delayLoad(forcedExtension?: string): void;
  70731. /**
  70732. * Returns the reflection texture matrix
  70733. * @returns the reflection texture matrix
  70734. */
  70735. getReflectionTextureMatrix(): Matrix;
  70736. /**
  70737. * Sets the reflection texture matrix
  70738. * @param value Reflection texture matrix
  70739. */
  70740. setReflectionTextureMatrix(value: Matrix): void;
  70741. /**
  70742. * Parses text to create a cube texture
  70743. * @param parsedTexture define the serialized text to read from
  70744. * @param scene defines the hosting scene
  70745. * @param rootUrl defines the root url of the cube texture
  70746. * @returns a cube texture
  70747. */
  70748. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  70749. /**
  70750. * Makes a clone, or deep copy, of the cube texture
  70751. * @returns a new cube texture
  70752. */
  70753. clone(): CubeTexture;
  70754. }
  70755. }
  70756. declare module BABYLON {
  70757. /** @hidden */
  70758. export var postprocessVertexShader: {
  70759. name: string;
  70760. shader: string;
  70761. };
  70762. }
  70763. declare module BABYLON {
  70764. /**
  70765. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  70766. * This is the base of the follow, arc rotate cameras and Free camera
  70767. * @see http://doc.babylonjs.com/features/cameras
  70768. */
  70769. export class TargetCamera extends Camera {
  70770. private static _RigCamTransformMatrix;
  70771. private static _TargetTransformMatrix;
  70772. private static _TargetFocalPoint;
  70773. /**
  70774. * Define the current direction the camera is moving to
  70775. */
  70776. cameraDirection: Vector3;
  70777. /**
  70778. * Define the current rotation the camera is rotating to
  70779. */
  70780. cameraRotation: Vector2;
  70781. /**
  70782. * When set, the up vector of the camera will be updated by the rotation of the camera
  70783. */
  70784. updateUpVectorFromRotation: boolean;
  70785. private _tmpQuaternion;
  70786. /**
  70787. * Define the current rotation of the camera
  70788. */
  70789. rotation: Vector3;
  70790. /**
  70791. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  70792. */
  70793. rotationQuaternion: Quaternion;
  70794. /**
  70795. * Define the current speed of the camera
  70796. */
  70797. speed: number;
  70798. /**
  70799. * Add cconstraint to the camera to prevent it to move freely in all directions and
  70800. * around all axis.
  70801. */
  70802. noRotationConstraint: boolean;
  70803. /**
  70804. * Define the current target of the camera as an object or a position.
  70805. */
  70806. lockedTarget: any;
  70807. /** @hidden */
  70808. _currentTarget: Vector3;
  70809. /** @hidden */
  70810. _initialFocalDistance: number;
  70811. /** @hidden */
  70812. _viewMatrix: Matrix;
  70813. /** @hidden */
  70814. _camMatrix: Matrix;
  70815. /** @hidden */
  70816. _cameraTransformMatrix: Matrix;
  70817. /** @hidden */
  70818. _cameraRotationMatrix: Matrix;
  70819. /** @hidden */
  70820. _referencePoint: Vector3;
  70821. /** @hidden */
  70822. _transformedReferencePoint: Vector3;
  70823. protected _globalCurrentTarget: Vector3;
  70824. protected _globalCurrentUpVector: Vector3;
  70825. /** @hidden */
  70826. _reset: () => void;
  70827. private _defaultUp;
  70828. /**
  70829. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  70830. * This is the base of the follow, arc rotate cameras and Free camera
  70831. * @see http://doc.babylonjs.com/features/cameras
  70832. * @param name Defines the name of the camera in the scene
  70833. * @param position Defines the start position of the camera in the scene
  70834. * @param scene Defines the scene the camera belongs to
  70835. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  70836. */
  70837. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  70838. /**
  70839. * Gets the position in front of the camera at a given distance.
  70840. * @param distance The distance from the camera we want the position to be
  70841. * @returns the position
  70842. */
  70843. getFrontPosition(distance: number): Vector3;
  70844. /** @hidden */
  70845. _getLockedTargetPosition(): Nullable<Vector3>;
  70846. private _storedPosition;
  70847. private _storedRotation;
  70848. private _storedRotationQuaternion;
  70849. /**
  70850. * Store current camera state of the camera (fov, position, rotation, etc..)
  70851. * @returns the camera
  70852. */
  70853. storeState(): Camera;
  70854. /**
  70855. * Restored camera state. You must call storeState() first
  70856. * @returns whether it was successful or not
  70857. * @hidden
  70858. */
  70859. _restoreStateValues(): boolean;
  70860. /** @hidden */
  70861. _initCache(): void;
  70862. /** @hidden */
  70863. _updateCache(ignoreParentClass?: boolean): void;
  70864. /** @hidden */
  70865. _isSynchronizedViewMatrix(): boolean;
  70866. /** @hidden */
  70867. _computeLocalCameraSpeed(): number;
  70868. /**
  70869. * Defines the target the camera should look at.
  70870. * This will automatically adapt alpha beta and radius to fit within the new target.
  70871. * @param target Defines the new target as a Vector or a mesh
  70872. */
  70873. setTarget(target: Vector3): void;
  70874. /**
  70875. * Return the current target position of the camera. This value is expressed in local space.
  70876. * @returns the target position
  70877. */
  70878. getTarget(): Vector3;
  70879. /** @hidden */
  70880. _decideIfNeedsToMove(): boolean;
  70881. /** @hidden */
  70882. _updatePosition(): void;
  70883. /** @hidden */
  70884. _checkInputs(): void;
  70885. protected _updateCameraRotationMatrix(): void;
  70886. /**
  70887. * 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)
  70888. * @returns the current camera
  70889. */
  70890. private _rotateUpVectorWithCameraRotationMatrix;
  70891. private _cachedRotationZ;
  70892. private _cachedQuaternionRotationZ;
  70893. /** @hidden */
  70894. _getViewMatrix(): Matrix;
  70895. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  70896. /**
  70897. * @hidden
  70898. */
  70899. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  70900. /**
  70901. * @hidden
  70902. */
  70903. _updateRigCameras(): void;
  70904. private _getRigCamPositionAndTarget;
  70905. /**
  70906. * Gets the current object class name.
  70907. * @return the class name
  70908. */
  70909. getClassName(): string;
  70910. }
  70911. }
  70912. declare module BABYLON {
  70913. /**
  70914. * @ignore
  70915. * This is a list of all the different input types that are available in the application.
  70916. * Fo instance: ArcRotateCameraGamepadInput...
  70917. */
  70918. export var CameraInputTypes: {};
  70919. /**
  70920. * This is the contract to implement in order to create a new input class.
  70921. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  70922. */
  70923. export interface ICameraInput<TCamera extends Camera> {
  70924. /**
  70925. * Defines the camera the input is attached to.
  70926. */
  70927. camera: Nullable<TCamera>;
  70928. /**
  70929. * Gets the class name of the current intput.
  70930. * @returns the class name
  70931. */
  70932. getClassName(): string;
  70933. /**
  70934. * Get the friendly name associated with the input class.
  70935. * @returns the input friendly name
  70936. */
  70937. getSimpleName(): string;
  70938. /**
  70939. * Attach the input controls to a specific dom element to get the input from.
  70940. * @param element Defines the element the controls should be listened from
  70941. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70942. */
  70943. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  70944. /**
  70945. * Detach the current controls from the specified dom element.
  70946. * @param element Defines the element to stop listening the inputs from
  70947. */
  70948. detachControl(element: Nullable<HTMLElement>): void;
  70949. /**
  70950. * Update the current camera state depending on the inputs that have been used this frame.
  70951. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70952. */
  70953. checkInputs?: () => void;
  70954. }
  70955. /**
  70956. * Represents a map of input types to input instance or input index to input instance.
  70957. */
  70958. export interface CameraInputsMap<TCamera extends Camera> {
  70959. /**
  70960. * Accessor to the input by input type.
  70961. */
  70962. [name: string]: ICameraInput<TCamera>;
  70963. /**
  70964. * Accessor to the input by input index.
  70965. */
  70966. [idx: number]: ICameraInput<TCamera>;
  70967. }
  70968. /**
  70969. * This represents the input manager used within a camera.
  70970. * It helps dealing with all the different kind of input attached to a camera.
  70971. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  70972. */
  70973. export class CameraInputsManager<TCamera extends Camera> {
  70974. /**
  70975. * Defines the list of inputs attahed to the camera.
  70976. */
  70977. attached: CameraInputsMap<TCamera>;
  70978. /**
  70979. * Defines the dom element the camera is collecting inputs from.
  70980. * This is null if the controls have not been attached.
  70981. */
  70982. attachedElement: Nullable<HTMLElement>;
  70983. /**
  70984. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  70985. */
  70986. noPreventDefault: boolean;
  70987. /**
  70988. * Defined the camera the input manager belongs to.
  70989. */
  70990. camera: TCamera;
  70991. /**
  70992. * Update the current camera state depending on the inputs that have been used this frame.
  70993. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  70994. */
  70995. checkInputs: () => void;
  70996. /**
  70997. * Instantiate a new Camera Input Manager.
  70998. * @param camera Defines the camera the input manager blongs to
  70999. */
  71000. constructor(camera: TCamera);
  71001. /**
  71002. * Add an input method to a camera
  71003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71004. * @param input camera input method
  71005. */
  71006. add(input: ICameraInput<TCamera>): void;
  71007. /**
  71008. * Remove a specific input method from a camera
  71009. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  71010. * @param inputToRemove camera input method
  71011. */
  71012. remove(inputToRemove: ICameraInput<TCamera>): void;
  71013. /**
  71014. * Remove a specific input type from a camera
  71015. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  71016. * @param inputType the type of the input to remove
  71017. */
  71018. removeByType(inputType: string): void;
  71019. private _addCheckInputs;
  71020. /**
  71021. * Attach the input controls to the currently attached dom element to listen the events from.
  71022. * @param input Defines the input to attach
  71023. */
  71024. attachInput(input: ICameraInput<TCamera>): void;
  71025. /**
  71026. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  71027. * @param element Defines the dom element to collect the events from
  71028. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71029. */
  71030. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  71031. /**
  71032. * Detach the current manager inputs controls from a specific dom element.
  71033. * @param element Defines the dom element to collect the events from
  71034. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  71035. */
  71036. detachElement(element: HTMLElement, disconnect?: boolean): void;
  71037. /**
  71038. * Rebuild the dynamic inputCheck function from the current list of
  71039. * defined inputs in the manager.
  71040. */
  71041. rebuildInputCheck(): void;
  71042. /**
  71043. * Remove all attached input methods from a camera
  71044. */
  71045. clear(): void;
  71046. /**
  71047. * Serialize the current input manager attached to a camera.
  71048. * This ensures than once parsed,
  71049. * the input associated to the camera will be identical to the current ones
  71050. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  71051. */
  71052. serialize(serializedCamera: any): void;
  71053. /**
  71054. * Parses an input manager serialized JSON to restore the previous list of inputs
  71055. * and states associated to a camera.
  71056. * @param parsedCamera Defines the JSON to parse
  71057. */
  71058. parse(parsedCamera: any): void;
  71059. }
  71060. }
  71061. declare module BABYLON {
  71062. /**
  71063. * Gather the list of keyboard event types as constants.
  71064. */
  71065. export class KeyboardEventTypes {
  71066. /**
  71067. * The keydown event is fired when a key becomes active (pressed).
  71068. */
  71069. static readonly KEYDOWN: number;
  71070. /**
  71071. * The keyup event is fired when a key has been released.
  71072. */
  71073. static readonly KEYUP: number;
  71074. }
  71075. /**
  71076. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71077. */
  71078. export class KeyboardInfo {
  71079. /**
  71080. * Defines the type of event (KeyboardEventTypes)
  71081. */
  71082. type: number;
  71083. /**
  71084. * Defines the related dom event
  71085. */
  71086. event: KeyboardEvent;
  71087. /**
  71088. * Instantiates a new keyboard info.
  71089. * This class is used to store keyboard related info for the onKeyboardObservable event.
  71090. * @param type Defines the type of event (KeyboardEventTypes)
  71091. * @param event Defines the related dom event
  71092. */
  71093. constructor(
  71094. /**
  71095. * Defines the type of event (KeyboardEventTypes)
  71096. */
  71097. type: number,
  71098. /**
  71099. * Defines the related dom event
  71100. */
  71101. event: KeyboardEvent);
  71102. }
  71103. /**
  71104. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71105. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  71106. */
  71107. export class KeyboardInfoPre extends KeyboardInfo {
  71108. /**
  71109. * Defines the type of event (KeyboardEventTypes)
  71110. */
  71111. type: number;
  71112. /**
  71113. * Defines the related dom event
  71114. */
  71115. event: KeyboardEvent;
  71116. /**
  71117. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  71118. */
  71119. skipOnPointerObservable: boolean;
  71120. /**
  71121. * Instantiates a new keyboard pre info.
  71122. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  71123. * @param type Defines the type of event (KeyboardEventTypes)
  71124. * @param event Defines the related dom event
  71125. */
  71126. constructor(
  71127. /**
  71128. * Defines the type of event (KeyboardEventTypes)
  71129. */
  71130. type: number,
  71131. /**
  71132. * Defines the related dom event
  71133. */
  71134. event: KeyboardEvent);
  71135. }
  71136. }
  71137. declare module BABYLON {
  71138. /**
  71139. * Manage the keyboard inputs to control the movement of a free camera.
  71140. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71141. */
  71142. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  71143. /**
  71144. * Defines the camera the input is attached to.
  71145. */
  71146. camera: FreeCamera;
  71147. /**
  71148. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71149. */
  71150. keysUp: number[];
  71151. /**
  71152. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71153. */
  71154. keysDown: number[];
  71155. /**
  71156. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71157. */
  71158. keysLeft: number[];
  71159. /**
  71160. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71161. */
  71162. keysRight: number[];
  71163. private _keys;
  71164. private _onCanvasBlurObserver;
  71165. private _onKeyboardObserver;
  71166. private _engine;
  71167. private _scene;
  71168. /**
  71169. * Attach the input controls to a specific dom element to get the input from.
  71170. * @param element Defines the element the controls should be listened from
  71171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71172. */
  71173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71174. /**
  71175. * Detach the current controls from the specified dom element.
  71176. * @param element Defines the element to stop listening the inputs from
  71177. */
  71178. detachControl(element: Nullable<HTMLElement>): void;
  71179. /**
  71180. * Update the current camera state depending on the inputs that have been used this frame.
  71181. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71182. */
  71183. checkInputs(): void;
  71184. /**
  71185. * Gets the class name of the current intput.
  71186. * @returns the class name
  71187. */
  71188. getClassName(): string;
  71189. /** @hidden */
  71190. _onLostFocus(): void;
  71191. /**
  71192. * Get the friendly name associated with the input class.
  71193. * @returns the input friendly name
  71194. */
  71195. getSimpleName(): string;
  71196. }
  71197. }
  71198. declare module BABYLON {
  71199. /**
  71200. * Interface describing all the common properties and methods a shadow light needs to implement.
  71201. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  71202. * as well as binding the different shadow properties to the effects.
  71203. */
  71204. export interface IShadowLight extends Light {
  71205. /**
  71206. * The light id in the scene (used in scene.findLighById for instance)
  71207. */
  71208. id: string;
  71209. /**
  71210. * The position the shdow will be casted from.
  71211. */
  71212. position: Vector3;
  71213. /**
  71214. * In 2d mode (needCube being false), the direction used to cast the shadow.
  71215. */
  71216. direction: Vector3;
  71217. /**
  71218. * The transformed position. Position of the light in world space taking parenting in account.
  71219. */
  71220. transformedPosition: Vector3;
  71221. /**
  71222. * The transformed direction. Direction of the light in world space taking parenting in account.
  71223. */
  71224. transformedDirection: Vector3;
  71225. /**
  71226. * The friendly name of the light in the scene.
  71227. */
  71228. name: string;
  71229. /**
  71230. * Defines the shadow projection clipping minimum z value.
  71231. */
  71232. shadowMinZ: number;
  71233. /**
  71234. * Defines the shadow projection clipping maximum z value.
  71235. */
  71236. shadowMaxZ: number;
  71237. /**
  71238. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71239. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71240. */
  71241. computeTransformedInformation(): boolean;
  71242. /**
  71243. * Gets the scene the light belongs to.
  71244. * @returns The scene
  71245. */
  71246. getScene(): Scene;
  71247. /**
  71248. * Callback defining a custom Projection Matrix Builder.
  71249. * This can be used to override the default projection matrix computation.
  71250. */
  71251. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71252. /**
  71253. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71254. * @param matrix The materix to updated with the projection information
  71255. * @param viewMatrix The transform matrix of the light
  71256. * @param renderList The list of mesh to render in the map
  71257. * @returns The current light
  71258. */
  71259. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71260. /**
  71261. * Gets the current depth scale used in ESM.
  71262. * @returns The scale
  71263. */
  71264. getDepthScale(): number;
  71265. /**
  71266. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71267. * @returns true if a cube texture needs to be use
  71268. */
  71269. needCube(): boolean;
  71270. /**
  71271. * Detects if the projection matrix requires to be recomputed this frame.
  71272. * @returns true if it requires to be recomputed otherwise, false.
  71273. */
  71274. needProjectionMatrixCompute(): boolean;
  71275. /**
  71276. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71277. */
  71278. forceProjectionMatrixCompute(): void;
  71279. /**
  71280. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71281. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71282. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71283. */
  71284. getShadowDirection(faceIndex?: number): Vector3;
  71285. /**
  71286. * Gets the minZ used for shadow according to both the scene and the light.
  71287. * @param activeCamera The camera we are returning the min for
  71288. * @returns the depth min z
  71289. */
  71290. getDepthMinZ(activeCamera: Camera): number;
  71291. /**
  71292. * Gets the maxZ used for shadow according to both the scene and the light.
  71293. * @param activeCamera The camera we are returning the max for
  71294. * @returns the depth max z
  71295. */
  71296. getDepthMaxZ(activeCamera: Camera): number;
  71297. }
  71298. /**
  71299. * Base implementation IShadowLight
  71300. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  71301. */
  71302. export abstract class ShadowLight extends Light implements IShadowLight {
  71303. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  71304. protected _position: Vector3;
  71305. protected _setPosition(value: Vector3): void;
  71306. /**
  71307. * Sets the position the shadow will be casted from. Also use as the light position for both
  71308. * point and spot lights.
  71309. */
  71310. /**
  71311. * Sets the position the shadow will be casted from. Also use as the light position for both
  71312. * point and spot lights.
  71313. */
  71314. position: Vector3;
  71315. protected _direction: Vector3;
  71316. protected _setDirection(value: Vector3): void;
  71317. /**
  71318. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  71319. * Also use as the light direction on spot and directional lights.
  71320. */
  71321. /**
  71322. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  71323. * Also use as the light direction on spot and directional lights.
  71324. */
  71325. direction: Vector3;
  71326. private _shadowMinZ;
  71327. /**
  71328. * Gets the shadow projection clipping minimum z value.
  71329. */
  71330. /**
  71331. * Sets the shadow projection clipping minimum z value.
  71332. */
  71333. shadowMinZ: number;
  71334. private _shadowMaxZ;
  71335. /**
  71336. * Sets the shadow projection clipping maximum z value.
  71337. */
  71338. /**
  71339. * Gets the shadow projection clipping maximum z value.
  71340. */
  71341. shadowMaxZ: number;
  71342. /**
  71343. * Callback defining a custom Projection Matrix Builder.
  71344. * This can be used to override the default projection matrix computation.
  71345. */
  71346. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  71347. /**
  71348. * The transformed position. Position of the light in world space taking parenting in account.
  71349. */
  71350. transformedPosition: Vector3;
  71351. /**
  71352. * The transformed direction. Direction of the light in world space taking parenting in account.
  71353. */
  71354. transformedDirection: Vector3;
  71355. private _needProjectionMatrixCompute;
  71356. /**
  71357. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  71358. * @returns true if the information has been computed, false if it does not need to (no parenting)
  71359. */
  71360. computeTransformedInformation(): boolean;
  71361. /**
  71362. * Return the depth scale used for the shadow map.
  71363. * @returns the depth scale.
  71364. */
  71365. getDepthScale(): number;
  71366. /**
  71367. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  71368. * @param faceIndex The index of the face we are computed the direction to generate shadow
  71369. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  71370. */
  71371. getShadowDirection(faceIndex?: number): Vector3;
  71372. /**
  71373. * Returns the ShadowLight absolute position in the World.
  71374. * @returns the position vector in world space
  71375. */
  71376. getAbsolutePosition(): Vector3;
  71377. /**
  71378. * Sets the ShadowLight direction toward the passed target.
  71379. * @param target The point to target in local space
  71380. * @returns the updated ShadowLight direction
  71381. */
  71382. setDirectionToTarget(target: Vector3): Vector3;
  71383. /**
  71384. * Returns the light rotation in euler definition.
  71385. * @returns the x y z rotation in local space.
  71386. */
  71387. getRotation(): Vector3;
  71388. /**
  71389. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  71390. * @returns true if a cube texture needs to be use
  71391. */
  71392. needCube(): boolean;
  71393. /**
  71394. * Detects if the projection matrix requires to be recomputed this frame.
  71395. * @returns true if it requires to be recomputed otherwise, false.
  71396. */
  71397. needProjectionMatrixCompute(): boolean;
  71398. /**
  71399. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  71400. */
  71401. forceProjectionMatrixCompute(): void;
  71402. /** @hidden */
  71403. _initCache(): void;
  71404. /** @hidden */
  71405. _isSynchronized(): boolean;
  71406. /**
  71407. * Computes the world matrix of the node
  71408. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  71409. * @returns the world matrix
  71410. */
  71411. computeWorldMatrix(force?: boolean): Matrix;
  71412. /**
  71413. * Gets the minZ used for shadow according to both the scene and the light.
  71414. * @param activeCamera The camera we are returning the min for
  71415. * @returns the depth min z
  71416. */
  71417. getDepthMinZ(activeCamera: Camera): number;
  71418. /**
  71419. * Gets the maxZ used for shadow according to both the scene and the light.
  71420. * @param activeCamera The camera we are returning the max for
  71421. * @returns the depth max z
  71422. */
  71423. getDepthMaxZ(activeCamera: Camera): number;
  71424. /**
  71425. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  71426. * @param matrix The materix to updated with the projection information
  71427. * @param viewMatrix The transform matrix of the light
  71428. * @param renderList The list of mesh to render in the map
  71429. * @returns The current light
  71430. */
  71431. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  71432. }
  71433. }
  71434. declare module BABYLON {
  71435. /**
  71436. * "Static Class" containing the most commonly used helper while dealing with material for
  71437. * rendering purpose.
  71438. *
  71439. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  71440. *
  71441. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  71442. */
  71443. export class MaterialHelper {
  71444. /**
  71445. * Bind the current view position to an effect.
  71446. * @param effect The effect to be bound
  71447. * @param scene The scene the eyes position is used from
  71448. */
  71449. static BindEyePosition(effect: Effect, scene: Scene): void;
  71450. /**
  71451. * Helps preparing the defines values about the UVs in used in the effect.
  71452. * UVs are shared as much as we can accross channels in the shaders.
  71453. * @param texture The texture we are preparing the UVs for
  71454. * @param defines The defines to update
  71455. * @param key The channel key "diffuse", "specular"... used in the shader
  71456. */
  71457. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  71458. /**
  71459. * Binds a texture matrix value to its corrsponding uniform
  71460. * @param texture The texture to bind the matrix for
  71461. * @param uniformBuffer The uniform buffer receivin the data
  71462. * @param key The channel key "diffuse", "specular"... used in the shader
  71463. */
  71464. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  71465. /**
  71466. * Gets the current status of the fog (should it be enabled?)
  71467. * @param mesh defines the mesh to evaluate for fog support
  71468. * @param scene defines the hosting scene
  71469. * @returns true if fog must be enabled
  71470. */
  71471. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  71472. /**
  71473. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  71474. * @param mesh defines the current mesh
  71475. * @param scene defines the current scene
  71476. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  71477. * @param pointsCloud defines if point cloud rendering has to be turned on
  71478. * @param fogEnabled defines if fog has to be turned on
  71479. * @param alphaTest defines if alpha testing has to be turned on
  71480. * @param defines defines the current list of defines
  71481. */
  71482. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  71483. /**
  71484. * Helper used to prepare the list of defines associated with frame values for shader compilation
  71485. * @param scene defines the current scene
  71486. * @param engine defines the current engine
  71487. * @param defines specifies the list of active defines
  71488. * @param useInstances defines if instances have to be turned on
  71489. * @param useClipPlane defines if clip plane have to be turned on
  71490. */
  71491. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  71492. /**
  71493. * Prepares the defines for bones
  71494. * @param mesh The mesh containing the geometry data we will draw
  71495. * @param defines The defines to update
  71496. */
  71497. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  71498. /**
  71499. * Prepares the defines for morph targets
  71500. * @param mesh The mesh containing the geometry data we will draw
  71501. * @param defines The defines to update
  71502. */
  71503. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  71504. /**
  71505. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  71506. * @param mesh The mesh containing the geometry data we will draw
  71507. * @param defines The defines to update
  71508. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  71509. * @param useBones Precise whether bones should be used or not (override mesh info)
  71510. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  71511. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  71512. * @returns false if defines are considered not dirty and have not been checked
  71513. */
  71514. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  71515. /**
  71516. * Prepares the defines related to multiview
  71517. * @param scene The scene we are intending to draw
  71518. * @param defines The defines to update
  71519. */
  71520. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  71521. /**
  71522. * Prepares the defines related to the light information passed in parameter
  71523. * @param scene The scene we are intending to draw
  71524. * @param mesh The mesh the effect is compiling for
  71525. * @param defines The defines to update
  71526. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  71527. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  71528. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  71529. * @returns true if normals will be required for the rest of the effect
  71530. */
  71531. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  71532. /**
  71533. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  71534. * that won t be acctive due to defines being turned off.
  71535. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  71536. * @param samplersList The samplers list
  71537. * @param defines The defines helping in the list generation
  71538. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  71539. */
  71540. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  71541. /**
  71542. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  71543. * @param defines The defines to update while falling back
  71544. * @param fallbacks The authorized effect fallbacks
  71545. * @param maxSimultaneousLights The maximum number of lights allowed
  71546. * @param rank the current rank of the Effect
  71547. * @returns The newly affected rank
  71548. */
  71549. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  71550. /**
  71551. * Prepares the list of attributes required for morph targets according to the effect defines.
  71552. * @param attribs The current list of supported attribs
  71553. * @param mesh The mesh to prepare the morph targets attributes for
  71554. * @param defines The current Defines of the effect
  71555. */
  71556. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  71557. /**
  71558. * Prepares the list of attributes required for bones according to the effect defines.
  71559. * @param attribs The current list of supported attribs
  71560. * @param mesh The mesh to prepare the bones attributes for
  71561. * @param defines The current Defines of the effect
  71562. * @param fallbacks The current efffect fallback strategy
  71563. */
  71564. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  71565. /**
  71566. * Check and prepare the list of attributes required for instances according to the effect defines.
  71567. * @param attribs The current list of supported attribs
  71568. * @param defines The current MaterialDefines of the effect
  71569. */
  71570. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  71571. /**
  71572. * Add the list of attributes required for instances to the attribs array.
  71573. * @param attribs The current list of supported attribs
  71574. */
  71575. static PushAttributesForInstances(attribs: string[]): void;
  71576. /**
  71577. * Binds the light shadow information to the effect for the given mesh.
  71578. * @param light The light containing the generator
  71579. * @param scene The scene the lights belongs to
  71580. * @param mesh The mesh we are binding the information to render
  71581. * @param lightIndex The light index in the effect used to render the mesh
  71582. * @param effect The effect we are binding the data to
  71583. */
  71584. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  71585. /**
  71586. * Binds the light information to the effect.
  71587. * @param light The light containing the generator
  71588. * @param effect The effect we are binding the data to
  71589. * @param lightIndex The light index in the effect used to render
  71590. */
  71591. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  71592. /**
  71593. * Binds the lights information from the scene to the effect for the given mesh.
  71594. * @param scene The scene the lights belongs to
  71595. * @param mesh The mesh we are binding the information to render
  71596. * @param effect The effect we are binding the data to
  71597. * @param defines The generated defines for the effect
  71598. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  71599. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  71600. */
  71601. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  71602. private static _tempFogColor;
  71603. /**
  71604. * Binds the fog information from the scene to the effect for the given mesh.
  71605. * @param scene The scene the lights belongs to
  71606. * @param mesh The mesh we are binding the information to render
  71607. * @param effect The effect we are binding the data to
  71608. * @param linearSpace Defines if the fog effect is applied in linear space
  71609. */
  71610. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  71611. /**
  71612. * Binds the bones information from the mesh to the effect.
  71613. * @param mesh The mesh we are binding the information to render
  71614. * @param effect The effect we are binding the data to
  71615. */
  71616. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  71617. /**
  71618. * Binds the morph targets information from the mesh to the effect.
  71619. * @param abstractMesh The mesh we are binding the information to render
  71620. * @param effect The effect we are binding the data to
  71621. */
  71622. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  71623. /**
  71624. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  71625. * @param defines The generated defines used in the effect
  71626. * @param effect The effect we are binding the data to
  71627. * @param scene The scene we are willing to render with logarithmic scale for
  71628. */
  71629. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  71630. /**
  71631. * Binds the clip plane information from the scene to the effect.
  71632. * @param scene The scene the clip plane information are extracted from
  71633. * @param effect The effect we are binding the data to
  71634. */
  71635. static BindClipPlane(effect: Effect, scene: Scene): void;
  71636. }
  71637. }
  71638. declare module BABYLON {
  71639. /** @hidden */
  71640. export var kernelBlurVaryingDeclaration: {
  71641. name: string;
  71642. shader: string;
  71643. };
  71644. }
  71645. declare module BABYLON {
  71646. /** @hidden */
  71647. export var kernelBlurFragment: {
  71648. name: string;
  71649. shader: string;
  71650. };
  71651. }
  71652. declare module BABYLON {
  71653. /** @hidden */
  71654. export var kernelBlurFragment2: {
  71655. name: string;
  71656. shader: string;
  71657. };
  71658. }
  71659. declare module BABYLON {
  71660. /** @hidden */
  71661. export var kernelBlurPixelShader: {
  71662. name: string;
  71663. shader: string;
  71664. };
  71665. }
  71666. declare module BABYLON {
  71667. /** @hidden */
  71668. export var kernelBlurVertex: {
  71669. name: string;
  71670. shader: string;
  71671. };
  71672. }
  71673. declare module BABYLON {
  71674. /** @hidden */
  71675. export var kernelBlurVertexShader: {
  71676. name: string;
  71677. shader: string;
  71678. };
  71679. }
  71680. declare module BABYLON {
  71681. /**
  71682. * The Blur Post Process which blurs an image based on a kernel and direction.
  71683. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  71684. */
  71685. export class BlurPostProcess extends PostProcess {
  71686. /** The direction in which to blur the image. */
  71687. direction: Vector2;
  71688. private blockCompilation;
  71689. protected _kernel: number;
  71690. protected _idealKernel: number;
  71691. protected _packedFloat: boolean;
  71692. private _staticDefines;
  71693. /**
  71694. * Sets the length in pixels of the blur sample region
  71695. */
  71696. /**
  71697. * Gets the length in pixels of the blur sample region
  71698. */
  71699. kernel: number;
  71700. /**
  71701. * Sets wether or not the blur needs to unpack/repack floats
  71702. */
  71703. /**
  71704. * Gets wether or not the blur is unpacking/repacking floats
  71705. */
  71706. packedFloat: boolean;
  71707. /**
  71708. * Creates a new instance BlurPostProcess
  71709. * @param name The name of the effect.
  71710. * @param direction The direction in which to blur the image.
  71711. * @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.
  71712. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  71713. * @param camera The camera to apply the render pass to.
  71714. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  71715. * @param engine The engine which the post process will be applied. (default: current engine)
  71716. * @param reusable If the post process can be reused on the same frame. (default: false)
  71717. * @param textureType Type of textures used when performing the post process. (default: 0)
  71718. * @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)
  71719. */
  71720. constructor(name: string,
  71721. /** The direction in which to blur the image. */
  71722. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  71723. /**
  71724. * Updates the effect with the current post process compile time values and recompiles the shader.
  71725. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  71726. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  71727. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  71728. * @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
  71729. * @param onCompiled Called when the shader has been compiled.
  71730. * @param onError Called if there is an error when compiling a shader.
  71731. */
  71732. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71733. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  71734. /**
  71735. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  71736. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  71737. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  71738. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  71739. * The gaps between physical kernels are compensated for in the weighting of the samples
  71740. * @param idealKernel Ideal blur kernel.
  71741. * @return Nearest best kernel.
  71742. */
  71743. protected _nearestBestKernel(idealKernel: number): number;
  71744. /**
  71745. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  71746. * @param x The point on the Gaussian distribution to sample.
  71747. * @return the value of the Gaussian function at x.
  71748. */
  71749. protected _gaussianWeight(x: number): number;
  71750. /**
  71751. * Generates a string that can be used as a floating point number in GLSL.
  71752. * @param x Value to print.
  71753. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  71754. * @return GLSL float string.
  71755. */
  71756. protected _glslFloat(x: number, decimalFigures?: number): string;
  71757. }
  71758. }
  71759. declare module BABYLON {
  71760. /** @hidden */
  71761. export var shadowMapPixelShader: {
  71762. name: string;
  71763. shader: string;
  71764. };
  71765. }
  71766. declare module BABYLON {
  71767. /** @hidden */
  71768. export var bonesDeclaration: {
  71769. name: string;
  71770. shader: string;
  71771. };
  71772. }
  71773. declare module BABYLON {
  71774. /** @hidden */
  71775. export var morphTargetsVertexGlobalDeclaration: {
  71776. name: string;
  71777. shader: string;
  71778. };
  71779. }
  71780. declare module BABYLON {
  71781. /** @hidden */
  71782. export var morphTargetsVertexDeclaration: {
  71783. name: string;
  71784. shader: string;
  71785. };
  71786. }
  71787. declare module BABYLON {
  71788. /** @hidden */
  71789. export var instancesDeclaration: {
  71790. name: string;
  71791. shader: string;
  71792. };
  71793. }
  71794. declare module BABYLON {
  71795. /** @hidden */
  71796. export var helperFunctions: {
  71797. name: string;
  71798. shader: string;
  71799. };
  71800. }
  71801. declare module BABYLON {
  71802. /** @hidden */
  71803. export var morphTargetsVertex: {
  71804. name: string;
  71805. shader: string;
  71806. };
  71807. }
  71808. declare module BABYLON {
  71809. /** @hidden */
  71810. export var instancesVertex: {
  71811. name: string;
  71812. shader: string;
  71813. };
  71814. }
  71815. declare module BABYLON {
  71816. /** @hidden */
  71817. export var bonesVertex: {
  71818. name: string;
  71819. shader: string;
  71820. };
  71821. }
  71822. declare module BABYLON {
  71823. /** @hidden */
  71824. export var shadowMapVertexShader: {
  71825. name: string;
  71826. shader: string;
  71827. };
  71828. }
  71829. declare module BABYLON {
  71830. /** @hidden */
  71831. export var depthBoxBlurPixelShader: {
  71832. name: string;
  71833. shader: string;
  71834. };
  71835. }
  71836. declare module BABYLON {
  71837. /**
  71838. * Defines the options associated with the creation of a custom shader for a shadow generator.
  71839. */
  71840. export interface ICustomShaderOptions {
  71841. /**
  71842. * Gets or sets the custom shader name to use
  71843. */
  71844. shaderName: string;
  71845. /**
  71846. * The list of attribute names used in the shader
  71847. */
  71848. attributes?: string[];
  71849. /**
  71850. * The list of unifrom names used in the shader
  71851. */
  71852. uniforms?: string[];
  71853. /**
  71854. * The list of sampler names used in the shader
  71855. */
  71856. samplers?: string[];
  71857. /**
  71858. * The list of defines used in the shader
  71859. */
  71860. defines?: string[];
  71861. }
  71862. /**
  71863. * Interface to implement to create a shadow generator compatible with BJS.
  71864. */
  71865. export interface IShadowGenerator {
  71866. /**
  71867. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  71868. * @returns The render target texture if present otherwise, null
  71869. */
  71870. getShadowMap(): Nullable<RenderTargetTexture>;
  71871. /**
  71872. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  71873. * @returns The render target texture if the shadow map is present otherwise, null
  71874. */
  71875. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  71876. /**
  71877. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  71878. * @param subMesh The submesh we want to render in the shadow map
  71879. * @param useInstances Defines wether will draw in the map using instances
  71880. * @returns true if ready otherwise, false
  71881. */
  71882. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71883. /**
  71884. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  71885. * @param defines Defines of the material we want to update
  71886. * @param lightIndex Index of the light in the enabled light list of the material
  71887. */
  71888. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  71889. /**
  71890. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  71891. * defined in the generator but impacting the effect).
  71892. * It implies the unifroms available on the materials are the standard BJS ones.
  71893. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  71894. * @param effect The effect we are binfing the information for
  71895. */
  71896. bindShadowLight(lightIndex: string, effect: Effect): void;
  71897. /**
  71898. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  71899. * (eq to shadow prjection matrix * light transform matrix)
  71900. * @returns The transform matrix used to create the shadow map
  71901. */
  71902. getTransformMatrix(): Matrix;
  71903. /**
  71904. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  71905. * Cube and 2D textures for instance.
  71906. */
  71907. recreateShadowMap(): void;
  71908. /**
  71909. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  71910. * @param onCompiled Callback triggered at the and of the effects compilation
  71911. * @param options Sets of optional options forcing the compilation with different modes
  71912. */
  71913. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  71914. useInstances: boolean;
  71915. }>): void;
  71916. /**
  71917. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  71918. * @param options Sets of optional options forcing the compilation with different modes
  71919. * @returns A promise that resolves when the compilation completes
  71920. */
  71921. forceCompilationAsync(options?: Partial<{
  71922. useInstances: boolean;
  71923. }>): Promise<void>;
  71924. /**
  71925. * Serializes the shadow generator setup to a json object.
  71926. * @returns The serialized JSON object
  71927. */
  71928. serialize(): any;
  71929. /**
  71930. * Disposes the Shadow map and related Textures and effects.
  71931. */
  71932. dispose(): void;
  71933. }
  71934. /**
  71935. * Default implementation IShadowGenerator.
  71936. * This is the main object responsible of generating shadows in the framework.
  71937. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  71938. */
  71939. export class ShadowGenerator implements IShadowGenerator {
  71940. /**
  71941. * Shadow generator mode None: no filtering applied.
  71942. */
  71943. static readonly FILTER_NONE: number;
  71944. /**
  71945. * Shadow generator mode ESM: Exponential Shadow Mapping.
  71946. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  71947. */
  71948. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  71949. /**
  71950. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  71951. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  71952. */
  71953. static readonly FILTER_POISSONSAMPLING: number;
  71954. /**
  71955. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  71956. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  71957. */
  71958. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  71959. /**
  71960. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  71961. * edge artifacts on steep falloff.
  71962. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  71963. */
  71964. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  71965. /**
  71966. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  71967. * edge artifacts on steep falloff.
  71968. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  71969. */
  71970. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  71971. /**
  71972. * Shadow generator mode PCF: Percentage Closer Filtering
  71973. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  71974. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  71975. */
  71976. static readonly FILTER_PCF: number;
  71977. /**
  71978. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  71979. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  71980. * Contact Hardening
  71981. */
  71982. static readonly FILTER_PCSS: number;
  71983. /**
  71984. * Reserved for PCF and PCSS
  71985. * Highest Quality.
  71986. *
  71987. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  71988. *
  71989. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  71990. */
  71991. static readonly QUALITY_HIGH: number;
  71992. /**
  71993. * Reserved for PCF and PCSS
  71994. * Good tradeoff for quality/perf cross devices
  71995. *
  71996. * Execute PCF on a 3*3 kernel.
  71997. *
  71998. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  71999. */
  72000. static readonly QUALITY_MEDIUM: number;
  72001. /**
  72002. * Reserved for PCF and PCSS
  72003. * The lowest quality but the fastest.
  72004. *
  72005. * Execute PCF on a 1*1 kernel.
  72006. *
  72007. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  72008. */
  72009. static readonly QUALITY_LOW: number;
  72010. /** Gets or sets the custom shader name to use */
  72011. customShaderOptions: ICustomShaderOptions;
  72012. /**
  72013. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  72014. */
  72015. onBeforeShadowMapRenderObservable: Observable<Effect>;
  72016. /**
  72017. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  72018. */
  72019. onAfterShadowMapRenderObservable: Observable<Effect>;
  72020. /**
  72021. * Observable triggered before a mesh is rendered in the shadow map.
  72022. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  72023. */
  72024. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  72025. /**
  72026. * Observable triggered after a mesh is rendered in the shadow map.
  72027. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  72028. */
  72029. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  72030. private _bias;
  72031. /**
  72032. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  72033. */
  72034. /**
  72035. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  72036. */
  72037. bias: number;
  72038. private _normalBias;
  72039. /**
  72040. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72041. */
  72042. /**
  72043. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  72044. */
  72045. normalBias: number;
  72046. private _blurBoxOffset;
  72047. /**
  72048. * Gets the blur box offset: offset applied during the blur pass.
  72049. * Only useful if useKernelBlur = false
  72050. */
  72051. /**
  72052. * Sets the blur box offset: offset applied during the blur pass.
  72053. * Only useful if useKernelBlur = false
  72054. */
  72055. blurBoxOffset: number;
  72056. private _blurScale;
  72057. /**
  72058. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  72059. * 2 means half of the size.
  72060. */
  72061. /**
  72062. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  72063. * 2 means half of the size.
  72064. */
  72065. blurScale: number;
  72066. private _blurKernel;
  72067. /**
  72068. * Gets the blur kernel: kernel size of the blur pass.
  72069. * Only useful if useKernelBlur = true
  72070. */
  72071. /**
  72072. * Sets the blur kernel: kernel size of the blur pass.
  72073. * Only useful if useKernelBlur = true
  72074. */
  72075. blurKernel: number;
  72076. private _useKernelBlur;
  72077. /**
  72078. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  72079. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72080. */
  72081. /**
  72082. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  72083. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  72084. */
  72085. useKernelBlur: boolean;
  72086. private _depthScale;
  72087. /**
  72088. * Gets the depth scale used in ESM mode.
  72089. */
  72090. /**
  72091. * Sets the depth scale used in ESM mode.
  72092. * This can override the scale stored on the light.
  72093. */
  72094. depthScale: number;
  72095. private _filter;
  72096. /**
  72097. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  72098. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72099. */
  72100. /**
  72101. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  72102. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  72103. */
  72104. filter: number;
  72105. /**
  72106. * Gets if the current filter is set to Poisson Sampling.
  72107. */
  72108. /**
  72109. * Sets the current filter to Poisson Sampling.
  72110. */
  72111. usePoissonSampling: boolean;
  72112. /**
  72113. * Gets if the current filter is set to ESM.
  72114. */
  72115. /**
  72116. * Sets the current filter is to ESM.
  72117. */
  72118. useExponentialShadowMap: boolean;
  72119. /**
  72120. * Gets if the current filter is set to filtered ESM.
  72121. */
  72122. /**
  72123. * Gets if the current filter is set to filtered ESM.
  72124. */
  72125. useBlurExponentialShadowMap: boolean;
  72126. /**
  72127. * Gets if the current filter is set to "close ESM" (using the inverse of the
  72128. * exponential to prevent steep falloff artifacts).
  72129. */
  72130. /**
  72131. * Sets the current filter to "close ESM" (using the inverse of the
  72132. * exponential to prevent steep falloff artifacts).
  72133. */
  72134. useCloseExponentialShadowMap: boolean;
  72135. /**
  72136. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  72137. * exponential to prevent steep falloff artifacts).
  72138. */
  72139. /**
  72140. * Sets the current filter to filtered "close ESM" (using the inverse of the
  72141. * exponential to prevent steep falloff artifacts).
  72142. */
  72143. useBlurCloseExponentialShadowMap: boolean;
  72144. /**
  72145. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  72146. */
  72147. /**
  72148. * Sets the current filter to "PCF" (percentage closer filtering).
  72149. */
  72150. usePercentageCloserFiltering: boolean;
  72151. private _filteringQuality;
  72152. /**
  72153. * Gets the PCF or PCSS Quality.
  72154. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72155. */
  72156. /**
  72157. * Sets the PCF or PCSS Quality.
  72158. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  72159. */
  72160. filteringQuality: number;
  72161. /**
  72162. * Gets if the current filter is set to "PCSS" (contact hardening).
  72163. */
  72164. /**
  72165. * Sets the current filter to "PCSS" (contact hardening).
  72166. */
  72167. useContactHardeningShadow: boolean;
  72168. private _contactHardeningLightSizeUVRatio;
  72169. /**
  72170. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72171. * Using a ratio helps keeping shape stability independently of the map size.
  72172. *
  72173. * It does not account for the light projection as it was having too much
  72174. * instability during the light setup or during light position changes.
  72175. *
  72176. * Only valid if useContactHardeningShadow is true.
  72177. */
  72178. /**
  72179. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  72180. * Using a ratio helps keeping shape stability independently of the map size.
  72181. *
  72182. * It does not account for the light projection as it was having too much
  72183. * instability during the light setup or during light position changes.
  72184. *
  72185. * Only valid if useContactHardeningShadow is true.
  72186. */
  72187. contactHardeningLightSizeUVRatio: number;
  72188. private _darkness;
  72189. /** Gets or sets the actual darkness of a shadow */
  72190. darkness: number;
  72191. /**
  72192. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  72193. * 0 means strongest and 1 would means no shadow.
  72194. * @returns the darkness.
  72195. */
  72196. getDarkness(): number;
  72197. /**
  72198. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  72199. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  72200. * @returns the shadow generator allowing fluent coding.
  72201. */
  72202. setDarkness(darkness: number): ShadowGenerator;
  72203. private _transparencyShadow;
  72204. /** Gets or sets the ability to have transparent shadow */
  72205. transparencyShadow: boolean;
  72206. /**
  72207. * Sets the ability to have transparent shadow (boolean).
  72208. * @param transparent True if transparent else False
  72209. * @returns the shadow generator allowing fluent coding
  72210. */
  72211. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  72212. private _shadowMap;
  72213. private _shadowMap2;
  72214. /**
  72215. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  72216. * @returns The render target texture if present otherwise, null
  72217. */
  72218. getShadowMap(): Nullable<RenderTargetTexture>;
  72219. /**
  72220. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  72221. * @returns The render target texture if the shadow map is present otherwise, null
  72222. */
  72223. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  72224. /**
  72225. * Gets the class name of that object
  72226. * @returns "ShadowGenerator"
  72227. */
  72228. getClassName(): string;
  72229. /**
  72230. * Helper function to add a mesh and its descendants to the list of shadow casters.
  72231. * @param mesh Mesh to add
  72232. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  72233. * @returns the Shadow Generator itself
  72234. */
  72235. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72236. /**
  72237. * Helper function to remove a mesh and its descendants from the list of shadow casters
  72238. * @param mesh Mesh to remove
  72239. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  72240. * @returns the Shadow Generator itself
  72241. */
  72242. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  72243. /**
  72244. * Controls the extent to which the shadows fade out at the edge of the frustum
  72245. * Used only by directionals and spots
  72246. */
  72247. frustumEdgeFalloff: number;
  72248. private _light;
  72249. /**
  72250. * Returns the associated light object.
  72251. * @returns the light generating the shadow
  72252. */
  72253. getLight(): IShadowLight;
  72254. /**
  72255. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  72256. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  72257. * It might on the other hand introduce peter panning.
  72258. */
  72259. forceBackFacesOnly: boolean;
  72260. private _scene;
  72261. private _lightDirection;
  72262. private _effect;
  72263. private _viewMatrix;
  72264. private _projectionMatrix;
  72265. private _transformMatrix;
  72266. private _cachedPosition;
  72267. private _cachedDirection;
  72268. private _cachedDefines;
  72269. private _currentRenderID;
  72270. private _boxBlurPostprocess;
  72271. private _kernelBlurXPostprocess;
  72272. private _kernelBlurYPostprocess;
  72273. private _blurPostProcesses;
  72274. private _mapSize;
  72275. private _currentFaceIndex;
  72276. private _currentFaceIndexCache;
  72277. private _textureType;
  72278. private _defaultTextureMatrix;
  72279. /** @hidden */
  72280. static _SceneComponentInitialization: (scene: Scene) => void;
  72281. /**
  72282. * Creates a ShadowGenerator object.
  72283. * A ShadowGenerator is the required tool to use the shadows.
  72284. * Each light casting shadows needs to use its own ShadowGenerator.
  72285. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  72286. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  72287. * @param light The light object generating the shadows.
  72288. * @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.
  72289. */
  72290. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  72291. private _initializeGenerator;
  72292. private _initializeShadowMap;
  72293. private _initializeBlurRTTAndPostProcesses;
  72294. private _renderForShadowMap;
  72295. private _renderSubMeshForShadowMap;
  72296. private _applyFilterValues;
  72297. /**
  72298. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72299. * @param onCompiled Callback triggered at the and of the effects compilation
  72300. * @param options Sets of optional options forcing the compilation with different modes
  72301. */
  72302. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  72303. useInstances: boolean;
  72304. }>): void;
  72305. /**
  72306. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  72307. * @param options Sets of optional options forcing the compilation with different modes
  72308. * @returns A promise that resolves when the compilation completes
  72309. */
  72310. forceCompilationAsync(options?: Partial<{
  72311. useInstances: boolean;
  72312. }>): Promise<void>;
  72313. /**
  72314. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  72315. * @param subMesh The submesh we want to render in the shadow map
  72316. * @param useInstances Defines wether will draw in the map using instances
  72317. * @returns true if ready otherwise, false
  72318. */
  72319. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  72320. /**
  72321. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  72322. * @param defines Defines of the material we want to update
  72323. * @param lightIndex Index of the light in the enabled light list of the material
  72324. */
  72325. prepareDefines(defines: any, lightIndex: number): void;
  72326. /**
  72327. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  72328. * defined in the generator but impacting the effect).
  72329. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  72330. * @param effect The effect we are binfing the information for
  72331. */
  72332. bindShadowLight(lightIndex: string, effect: Effect): void;
  72333. /**
  72334. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  72335. * (eq to shadow prjection matrix * light transform matrix)
  72336. * @returns The transform matrix used to create the shadow map
  72337. */
  72338. getTransformMatrix(): Matrix;
  72339. /**
  72340. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  72341. * Cube and 2D textures for instance.
  72342. */
  72343. recreateShadowMap(): void;
  72344. private _disposeBlurPostProcesses;
  72345. private _disposeRTTandPostProcesses;
  72346. /**
  72347. * Disposes the ShadowGenerator.
  72348. * Returns nothing.
  72349. */
  72350. dispose(): void;
  72351. /**
  72352. * Serializes the shadow generator setup to a json object.
  72353. * @returns The serialized JSON object
  72354. */
  72355. serialize(): any;
  72356. /**
  72357. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  72358. * @param parsedShadowGenerator The JSON object to parse
  72359. * @param scene The scene to create the shadow map for
  72360. * @returns The parsed shadow generator
  72361. */
  72362. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  72363. }
  72364. }
  72365. declare module BABYLON {
  72366. /**
  72367. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  72368. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  72369. * 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.
  72370. */
  72371. export abstract class Light extends Node {
  72372. /**
  72373. * Falloff Default: light is falling off following the material specification:
  72374. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  72375. */
  72376. static readonly FALLOFF_DEFAULT: number;
  72377. /**
  72378. * Falloff Physical: light is falling off following the inverse squared distance law.
  72379. */
  72380. static readonly FALLOFF_PHYSICAL: number;
  72381. /**
  72382. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  72383. * to enhance interoperability with other engines.
  72384. */
  72385. static readonly FALLOFF_GLTF: number;
  72386. /**
  72387. * Falloff Standard: light is falling off like in the standard material
  72388. * to enhance interoperability with other materials.
  72389. */
  72390. static readonly FALLOFF_STANDARD: number;
  72391. /**
  72392. * If every light affecting the material is in this lightmapMode,
  72393. * material.lightmapTexture adds or multiplies
  72394. * (depends on material.useLightmapAsShadowmap)
  72395. * after every other light calculations.
  72396. */
  72397. static readonly LIGHTMAP_DEFAULT: number;
  72398. /**
  72399. * material.lightmapTexture as only diffuse lighting from this light
  72400. * adds only specular lighting from this light
  72401. * adds dynamic shadows
  72402. */
  72403. static readonly LIGHTMAP_SPECULAR: number;
  72404. /**
  72405. * material.lightmapTexture as only lighting
  72406. * no light calculation from this light
  72407. * only adds dynamic shadows from this light
  72408. */
  72409. static readonly LIGHTMAP_SHADOWSONLY: number;
  72410. /**
  72411. * Each light type uses the default quantity according to its type:
  72412. * point/spot lights use luminous intensity
  72413. * directional lights use illuminance
  72414. */
  72415. static readonly INTENSITYMODE_AUTOMATIC: number;
  72416. /**
  72417. * lumen (lm)
  72418. */
  72419. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  72420. /**
  72421. * candela (lm/sr)
  72422. */
  72423. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  72424. /**
  72425. * lux (lm/m^2)
  72426. */
  72427. static readonly INTENSITYMODE_ILLUMINANCE: number;
  72428. /**
  72429. * nit (cd/m^2)
  72430. */
  72431. static readonly INTENSITYMODE_LUMINANCE: number;
  72432. /**
  72433. * Light type const id of the point light.
  72434. */
  72435. static readonly LIGHTTYPEID_POINTLIGHT: number;
  72436. /**
  72437. * Light type const id of the directional light.
  72438. */
  72439. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  72440. /**
  72441. * Light type const id of the spot light.
  72442. */
  72443. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  72444. /**
  72445. * Light type const id of the hemispheric light.
  72446. */
  72447. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  72448. /**
  72449. * Diffuse gives the basic color to an object.
  72450. */
  72451. diffuse: Color3;
  72452. /**
  72453. * Specular produces a highlight color on an object.
  72454. * Note: This is note affecting PBR materials.
  72455. */
  72456. specular: Color3;
  72457. /**
  72458. * Defines the falloff type for this light. This lets overrriding how punctual light are
  72459. * falling off base on range or angle.
  72460. * This can be set to any values in Light.FALLOFF_x.
  72461. *
  72462. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  72463. * other types of materials.
  72464. */
  72465. falloffType: number;
  72466. /**
  72467. * Strength of the light.
  72468. * Note: By default it is define in the framework own unit.
  72469. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  72470. */
  72471. intensity: number;
  72472. private _range;
  72473. protected _inverseSquaredRange: number;
  72474. /**
  72475. * Defines how far from the source the light is impacting in scene units.
  72476. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72477. */
  72478. /**
  72479. * Defines how far from the source the light is impacting in scene units.
  72480. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  72481. */
  72482. range: number;
  72483. /**
  72484. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  72485. * of light.
  72486. */
  72487. private _photometricScale;
  72488. private _intensityMode;
  72489. /**
  72490. * Gets the photometric scale used to interpret the intensity.
  72491. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72492. */
  72493. /**
  72494. * Sets the photometric scale used to interpret the intensity.
  72495. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  72496. */
  72497. intensityMode: number;
  72498. private _radius;
  72499. /**
  72500. * Gets the light radius used by PBR Materials to simulate soft area lights.
  72501. */
  72502. /**
  72503. * sets the light radius used by PBR Materials to simulate soft area lights.
  72504. */
  72505. radius: number;
  72506. private _renderPriority;
  72507. /**
  72508. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  72509. * exceeding the number allowed of the materials.
  72510. */
  72511. renderPriority: number;
  72512. private _shadowEnabled;
  72513. /**
  72514. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72515. * the current shadow generator.
  72516. */
  72517. /**
  72518. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  72519. * the current shadow generator.
  72520. */
  72521. shadowEnabled: boolean;
  72522. private _includedOnlyMeshes;
  72523. /**
  72524. * Gets the only meshes impacted by this light.
  72525. */
  72526. /**
  72527. * Sets the only meshes impacted by this light.
  72528. */
  72529. includedOnlyMeshes: AbstractMesh[];
  72530. private _excludedMeshes;
  72531. /**
  72532. * Gets the meshes not impacted by this light.
  72533. */
  72534. /**
  72535. * Sets the meshes not impacted by this light.
  72536. */
  72537. excludedMeshes: AbstractMesh[];
  72538. private _excludeWithLayerMask;
  72539. /**
  72540. * Gets the layer id use to find what meshes are not impacted by the light.
  72541. * Inactive if 0
  72542. */
  72543. /**
  72544. * Sets the layer id use to find what meshes are not impacted by the light.
  72545. * Inactive if 0
  72546. */
  72547. excludeWithLayerMask: number;
  72548. private _includeOnlyWithLayerMask;
  72549. /**
  72550. * Gets the layer id use to find what meshes are impacted by the light.
  72551. * Inactive if 0
  72552. */
  72553. /**
  72554. * Sets the layer id use to find what meshes are impacted by the light.
  72555. * Inactive if 0
  72556. */
  72557. includeOnlyWithLayerMask: number;
  72558. private _lightmapMode;
  72559. /**
  72560. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72561. */
  72562. /**
  72563. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  72564. */
  72565. lightmapMode: number;
  72566. /**
  72567. * Shadow generator associted to the light.
  72568. * @hidden Internal use only.
  72569. */
  72570. _shadowGenerator: Nullable<IShadowGenerator>;
  72571. /**
  72572. * @hidden Internal use only.
  72573. */
  72574. _excludedMeshesIds: string[];
  72575. /**
  72576. * @hidden Internal use only.
  72577. */
  72578. _includedOnlyMeshesIds: string[];
  72579. /**
  72580. * The current light unifom buffer.
  72581. * @hidden Internal use only.
  72582. */
  72583. _uniformBuffer: UniformBuffer;
  72584. /**
  72585. * Creates a Light object in the scene.
  72586. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72587. * @param name The firendly name of the light
  72588. * @param scene The scene the light belongs too
  72589. */
  72590. constructor(name: string, scene: Scene);
  72591. protected abstract _buildUniformLayout(): void;
  72592. /**
  72593. * Sets the passed Effect "effect" with the Light information.
  72594. * @param effect The effect to update
  72595. * @param lightIndex The index of the light in the effect to update
  72596. * @returns The light
  72597. */
  72598. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  72599. /**
  72600. * Returns the string "Light".
  72601. * @returns the class name
  72602. */
  72603. getClassName(): string;
  72604. /** @hidden */
  72605. readonly _isLight: boolean;
  72606. /**
  72607. * Converts the light information to a readable string for debug purpose.
  72608. * @param fullDetails Supports for multiple levels of logging within scene loading
  72609. * @returns the human readable light info
  72610. */
  72611. toString(fullDetails?: boolean): string;
  72612. /** @hidden */
  72613. protected _syncParentEnabledState(): void;
  72614. /**
  72615. * Set the enabled state of this node.
  72616. * @param value - the new enabled state
  72617. */
  72618. setEnabled(value: boolean): void;
  72619. /**
  72620. * Returns the Light associated shadow generator if any.
  72621. * @return the associated shadow generator.
  72622. */
  72623. getShadowGenerator(): Nullable<IShadowGenerator>;
  72624. /**
  72625. * Returns a Vector3, the absolute light position in the World.
  72626. * @returns the world space position of the light
  72627. */
  72628. getAbsolutePosition(): Vector3;
  72629. /**
  72630. * Specifies if the light will affect the passed mesh.
  72631. * @param mesh The mesh to test against the light
  72632. * @return true the mesh is affected otherwise, false.
  72633. */
  72634. canAffectMesh(mesh: AbstractMesh): boolean;
  72635. /**
  72636. * Sort function to order lights for rendering.
  72637. * @param a First Light object to compare to second.
  72638. * @param b Second Light object to compare first.
  72639. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  72640. */
  72641. static CompareLightsPriority(a: Light, b: Light): number;
  72642. /**
  72643. * Releases resources associated with this node.
  72644. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  72645. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  72646. */
  72647. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  72648. /**
  72649. * Returns the light type ID (integer).
  72650. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72651. */
  72652. getTypeID(): number;
  72653. /**
  72654. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  72655. * @returns the scaled intensity in intensity mode unit
  72656. */
  72657. getScaledIntensity(): number;
  72658. /**
  72659. * Returns a new Light object, named "name", from the current one.
  72660. * @param name The name of the cloned light
  72661. * @returns the new created light
  72662. */
  72663. clone(name: string): Nullable<Light>;
  72664. /**
  72665. * Serializes the current light into a Serialization object.
  72666. * @returns the serialized object.
  72667. */
  72668. serialize(): any;
  72669. /**
  72670. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  72671. * This new light is named "name" and added to the passed scene.
  72672. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  72673. * @param name The friendly name of the light
  72674. * @param scene The scene the new light will belong to
  72675. * @returns the constructor function
  72676. */
  72677. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  72678. /**
  72679. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  72680. * @param parsedLight The JSON representation of the light
  72681. * @param scene The scene to create the parsed light in
  72682. * @returns the created light after parsing
  72683. */
  72684. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  72685. private _hookArrayForExcluded;
  72686. private _hookArrayForIncludedOnly;
  72687. private _resyncMeshes;
  72688. /**
  72689. * Forces the meshes to update their light related information in their rendering used effects
  72690. * @hidden Internal Use Only
  72691. */
  72692. _markMeshesAsLightDirty(): void;
  72693. /**
  72694. * Recomputes the cached photometric scale if needed.
  72695. */
  72696. private _computePhotometricScale;
  72697. /**
  72698. * Returns the Photometric Scale according to the light type and intensity mode.
  72699. */
  72700. private _getPhotometricScale;
  72701. /**
  72702. * Reorder the light in the scene according to their defined priority.
  72703. * @hidden Internal Use Only
  72704. */
  72705. _reorderLightsInScene(): void;
  72706. /**
  72707. * Prepares the list of defines specific to the light type.
  72708. * @param defines the list of defines
  72709. * @param lightIndex defines the index of the light for the effect
  72710. */
  72711. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72712. }
  72713. }
  72714. declare module BABYLON {
  72715. /**
  72716. * Interface used to define Action
  72717. */
  72718. export interface IAction {
  72719. /**
  72720. * Trigger for the action
  72721. */
  72722. trigger: number;
  72723. /** Options of the trigger */
  72724. triggerOptions: any;
  72725. /**
  72726. * Gets the trigger parameters
  72727. * @returns the trigger parameters
  72728. */
  72729. getTriggerParameter(): any;
  72730. /**
  72731. * Internal only - executes current action event
  72732. * @hidden
  72733. */
  72734. _executeCurrent(evt?: ActionEvent): void;
  72735. /**
  72736. * Serialize placeholder for child classes
  72737. * @param parent of child
  72738. * @returns the serialized object
  72739. */
  72740. serialize(parent: any): any;
  72741. /**
  72742. * Internal only
  72743. * @hidden
  72744. */
  72745. _prepare(): void;
  72746. /**
  72747. * Internal only - manager for action
  72748. * @hidden
  72749. */
  72750. _actionManager: AbstractActionManager;
  72751. /**
  72752. * Adds action to chain of actions, may be a DoNothingAction
  72753. * @param action defines the next action to execute
  72754. * @returns The action passed in
  72755. * @see https://www.babylonjs-playground.com/#1T30HR#0
  72756. */
  72757. then(action: IAction): IAction;
  72758. }
  72759. /**
  72760. * The action to be carried out following a trigger
  72761. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  72762. */
  72763. export class Action implements IAction {
  72764. /** the trigger, with or without parameters, for the action */
  72765. triggerOptions: any;
  72766. /**
  72767. * Trigger for the action
  72768. */
  72769. trigger: number;
  72770. /**
  72771. * Internal only - manager for action
  72772. * @hidden
  72773. */
  72774. _actionManager: ActionManager;
  72775. private _nextActiveAction;
  72776. private _child;
  72777. private _condition?;
  72778. private _triggerParameter;
  72779. /**
  72780. * An event triggered prior to action being executed.
  72781. */
  72782. onBeforeExecuteObservable: Observable<Action>;
  72783. /**
  72784. * Creates a new Action
  72785. * @param triggerOptions the trigger, with or without parameters, for the action
  72786. * @param condition an optional determinant of action
  72787. */
  72788. constructor(
  72789. /** the trigger, with or without parameters, for the action */
  72790. triggerOptions: any, condition?: Condition);
  72791. /**
  72792. * Internal only
  72793. * @hidden
  72794. */
  72795. _prepare(): void;
  72796. /**
  72797. * Gets the trigger parameters
  72798. * @returns the trigger parameters
  72799. */
  72800. getTriggerParameter(): any;
  72801. /**
  72802. * Internal only - executes current action event
  72803. * @hidden
  72804. */
  72805. _executeCurrent(evt?: ActionEvent): void;
  72806. /**
  72807. * Execute placeholder for child classes
  72808. * @param evt optional action event
  72809. */
  72810. execute(evt?: ActionEvent): void;
  72811. /**
  72812. * Skips to next active action
  72813. */
  72814. skipToNextActiveAction(): void;
  72815. /**
  72816. * Adds action to chain of actions, may be a DoNothingAction
  72817. * @param action defines the next action to execute
  72818. * @returns The action passed in
  72819. * @see https://www.babylonjs-playground.com/#1T30HR#0
  72820. */
  72821. then(action: Action): Action;
  72822. /**
  72823. * Internal only
  72824. * @hidden
  72825. */
  72826. _getProperty(propertyPath: string): string;
  72827. /**
  72828. * Internal only
  72829. * @hidden
  72830. */
  72831. _getEffectiveTarget(target: any, propertyPath: string): any;
  72832. /**
  72833. * Serialize placeholder for child classes
  72834. * @param parent of child
  72835. * @returns the serialized object
  72836. */
  72837. serialize(parent: any): any;
  72838. /**
  72839. * Internal only called by serialize
  72840. * @hidden
  72841. */
  72842. protected _serialize(serializedAction: any, parent?: any): any;
  72843. /**
  72844. * Internal only
  72845. * @hidden
  72846. */
  72847. static _SerializeValueAsString: (value: any) => string;
  72848. /**
  72849. * Internal only
  72850. * @hidden
  72851. */
  72852. static _GetTargetProperty: (target: Scene | Node) => {
  72853. name: string;
  72854. targetType: string;
  72855. value: string;
  72856. };
  72857. }
  72858. }
  72859. declare module BABYLON {
  72860. /**
  72861. * A Condition applied to an Action
  72862. */
  72863. export class Condition {
  72864. /**
  72865. * Internal only - manager for action
  72866. * @hidden
  72867. */
  72868. _actionManager: ActionManager;
  72869. /**
  72870. * Internal only
  72871. * @hidden
  72872. */
  72873. _evaluationId: number;
  72874. /**
  72875. * Internal only
  72876. * @hidden
  72877. */
  72878. _currentResult: boolean;
  72879. /**
  72880. * Creates a new Condition
  72881. * @param actionManager the manager of the action the condition is applied to
  72882. */
  72883. constructor(actionManager: ActionManager);
  72884. /**
  72885. * Check if the current condition is valid
  72886. * @returns a boolean
  72887. */
  72888. isValid(): boolean;
  72889. /**
  72890. * Internal only
  72891. * @hidden
  72892. */
  72893. _getProperty(propertyPath: string): string;
  72894. /**
  72895. * Internal only
  72896. * @hidden
  72897. */
  72898. _getEffectiveTarget(target: any, propertyPath: string): any;
  72899. /**
  72900. * Serialize placeholder for child classes
  72901. * @returns the serialized object
  72902. */
  72903. serialize(): any;
  72904. /**
  72905. * Internal only
  72906. * @hidden
  72907. */
  72908. protected _serialize(serializedCondition: any): any;
  72909. }
  72910. /**
  72911. * Defines specific conditional operators as extensions of Condition
  72912. */
  72913. export class ValueCondition extends Condition {
  72914. /** path to specify the property of the target the conditional operator uses */
  72915. propertyPath: string;
  72916. /** the value compared by the conditional operator against the current value of the property */
  72917. value: any;
  72918. /** the conditional operator, default ValueCondition.IsEqual */
  72919. operator: number;
  72920. /**
  72921. * Internal only
  72922. * @hidden
  72923. */
  72924. private static _IsEqual;
  72925. /**
  72926. * Internal only
  72927. * @hidden
  72928. */
  72929. private static _IsDifferent;
  72930. /**
  72931. * Internal only
  72932. * @hidden
  72933. */
  72934. private static _IsGreater;
  72935. /**
  72936. * Internal only
  72937. * @hidden
  72938. */
  72939. private static _IsLesser;
  72940. /**
  72941. * returns the number for IsEqual
  72942. */
  72943. static readonly IsEqual: number;
  72944. /**
  72945. * Returns the number for IsDifferent
  72946. */
  72947. static readonly IsDifferent: number;
  72948. /**
  72949. * Returns the number for IsGreater
  72950. */
  72951. static readonly IsGreater: number;
  72952. /**
  72953. * Returns the number for IsLesser
  72954. */
  72955. static readonly IsLesser: number;
  72956. /**
  72957. * Internal only The action manager for the condition
  72958. * @hidden
  72959. */
  72960. _actionManager: ActionManager;
  72961. /**
  72962. * Internal only
  72963. * @hidden
  72964. */
  72965. private _target;
  72966. /**
  72967. * Internal only
  72968. * @hidden
  72969. */
  72970. private _effectiveTarget;
  72971. /**
  72972. * Internal only
  72973. * @hidden
  72974. */
  72975. private _property;
  72976. /**
  72977. * Creates a new ValueCondition
  72978. * @param actionManager manager for the action the condition applies to
  72979. * @param target for the action
  72980. * @param propertyPath path to specify the property of the target the conditional operator uses
  72981. * @param value the value compared by the conditional operator against the current value of the property
  72982. * @param operator the conditional operator, default ValueCondition.IsEqual
  72983. */
  72984. constructor(actionManager: ActionManager, target: any,
  72985. /** path to specify the property of the target the conditional operator uses */
  72986. propertyPath: string,
  72987. /** the value compared by the conditional operator against the current value of the property */
  72988. value: any,
  72989. /** the conditional operator, default ValueCondition.IsEqual */
  72990. operator?: number);
  72991. /**
  72992. * Compares the given value with the property value for the specified conditional operator
  72993. * @returns the result of the comparison
  72994. */
  72995. isValid(): boolean;
  72996. /**
  72997. * Serialize the ValueCondition into a JSON compatible object
  72998. * @returns serialization object
  72999. */
  73000. serialize(): any;
  73001. /**
  73002. * Gets the name of the conditional operator for the ValueCondition
  73003. * @param operator the conditional operator
  73004. * @returns the name
  73005. */
  73006. static GetOperatorName(operator: number): string;
  73007. }
  73008. /**
  73009. * Defines a predicate condition as an extension of Condition
  73010. */
  73011. export class PredicateCondition extends Condition {
  73012. /** defines the predicate function used to validate the condition */
  73013. predicate: () => boolean;
  73014. /**
  73015. * Internal only - manager for action
  73016. * @hidden
  73017. */
  73018. _actionManager: ActionManager;
  73019. /**
  73020. * Creates a new PredicateCondition
  73021. * @param actionManager manager for the action the condition applies to
  73022. * @param predicate defines the predicate function used to validate the condition
  73023. */
  73024. constructor(actionManager: ActionManager,
  73025. /** defines the predicate function used to validate the condition */
  73026. predicate: () => boolean);
  73027. /**
  73028. * @returns the validity of the predicate condition
  73029. */
  73030. isValid(): boolean;
  73031. }
  73032. /**
  73033. * Defines a state condition as an extension of Condition
  73034. */
  73035. export class StateCondition extends Condition {
  73036. /** Value to compare with target state */
  73037. value: string;
  73038. /**
  73039. * Internal only - manager for action
  73040. * @hidden
  73041. */
  73042. _actionManager: ActionManager;
  73043. /**
  73044. * Internal only
  73045. * @hidden
  73046. */
  73047. private _target;
  73048. /**
  73049. * Creates a new StateCondition
  73050. * @param actionManager manager for the action the condition applies to
  73051. * @param target of the condition
  73052. * @param value to compare with target state
  73053. */
  73054. constructor(actionManager: ActionManager, target: any,
  73055. /** Value to compare with target state */
  73056. value: string);
  73057. /**
  73058. * Gets a boolean indicating if the current condition is met
  73059. * @returns the validity of the state
  73060. */
  73061. isValid(): boolean;
  73062. /**
  73063. * Serialize the StateCondition into a JSON compatible object
  73064. * @returns serialization object
  73065. */
  73066. serialize(): any;
  73067. }
  73068. }
  73069. declare module BABYLON {
  73070. /**
  73071. * This defines an action responsible to toggle a boolean once triggered.
  73072. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73073. */
  73074. export class SwitchBooleanAction extends Action {
  73075. /**
  73076. * The path to the boolean property in the target object
  73077. */
  73078. propertyPath: string;
  73079. private _target;
  73080. private _effectiveTarget;
  73081. private _property;
  73082. /**
  73083. * Instantiate the action
  73084. * @param triggerOptions defines the trigger options
  73085. * @param target defines the object containing the boolean
  73086. * @param propertyPath defines the path to the boolean property in the target object
  73087. * @param condition defines the trigger related conditions
  73088. */
  73089. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  73090. /** @hidden */
  73091. _prepare(): void;
  73092. /**
  73093. * Execute the action toggle the boolean value.
  73094. */
  73095. execute(): void;
  73096. /**
  73097. * Serializes the actions and its related information.
  73098. * @param parent defines the object to serialize in
  73099. * @returns the serialized object
  73100. */
  73101. serialize(parent: any): any;
  73102. }
  73103. /**
  73104. * This defines an action responsible to set a the state field of the target
  73105. * to a desired value once triggered.
  73106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73107. */
  73108. export class SetStateAction extends Action {
  73109. /**
  73110. * The value to store in the state field.
  73111. */
  73112. value: string;
  73113. private _target;
  73114. /**
  73115. * Instantiate the action
  73116. * @param triggerOptions defines the trigger options
  73117. * @param target defines the object containing the state property
  73118. * @param value defines the value to store in the state field
  73119. * @param condition defines the trigger related conditions
  73120. */
  73121. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  73122. /**
  73123. * Execute the action and store the value on the target state property.
  73124. */
  73125. execute(): void;
  73126. /**
  73127. * Serializes the actions and its related information.
  73128. * @param parent defines the object to serialize in
  73129. * @returns the serialized object
  73130. */
  73131. serialize(parent: any): any;
  73132. }
  73133. /**
  73134. * This defines an action responsible to set a property of the target
  73135. * to a desired value once triggered.
  73136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73137. */
  73138. export class SetValueAction extends Action {
  73139. /**
  73140. * The path of the property to set in the target.
  73141. */
  73142. propertyPath: string;
  73143. /**
  73144. * The value to set in the property
  73145. */
  73146. value: any;
  73147. private _target;
  73148. private _effectiveTarget;
  73149. private _property;
  73150. /**
  73151. * Instantiate the action
  73152. * @param triggerOptions defines the trigger options
  73153. * @param target defines the object containing the property
  73154. * @param propertyPath defines the path of the property to set in the target
  73155. * @param value defines the value to set in the property
  73156. * @param condition defines the trigger related conditions
  73157. */
  73158. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73159. /** @hidden */
  73160. _prepare(): void;
  73161. /**
  73162. * Execute the action and set the targetted property to the desired value.
  73163. */
  73164. execute(): void;
  73165. /**
  73166. * Serializes the actions and its related information.
  73167. * @param parent defines the object to serialize in
  73168. * @returns the serialized object
  73169. */
  73170. serialize(parent: any): any;
  73171. }
  73172. /**
  73173. * This defines an action responsible to increment the target value
  73174. * to a desired value once triggered.
  73175. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73176. */
  73177. export class IncrementValueAction extends Action {
  73178. /**
  73179. * The path of the property to increment in the target.
  73180. */
  73181. propertyPath: string;
  73182. /**
  73183. * The value we should increment the property by.
  73184. */
  73185. value: any;
  73186. private _target;
  73187. private _effectiveTarget;
  73188. private _property;
  73189. /**
  73190. * Instantiate the action
  73191. * @param triggerOptions defines the trigger options
  73192. * @param target defines the object containing the property
  73193. * @param propertyPath defines the path of the property to increment in the target
  73194. * @param value defines the value value we should increment the property by
  73195. * @param condition defines the trigger related conditions
  73196. */
  73197. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  73198. /** @hidden */
  73199. _prepare(): void;
  73200. /**
  73201. * Execute the action and increment the target of the value amount.
  73202. */
  73203. execute(): void;
  73204. /**
  73205. * Serializes the actions and its related information.
  73206. * @param parent defines the object to serialize in
  73207. * @returns the serialized object
  73208. */
  73209. serialize(parent: any): any;
  73210. }
  73211. /**
  73212. * This defines an action responsible to start an animation once triggered.
  73213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73214. */
  73215. export class PlayAnimationAction extends Action {
  73216. /**
  73217. * Where the animation should start (animation frame)
  73218. */
  73219. from: number;
  73220. /**
  73221. * Where the animation should stop (animation frame)
  73222. */
  73223. to: number;
  73224. /**
  73225. * Define if the animation should loop or stop after the first play.
  73226. */
  73227. loop?: boolean;
  73228. private _target;
  73229. /**
  73230. * Instantiate the action
  73231. * @param triggerOptions defines the trigger options
  73232. * @param target defines the target animation or animation name
  73233. * @param from defines from where the animation should start (animation frame)
  73234. * @param end defines where the animation should stop (animation frame)
  73235. * @param loop defines if the animation should loop or stop after the first play
  73236. * @param condition defines the trigger related conditions
  73237. */
  73238. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  73239. /** @hidden */
  73240. _prepare(): void;
  73241. /**
  73242. * Execute the action and play the animation.
  73243. */
  73244. execute(): void;
  73245. /**
  73246. * Serializes the actions and its related information.
  73247. * @param parent defines the object to serialize in
  73248. * @returns the serialized object
  73249. */
  73250. serialize(parent: any): any;
  73251. }
  73252. /**
  73253. * This defines an action responsible to stop an animation once triggered.
  73254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73255. */
  73256. export class StopAnimationAction extends Action {
  73257. private _target;
  73258. /**
  73259. * Instantiate the action
  73260. * @param triggerOptions defines the trigger options
  73261. * @param target defines the target animation or animation name
  73262. * @param condition defines the trigger related conditions
  73263. */
  73264. constructor(triggerOptions: any, target: any, condition?: Condition);
  73265. /** @hidden */
  73266. _prepare(): void;
  73267. /**
  73268. * Execute the action and stop the animation.
  73269. */
  73270. execute(): void;
  73271. /**
  73272. * Serializes the actions and its related information.
  73273. * @param parent defines the object to serialize in
  73274. * @returns the serialized object
  73275. */
  73276. serialize(parent: any): any;
  73277. }
  73278. /**
  73279. * This defines an action responsible that does nothing once triggered.
  73280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73281. */
  73282. export class DoNothingAction extends Action {
  73283. /**
  73284. * Instantiate the action
  73285. * @param triggerOptions defines the trigger options
  73286. * @param condition defines the trigger related conditions
  73287. */
  73288. constructor(triggerOptions?: any, condition?: Condition);
  73289. /**
  73290. * Execute the action and do nothing.
  73291. */
  73292. execute(): void;
  73293. /**
  73294. * Serializes the actions and its related information.
  73295. * @param parent defines the object to serialize in
  73296. * @returns the serialized object
  73297. */
  73298. serialize(parent: any): any;
  73299. }
  73300. /**
  73301. * This defines an action responsible to trigger several actions once triggered.
  73302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73303. */
  73304. export class CombineAction extends Action {
  73305. /**
  73306. * The list of aggregated animations to run.
  73307. */
  73308. children: Action[];
  73309. /**
  73310. * Instantiate the action
  73311. * @param triggerOptions defines the trigger options
  73312. * @param children defines the list of aggregated animations to run
  73313. * @param condition defines the trigger related conditions
  73314. */
  73315. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  73316. /** @hidden */
  73317. _prepare(): void;
  73318. /**
  73319. * Execute the action and executes all the aggregated actions.
  73320. */
  73321. execute(evt: ActionEvent): void;
  73322. /**
  73323. * Serializes the actions and its related information.
  73324. * @param parent defines the object to serialize in
  73325. * @returns the serialized object
  73326. */
  73327. serialize(parent: any): any;
  73328. }
  73329. /**
  73330. * This defines an action responsible to run code (external event) once triggered.
  73331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73332. */
  73333. export class ExecuteCodeAction extends Action {
  73334. /**
  73335. * The callback function to run.
  73336. */
  73337. func: (evt: ActionEvent) => void;
  73338. /**
  73339. * Instantiate the action
  73340. * @param triggerOptions defines the trigger options
  73341. * @param func defines the callback function to run
  73342. * @param condition defines the trigger related conditions
  73343. */
  73344. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  73345. /**
  73346. * Execute the action and run the attached code.
  73347. */
  73348. execute(evt: ActionEvent): void;
  73349. }
  73350. /**
  73351. * This defines an action responsible to set the parent property of the target once triggered.
  73352. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73353. */
  73354. export class SetParentAction extends Action {
  73355. private _parent;
  73356. private _target;
  73357. /**
  73358. * Instantiate the action
  73359. * @param triggerOptions defines the trigger options
  73360. * @param target defines the target containing the parent property
  73361. * @param parent defines from where the animation should start (animation frame)
  73362. * @param condition defines the trigger related conditions
  73363. */
  73364. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  73365. /** @hidden */
  73366. _prepare(): void;
  73367. /**
  73368. * Execute the action and set the parent property.
  73369. */
  73370. execute(): void;
  73371. /**
  73372. * Serializes the actions and its related information.
  73373. * @param parent defines the object to serialize in
  73374. * @returns the serialized object
  73375. */
  73376. serialize(parent: any): any;
  73377. }
  73378. }
  73379. declare module BABYLON {
  73380. /**
  73381. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  73382. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  73383. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  73384. */
  73385. export class ActionManager extends AbstractActionManager {
  73386. /**
  73387. * Nothing
  73388. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73389. */
  73390. static readonly NothingTrigger: number;
  73391. /**
  73392. * On pick
  73393. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73394. */
  73395. static readonly OnPickTrigger: number;
  73396. /**
  73397. * On left pick
  73398. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73399. */
  73400. static readonly OnLeftPickTrigger: number;
  73401. /**
  73402. * On right pick
  73403. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73404. */
  73405. static readonly OnRightPickTrigger: number;
  73406. /**
  73407. * On center pick
  73408. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73409. */
  73410. static readonly OnCenterPickTrigger: number;
  73411. /**
  73412. * On pick down
  73413. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73414. */
  73415. static readonly OnPickDownTrigger: number;
  73416. /**
  73417. * On double pick
  73418. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73419. */
  73420. static readonly OnDoublePickTrigger: number;
  73421. /**
  73422. * On pick up
  73423. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73424. */
  73425. static readonly OnPickUpTrigger: number;
  73426. /**
  73427. * On pick out.
  73428. * This trigger will only be raised if you also declared a OnPickDown
  73429. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73430. */
  73431. static readonly OnPickOutTrigger: number;
  73432. /**
  73433. * On long press
  73434. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73435. */
  73436. static readonly OnLongPressTrigger: number;
  73437. /**
  73438. * On pointer over
  73439. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73440. */
  73441. static readonly OnPointerOverTrigger: number;
  73442. /**
  73443. * On pointer out
  73444. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73445. */
  73446. static readonly OnPointerOutTrigger: number;
  73447. /**
  73448. * On every frame
  73449. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73450. */
  73451. static readonly OnEveryFrameTrigger: number;
  73452. /**
  73453. * On intersection enter
  73454. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73455. */
  73456. static readonly OnIntersectionEnterTrigger: number;
  73457. /**
  73458. * On intersection exit
  73459. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73460. */
  73461. static readonly OnIntersectionExitTrigger: number;
  73462. /**
  73463. * On key down
  73464. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73465. */
  73466. static readonly OnKeyDownTrigger: number;
  73467. /**
  73468. * On key up
  73469. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  73470. */
  73471. static readonly OnKeyUpTrigger: number;
  73472. private _scene;
  73473. /**
  73474. * Creates a new action manager
  73475. * @param scene defines the hosting scene
  73476. */
  73477. constructor(scene: Scene);
  73478. /**
  73479. * Releases all associated resources
  73480. */
  73481. dispose(): void;
  73482. /**
  73483. * Gets hosting scene
  73484. * @returns the hosting scene
  73485. */
  73486. getScene(): Scene;
  73487. /**
  73488. * Does this action manager handles actions of any of the given triggers
  73489. * @param triggers defines the triggers to be tested
  73490. * @return a boolean indicating whether one (or more) of the triggers is handled
  73491. */
  73492. hasSpecificTriggers(triggers: number[]): boolean;
  73493. /**
  73494. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  73495. * speed.
  73496. * @param triggerA defines the trigger to be tested
  73497. * @param triggerB defines the trigger to be tested
  73498. * @return a boolean indicating whether one (or more) of the triggers is handled
  73499. */
  73500. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  73501. /**
  73502. * Does this action manager handles actions of a given trigger
  73503. * @param trigger defines the trigger to be tested
  73504. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  73505. * @return whether the trigger is handled
  73506. */
  73507. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  73508. /**
  73509. * Does this action manager has pointer triggers
  73510. */
  73511. readonly hasPointerTriggers: boolean;
  73512. /**
  73513. * Does this action manager has pick triggers
  73514. */
  73515. readonly hasPickTriggers: boolean;
  73516. /**
  73517. * Registers an action to this action manager
  73518. * @param action defines the action to be registered
  73519. * @return the action amended (prepared) after registration
  73520. */
  73521. registerAction(action: IAction): Nullable<IAction>;
  73522. /**
  73523. * Unregisters an action to this action manager
  73524. * @param action defines the action to be unregistered
  73525. * @return a boolean indicating whether the action has been unregistered
  73526. */
  73527. unregisterAction(action: IAction): Boolean;
  73528. /**
  73529. * Process a specific trigger
  73530. * @param trigger defines the trigger to process
  73531. * @param evt defines the event details to be processed
  73532. */
  73533. processTrigger(trigger: number, evt?: IActionEvent): void;
  73534. /** @hidden */
  73535. _getEffectiveTarget(target: any, propertyPath: string): any;
  73536. /** @hidden */
  73537. _getProperty(propertyPath: string): string;
  73538. /**
  73539. * Serialize this manager to a JSON object
  73540. * @param name defines the property name to store this manager
  73541. * @returns a JSON representation of this manager
  73542. */
  73543. serialize(name: string): any;
  73544. /**
  73545. * Creates a new ActionManager from a JSON data
  73546. * @param parsedActions defines the JSON data to read from
  73547. * @param object defines the hosting mesh
  73548. * @param scene defines the hosting scene
  73549. */
  73550. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  73551. /**
  73552. * Get a trigger name by index
  73553. * @param trigger defines the trigger index
  73554. * @returns a trigger name
  73555. */
  73556. static GetTriggerName(trigger: number): string;
  73557. }
  73558. }
  73559. declare module BABYLON {
  73560. /**
  73561. * Class representing a ray with position and direction
  73562. */
  73563. export class Ray {
  73564. /** origin point */
  73565. origin: Vector3;
  73566. /** direction */
  73567. direction: Vector3;
  73568. /** length of the ray */
  73569. length: number;
  73570. private static readonly TmpVector3;
  73571. private _tmpRay;
  73572. /**
  73573. * Creates a new ray
  73574. * @param origin origin point
  73575. * @param direction direction
  73576. * @param length length of the ray
  73577. */
  73578. constructor(
  73579. /** origin point */
  73580. origin: Vector3,
  73581. /** direction */
  73582. direction: Vector3,
  73583. /** length of the ray */
  73584. length?: number);
  73585. /**
  73586. * Checks if the ray intersects a box
  73587. * @param minimum bound of the box
  73588. * @param maximum bound of the box
  73589. * @param intersectionTreshold extra extend to be added to the box in all direction
  73590. * @returns if the box was hit
  73591. */
  73592. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  73593. /**
  73594. * Checks if the ray intersects a box
  73595. * @param box the bounding box to check
  73596. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  73597. * @returns if the box was hit
  73598. */
  73599. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  73600. /**
  73601. * If the ray hits a sphere
  73602. * @param sphere the bounding sphere to check
  73603. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  73604. * @returns true if it hits the sphere
  73605. */
  73606. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  73607. /**
  73608. * If the ray hits a triange
  73609. * @param vertex0 triangle vertex
  73610. * @param vertex1 triangle vertex
  73611. * @param vertex2 triangle vertex
  73612. * @returns intersection information if hit
  73613. */
  73614. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  73615. /**
  73616. * Checks if ray intersects a plane
  73617. * @param plane the plane to check
  73618. * @returns the distance away it was hit
  73619. */
  73620. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  73621. /**
  73622. * Checks if ray intersects a mesh
  73623. * @param mesh the mesh to check
  73624. * @param fastCheck if only the bounding box should checked
  73625. * @returns picking info of the intersecton
  73626. */
  73627. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  73628. /**
  73629. * Checks if ray intersects a mesh
  73630. * @param meshes the meshes to check
  73631. * @param fastCheck if only the bounding box should checked
  73632. * @param results array to store result in
  73633. * @returns Array of picking infos
  73634. */
  73635. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  73636. private _comparePickingInfo;
  73637. private static smallnum;
  73638. private static rayl;
  73639. /**
  73640. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  73641. * @param sega the first point of the segment to test the intersection against
  73642. * @param segb the second point of the segment to test the intersection against
  73643. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  73644. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  73645. */
  73646. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  73647. /**
  73648. * Update the ray from viewport position
  73649. * @param x position
  73650. * @param y y position
  73651. * @param viewportWidth viewport width
  73652. * @param viewportHeight viewport height
  73653. * @param world world matrix
  73654. * @param view view matrix
  73655. * @param projection projection matrix
  73656. * @returns this ray updated
  73657. */
  73658. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  73659. /**
  73660. * Creates a ray with origin and direction of 0,0,0
  73661. * @returns the new ray
  73662. */
  73663. static Zero(): Ray;
  73664. /**
  73665. * Creates a new ray from screen space and viewport
  73666. * @param x position
  73667. * @param y y position
  73668. * @param viewportWidth viewport width
  73669. * @param viewportHeight viewport height
  73670. * @param world world matrix
  73671. * @param view view matrix
  73672. * @param projection projection matrix
  73673. * @returns new ray
  73674. */
  73675. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  73676. /**
  73677. * 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
  73678. * transformed to the given world matrix.
  73679. * @param origin The origin point
  73680. * @param end The end point
  73681. * @param world a matrix to transform the ray to. Default is the identity matrix.
  73682. * @returns the new ray
  73683. */
  73684. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  73685. /**
  73686. * Transforms a ray by a matrix
  73687. * @param ray ray to transform
  73688. * @param matrix matrix to apply
  73689. * @returns the resulting new ray
  73690. */
  73691. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  73692. /**
  73693. * Transforms a ray by a matrix
  73694. * @param ray ray to transform
  73695. * @param matrix matrix to apply
  73696. * @param result ray to store result in
  73697. */
  73698. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  73699. /**
  73700. * Unproject a ray from screen space to object space
  73701. * @param sourceX defines the screen space x coordinate to use
  73702. * @param sourceY defines the screen space y coordinate to use
  73703. * @param viewportWidth defines the current width of the viewport
  73704. * @param viewportHeight defines the current height of the viewport
  73705. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  73706. * @param view defines the view matrix to use
  73707. * @param projection defines the projection matrix to use
  73708. */
  73709. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  73710. }
  73711. /**
  73712. * Type used to define predicate used to select faces when a mesh intersection is detected
  73713. */
  73714. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  73715. interface Scene {
  73716. /** @hidden */
  73717. _tempPickingRay: Nullable<Ray>;
  73718. /** @hidden */
  73719. _cachedRayForTransform: Ray;
  73720. /** @hidden */
  73721. _pickWithRayInverseMatrix: Matrix;
  73722. /** @hidden */
  73723. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  73724. /** @hidden */
  73725. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  73726. }
  73727. }
  73728. declare module BABYLON {
  73729. /**
  73730. * Groups all the scene component constants in one place to ease maintenance.
  73731. * @hidden
  73732. */
  73733. export class SceneComponentConstants {
  73734. static readonly NAME_EFFECTLAYER: string;
  73735. static readonly NAME_LAYER: string;
  73736. static readonly NAME_LENSFLARESYSTEM: string;
  73737. static readonly NAME_BOUNDINGBOXRENDERER: string;
  73738. static readonly NAME_PARTICLESYSTEM: string;
  73739. static readonly NAME_GAMEPAD: string;
  73740. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  73741. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  73742. static readonly NAME_DEPTHRENDERER: string;
  73743. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  73744. static readonly NAME_SPRITE: string;
  73745. static readonly NAME_OUTLINERENDERER: string;
  73746. static readonly NAME_PROCEDURALTEXTURE: string;
  73747. static readonly NAME_SHADOWGENERATOR: string;
  73748. static readonly NAME_OCTREE: string;
  73749. static readonly NAME_PHYSICSENGINE: string;
  73750. static readonly NAME_AUDIO: string;
  73751. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  73752. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73753. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  73754. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  73755. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  73756. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  73757. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  73758. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  73759. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  73760. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  73761. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  73762. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  73763. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  73764. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  73765. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  73766. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  73767. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  73768. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  73769. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  73770. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  73771. static readonly STEP_AFTERRENDER_AUDIO: number;
  73772. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  73773. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  73774. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  73775. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  73776. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  73777. static readonly STEP_POINTERMOVE_SPRITE: number;
  73778. static readonly STEP_POINTERDOWN_SPRITE: number;
  73779. static readonly STEP_POINTERUP_SPRITE: number;
  73780. }
  73781. /**
  73782. * This represents a scene component.
  73783. *
  73784. * This is used to decouple the dependency the scene is having on the different workloads like
  73785. * layers, post processes...
  73786. */
  73787. export interface ISceneComponent {
  73788. /**
  73789. * The name of the component. Each component must have a unique name.
  73790. */
  73791. name: string;
  73792. /**
  73793. * The scene the component belongs to.
  73794. */
  73795. scene: Scene;
  73796. /**
  73797. * Register the component to one instance of a scene.
  73798. */
  73799. register(): void;
  73800. /**
  73801. * Rebuilds the elements related to this component in case of
  73802. * context lost for instance.
  73803. */
  73804. rebuild(): void;
  73805. /**
  73806. * Disposes the component and the associated ressources.
  73807. */
  73808. dispose(): void;
  73809. }
  73810. /**
  73811. * This represents a SERIALIZABLE scene component.
  73812. *
  73813. * This extends Scene Component to add Serialization methods on top.
  73814. */
  73815. export interface ISceneSerializableComponent extends ISceneComponent {
  73816. /**
  73817. * Adds all the elements from the container to the scene
  73818. * @param container the container holding the elements
  73819. */
  73820. addFromContainer(container: AbstractScene): void;
  73821. /**
  73822. * Removes all the elements in the container from the scene
  73823. * @param container contains the elements to remove
  73824. * @param dispose if the removed element should be disposed (default: false)
  73825. */
  73826. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  73827. /**
  73828. * Serializes the component data to the specified json object
  73829. * @param serializationObject The object to serialize to
  73830. */
  73831. serialize(serializationObject: any): void;
  73832. }
  73833. /**
  73834. * Strong typing of a Mesh related stage step action
  73835. */
  73836. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  73837. /**
  73838. * Strong typing of a Evaluate Sub Mesh related stage step action
  73839. */
  73840. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  73841. /**
  73842. * Strong typing of a Active Mesh related stage step action
  73843. */
  73844. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  73845. /**
  73846. * Strong typing of a Camera related stage step action
  73847. */
  73848. export type CameraStageAction = (camera: Camera) => void;
  73849. /**
  73850. * Strong typing of a Camera Frame buffer related stage step action
  73851. */
  73852. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  73853. /**
  73854. * Strong typing of a Render Target related stage step action
  73855. */
  73856. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  73857. /**
  73858. * Strong typing of a RenderingGroup related stage step action
  73859. */
  73860. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  73861. /**
  73862. * Strong typing of a Mesh Render related stage step action
  73863. */
  73864. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  73865. /**
  73866. * Strong typing of a simple stage step action
  73867. */
  73868. export type SimpleStageAction = () => void;
  73869. /**
  73870. * Strong typing of a render target action.
  73871. */
  73872. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  73873. /**
  73874. * Strong typing of a pointer move action.
  73875. */
  73876. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  73877. /**
  73878. * Strong typing of a pointer up/down action.
  73879. */
  73880. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  73881. /**
  73882. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  73883. * @hidden
  73884. */
  73885. export class Stage<T extends Function> extends Array<{
  73886. index: number;
  73887. component: ISceneComponent;
  73888. action: T;
  73889. }> {
  73890. /**
  73891. * Hide ctor from the rest of the world.
  73892. * @param items The items to add.
  73893. */
  73894. private constructor();
  73895. /**
  73896. * Creates a new Stage.
  73897. * @returns A new instance of a Stage
  73898. */
  73899. static Create<T extends Function>(): Stage<T>;
  73900. /**
  73901. * Registers a step in an ordered way in the targeted stage.
  73902. * @param index Defines the position to register the step in
  73903. * @param component Defines the component attached to the step
  73904. * @param action Defines the action to launch during the step
  73905. */
  73906. registerStep(index: number, component: ISceneComponent, action: T): void;
  73907. /**
  73908. * Clears all the steps from the stage.
  73909. */
  73910. clear(): void;
  73911. }
  73912. }
  73913. declare module BABYLON {
  73914. interface Scene {
  73915. /** @hidden */
  73916. _pointerOverSprite: Nullable<Sprite>;
  73917. /** @hidden */
  73918. _pickedDownSprite: Nullable<Sprite>;
  73919. /** @hidden */
  73920. _tempSpritePickingRay: Nullable<Ray>;
  73921. /**
  73922. * All of the sprite managers added to this scene
  73923. * @see http://doc.babylonjs.com/babylon101/sprites
  73924. */
  73925. spriteManagers: Array<ISpriteManager>;
  73926. /**
  73927. * An event triggered when sprites rendering is about to start
  73928. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  73929. */
  73930. onBeforeSpritesRenderingObservable: Observable<Scene>;
  73931. /**
  73932. * An event triggered when sprites rendering is done
  73933. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  73934. */
  73935. onAfterSpritesRenderingObservable: Observable<Scene>;
  73936. /** @hidden */
  73937. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  73938. /** Launch a ray to try to pick a sprite in the scene
  73939. * @param x position on screen
  73940. * @param y position on screen
  73941. * @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
  73942. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  73943. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  73944. * @returns a PickingInfo
  73945. */
  73946. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  73947. /** Use the given ray to pick a sprite in the scene
  73948. * @param ray The ray (in world space) to use to pick meshes
  73949. * @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
  73950. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  73951. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  73952. * @returns a PickingInfo
  73953. */
  73954. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  73955. /**
  73956. * Force the sprite under the pointer
  73957. * @param sprite defines the sprite to use
  73958. */
  73959. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  73960. /**
  73961. * Gets the sprite under the pointer
  73962. * @returns a Sprite or null if no sprite is under the pointer
  73963. */
  73964. getPointerOverSprite(): Nullable<Sprite>;
  73965. }
  73966. /**
  73967. * Defines the sprite scene component responsible to manage sprites
  73968. * in a given scene.
  73969. */
  73970. export class SpriteSceneComponent implements ISceneComponent {
  73971. /**
  73972. * The component name helpfull to identify the component in the list of scene components.
  73973. */
  73974. readonly name: string;
  73975. /**
  73976. * The scene the component belongs to.
  73977. */
  73978. scene: Scene;
  73979. /** @hidden */
  73980. private _spritePredicate;
  73981. /**
  73982. * Creates a new instance of the component for the given scene
  73983. * @param scene Defines the scene to register the component in
  73984. */
  73985. constructor(scene: Scene);
  73986. /**
  73987. * Registers the component in a given scene
  73988. */
  73989. register(): void;
  73990. /**
  73991. * Rebuilds the elements related to this component in case of
  73992. * context lost for instance.
  73993. */
  73994. rebuild(): void;
  73995. /**
  73996. * Disposes the component and the associated ressources.
  73997. */
  73998. dispose(): void;
  73999. private _pickSpriteButKeepRay;
  74000. private _pointerMove;
  74001. private _pointerDown;
  74002. private _pointerUp;
  74003. }
  74004. }
  74005. declare module BABYLON {
  74006. /** @hidden */
  74007. export var fogFragmentDeclaration: {
  74008. name: string;
  74009. shader: string;
  74010. };
  74011. }
  74012. declare module BABYLON {
  74013. /** @hidden */
  74014. export var fogFragment: {
  74015. name: string;
  74016. shader: string;
  74017. };
  74018. }
  74019. declare module BABYLON {
  74020. /** @hidden */
  74021. export var spritesPixelShader: {
  74022. name: string;
  74023. shader: string;
  74024. };
  74025. }
  74026. declare module BABYLON {
  74027. /** @hidden */
  74028. export var fogVertexDeclaration: {
  74029. name: string;
  74030. shader: string;
  74031. };
  74032. }
  74033. declare module BABYLON {
  74034. /** @hidden */
  74035. export var spritesVertexShader: {
  74036. name: string;
  74037. shader: string;
  74038. };
  74039. }
  74040. declare module BABYLON {
  74041. /**
  74042. * Defines the minimum interface to fullfil in order to be a sprite manager.
  74043. */
  74044. export interface ISpriteManager extends IDisposable {
  74045. /**
  74046. * Restricts the camera to viewing objects with the same layerMask.
  74047. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  74048. */
  74049. layerMask: number;
  74050. /**
  74051. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  74052. */
  74053. isPickable: boolean;
  74054. /**
  74055. * Specifies the rendering group id for this mesh (0 by default)
  74056. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  74057. */
  74058. renderingGroupId: number;
  74059. /**
  74060. * Defines the list of sprites managed by the manager.
  74061. */
  74062. sprites: Array<Sprite>;
  74063. /**
  74064. * Tests the intersection of a sprite with a specific ray.
  74065. * @param ray The ray we are sending to test the collision
  74066. * @param camera The camera space we are sending rays in
  74067. * @param predicate A predicate allowing excluding sprites from the list of object to test
  74068. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  74069. * @returns picking info or null.
  74070. */
  74071. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74072. /**
  74073. * Renders the list of sprites on screen.
  74074. */
  74075. render(): void;
  74076. }
  74077. /**
  74078. * Class used to manage multiple sprites on the same spritesheet
  74079. * @see http://doc.babylonjs.com/babylon101/sprites
  74080. */
  74081. export class SpriteManager implements ISpriteManager {
  74082. /** defines the manager's name */
  74083. name: string;
  74084. /** Gets the list of sprites */
  74085. sprites: Sprite[];
  74086. /** Gets or sets the rendering group id (0 by default) */
  74087. renderingGroupId: number;
  74088. /** Gets or sets camera layer mask */
  74089. layerMask: number;
  74090. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  74091. fogEnabled: boolean;
  74092. /** Gets or sets a boolean indicating if the sprites are pickable */
  74093. isPickable: boolean;
  74094. /** Defines the default width of a cell in the spritesheet */
  74095. cellWidth: number;
  74096. /** Defines the default height of a cell in the spritesheet */
  74097. cellHeight: number;
  74098. /**
  74099. * An event triggered when the manager is disposed.
  74100. */
  74101. onDisposeObservable: Observable<SpriteManager>;
  74102. private _onDisposeObserver;
  74103. /**
  74104. * Callback called when the manager is disposed
  74105. */
  74106. onDispose: () => void;
  74107. private _capacity;
  74108. private _spriteTexture;
  74109. private _epsilon;
  74110. private _scene;
  74111. private _vertexData;
  74112. private _buffer;
  74113. private _vertexBuffers;
  74114. private _indexBuffer;
  74115. private _effectBase;
  74116. private _effectFog;
  74117. /**
  74118. * Gets or sets the spritesheet texture
  74119. */
  74120. texture: Texture;
  74121. /**
  74122. * Creates a new sprite manager
  74123. * @param name defines the manager's name
  74124. * @param imgUrl defines the sprite sheet url
  74125. * @param capacity defines the maximum allowed number of sprites
  74126. * @param cellSize defines the size of a sprite cell
  74127. * @param scene defines the hosting scene
  74128. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  74129. * @param samplingMode defines the smapling mode to use with spritesheet
  74130. */
  74131. constructor(
  74132. /** defines the manager's name */
  74133. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  74134. private _appendSpriteVertex;
  74135. /**
  74136. * Intersects the sprites with a ray
  74137. * @param ray defines the ray to intersect with
  74138. * @param camera defines the current active camera
  74139. * @param predicate defines a predicate used to select candidate sprites
  74140. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  74141. * @returns null if no hit or a PickingInfo
  74142. */
  74143. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  74144. /**
  74145. * Render all child sprites
  74146. */
  74147. render(): void;
  74148. /**
  74149. * Release associated resources
  74150. */
  74151. dispose(): void;
  74152. }
  74153. }
  74154. declare module BABYLON {
  74155. /**
  74156. * Class used to represent a sprite
  74157. * @see http://doc.babylonjs.com/babylon101/sprites
  74158. */
  74159. export class Sprite {
  74160. /** defines the name */
  74161. name: string;
  74162. /** Gets or sets the current world position */
  74163. position: Vector3;
  74164. /** Gets or sets the main color */
  74165. color: Color4;
  74166. /** Gets or sets the width */
  74167. width: number;
  74168. /** Gets or sets the height */
  74169. height: number;
  74170. /** Gets or sets rotation angle */
  74171. angle: number;
  74172. /** Gets or sets the cell index in the sprite sheet */
  74173. cellIndex: number;
  74174. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  74175. invertU: number;
  74176. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  74177. invertV: number;
  74178. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  74179. disposeWhenFinishedAnimating: boolean;
  74180. /** Gets the list of attached animations */
  74181. animations: Animation[];
  74182. /** Gets or sets a boolean indicating if the sprite can be picked */
  74183. isPickable: boolean;
  74184. /**
  74185. * Gets or sets the associated action manager
  74186. */
  74187. actionManager: Nullable<ActionManager>;
  74188. private _animationStarted;
  74189. private _loopAnimation;
  74190. private _fromIndex;
  74191. private _toIndex;
  74192. private _delay;
  74193. private _direction;
  74194. private _manager;
  74195. private _time;
  74196. private _onAnimationEnd;
  74197. /**
  74198. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  74199. */
  74200. isVisible: boolean;
  74201. /**
  74202. * Gets or sets the sprite size
  74203. */
  74204. size: number;
  74205. /**
  74206. * Creates a new Sprite
  74207. * @param name defines the name
  74208. * @param manager defines the manager
  74209. */
  74210. constructor(
  74211. /** defines the name */
  74212. name: string, manager: ISpriteManager);
  74213. /**
  74214. * Starts an animation
  74215. * @param from defines the initial key
  74216. * @param to defines the end key
  74217. * @param loop defines if the animation must loop
  74218. * @param delay defines the start delay (in ms)
  74219. * @param onAnimationEnd defines a callback to call when animation ends
  74220. */
  74221. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  74222. /** Stops current animation (if any) */
  74223. stopAnimation(): void;
  74224. /** @hidden */
  74225. _animate(deltaTime: number): void;
  74226. /** Release associated resources */
  74227. dispose(): void;
  74228. }
  74229. }
  74230. declare module BABYLON {
  74231. /**
  74232. * Information about the result of picking within a scene
  74233. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  74234. */
  74235. export class PickingInfo {
  74236. /** @hidden */
  74237. _pickingUnavailable: boolean;
  74238. /**
  74239. * If the pick collided with an object
  74240. */
  74241. hit: boolean;
  74242. /**
  74243. * Distance away where the pick collided
  74244. */
  74245. distance: number;
  74246. /**
  74247. * The location of pick collision
  74248. */
  74249. pickedPoint: Nullable<Vector3>;
  74250. /**
  74251. * The mesh corresponding the the pick collision
  74252. */
  74253. pickedMesh: Nullable<AbstractMesh>;
  74254. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  74255. bu: number;
  74256. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  74257. bv: number;
  74258. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  74259. faceId: number;
  74260. /** Id of the the submesh that was picked */
  74261. subMeshId: number;
  74262. /** If a sprite was picked, this will be the sprite the pick collided with */
  74263. pickedSprite: Nullable<Sprite>;
  74264. /**
  74265. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  74266. */
  74267. originMesh: Nullable<AbstractMesh>;
  74268. /**
  74269. * The ray that was used to perform the picking.
  74270. */
  74271. ray: Nullable<Ray>;
  74272. /**
  74273. * Gets the normal correspodning to the face the pick collided with
  74274. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  74275. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  74276. * @returns The normal correspodning to the face the pick collided with
  74277. */
  74278. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  74279. /**
  74280. * Gets the texture coordinates of where the pick occured
  74281. * @returns the vector containing the coordnates of the texture
  74282. */
  74283. getTextureCoordinates(): Nullable<Vector2>;
  74284. }
  74285. }
  74286. declare module BABYLON {
  74287. /**
  74288. * Gather the list of pointer event types as constants.
  74289. */
  74290. export class PointerEventTypes {
  74291. /**
  74292. * 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.
  74293. */
  74294. static readonly POINTERDOWN: number;
  74295. /**
  74296. * The pointerup event is fired when a pointer is no longer active.
  74297. */
  74298. static readonly POINTERUP: number;
  74299. /**
  74300. * The pointermove event is fired when a pointer changes coordinates.
  74301. */
  74302. static readonly POINTERMOVE: number;
  74303. /**
  74304. * The pointerwheel event is fired when a mouse wheel has been rotated.
  74305. */
  74306. static readonly POINTERWHEEL: number;
  74307. /**
  74308. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  74309. */
  74310. static readonly POINTERPICK: number;
  74311. /**
  74312. * The pointertap event is fired when a the object has been touched and released without drag.
  74313. */
  74314. static readonly POINTERTAP: number;
  74315. /**
  74316. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  74317. */
  74318. static readonly POINTERDOUBLETAP: number;
  74319. }
  74320. /**
  74321. * Base class of pointer info types.
  74322. */
  74323. export class PointerInfoBase {
  74324. /**
  74325. * Defines the type of event (PointerEventTypes)
  74326. */
  74327. type: number;
  74328. /**
  74329. * Defines the related dom event
  74330. */
  74331. event: PointerEvent | MouseWheelEvent;
  74332. /**
  74333. * Instantiates the base class of pointers info.
  74334. * @param type Defines the type of event (PointerEventTypes)
  74335. * @param event Defines the related dom event
  74336. */
  74337. constructor(
  74338. /**
  74339. * Defines the type of event (PointerEventTypes)
  74340. */
  74341. type: number,
  74342. /**
  74343. * Defines the related dom event
  74344. */
  74345. event: PointerEvent | MouseWheelEvent);
  74346. }
  74347. /**
  74348. * This class is used to store pointer related info for the onPrePointerObservable event.
  74349. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  74350. */
  74351. export class PointerInfoPre extends PointerInfoBase {
  74352. /**
  74353. * Ray from a pointer if availible (eg. 6dof controller)
  74354. */
  74355. ray: Nullable<Ray>;
  74356. /**
  74357. * Defines the local position of the pointer on the canvas.
  74358. */
  74359. localPosition: Vector2;
  74360. /**
  74361. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  74362. */
  74363. skipOnPointerObservable: boolean;
  74364. /**
  74365. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  74366. * @param type Defines the type of event (PointerEventTypes)
  74367. * @param event Defines the related dom event
  74368. * @param localX Defines the local x coordinates of the pointer when the event occured
  74369. * @param localY Defines the local y coordinates of the pointer when the event occured
  74370. */
  74371. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  74372. }
  74373. /**
  74374. * This type contains all the data related to a pointer event in Babylon.js.
  74375. * 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.
  74376. */
  74377. export class PointerInfo extends PointerInfoBase {
  74378. /**
  74379. * Defines the picking info associated to the info (if any)\
  74380. */
  74381. pickInfo: Nullable<PickingInfo>;
  74382. /**
  74383. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  74384. * @param type Defines the type of event (PointerEventTypes)
  74385. * @param event Defines the related dom event
  74386. * @param pickInfo Defines the picking info associated to the info (if any)\
  74387. */
  74388. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  74389. /**
  74390. * Defines the picking info associated to the info (if any)\
  74391. */
  74392. pickInfo: Nullable<PickingInfo>);
  74393. }
  74394. /**
  74395. * Data relating to a touch event on the screen.
  74396. */
  74397. export interface PointerTouch {
  74398. /**
  74399. * X coordinate of touch.
  74400. */
  74401. x: number;
  74402. /**
  74403. * Y coordinate of touch.
  74404. */
  74405. y: number;
  74406. /**
  74407. * Id of touch. Unique for each finger.
  74408. */
  74409. pointerId: number;
  74410. /**
  74411. * Event type passed from DOM.
  74412. */
  74413. type: any;
  74414. }
  74415. }
  74416. declare module BABYLON {
  74417. /**
  74418. * Manage the mouse inputs to control the movement of a free camera.
  74419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74420. */
  74421. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  74422. /**
  74423. * Define if touch is enabled in the mouse input
  74424. */
  74425. touchEnabled: boolean;
  74426. /**
  74427. * Defines the camera the input is attached to.
  74428. */
  74429. camera: FreeCamera;
  74430. /**
  74431. * Defines the buttons associated with the input to handle camera move.
  74432. */
  74433. buttons: number[];
  74434. /**
  74435. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  74436. */
  74437. angularSensibility: number;
  74438. private _pointerInput;
  74439. private _onMouseMove;
  74440. private _observer;
  74441. private previousPosition;
  74442. /**
  74443. * Observable for when a pointer move event occurs containing the move offset
  74444. */
  74445. onPointerMovedObservable: Observable<{
  74446. offsetX: number;
  74447. offsetY: number;
  74448. }>;
  74449. /**
  74450. * @hidden
  74451. * If the camera should be rotated automatically based on pointer movement
  74452. */
  74453. _allowCameraRotation: boolean;
  74454. /**
  74455. * Manage the mouse inputs to control the movement of a free camera.
  74456. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74457. * @param touchEnabled Defines if touch is enabled or not
  74458. */
  74459. constructor(
  74460. /**
  74461. * Define if touch is enabled in the mouse input
  74462. */
  74463. touchEnabled?: boolean);
  74464. /**
  74465. * Attach the input controls to a specific dom element to get the input from.
  74466. * @param element Defines the element the controls should be listened from
  74467. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74468. */
  74469. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74470. /**
  74471. * Called on JS contextmenu event.
  74472. * Override this method to provide functionality.
  74473. */
  74474. protected onContextMenu(evt: PointerEvent): void;
  74475. /**
  74476. * Detach the current controls from the specified dom element.
  74477. * @param element Defines the element to stop listening the inputs from
  74478. */
  74479. detachControl(element: Nullable<HTMLElement>): void;
  74480. /**
  74481. * Gets the class name of the current intput.
  74482. * @returns the class name
  74483. */
  74484. getClassName(): string;
  74485. /**
  74486. * Get the friendly name associated with the input class.
  74487. * @returns the input friendly name
  74488. */
  74489. getSimpleName(): string;
  74490. }
  74491. }
  74492. declare module BABYLON {
  74493. /**
  74494. * Manage the touch inputs to control the movement of a free camera.
  74495. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74496. */
  74497. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  74498. /**
  74499. * Defines the camera the input is attached to.
  74500. */
  74501. camera: FreeCamera;
  74502. /**
  74503. * Defines the touch sensibility for rotation.
  74504. * The higher the faster.
  74505. */
  74506. touchAngularSensibility: number;
  74507. /**
  74508. * Defines the touch sensibility for move.
  74509. * The higher the faster.
  74510. */
  74511. touchMoveSensibility: number;
  74512. private _offsetX;
  74513. private _offsetY;
  74514. private _pointerPressed;
  74515. private _pointerInput;
  74516. private _observer;
  74517. private _onLostFocus;
  74518. /**
  74519. * Attach the input controls to a specific dom element to get the input from.
  74520. * @param element Defines the element the controls should be listened from
  74521. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74522. */
  74523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74524. /**
  74525. * Detach the current controls from the specified dom element.
  74526. * @param element Defines the element to stop listening the inputs from
  74527. */
  74528. detachControl(element: Nullable<HTMLElement>): void;
  74529. /**
  74530. * Update the current camera state depending on the inputs that have been used this frame.
  74531. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  74532. */
  74533. checkInputs(): void;
  74534. /**
  74535. * Gets the class name of the current intput.
  74536. * @returns the class name
  74537. */
  74538. getClassName(): string;
  74539. /**
  74540. * Get the friendly name associated with the input class.
  74541. * @returns the input friendly name
  74542. */
  74543. getSimpleName(): string;
  74544. }
  74545. }
  74546. declare module BABYLON {
  74547. /**
  74548. * Default Inputs manager for the FreeCamera.
  74549. * It groups all the default supported inputs for ease of use.
  74550. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  74551. */
  74552. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  74553. /**
  74554. * @hidden
  74555. */
  74556. _mouseInput: Nullable<FreeCameraMouseInput>;
  74557. /**
  74558. * Instantiates a new FreeCameraInputsManager.
  74559. * @param camera Defines the camera the inputs belong to
  74560. */
  74561. constructor(camera: FreeCamera);
  74562. /**
  74563. * Add keyboard input support to the input manager.
  74564. * @returns the current input manager
  74565. */
  74566. addKeyboard(): FreeCameraInputsManager;
  74567. /**
  74568. * Add mouse input support to the input manager.
  74569. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  74570. * @returns the current input manager
  74571. */
  74572. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  74573. /**
  74574. * Removes the mouse input support from the manager
  74575. * @returns the current input manager
  74576. */
  74577. removeMouse(): FreeCameraInputsManager;
  74578. /**
  74579. * Add touch input support to the input manager.
  74580. * @returns the current input manager
  74581. */
  74582. addTouch(): FreeCameraInputsManager;
  74583. /**
  74584. * Remove all attached input methods from a camera
  74585. */
  74586. clear(): void;
  74587. }
  74588. }
  74589. declare module BABYLON {
  74590. /**
  74591. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  74592. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  74593. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  74594. */
  74595. export class FreeCamera extends TargetCamera {
  74596. /**
  74597. * Define the collision ellipsoid of the camera.
  74598. * This is helpful to simulate a camera body like the player body around the camera
  74599. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  74600. */
  74601. ellipsoid: Vector3;
  74602. /**
  74603. * Define an offset for the position of the ellipsoid around the camera.
  74604. * This can be helpful to determine the center of the body near the gravity center of the body
  74605. * instead of its head.
  74606. */
  74607. ellipsoidOffset: Vector3;
  74608. /**
  74609. * Enable or disable collisions of the camera with the rest of the scene objects.
  74610. */
  74611. checkCollisions: boolean;
  74612. /**
  74613. * Enable or disable gravity on the camera.
  74614. */
  74615. applyGravity: boolean;
  74616. /**
  74617. * Define the input manager associated to the camera.
  74618. */
  74619. inputs: FreeCameraInputsManager;
  74620. /**
  74621. * Gets the input sensibility for a mouse input. (default is 2000.0)
  74622. * Higher values reduce sensitivity.
  74623. */
  74624. /**
  74625. * Sets the input sensibility for a mouse input. (default is 2000.0)
  74626. * Higher values reduce sensitivity.
  74627. */
  74628. angularSensibility: number;
  74629. /**
  74630. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  74631. */
  74632. keysUp: number[];
  74633. /**
  74634. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  74635. */
  74636. keysDown: number[];
  74637. /**
  74638. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  74639. */
  74640. keysLeft: number[];
  74641. /**
  74642. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  74643. */
  74644. keysRight: number[];
  74645. /**
  74646. * Event raised when the camera collide with a mesh in the scene.
  74647. */
  74648. onCollide: (collidedMesh: AbstractMesh) => void;
  74649. private _collider;
  74650. private _needMoveForGravity;
  74651. private _oldPosition;
  74652. private _diffPosition;
  74653. private _newPosition;
  74654. /** @hidden */
  74655. _localDirection: Vector3;
  74656. /** @hidden */
  74657. _transformedDirection: Vector3;
  74658. /**
  74659. * Instantiates a Free Camera.
  74660. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  74661. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  74662. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  74663. * @param name Define the name of the camera in the scene
  74664. * @param position Define the start position of the camera in the scene
  74665. * @param scene Define the scene the camera belongs to
  74666. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  74667. */
  74668. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  74669. /**
  74670. * Attached controls to the current camera.
  74671. * @param element Defines the element the controls should be listened from
  74672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  74673. */
  74674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  74675. /**
  74676. * Detach the current controls from the camera.
  74677. * The camera will stop reacting to inputs.
  74678. * @param element Defines the element to stop listening the inputs from
  74679. */
  74680. detachControl(element: HTMLElement): void;
  74681. private _collisionMask;
  74682. /**
  74683. * Define a collision mask to limit the list of object the camera can collide with
  74684. */
  74685. collisionMask: number;
  74686. /** @hidden */
  74687. _collideWithWorld(displacement: Vector3): void;
  74688. private _onCollisionPositionChange;
  74689. /** @hidden */
  74690. _checkInputs(): void;
  74691. /** @hidden */
  74692. _decideIfNeedsToMove(): boolean;
  74693. /** @hidden */
  74694. _updatePosition(): void;
  74695. /**
  74696. * Destroy the camera and release the current resources hold by it.
  74697. */
  74698. dispose(): void;
  74699. /**
  74700. * Gets the current object class name.
  74701. * @return the class name
  74702. */
  74703. getClassName(): string;
  74704. }
  74705. }
  74706. declare module BABYLON {
  74707. /**
  74708. * Represents a gamepad control stick position
  74709. */
  74710. export class StickValues {
  74711. /**
  74712. * The x component of the control stick
  74713. */
  74714. x: number;
  74715. /**
  74716. * The y component of the control stick
  74717. */
  74718. y: number;
  74719. /**
  74720. * Initializes the gamepad x and y control stick values
  74721. * @param x The x component of the gamepad control stick value
  74722. * @param y The y component of the gamepad control stick value
  74723. */
  74724. constructor(
  74725. /**
  74726. * The x component of the control stick
  74727. */
  74728. x: number,
  74729. /**
  74730. * The y component of the control stick
  74731. */
  74732. y: number);
  74733. }
  74734. /**
  74735. * An interface which manages callbacks for gamepad button changes
  74736. */
  74737. export interface GamepadButtonChanges {
  74738. /**
  74739. * Called when a gamepad has been changed
  74740. */
  74741. changed: boolean;
  74742. /**
  74743. * Called when a gamepad press event has been triggered
  74744. */
  74745. pressChanged: boolean;
  74746. /**
  74747. * Called when a touch event has been triggered
  74748. */
  74749. touchChanged: boolean;
  74750. /**
  74751. * Called when a value has changed
  74752. */
  74753. valueChanged: boolean;
  74754. }
  74755. /**
  74756. * Represents a gamepad
  74757. */
  74758. export class Gamepad {
  74759. /**
  74760. * The id of the gamepad
  74761. */
  74762. id: string;
  74763. /**
  74764. * The index of the gamepad
  74765. */
  74766. index: number;
  74767. /**
  74768. * The browser gamepad
  74769. */
  74770. browserGamepad: any;
  74771. /**
  74772. * Specifies what type of gamepad this represents
  74773. */
  74774. type: number;
  74775. private _leftStick;
  74776. private _rightStick;
  74777. /** @hidden */
  74778. _isConnected: boolean;
  74779. private _leftStickAxisX;
  74780. private _leftStickAxisY;
  74781. private _rightStickAxisX;
  74782. private _rightStickAxisY;
  74783. /**
  74784. * Triggered when the left control stick has been changed
  74785. */
  74786. private _onleftstickchanged;
  74787. /**
  74788. * Triggered when the right control stick has been changed
  74789. */
  74790. private _onrightstickchanged;
  74791. /**
  74792. * Represents a gamepad controller
  74793. */
  74794. static GAMEPAD: number;
  74795. /**
  74796. * Represents a generic controller
  74797. */
  74798. static GENERIC: number;
  74799. /**
  74800. * Represents an XBox controller
  74801. */
  74802. static XBOX: number;
  74803. /**
  74804. * Represents a pose-enabled controller
  74805. */
  74806. static POSE_ENABLED: number;
  74807. /**
  74808. * Specifies whether the left control stick should be Y-inverted
  74809. */
  74810. protected _invertLeftStickY: boolean;
  74811. /**
  74812. * Specifies if the gamepad has been connected
  74813. */
  74814. readonly isConnected: boolean;
  74815. /**
  74816. * Initializes the gamepad
  74817. * @param id The id of the gamepad
  74818. * @param index The index of the gamepad
  74819. * @param browserGamepad The browser gamepad
  74820. * @param leftStickX The x component of the left joystick
  74821. * @param leftStickY The y component of the left joystick
  74822. * @param rightStickX The x component of the right joystick
  74823. * @param rightStickY The y component of the right joystick
  74824. */
  74825. constructor(
  74826. /**
  74827. * The id of the gamepad
  74828. */
  74829. id: string,
  74830. /**
  74831. * The index of the gamepad
  74832. */
  74833. index: number,
  74834. /**
  74835. * The browser gamepad
  74836. */
  74837. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  74838. /**
  74839. * Callback triggered when the left joystick has changed
  74840. * @param callback
  74841. */
  74842. onleftstickchanged(callback: (values: StickValues) => void): void;
  74843. /**
  74844. * Callback triggered when the right joystick has changed
  74845. * @param callback
  74846. */
  74847. onrightstickchanged(callback: (values: StickValues) => void): void;
  74848. /**
  74849. * Gets the left joystick
  74850. */
  74851. /**
  74852. * Sets the left joystick values
  74853. */
  74854. leftStick: StickValues;
  74855. /**
  74856. * Gets the right joystick
  74857. */
  74858. /**
  74859. * Sets the right joystick value
  74860. */
  74861. rightStick: StickValues;
  74862. /**
  74863. * Updates the gamepad joystick positions
  74864. */
  74865. update(): void;
  74866. /**
  74867. * Disposes the gamepad
  74868. */
  74869. dispose(): void;
  74870. }
  74871. /**
  74872. * Represents a generic gamepad
  74873. */
  74874. export class GenericPad extends Gamepad {
  74875. private _buttons;
  74876. private _onbuttondown;
  74877. private _onbuttonup;
  74878. /**
  74879. * Observable triggered when a button has been pressed
  74880. */
  74881. onButtonDownObservable: Observable<number>;
  74882. /**
  74883. * Observable triggered when a button has been released
  74884. */
  74885. onButtonUpObservable: Observable<number>;
  74886. /**
  74887. * Callback triggered when a button has been pressed
  74888. * @param callback Called when a button has been pressed
  74889. */
  74890. onbuttondown(callback: (buttonPressed: number) => void): void;
  74891. /**
  74892. * Callback triggered when a button has been released
  74893. * @param callback Called when a button has been released
  74894. */
  74895. onbuttonup(callback: (buttonReleased: number) => void): void;
  74896. /**
  74897. * Initializes the generic gamepad
  74898. * @param id The id of the generic gamepad
  74899. * @param index The index of the generic gamepad
  74900. * @param browserGamepad The browser gamepad
  74901. */
  74902. constructor(id: string, index: number, browserGamepad: any);
  74903. private _setButtonValue;
  74904. /**
  74905. * Updates the generic gamepad
  74906. */
  74907. update(): void;
  74908. /**
  74909. * Disposes the generic gamepad
  74910. */
  74911. dispose(): void;
  74912. }
  74913. }
  74914. declare module BABYLON {
  74915. /**
  74916. * Defines the types of pose enabled controllers that are supported
  74917. */
  74918. export enum PoseEnabledControllerType {
  74919. /**
  74920. * HTC Vive
  74921. */
  74922. VIVE = 0,
  74923. /**
  74924. * Oculus Rift
  74925. */
  74926. OCULUS = 1,
  74927. /**
  74928. * Windows mixed reality
  74929. */
  74930. WINDOWS = 2,
  74931. /**
  74932. * Samsung gear VR
  74933. */
  74934. GEAR_VR = 3,
  74935. /**
  74936. * Google Daydream
  74937. */
  74938. DAYDREAM = 4,
  74939. /**
  74940. * Generic
  74941. */
  74942. GENERIC = 5
  74943. }
  74944. /**
  74945. * Defines the MutableGamepadButton interface for the state of a gamepad button
  74946. */
  74947. export interface MutableGamepadButton {
  74948. /**
  74949. * Value of the button/trigger
  74950. */
  74951. value: number;
  74952. /**
  74953. * If the button/trigger is currently touched
  74954. */
  74955. touched: boolean;
  74956. /**
  74957. * If the button/trigger is currently pressed
  74958. */
  74959. pressed: boolean;
  74960. }
  74961. /**
  74962. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  74963. * @hidden
  74964. */
  74965. export interface ExtendedGamepadButton extends GamepadButton {
  74966. /**
  74967. * If the button/trigger is currently pressed
  74968. */
  74969. readonly pressed: boolean;
  74970. /**
  74971. * If the button/trigger is currently touched
  74972. */
  74973. readonly touched: boolean;
  74974. /**
  74975. * Value of the button/trigger
  74976. */
  74977. readonly value: number;
  74978. }
  74979. /** @hidden */
  74980. export interface _GamePadFactory {
  74981. /**
  74982. * Returns wether or not the current gamepad can be created for this type of controller.
  74983. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  74984. * @returns true if it can be created, otherwise false
  74985. */
  74986. canCreate(gamepadInfo: any): boolean;
  74987. /**
  74988. * Creates a new instance of the Gamepad.
  74989. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  74990. * @returns the new gamepad instance
  74991. */
  74992. create(gamepadInfo: any): Gamepad;
  74993. }
  74994. /**
  74995. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  74996. */
  74997. export class PoseEnabledControllerHelper {
  74998. /** @hidden */
  74999. static _ControllerFactories: _GamePadFactory[];
  75000. /** @hidden */
  75001. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  75002. /**
  75003. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  75004. * @param vrGamepad the gamepad to initialized
  75005. * @returns a vr controller of the type the gamepad identified as
  75006. */
  75007. static InitiateController(vrGamepad: any): Gamepad;
  75008. }
  75009. /**
  75010. * Defines the PoseEnabledController object that contains state of a vr capable controller
  75011. */
  75012. export class PoseEnabledController extends Gamepad implements PoseControlled {
  75013. private _deviceRoomPosition;
  75014. private _deviceRoomRotationQuaternion;
  75015. /**
  75016. * The device position in babylon space
  75017. */
  75018. devicePosition: Vector3;
  75019. /**
  75020. * The device rotation in babylon space
  75021. */
  75022. deviceRotationQuaternion: Quaternion;
  75023. /**
  75024. * The scale factor of the device in babylon space
  75025. */
  75026. deviceScaleFactor: number;
  75027. /**
  75028. * (Likely devicePosition should be used instead) The device position in its room space
  75029. */
  75030. position: Vector3;
  75031. /**
  75032. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  75033. */
  75034. rotationQuaternion: Quaternion;
  75035. /**
  75036. * The type of controller (Eg. Windows mixed reality)
  75037. */
  75038. controllerType: PoseEnabledControllerType;
  75039. protected _calculatedPosition: Vector3;
  75040. private _calculatedRotation;
  75041. /**
  75042. * The raw pose from the device
  75043. */
  75044. rawPose: DevicePose;
  75045. private _trackPosition;
  75046. private _maxRotationDistFromHeadset;
  75047. private _draggedRoomRotation;
  75048. /**
  75049. * @hidden
  75050. */
  75051. _disableTrackPosition(fixedPosition: Vector3): void;
  75052. /**
  75053. * Internal, the mesh attached to the controller
  75054. * @hidden
  75055. */
  75056. _mesh: Nullable<AbstractMesh>;
  75057. private _poseControlledCamera;
  75058. private _leftHandSystemQuaternion;
  75059. /**
  75060. * Internal, matrix used to convert room space to babylon space
  75061. * @hidden
  75062. */
  75063. _deviceToWorld: Matrix;
  75064. /**
  75065. * Node to be used when casting a ray from the controller
  75066. * @hidden
  75067. */
  75068. _pointingPoseNode: Nullable<TransformNode>;
  75069. /**
  75070. * Name of the child mesh that can be used to cast a ray from the controller
  75071. */
  75072. static readonly POINTING_POSE: string;
  75073. /**
  75074. * Creates a new PoseEnabledController from a gamepad
  75075. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  75076. */
  75077. constructor(browserGamepad: any);
  75078. private _workingMatrix;
  75079. /**
  75080. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  75081. */
  75082. update(): void;
  75083. /**
  75084. * Updates only the pose device and mesh without doing any button event checking
  75085. */
  75086. protected _updatePoseAndMesh(): void;
  75087. /**
  75088. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  75089. * @param poseData raw pose fromthe device
  75090. */
  75091. updateFromDevice(poseData: DevicePose): void;
  75092. /**
  75093. * @hidden
  75094. */
  75095. _meshAttachedObservable: Observable<AbstractMesh>;
  75096. /**
  75097. * Attaches a mesh to the controller
  75098. * @param mesh the mesh to be attached
  75099. */
  75100. attachToMesh(mesh: AbstractMesh): void;
  75101. /**
  75102. * Attaches the controllers mesh to a camera
  75103. * @param camera the camera the mesh should be attached to
  75104. */
  75105. attachToPoseControlledCamera(camera: TargetCamera): void;
  75106. /**
  75107. * Disposes of the controller
  75108. */
  75109. dispose(): void;
  75110. /**
  75111. * The mesh that is attached to the controller
  75112. */
  75113. readonly mesh: Nullable<AbstractMesh>;
  75114. /**
  75115. * Gets the ray of the controller in the direction the controller is pointing
  75116. * @param length the length the resulting ray should be
  75117. * @returns a ray in the direction the controller is pointing
  75118. */
  75119. getForwardRay(length?: number): Ray;
  75120. }
  75121. }
  75122. declare module BABYLON {
  75123. /**
  75124. * Defines the WebVRController object that represents controllers tracked in 3D space
  75125. */
  75126. export abstract class WebVRController extends PoseEnabledController {
  75127. /**
  75128. * Internal, the default controller model for the controller
  75129. */
  75130. protected _defaultModel: AbstractMesh;
  75131. /**
  75132. * Fired when the trigger state has changed
  75133. */
  75134. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  75135. /**
  75136. * Fired when the main button state has changed
  75137. */
  75138. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75139. /**
  75140. * Fired when the secondary button state has changed
  75141. */
  75142. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  75143. /**
  75144. * Fired when the pad state has changed
  75145. */
  75146. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  75147. /**
  75148. * Fired when controllers stick values have changed
  75149. */
  75150. onPadValuesChangedObservable: Observable<StickValues>;
  75151. /**
  75152. * Array of button availible on the controller
  75153. */
  75154. protected _buttons: Array<MutableGamepadButton>;
  75155. private _onButtonStateChange;
  75156. /**
  75157. * Fired when a controller button's state has changed
  75158. * @param callback the callback containing the button that was modified
  75159. */
  75160. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  75161. /**
  75162. * X and Y axis corrisponding to the controllers joystick
  75163. */
  75164. pad: StickValues;
  75165. /**
  75166. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  75167. */
  75168. hand: string;
  75169. /**
  75170. * The default controller model for the controller
  75171. */
  75172. readonly defaultModel: AbstractMesh;
  75173. /**
  75174. * Creates a new WebVRController from a gamepad
  75175. * @param vrGamepad the gamepad that the WebVRController should be created from
  75176. */
  75177. constructor(vrGamepad: any);
  75178. /**
  75179. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  75180. */
  75181. update(): void;
  75182. /**
  75183. * Function to be called when a button is modified
  75184. */
  75185. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  75186. /**
  75187. * Loads a mesh and attaches it to the controller
  75188. * @param scene the scene the mesh should be added to
  75189. * @param meshLoaded callback for when the mesh has been loaded
  75190. */
  75191. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  75192. private _setButtonValue;
  75193. private _changes;
  75194. private _checkChanges;
  75195. /**
  75196. * Disposes of th webVRCOntroller
  75197. */
  75198. dispose(): void;
  75199. }
  75200. }
  75201. declare module BABYLON {
  75202. /**
  75203. * The HemisphericLight simulates the ambient environment light,
  75204. * so the passed direction is the light reflection direction, not the incoming direction.
  75205. */
  75206. export class HemisphericLight extends Light {
  75207. /**
  75208. * The groundColor is the light in the opposite direction to the one specified during creation.
  75209. * 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.
  75210. */
  75211. groundColor: Color3;
  75212. /**
  75213. * The light reflection direction, not the incoming direction.
  75214. */
  75215. direction: Vector3;
  75216. /**
  75217. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  75218. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  75219. * The HemisphericLight can't cast shadows.
  75220. * Documentation : https://doc.babylonjs.com/babylon101/lights
  75221. * @param name The friendly name of the light
  75222. * @param direction The direction of the light reflection
  75223. * @param scene The scene the light belongs to
  75224. */
  75225. constructor(name: string, direction: Vector3, scene: Scene);
  75226. protected _buildUniformLayout(): void;
  75227. /**
  75228. * Returns the string "HemisphericLight".
  75229. * @return The class name
  75230. */
  75231. getClassName(): string;
  75232. /**
  75233. * Sets the HemisphericLight direction towards the passed target (Vector3).
  75234. * Returns the updated direction.
  75235. * @param target The target the direction should point to
  75236. * @return The computed direction
  75237. */
  75238. setDirectionToTarget(target: Vector3): Vector3;
  75239. /**
  75240. * Returns the shadow generator associated to the light.
  75241. * @returns Always null for hemispheric lights because it does not support shadows.
  75242. */
  75243. getShadowGenerator(): Nullable<IShadowGenerator>;
  75244. /**
  75245. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  75246. * @param effect The effect to update
  75247. * @param lightIndex The index of the light in the effect to update
  75248. * @returns The hemispheric light
  75249. */
  75250. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  75251. /**
  75252. * Computes the world matrix of the node
  75253. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75254. * @param useWasUpdatedFlag defines a reserved property
  75255. * @returns the world matrix
  75256. */
  75257. computeWorldMatrix(): Matrix;
  75258. /**
  75259. * Returns the integer 3.
  75260. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  75261. */
  75262. getTypeID(): number;
  75263. /**
  75264. * Prepares the list of defines specific to the light type.
  75265. * @param defines the list of defines
  75266. * @param lightIndex defines the index of the light for the effect
  75267. */
  75268. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  75269. }
  75270. }
  75271. declare module BABYLON {
  75272. /** @hidden */
  75273. export var vrMultiviewToSingleviewPixelShader: {
  75274. name: string;
  75275. shader: string;
  75276. };
  75277. }
  75278. declare module BABYLON {
  75279. /**
  75280. * Renders to multiple views with a single draw call
  75281. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  75282. */
  75283. export class MultiviewRenderTarget extends RenderTargetTexture {
  75284. /**
  75285. * Creates a multiview render target
  75286. * @param scene scene used with the render target
  75287. * @param size the size of the render target (used for each view)
  75288. */
  75289. constructor(scene: Scene, size?: number | {
  75290. width: number;
  75291. height: number;
  75292. } | {
  75293. ratio: number;
  75294. });
  75295. /**
  75296. * @hidden
  75297. * @param faceIndex the face index, if its a cube texture
  75298. */
  75299. _bindFrameBuffer(faceIndex?: number): void;
  75300. /**
  75301. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  75302. * @returns the view count
  75303. */
  75304. getViewCount(): number;
  75305. }
  75306. }
  75307. declare module BABYLON {
  75308. interface Engine {
  75309. /**
  75310. * Creates a new multiview render target
  75311. * @param width defines the width of the texture
  75312. * @param height defines the height of the texture
  75313. * @returns the created multiview texture
  75314. */
  75315. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  75316. /**
  75317. * Binds a multiview framebuffer to be drawn to
  75318. * @param multiviewTexture texture to bind
  75319. */
  75320. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  75321. }
  75322. interface Camera {
  75323. /**
  75324. * @hidden
  75325. * 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)
  75326. */
  75327. _useMultiviewToSingleView: boolean;
  75328. /**
  75329. * @hidden
  75330. * 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)
  75331. */
  75332. _multiviewTexture: Nullable<RenderTargetTexture>;
  75333. /**
  75334. * @hidden
  75335. * ensures the multiview texture of the camera exists and has the specified width/height
  75336. * @param width height to set on the multiview texture
  75337. * @param height width to set on the multiview texture
  75338. */
  75339. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  75340. }
  75341. interface Scene {
  75342. /** @hidden */
  75343. _transformMatrixR: Matrix;
  75344. /** @hidden */
  75345. _multiviewSceneUbo: Nullable<UniformBuffer>;
  75346. /** @hidden */
  75347. _createMultiviewUbo(): void;
  75348. /** @hidden */
  75349. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  75350. /** @hidden */
  75351. _renderMultiviewToSingleView(camera: Camera): void;
  75352. }
  75353. }
  75354. declare module BABYLON {
  75355. /**
  75356. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  75357. * This will not be used for webXR as it supports displaying texture arrays directly
  75358. */
  75359. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  75360. /**
  75361. * Initializes a VRMultiviewToSingleview
  75362. * @param name name of the post process
  75363. * @param camera camera to be applied to
  75364. * @param scaleFactor scaling factor to the size of the output texture
  75365. */
  75366. constructor(name: string, camera: Camera, scaleFactor: number);
  75367. }
  75368. }
  75369. declare module BABYLON {
  75370. /**
  75371. * Defines the interface used by display changed events
  75372. */
  75373. interface IDisplayChangedEventArgs {
  75374. /** Gets the vrDisplay object (if any) */
  75375. vrDisplay: Nullable<any>;
  75376. /** Gets a boolean indicating if webVR is supported */
  75377. vrSupported: boolean;
  75378. }
  75379. interface Engine {
  75380. /** @hidden */
  75381. _vrDisplay: any;
  75382. /** @hidden */
  75383. _vrSupported: boolean;
  75384. /** @hidden */
  75385. _oldSize: Size;
  75386. /** @hidden */
  75387. _oldHardwareScaleFactor: number;
  75388. /** @hidden */
  75389. _vrExclusivePointerMode: boolean;
  75390. /** @hidden */
  75391. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  75392. /** @hidden */
  75393. _onVRDisplayPointerRestricted: () => void;
  75394. /** @hidden */
  75395. _onVRDisplayPointerUnrestricted: () => void;
  75396. /** @hidden */
  75397. _onVrDisplayConnect: Nullable<(display: any) => void>;
  75398. /** @hidden */
  75399. _onVrDisplayDisconnect: Nullable<() => void>;
  75400. /** @hidden */
  75401. _onVrDisplayPresentChange: Nullable<() => void>;
  75402. /**
  75403. * Observable signaled when VR display mode changes
  75404. */
  75405. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  75406. /**
  75407. * Observable signaled when VR request present is complete
  75408. */
  75409. onVRRequestPresentComplete: Observable<boolean>;
  75410. /**
  75411. * Observable signaled when VR request present starts
  75412. */
  75413. onVRRequestPresentStart: Observable<Engine>;
  75414. /**
  75415. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  75416. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  75417. */
  75418. isInVRExclusivePointerMode: boolean;
  75419. /**
  75420. * Gets a boolean indicating if a webVR device was detected
  75421. * @returns true if a webVR device was detected
  75422. */
  75423. isVRDevicePresent(): boolean;
  75424. /**
  75425. * Gets the current webVR device
  75426. * @returns the current webVR device (or null)
  75427. */
  75428. getVRDevice(): any;
  75429. /**
  75430. * Initializes a webVR display and starts listening to display change events
  75431. * The onVRDisplayChangedObservable will be notified upon these changes
  75432. * @returns A promise containing a VRDisplay and if vr is supported
  75433. */
  75434. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  75435. /** @hidden */
  75436. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  75437. /**
  75438. * Call this function to switch to webVR mode
  75439. * Will do nothing if webVR is not supported or if there is no webVR device
  75440. * @see http://doc.babylonjs.com/how_to/webvr_camera
  75441. */
  75442. enableVR(): void;
  75443. /** @hidden */
  75444. _onVRFullScreenTriggered(): void;
  75445. }
  75446. }
  75447. declare module BABYLON {
  75448. /**
  75449. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  75450. * IMPORTANT!! The data is right-hand data.
  75451. * @export
  75452. * @interface DevicePose
  75453. */
  75454. export interface DevicePose {
  75455. /**
  75456. * The position of the device, values in array are [x,y,z].
  75457. */
  75458. readonly position: Nullable<Float32Array>;
  75459. /**
  75460. * The linearVelocity of the device, values in array are [x,y,z].
  75461. */
  75462. readonly linearVelocity: Nullable<Float32Array>;
  75463. /**
  75464. * The linearAcceleration of the device, values in array are [x,y,z].
  75465. */
  75466. readonly linearAcceleration: Nullable<Float32Array>;
  75467. /**
  75468. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  75469. */
  75470. readonly orientation: Nullable<Float32Array>;
  75471. /**
  75472. * The angularVelocity of the device, values in array are [x,y,z].
  75473. */
  75474. readonly angularVelocity: Nullable<Float32Array>;
  75475. /**
  75476. * The angularAcceleration of the device, values in array are [x,y,z].
  75477. */
  75478. readonly angularAcceleration: Nullable<Float32Array>;
  75479. }
  75480. /**
  75481. * Interface representing a pose controlled object in Babylon.
  75482. * A pose controlled object has both regular pose values as well as pose values
  75483. * from an external device such as a VR head mounted display
  75484. */
  75485. export interface PoseControlled {
  75486. /**
  75487. * The position of the object in babylon space.
  75488. */
  75489. position: Vector3;
  75490. /**
  75491. * The rotation quaternion of the object in babylon space.
  75492. */
  75493. rotationQuaternion: Quaternion;
  75494. /**
  75495. * The position of the device in babylon space.
  75496. */
  75497. devicePosition?: Vector3;
  75498. /**
  75499. * The rotation quaternion of the device in babylon space.
  75500. */
  75501. deviceRotationQuaternion: Quaternion;
  75502. /**
  75503. * The raw pose coming from the device.
  75504. */
  75505. rawPose: Nullable<DevicePose>;
  75506. /**
  75507. * The scale of the device to be used when translating from device space to babylon space.
  75508. */
  75509. deviceScaleFactor: number;
  75510. /**
  75511. * Updates the poseControlled values based on the input device pose.
  75512. * @param poseData the pose data to update the object with
  75513. */
  75514. updateFromDevice(poseData: DevicePose): void;
  75515. }
  75516. /**
  75517. * Set of options to customize the webVRCamera
  75518. */
  75519. export interface WebVROptions {
  75520. /**
  75521. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  75522. */
  75523. trackPosition?: boolean;
  75524. /**
  75525. * Sets the scale of the vrDevice in babylon space. (default: 1)
  75526. */
  75527. positionScale?: number;
  75528. /**
  75529. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  75530. */
  75531. displayName?: string;
  75532. /**
  75533. * Should the native controller meshes be initialized. (default: true)
  75534. */
  75535. controllerMeshes?: boolean;
  75536. /**
  75537. * Creating a default HemiLight only on controllers. (default: true)
  75538. */
  75539. defaultLightingOnControllers?: boolean;
  75540. /**
  75541. * If you don't want to use the default VR button of the helper. (default: false)
  75542. */
  75543. useCustomVRButton?: boolean;
  75544. /**
  75545. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  75546. */
  75547. customVRButton?: HTMLButtonElement;
  75548. /**
  75549. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  75550. */
  75551. rayLength?: number;
  75552. /**
  75553. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  75554. */
  75555. defaultHeight?: number;
  75556. /**
  75557. * If multiview should be used if availible (default: false)
  75558. */
  75559. useMultiview?: boolean;
  75560. }
  75561. /**
  75562. * This represents a WebVR camera.
  75563. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  75564. * @example http://doc.babylonjs.com/how_to/webvr_camera
  75565. */
  75566. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  75567. private webVROptions;
  75568. /**
  75569. * @hidden
  75570. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  75571. */
  75572. _vrDevice: any;
  75573. /**
  75574. * The rawPose of the vrDevice.
  75575. */
  75576. rawPose: Nullable<DevicePose>;
  75577. private _onVREnabled;
  75578. private _specsVersion;
  75579. private _attached;
  75580. private _frameData;
  75581. protected _descendants: Array<Node>;
  75582. private _deviceRoomPosition;
  75583. /** @hidden */
  75584. _deviceRoomRotationQuaternion: Quaternion;
  75585. private _standingMatrix;
  75586. /**
  75587. * Represents device position in babylon space.
  75588. */
  75589. devicePosition: Vector3;
  75590. /**
  75591. * Represents device rotation in babylon space.
  75592. */
  75593. deviceRotationQuaternion: Quaternion;
  75594. /**
  75595. * The scale of the device to be used when translating from device space to babylon space.
  75596. */
  75597. deviceScaleFactor: number;
  75598. private _deviceToWorld;
  75599. private _worldToDevice;
  75600. /**
  75601. * References to the webVR controllers for the vrDevice.
  75602. */
  75603. controllers: Array<WebVRController>;
  75604. /**
  75605. * Emits an event when a controller is attached.
  75606. */
  75607. onControllersAttachedObservable: Observable<WebVRController[]>;
  75608. /**
  75609. * Emits an event when a controller's mesh has been loaded;
  75610. */
  75611. onControllerMeshLoadedObservable: Observable<WebVRController>;
  75612. /**
  75613. * Emits an event when the HMD's pose has been updated.
  75614. */
  75615. onPoseUpdatedFromDeviceObservable: Observable<any>;
  75616. private _poseSet;
  75617. /**
  75618. * If the rig cameras be used as parent instead of this camera.
  75619. */
  75620. rigParenting: boolean;
  75621. private _lightOnControllers;
  75622. private _defaultHeight?;
  75623. /**
  75624. * Instantiates a WebVRFreeCamera.
  75625. * @param name The name of the WebVRFreeCamera
  75626. * @param position The starting anchor position for the camera
  75627. * @param scene The scene the camera belongs to
  75628. * @param webVROptions a set of customizable options for the webVRCamera
  75629. */
  75630. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  75631. /**
  75632. * Gets the device distance from the ground in meters.
  75633. * @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.
  75634. */
  75635. deviceDistanceToRoomGround(): number;
  75636. /**
  75637. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  75638. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  75639. */
  75640. useStandingMatrix(callback?: (bool: boolean) => void): void;
  75641. /**
  75642. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  75643. * @returns A promise with a boolean set to if the standing matrix is supported.
  75644. */
  75645. useStandingMatrixAsync(): Promise<boolean>;
  75646. /**
  75647. * Disposes the camera
  75648. */
  75649. dispose(): void;
  75650. /**
  75651. * Gets a vrController by name.
  75652. * @param name The name of the controller to retreive
  75653. * @returns the controller matching the name specified or null if not found
  75654. */
  75655. getControllerByName(name: string): Nullable<WebVRController>;
  75656. private _leftController;
  75657. /**
  75658. * The controller corrisponding to the users left hand.
  75659. */
  75660. readonly leftController: Nullable<WebVRController>;
  75661. private _rightController;
  75662. /**
  75663. * The controller corrisponding to the users right hand.
  75664. */
  75665. readonly rightController: Nullable<WebVRController>;
  75666. /**
  75667. * Casts a ray forward from the vrCamera's gaze.
  75668. * @param length Length of the ray (default: 100)
  75669. * @returns the ray corrisponding to the gaze
  75670. */
  75671. getForwardRay(length?: number): Ray;
  75672. /**
  75673. * @hidden
  75674. * Updates the camera based on device's frame data
  75675. */
  75676. _checkInputs(): void;
  75677. /**
  75678. * Updates the poseControlled values based on the input device pose.
  75679. * @param poseData Pose coming from the device
  75680. */
  75681. updateFromDevice(poseData: DevicePose): void;
  75682. private _htmlElementAttached;
  75683. private _detachIfAttached;
  75684. /**
  75685. * WebVR's attach control will start broadcasting frames to the device.
  75686. * Note that in certain browsers (chrome for example) this function must be called
  75687. * within a user-interaction callback. Example:
  75688. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  75689. *
  75690. * @param element html element to attach the vrDevice to
  75691. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  75692. */
  75693. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75694. /**
  75695. * Detaches the camera from the html element and disables VR
  75696. *
  75697. * @param element html element to detach from
  75698. */
  75699. detachControl(element: HTMLElement): void;
  75700. /**
  75701. * @returns the name of this class
  75702. */
  75703. getClassName(): string;
  75704. /**
  75705. * Calls resetPose on the vrDisplay
  75706. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  75707. */
  75708. resetToCurrentRotation(): void;
  75709. /**
  75710. * @hidden
  75711. * Updates the rig cameras (left and right eye)
  75712. */
  75713. _updateRigCameras(): void;
  75714. private _workingVector;
  75715. private _oneVector;
  75716. private _workingMatrix;
  75717. private updateCacheCalled;
  75718. private _correctPositionIfNotTrackPosition;
  75719. /**
  75720. * @hidden
  75721. * Updates the cached values of the camera
  75722. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  75723. */
  75724. _updateCache(ignoreParentClass?: boolean): void;
  75725. /**
  75726. * @hidden
  75727. * Get current device position in babylon world
  75728. */
  75729. _computeDevicePosition(): void;
  75730. /**
  75731. * Updates the current device position and rotation in the babylon world
  75732. */
  75733. update(): void;
  75734. /**
  75735. * @hidden
  75736. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  75737. * @returns an identity matrix
  75738. */
  75739. _getViewMatrix(): Matrix;
  75740. private _tmpMatrix;
  75741. /**
  75742. * This function is called by the two RIG cameras.
  75743. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  75744. * @hidden
  75745. */
  75746. _getWebVRViewMatrix(): Matrix;
  75747. /** @hidden */
  75748. _getWebVRProjectionMatrix(): Matrix;
  75749. private _onGamepadConnectedObserver;
  75750. private _onGamepadDisconnectedObserver;
  75751. private _updateCacheWhenTrackingDisabledObserver;
  75752. /**
  75753. * Initializes the controllers and their meshes
  75754. */
  75755. initControllers(): void;
  75756. }
  75757. }
  75758. declare module BABYLON {
  75759. /**
  75760. * Size options for a post process
  75761. */
  75762. export type PostProcessOptions = {
  75763. width: number;
  75764. height: number;
  75765. };
  75766. /**
  75767. * PostProcess can be used to apply a shader to a texture after it has been rendered
  75768. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  75769. */
  75770. export class PostProcess {
  75771. /** Name of the PostProcess. */
  75772. name: string;
  75773. /**
  75774. * Gets or sets the unique id of the post process
  75775. */
  75776. uniqueId: number;
  75777. /**
  75778. * Width of the texture to apply the post process on
  75779. */
  75780. width: number;
  75781. /**
  75782. * Height of the texture to apply the post process on
  75783. */
  75784. height: number;
  75785. /**
  75786. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  75787. * @hidden
  75788. */
  75789. _outputTexture: Nullable<InternalTexture>;
  75790. /**
  75791. * Sampling mode used by the shader
  75792. * See https://doc.babylonjs.com/classes/3.1/texture
  75793. */
  75794. renderTargetSamplingMode: number;
  75795. /**
  75796. * Clear color to use when screen clearing
  75797. */
  75798. clearColor: Color4;
  75799. /**
  75800. * If the buffer needs to be cleared before applying the post process. (default: true)
  75801. * Should be set to false if shader will overwrite all previous pixels.
  75802. */
  75803. autoClear: boolean;
  75804. /**
  75805. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  75806. */
  75807. alphaMode: number;
  75808. /**
  75809. * Sets the setAlphaBlendConstants of the babylon engine
  75810. */
  75811. alphaConstants: Color4;
  75812. /**
  75813. * Animations to be used for the post processing
  75814. */
  75815. animations: Animation[];
  75816. /**
  75817. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  75818. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  75819. */
  75820. enablePixelPerfectMode: boolean;
  75821. /**
  75822. * Force the postprocess to be applied without taking in account viewport
  75823. */
  75824. forceFullscreenViewport: boolean;
  75825. /**
  75826. * List of inspectable custom properties (used by the Inspector)
  75827. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  75828. */
  75829. inspectableCustomProperties: IInspectable[];
  75830. /**
  75831. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  75832. *
  75833. * | Value | Type | Description |
  75834. * | ----- | ----------------------------------- | ----------- |
  75835. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  75836. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  75837. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  75838. *
  75839. */
  75840. scaleMode: number;
  75841. /**
  75842. * Force textures to be a power of two (default: false)
  75843. */
  75844. alwaysForcePOT: boolean;
  75845. private _samples;
  75846. /**
  75847. * Number of sample textures (default: 1)
  75848. */
  75849. samples: number;
  75850. /**
  75851. * Modify the scale of the post process to be the same as the viewport (default: false)
  75852. */
  75853. adaptScaleToCurrentViewport: boolean;
  75854. private _camera;
  75855. private _scene;
  75856. private _engine;
  75857. private _options;
  75858. private _reusable;
  75859. private _textureType;
  75860. /**
  75861. * Smart array of input and output textures for the post process.
  75862. * @hidden
  75863. */
  75864. _textures: SmartArray<InternalTexture>;
  75865. /**
  75866. * The index in _textures that corresponds to the output texture.
  75867. * @hidden
  75868. */
  75869. _currentRenderTextureInd: number;
  75870. private _effect;
  75871. private _samplers;
  75872. private _fragmentUrl;
  75873. private _vertexUrl;
  75874. private _parameters;
  75875. private _scaleRatio;
  75876. protected _indexParameters: any;
  75877. private _shareOutputWithPostProcess;
  75878. private _texelSize;
  75879. private _forcedOutputTexture;
  75880. /**
  75881. * Returns the fragment url or shader name used in the post process.
  75882. * @returns the fragment url or name in the shader store.
  75883. */
  75884. getEffectName(): string;
  75885. /**
  75886. * An event triggered when the postprocess is activated.
  75887. */
  75888. onActivateObservable: Observable<Camera>;
  75889. private _onActivateObserver;
  75890. /**
  75891. * A function that is added to the onActivateObservable
  75892. */
  75893. onActivate: Nullable<(camera: Camera) => void>;
  75894. /**
  75895. * An event triggered when the postprocess changes its size.
  75896. */
  75897. onSizeChangedObservable: Observable<PostProcess>;
  75898. private _onSizeChangedObserver;
  75899. /**
  75900. * A function that is added to the onSizeChangedObservable
  75901. */
  75902. onSizeChanged: (postProcess: PostProcess) => void;
  75903. /**
  75904. * An event triggered when the postprocess applies its effect.
  75905. */
  75906. onApplyObservable: Observable<Effect>;
  75907. private _onApplyObserver;
  75908. /**
  75909. * A function that is added to the onApplyObservable
  75910. */
  75911. onApply: (effect: Effect) => void;
  75912. /**
  75913. * An event triggered before rendering the postprocess
  75914. */
  75915. onBeforeRenderObservable: Observable<Effect>;
  75916. private _onBeforeRenderObserver;
  75917. /**
  75918. * A function that is added to the onBeforeRenderObservable
  75919. */
  75920. onBeforeRender: (effect: Effect) => void;
  75921. /**
  75922. * An event triggered after rendering the postprocess
  75923. */
  75924. onAfterRenderObservable: Observable<Effect>;
  75925. private _onAfterRenderObserver;
  75926. /**
  75927. * A function that is added to the onAfterRenderObservable
  75928. */
  75929. onAfterRender: (efect: Effect) => void;
  75930. /**
  75931. * 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
  75932. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  75933. */
  75934. inputTexture: InternalTexture;
  75935. /**
  75936. * Gets the camera which post process is applied to.
  75937. * @returns The camera the post process is applied to.
  75938. */
  75939. getCamera(): Camera;
  75940. /**
  75941. * Gets the texel size of the postprocess.
  75942. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  75943. */
  75944. readonly texelSize: Vector2;
  75945. /**
  75946. * Creates a new instance PostProcess
  75947. * @param name The name of the PostProcess.
  75948. * @param fragmentUrl The url of the fragment shader to be used.
  75949. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  75950. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  75951. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  75952. * @param camera The camera to apply the render pass to.
  75953. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75954. * @param engine The engine which the post process will be applied. (default: current engine)
  75955. * @param reusable If the post process can be reused on the same frame. (default: false)
  75956. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  75957. * @param textureType Type of textures used when performing the post process. (default: 0)
  75958. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  75959. * @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
  75960. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  75961. */
  75962. constructor(
  75963. /** Name of the PostProcess. */
  75964. 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);
  75965. /**
  75966. * Gets a string idenfifying the name of the class
  75967. * @returns "PostProcess" string
  75968. */
  75969. getClassName(): string;
  75970. /**
  75971. * Gets the engine which this post process belongs to.
  75972. * @returns The engine the post process was enabled with.
  75973. */
  75974. getEngine(): Engine;
  75975. /**
  75976. * The effect that is created when initializing the post process.
  75977. * @returns The created effect corrisponding the the postprocess.
  75978. */
  75979. getEffect(): Effect;
  75980. /**
  75981. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  75982. * @param postProcess The post process to share the output with.
  75983. * @returns This post process.
  75984. */
  75985. shareOutputWith(postProcess: PostProcess): PostProcess;
  75986. /**
  75987. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  75988. * This should be called if the post process that shares output with this post process is disabled/disposed.
  75989. */
  75990. useOwnOutput(): void;
  75991. /**
  75992. * Updates the effect with the current post process compile time values and recompiles the shader.
  75993. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  75994. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  75995. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  75996. * @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
  75997. * @param onCompiled Called when the shader has been compiled.
  75998. * @param onError Called if there is an error when compiling a shader.
  75999. */
  76000. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  76001. /**
  76002. * The post process is reusable if it can be used multiple times within one frame.
  76003. * @returns If the post process is reusable
  76004. */
  76005. isReusable(): boolean;
  76006. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  76007. markTextureDirty(): void;
  76008. /**
  76009. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  76010. * 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.
  76011. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  76012. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  76013. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  76014. * @returns The target texture that was bound to be written to.
  76015. */
  76016. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  76017. /**
  76018. * If the post process is supported.
  76019. */
  76020. readonly isSupported: boolean;
  76021. /**
  76022. * The aspect ratio of the output texture.
  76023. */
  76024. readonly aspectRatio: number;
  76025. /**
  76026. * Get a value indicating if the post-process is ready to be used
  76027. * @returns true if the post-process is ready (shader is compiled)
  76028. */
  76029. isReady(): boolean;
  76030. /**
  76031. * Binds all textures and uniforms to the shader, this will be run on every pass.
  76032. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  76033. */
  76034. apply(): Nullable<Effect>;
  76035. private _disposeTextures;
  76036. /**
  76037. * Disposes the post process.
  76038. * @param camera The camera to dispose the post process on.
  76039. */
  76040. dispose(camera?: Camera): void;
  76041. }
  76042. }
  76043. declare module BABYLON {
  76044. /**
  76045. * PostProcessManager is used to manage one or more post processes or post process pipelines
  76046. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  76047. */
  76048. export class PostProcessManager {
  76049. private _scene;
  76050. private _indexBuffer;
  76051. private _vertexBuffers;
  76052. /**
  76053. * Creates a new instance PostProcess
  76054. * @param scene The scene that the post process is associated with.
  76055. */
  76056. constructor(scene: Scene);
  76057. private _prepareBuffers;
  76058. private _buildIndexBuffer;
  76059. /**
  76060. * Rebuilds the vertex buffers of the manager.
  76061. * @hidden
  76062. */
  76063. _rebuild(): void;
  76064. /**
  76065. * Prepares a frame to be run through a post process.
  76066. * @param sourceTexture The input texture to the post procesess. (default: null)
  76067. * @param postProcesses An array of post processes to be run. (default: null)
  76068. * @returns True if the post processes were able to be run.
  76069. * @hidden
  76070. */
  76071. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  76072. /**
  76073. * Manually render a set of post processes to a texture.
  76074. * @param postProcesses An array of post processes to be run.
  76075. * @param targetTexture The target texture to render to.
  76076. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  76077. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  76078. * @param lodLevel defines which lod of the texture to render to
  76079. */
  76080. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  76081. /**
  76082. * Finalize the result of the output of the postprocesses.
  76083. * @param doNotPresent If true the result will not be displayed to the screen.
  76084. * @param targetTexture The target texture to render to.
  76085. * @param faceIndex The index of the face to bind the target texture to.
  76086. * @param postProcesses The array of post processes to render.
  76087. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  76088. * @hidden
  76089. */
  76090. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  76091. /**
  76092. * Disposes of the post process manager.
  76093. */
  76094. dispose(): void;
  76095. }
  76096. }
  76097. declare module BABYLON {
  76098. interface AbstractScene {
  76099. /**
  76100. * The list of procedural textures added to the scene
  76101. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76102. */
  76103. proceduralTextures: Array<ProceduralTexture>;
  76104. }
  76105. /**
  76106. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  76107. * in a given scene.
  76108. */
  76109. export class ProceduralTextureSceneComponent implements ISceneComponent {
  76110. /**
  76111. * The component name helpfull to identify the component in the list of scene components.
  76112. */
  76113. readonly name: string;
  76114. /**
  76115. * The scene the component belongs to.
  76116. */
  76117. scene: Scene;
  76118. /**
  76119. * Creates a new instance of the component for the given scene
  76120. * @param scene Defines the scene to register the component in
  76121. */
  76122. constructor(scene: Scene);
  76123. /**
  76124. * Registers the component in a given scene
  76125. */
  76126. register(): void;
  76127. /**
  76128. * Rebuilds the elements related to this component in case of
  76129. * context lost for instance.
  76130. */
  76131. rebuild(): void;
  76132. /**
  76133. * Disposes the component and the associated ressources.
  76134. */
  76135. dispose(): void;
  76136. private _beforeClear;
  76137. }
  76138. }
  76139. declare module BABYLON {
  76140. interface Engine {
  76141. /**
  76142. * Creates a new render target cube texture
  76143. * @param size defines the size of the texture
  76144. * @param options defines the options used to create the texture
  76145. * @returns a new render target cube texture stored in an InternalTexture
  76146. */
  76147. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  76148. }
  76149. }
  76150. declare module BABYLON {
  76151. /** @hidden */
  76152. export var proceduralVertexShader: {
  76153. name: string;
  76154. shader: string;
  76155. };
  76156. }
  76157. declare module BABYLON {
  76158. /**
  76159. * 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.
  76160. * This is the base class of any Procedural texture and contains most of the shareable code.
  76161. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76162. */
  76163. export class ProceduralTexture extends Texture {
  76164. isCube: boolean;
  76165. /**
  76166. * Define if the texture is enabled or not (disabled texture will not render)
  76167. */
  76168. isEnabled: boolean;
  76169. /**
  76170. * Define if the texture must be cleared before rendering (default is true)
  76171. */
  76172. autoClear: boolean;
  76173. /**
  76174. * Callback called when the texture is generated
  76175. */
  76176. onGenerated: () => void;
  76177. /**
  76178. * Event raised when the texture is generated
  76179. */
  76180. onGeneratedObservable: Observable<ProceduralTexture>;
  76181. /** @hidden */
  76182. _generateMipMaps: boolean;
  76183. /** @hidden **/
  76184. _effect: Effect;
  76185. /** @hidden */
  76186. _textures: {
  76187. [key: string]: Texture;
  76188. };
  76189. private _size;
  76190. private _currentRefreshId;
  76191. private _refreshRate;
  76192. private _vertexBuffers;
  76193. private _indexBuffer;
  76194. private _uniforms;
  76195. private _samplers;
  76196. private _fragment;
  76197. private _floats;
  76198. private _ints;
  76199. private _floatsArrays;
  76200. private _colors3;
  76201. private _colors4;
  76202. private _vectors2;
  76203. private _vectors3;
  76204. private _matrices;
  76205. private _fallbackTexture;
  76206. private _fallbackTextureUsed;
  76207. private _engine;
  76208. private _cachedDefines;
  76209. private _contentUpdateId;
  76210. private _contentData;
  76211. /**
  76212. * Instantiates a new procedural texture.
  76213. * 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.
  76214. * This is the base class of any Procedural texture and contains most of the shareable code.
  76215. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  76216. * @param name Define the name of the texture
  76217. * @param size Define the size of the texture to create
  76218. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  76219. * @param scene Define the scene the texture belongs to
  76220. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  76221. * @param generateMipMaps Define if the texture should creates mip maps or not
  76222. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  76223. */
  76224. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  76225. /**
  76226. * The effect that is created when initializing the post process.
  76227. * @returns The created effect corrisponding the the postprocess.
  76228. */
  76229. getEffect(): Effect;
  76230. /**
  76231. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  76232. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  76233. */
  76234. getContent(): Nullable<ArrayBufferView>;
  76235. private _createIndexBuffer;
  76236. /** @hidden */
  76237. _rebuild(): void;
  76238. /**
  76239. * Resets the texture in order to recreate its associated resources.
  76240. * This can be called in case of context loss
  76241. */
  76242. reset(): void;
  76243. protected _getDefines(): string;
  76244. /**
  76245. * Is the texture ready to be used ? (rendered at least once)
  76246. * @returns true if ready, otherwise, false.
  76247. */
  76248. isReady(): boolean;
  76249. /**
  76250. * Resets the refresh counter of the texture and start bak from scratch.
  76251. * Could be useful to regenerate the texture if it is setup to render only once.
  76252. */
  76253. resetRefreshCounter(): void;
  76254. /**
  76255. * Set the fragment shader to use in order to render the texture.
  76256. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  76257. */
  76258. setFragment(fragment: any): void;
  76259. /**
  76260. * Define the refresh rate of the texture or the rendering frequency.
  76261. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  76262. */
  76263. refreshRate: number;
  76264. /** @hidden */
  76265. _shouldRender(): boolean;
  76266. /**
  76267. * Get the size the texture is rendering at.
  76268. * @returns the size (texture is always squared)
  76269. */
  76270. getRenderSize(): number;
  76271. /**
  76272. * Resize the texture to new value.
  76273. * @param size Define the new size the texture should have
  76274. * @param generateMipMaps Define whether the new texture should create mip maps
  76275. */
  76276. resize(size: number, generateMipMaps: boolean): void;
  76277. private _checkUniform;
  76278. /**
  76279. * Set a texture in the shader program used to render.
  76280. * @param name Define the name of the uniform samplers as defined in the shader
  76281. * @param texture Define the texture to bind to this sampler
  76282. * @return the texture itself allowing "fluent" like uniform updates
  76283. */
  76284. setTexture(name: string, texture: Texture): ProceduralTexture;
  76285. /**
  76286. * Set a float in the shader.
  76287. * @param name Define the name of the uniform as defined in the shader
  76288. * @param value Define the value to give to the uniform
  76289. * @return the texture itself allowing "fluent" like uniform updates
  76290. */
  76291. setFloat(name: string, value: number): ProceduralTexture;
  76292. /**
  76293. * Set a int in the shader.
  76294. * @param name Define the name of the uniform as defined in the shader
  76295. * @param value Define the value to give to the uniform
  76296. * @return the texture itself allowing "fluent" like uniform updates
  76297. */
  76298. setInt(name: string, value: number): ProceduralTexture;
  76299. /**
  76300. * Set an array of floats in the shader.
  76301. * @param name Define the name of the uniform as defined in the shader
  76302. * @param value Define the value to give to the uniform
  76303. * @return the texture itself allowing "fluent" like uniform updates
  76304. */
  76305. setFloats(name: string, value: number[]): ProceduralTexture;
  76306. /**
  76307. * Set a vec3 in the shader from a Color3.
  76308. * @param name Define the name of the uniform as defined in the shader
  76309. * @param value Define the value to give to the uniform
  76310. * @return the texture itself allowing "fluent" like uniform updates
  76311. */
  76312. setColor3(name: string, value: Color3): ProceduralTexture;
  76313. /**
  76314. * Set a vec4 in the shader from a Color4.
  76315. * @param name Define the name of the uniform as defined in the shader
  76316. * @param value Define the value to give to the uniform
  76317. * @return the texture itself allowing "fluent" like uniform updates
  76318. */
  76319. setColor4(name: string, value: Color4): ProceduralTexture;
  76320. /**
  76321. * Set a vec2 in the shader from a Vector2.
  76322. * @param name Define the name of the uniform as defined in the shader
  76323. * @param value Define the value to give to the uniform
  76324. * @return the texture itself allowing "fluent" like uniform updates
  76325. */
  76326. setVector2(name: string, value: Vector2): ProceduralTexture;
  76327. /**
  76328. * Set a vec3 in the shader from a Vector3.
  76329. * @param name Define the name of the uniform as defined in the shader
  76330. * @param value Define the value to give to the uniform
  76331. * @return the texture itself allowing "fluent" like uniform updates
  76332. */
  76333. setVector3(name: string, value: Vector3): ProceduralTexture;
  76334. /**
  76335. * Set a mat4 in the shader from a MAtrix.
  76336. * @param name Define the name of the uniform as defined in the shader
  76337. * @param value Define the value to give to the uniform
  76338. * @return the texture itself allowing "fluent" like uniform updates
  76339. */
  76340. setMatrix(name: string, value: Matrix): ProceduralTexture;
  76341. /**
  76342. * Render the texture to its associated render target.
  76343. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  76344. */
  76345. render(useCameraPostProcess?: boolean): void;
  76346. /**
  76347. * Clone the texture.
  76348. * @returns the cloned texture
  76349. */
  76350. clone(): ProceduralTexture;
  76351. /**
  76352. * Dispose the texture and release its asoociated resources.
  76353. */
  76354. dispose(): void;
  76355. }
  76356. }
  76357. declare module BABYLON {
  76358. /**
  76359. * This represents the base class for particle system in Babylon.
  76360. * 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.
  76361. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  76362. * @example https://doc.babylonjs.com/babylon101/particles
  76363. */
  76364. export class BaseParticleSystem {
  76365. /**
  76366. * Source color is added to the destination color without alpha affecting the result
  76367. */
  76368. static BLENDMODE_ONEONE: number;
  76369. /**
  76370. * Blend current color and particle color using particle’s alpha
  76371. */
  76372. static BLENDMODE_STANDARD: number;
  76373. /**
  76374. * Add current color and particle color multiplied by particle’s alpha
  76375. */
  76376. static BLENDMODE_ADD: number;
  76377. /**
  76378. * Multiply current color with particle color
  76379. */
  76380. static BLENDMODE_MULTIPLY: number;
  76381. /**
  76382. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  76383. */
  76384. static BLENDMODE_MULTIPLYADD: number;
  76385. /**
  76386. * List of animations used by the particle system.
  76387. */
  76388. animations: Animation[];
  76389. /**
  76390. * The id of the Particle system.
  76391. */
  76392. id: string;
  76393. /**
  76394. * The friendly name of the Particle system.
  76395. */
  76396. name: string;
  76397. /**
  76398. * The rendering group used by the Particle system to chose when to render.
  76399. */
  76400. renderingGroupId: number;
  76401. /**
  76402. * The emitter represents the Mesh or position we are attaching the particle system to.
  76403. */
  76404. emitter: Nullable<AbstractMesh | Vector3>;
  76405. /**
  76406. * The maximum number of particles to emit per frame
  76407. */
  76408. emitRate: number;
  76409. /**
  76410. * If you want to launch only a few particles at once, that can be done, as well.
  76411. */
  76412. manualEmitCount: number;
  76413. /**
  76414. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  76415. */
  76416. updateSpeed: number;
  76417. /**
  76418. * The amount of time the particle system is running (depends of the overall update speed).
  76419. */
  76420. targetStopDuration: number;
  76421. /**
  76422. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  76423. */
  76424. disposeOnStop: boolean;
  76425. /**
  76426. * Minimum power of emitting particles.
  76427. */
  76428. minEmitPower: number;
  76429. /**
  76430. * Maximum power of emitting particles.
  76431. */
  76432. maxEmitPower: number;
  76433. /**
  76434. * Minimum life time of emitting particles.
  76435. */
  76436. minLifeTime: number;
  76437. /**
  76438. * Maximum life time of emitting particles.
  76439. */
  76440. maxLifeTime: number;
  76441. /**
  76442. * Minimum Size of emitting particles.
  76443. */
  76444. minSize: number;
  76445. /**
  76446. * Maximum Size of emitting particles.
  76447. */
  76448. maxSize: number;
  76449. /**
  76450. * Minimum scale of emitting particles on X axis.
  76451. */
  76452. minScaleX: number;
  76453. /**
  76454. * Maximum scale of emitting particles on X axis.
  76455. */
  76456. maxScaleX: number;
  76457. /**
  76458. * Minimum scale of emitting particles on Y axis.
  76459. */
  76460. minScaleY: number;
  76461. /**
  76462. * Maximum scale of emitting particles on Y axis.
  76463. */
  76464. maxScaleY: number;
  76465. /**
  76466. * Gets or sets the minimal initial rotation in radians.
  76467. */
  76468. minInitialRotation: number;
  76469. /**
  76470. * Gets or sets the maximal initial rotation in radians.
  76471. */
  76472. maxInitialRotation: number;
  76473. /**
  76474. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  76475. */
  76476. minAngularSpeed: number;
  76477. /**
  76478. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  76479. */
  76480. maxAngularSpeed: number;
  76481. /**
  76482. * The texture used to render each particle. (this can be a spritesheet)
  76483. */
  76484. particleTexture: Nullable<Texture>;
  76485. /**
  76486. * The layer mask we are rendering the particles through.
  76487. */
  76488. layerMask: number;
  76489. /**
  76490. * This can help using your own shader to render the particle system.
  76491. * The according effect will be created
  76492. */
  76493. customShader: any;
  76494. /**
  76495. * By default particle system starts as soon as they are created. This prevents the
  76496. * automatic start to happen and let you decide when to start emitting particles.
  76497. */
  76498. preventAutoStart: boolean;
  76499. private _noiseTexture;
  76500. /**
  76501. * Gets or sets a texture used to add random noise to particle positions
  76502. */
  76503. noiseTexture: Nullable<ProceduralTexture>;
  76504. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  76505. noiseStrength: Vector3;
  76506. /**
  76507. * Callback triggered when the particle animation is ending.
  76508. */
  76509. onAnimationEnd: Nullable<() => void>;
  76510. /**
  76511. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  76512. */
  76513. blendMode: number;
  76514. /**
  76515. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  76516. * to override the particles.
  76517. */
  76518. forceDepthWrite: boolean;
  76519. /** 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 */
  76520. preWarmCycles: number;
  76521. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  76522. preWarmStepOffset: number;
  76523. /**
  76524. * 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)
  76525. */
  76526. spriteCellChangeSpeed: number;
  76527. /**
  76528. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  76529. */
  76530. startSpriteCellID: number;
  76531. /**
  76532. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  76533. */
  76534. endSpriteCellID: number;
  76535. /**
  76536. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  76537. */
  76538. spriteCellWidth: number;
  76539. /**
  76540. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  76541. */
  76542. spriteCellHeight: number;
  76543. /**
  76544. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  76545. */
  76546. spriteRandomStartCell: boolean;
  76547. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  76548. translationPivot: Vector2;
  76549. /** @hidden */
  76550. protected _isAnimationSheetEnabled: boolean;
  76551. /**
  76552. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  76553. */
  76554. beginAnimationOnStart: boolean;
  76555. /**
  76556. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  76557. */
  76558. beginAnimationFrom: number;
  76559. /**
  76560. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  76561. */
  76562. beginAnimationTo: number;
  76563. /**
  76564. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  76565. */
  76566. beginAnimationLoop: boolean;
  76567. /**
  76568. * Gets or sets a world offset applied to all particles
  76569. */
  76570. worldOffset: Vector3;
  76571. /**
  76572. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  76573. */
  76574. isAnimationSheetEnabled: boolean;
  76575. /**
  76576. * Get hosting scene
  76577. * @returns the scene
  76578. */
  76579. getScene(): Scene;
  76580. /**
  76581. * You can use gravity if you want to give an orientation to your particles.
  76582. */
  76583. gravity: Vector3;
  76584. protected _colorGradients: Nullable<Array<ColorGradient>>;
  76585. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  76586. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  76587. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  76588. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  76589. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  76590. protected _dragGradients: Nullable<Array<FactorGradient>>;
  76591. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  76592. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  76593. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  76594. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  76595. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  76596. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  76597. /**
  76598. * Defines the delay in milliseconds before starting the system (0 by default)
  76599. */
  76600. startDelay: number;
  76601. /**
  76602. * Gets the current list of drag gradients.
  76603. * You must use addDragGradient and removeDragGradient to udpate this list
  76604. * @returns the list of drag gradients
  76605. */
  76606. getDragGradients(): Nullable<Array<FactorGradient>>;
  76607. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  76608. limitVelocityDamping: number;
  76609. /**
  76610. * Gets the current list of limit velocity gradients.
  76611. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  76612. * @returns the list of limit velocity gradients
  76613. */
  76614. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  76615. /**
  76616. * Gets the current list of color gradients.
  76617. * You must use addColorGradient and removeColorGradient to udpate this list
  76618. * @returns the list of color gradients
  76619. */
  76620. getColorGradients(): Nullable<Array<ColorGradient>>;
  76621. /**
  76622. * Gets the current list of size gradients.
  76623. * You must use addSizeGradient and removeSizeGradient to udpate this list
  76624. * @returns the list of size gradients
  76625. */
  76626. getSizeGradients(): Nullable<Array<FactorGradient>>;
  76627. /**
  76628. * Gets the current list of color remap gradients.
  76629. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  76630. * @returns the list of color remap gradients
  76631. */
  76632. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  76633. /**
  76634. * Gets the current list of alpha remap gradients.
  76635. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  76636. * @returns the list of alpha remap gradients
  76637. */
  76638. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  76639. /**
  76640. * Gets the current list of life time gradients.
  76641. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  76642. * @returns the list of life time gradients
  76643. */
  76644. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  76645. /**
  76646. * Gets the current list of angular speed gradients.
  76647. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  76648. * @returns the list of angular speed gradients
  76649. */
  76650. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  76651. /**
  76652. * Gets the current list of velocity gradients.
  76653. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  76654. * @returns the list of velocity gradients
  76655. */
  76656. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  76657. /**
  76658. * Gets the current list of start size gradients.
  76659. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  76660. * @returns the list of start size gradients
  76661. */
  76662. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  76663. /**
  76664. * Gets the current list of emit rate gradients.
  76665. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  76666. * @returns the list of emit rate gradients
  76667. */
  76668. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  76669. /**
  76670. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  76671. * This only works when particleEmitterTyps is a BoxParticleEmitter
  76672. */
  76673. direction1: Vector3;
  76674. /**
  76675. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  76676. * This only works when particleEmitterTyps is a BoxParticleEmitter
  76677. */
  76678. direction2: Vector3;
  76679. /**
  76680. * 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.
  76681. * This only works when particleEmitterTyps is a BoxParticleEmitter
  76682. */
  76683. minEmitBox: Vector3;
  76684. /**
  76685. * 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.
  76686. * This only works when particleEmitterTyps is a BoxParticleEmitter
  76687. */
  76688. maxEmitBox: Vector3;
  76689. /**
  76690. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  76691. */
  76692. color1: Color4;
  76693. /**
  76694. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  76695. */
  76696. color2: Color4;
  76697. /**
  76698. * Color the particle will have at the end of its lifetime
  76699. */
  76700. colorDead: Color4;
  76701. /**
  76702. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  76703. */
  76704. textureMask: Color4;
  76705. /**
  76706. * The particle emitter type defines the emitter used by the particle system.
  76707. * It can be for example box, sphere, or cone...
  76708. */
  76709. particleEmitterType: IParticleEmitterType;
  76710. /** @hidden */
  76711. _isSubEmitter: boolean;
  76712. /**
  76713. * Gets or sets the billboard mode to use when isBillboardBased = true.
  76714. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  76715. */
  76716. billboardMode: number;
  76717. protected _isBillboardBased: boolean;
  76718. /**
  76719. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  76720. */
  76721. isBillboardBased: boolean;
  76722. /**
  76723. * The scene the particle system belongs to.
  76724. */
  76725. protected _scene: Scene;
  76726. /**
  76727. * Local cache of defines for image processing.
  76728. */
  76729. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  76730. /**
  76731. * Default configuration related to image processing available in the standard Material.
  76732. */
  76733. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  76734. /**
  76735. * Gets the image processing configuration used either in this material.
  76736. */
  76737. /**
  76738. * Sets the Default image processing configuration used either in the this material.
  76739. *
  76740. * If sets to null, the scene one is in use.
  76741. */
  76742. imageProcessingConfiguration: ImageProcessingConfiguration;
  76743. /**
  76744. * Attaches a new image processing configuration to the Standard Material.
  76745. * @param configuration
  76746. */
  76747. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  76748. /** @hidden */
  76749. protected _reset(): void;
  76750. /** @hidden */
  76751. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  76752. /**
  76753. * Instantiates a particle system.
  76754. * 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.
  76755. * @param name The name of the particle system
  76756. */
  76757. constructor(name: string);
  76758. /**
  76759. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  76760. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76761. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76762. * @returns the emitter
  76763. */
  76764. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  76765. /**
  76766. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  76767. * @param radius The radius of the hemisphere to emit from
  76768. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76769. * @returns the emitter
  76770. */
  76771. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  76772. /**
  76773. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  76774. * @param radius The radius of the sphere to emit from
  76775. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  76776. * @returns the emitter
  76777. */
  76778. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  76779. /**
  76780. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  76781. * @param radius The radius of the sphere to emit from
  76782. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  76783. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  76784. * @returns the emitter
  76785. */
  76786. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  76787. /**
  76788. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  76789. * @param radius The radius of the emission cylinder
  76790. * @param height The height of the emission cylinder
  76791. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  76792. * @param directionRandomizer How much to randomize the particle direction [0-1]
  76793. * @returns the emitter
  76794. */
  76795. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  76796. /**
  76797. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76798. * @param radius The radius of the cylinder to emit from
  76799. * @param height The height of the emission cylinder
  76800. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76801. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76802. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76803. * @returns the emitter
  76804. */
  76805. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  76806. /**
  76807. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76808. * @param radius The radius of the cone to emit from
  76809. * @param angle The base angle of the cone
  76810. * @returns the emitter
  76811. */
  76812. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  76813. /**
  76814. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76815. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76816. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76817. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76818. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76819. * @returns the emitter
  76820. */
  76821. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76822. }
  76823. }
  76824. declare module BABYLON {
  76825. /**
  76826. * Type of sub emitter
  76827. */
  76828. export enum SubEmitterType {
  76829. /**
  76830. * Attached to the particle over it's lifetime
  76831. */
  76832. ATTACHED = 0,
  76833. /**
  76834. * Created when the particle dies
  76835. */
  76836. END = 1
  76837. }
  76838. /**
  76839. * Sub emitter class used to emit particles from an existing particle
  76840. */
  76841. export class SubEmitter {
  76842. /**
  76843. * the particle system to be used by the sub emitter
  76844. */
  76845. particleSystem: ParticleSystem;
  76846. /**
  76847. * Type of the submitter (Default: END)
  76848. */
  76849. type: SubEmitterType;
  76850. /**
  76851. * 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)
  76852. * Note: This only is supported when using an emitter of type Mesh
  76853. */
  76854. inheritDirection: boolean;
  76855. /**
  76856. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  76857. */
  76858. inheritedVelocityAmount: number;
  76859. /**
  76860. * Creates a sub emitter
  76861. * @param particleSystem the particle system to be used by the sub emitter
  76862. */
  76863. constructor(
  76864. /**
  76865. * the particle system to be used by the sub emitter
  76866. */
  76867. particleSystem: ParticleSystem);
  76868. /**
  76869. * Clones the sub emitter
  76870. * @returns the cloned sub emitter
  76871. */
  76872. clone(): SubEmitter;
  76873. /**
  76874. * Serialize current object to a JSON object
  76875. * @returns the serialized object
  76876. */
  76877. serialize(): any;
  76878. /** @hidden */
  76879. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  76880. /**
  76881. * Creates a new SubEmitter from a serialized JSON version
  76882. * @param serializationObject defines the JSON object to read from
  76883. * @param scene defines the hosting scene
  76884. * @param rootUrl defines the rootUrl for data loading
  76885. * @returns a new SubEmitter
  76886. */
  76887. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  76888. /** Release associated resources */
  76889. dispose(): void;
  76890. }
  76891. }
  76892. declare module BABYLON {
  76893. /** @hidden */
  76894. export var clipPlaneFragmentDeclaration: {
  76895. name: string;
  76896. shader: string;
  76897. };
  76898. }
  76899. declare module BABYLON {
  76900. /** @hidden */
  76901. export var imageProcessingDeclaration: {
  76902. name: string;
  76903. shader: string;
  76904. };
  76905. }
  76906. declare module BABYLON {
  76907. /** @hidden */
  76908. export var imageProcessingFunctions: {
  76909. name: string;
  76910. shader: string;
  76911. };
  76912. }
  76913. declare module BABYLON {
  76914. /** @hidden */
  76915. export var clipPlaneFragment: {
  76916. name: string;
  76917. shader: string;
  76918. };
  76919. }
  76920. declare module BABYLON {
  76921. /** @hidden */
  76922. export var particlesPixelShader: {
  76923. name: string;
  76924. shader: string;
  76925. };
  76926. }
  76927. declare module BABYLON {
  76928. /** @hidden */
  76929. export var clipPlaneVertexDeclaration: {
  76930. name: string;
  76931. shader: string;
  76932. };
  76933. }
  76934. declare module BABYLON {
  76935. /** @hidden */
  76936. export var clipPlaneVertex: {
  76937. name: string;
  76938. shader: string;
  76939. };
  76940. }
  76941. declare module BABYLON {
  76942. /** @hidden */
  76943. export var particlesVertexShader: {
  76944. name: string;
  76945. shader: string;
  76946. };
  76947. }
  76948. declare module BABYLON {
  76949. /**
  76950. * This represents a particle system in Babylon.
  76951. * 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.
  76952. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  76953. * @example https://doc.babylonjs.com/babylon101/particles
  76954. */
  76955. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  76956. /**
  76957. * Billboard mode will only apply to Y axis
  76958. */
  76959. static readonly BILLBOARDMODE_Y: number;
  76960. /**
  76961. * Billboard mode will apply to all axes
  76962. */
  76963. static readonly BILLBOARDMODE_ALL: number;
  76964. /**
  76965. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  76966. */
  76967. static readonly BILLBOARDMODE_STRETCHED: number;
  76968. /**
  76969. * This function can be defined to provide custom update for active particles.
  76970. * This function will be called instead of regular update (age, position, color, etc.).
  76971. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  76972. */
  76973. updateFunction: (particles: Particle[]) => void;
  76974. private _emitterWorldMatrix;
  76975. /**
  76976. * This function can be defined to specify initial direction for every new particle.
  76977. * It by default use the emitterType defined function
  76978. */
  76979. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  76980. /**
  76981. * This function can be defined to specify initial position for every new particle.
  76982. * It by default use the emitterType defined function
  76983. */
  76984. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  76985. /**
  76986. * @hidden
  76987. */
  76988. _inheritedVelocityOffset: Vector3;
  76989. /**
  76990. * An event triggered when the system is disposed
  76991. */
  76992. onDisposeObservable: Observable<ParticleSystem>;
  76993. private _onDisposeObserver;
  76994. /**
  76995. * Sets a callback that will be triggered when the system is disposed
  76996. */
  76997. onDispose: () => void;
  76998. private _particles;
  76999. private _epsilon;
  77000. private _capacity;
  77001. private _stockParticles;
  77002. private _newPartsExcess;
  77003. private _vertexData;
  77004. private _vertexBuffer;
  77005. private _vertexBuffers;
  77006. private _spriteBuffer;
  77007. private _indexBuffer;
  77008. private _effect;
  77009. private _customEffect;
  77010. private _cachedDefines;
  77011. private _scaledColorStep;
  77012. private _colorDiff;
  77013. private _scaledDirection;
  77014. private _scaledGravity;
  77015. private _currentRenderId;
  77016. private _alive;
  77017. private _useInstancing;
  77018. private _started;
  77019. private _stopped;
  77020. private _actualFrame;
  77021. private _scaledUpdateSpeed;
  77022. private _vertexBufferSize;
  77023. /** @hidden */
  77024. _currentEmitRateGradient: Nullable<FactorGradient>;
  77025. /** @hidden */
  77026. _currentEmitRate1: number;
  77027. /** @hidden */
  77028. _currentEmitRate2: number;
  77029. /** @hidden */
  77030. _currentStartSizeGradient: Nullable<FactorGradient>;
  77031. /** @hidden */
  77032. _currentStartSize1: number;
  77033. /** @hidden */
  77034. _currentStartSize2: number;
  77035. private readonly _rawTextureWidth;
  77036. private _rampGradientsTexture;
  77037. private _useRampGradients;
  77038. /** Gets or sets a boolean indicating that ramp gradients must be used
  77039. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  77040. */
  77041. useRampGradients: boolean;
  77042. /**
  77043. * 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.
  77044. * 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: [])
  77045. */
  77046. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  77047. private _subEmitters;
  77048. /**
  77049. * @hidden
  77050. * If the particle systems emitter should be disposed when the particle system is disposed
  77051. */
  77052. _disposeEmitterOnDispose: boolean;
  77053. /**
  77054. * The current active Sub-systems, this property is used by the root particle system only.
  77055. */
  77056. activeSubSystems: Array<ParticleSystem>;
  77057. private _rootParticleSystem;
  77058. /**
  77059. * Gets the current list of active particles
  77060. */
  77061. readonly particles: Particle[];
  77062. /**
  77063. * Returns the string "ParticleSystem"
  77064. * @returns a string containing the class name
  77065. */
  77066. getClassName(): string;
  77067. /**
  77068. * Instantiates a particle system.
  77069. * 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.
  77070. * @param name The name of the particle system
  77071. * @param capacity The max number of particles alive at the same time
  77072. * @param scene The scene the particle system belongs to
  77073. * @param customEffect a custom effect used to change the way particles are rendered by default
  77074. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  77075. * @param epsilon Offset used to render the particles
  77076. */
  77077. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  77078. private _addFactorGradient;
  77079. private _removeFactorGradient;
  77080. /**
  77081. * Adds a new life time gradient
  77082. * @param gradient defines the gradient to use (between 0 and 1)
  77083. * @param factor defines the life time factor to affect to the specified gradient
  77084. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77085. * @returns the current particle system
  77086. */
  77087. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77088. /**
  77089. * Remove a specific life time gradient
  77090. * @param gradient defines the gradient to remove
  77091. * @returns the current particle system
  77092. */
  77093. removeLifeTimeGradient(gradient: number): IParticleSystem;
  77094. /**
  77095. * Adds a new size gradient
  77096. * @param gradient defines the gradient to use (between 0 and 1)
  77097. * @param factor defines the size factor to affect to the specified gradient
  77098. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77099. * @returns the current particle system
  77100. */
  77101. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77102. /**
  77103. * Remove a specific size gradient
  77104. * @param gradient defines the gradient to remove
  77105. * @returns the current particle system
  77106. */
  77107. removeSizeGradient(gradient: number): IParticleSystem;
  77108. /**
  77109. * Adds a new color remap gradient
  77110. * @param gradient defines the gradient to use (between 0 and 1)
  77111. * @param min defines the color remap minimal range
  77112. * @param max defines the color remap maximal range
  77113. * @returns the current particle system
  77114. */
  77115. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77116. /**
  77117. * Remove a specific color remap gradient
  77118. * @param gradient defines the gradient to remove
  77119. * @returns the current particle system
  77120. */
  77121. removeColorRemapGradient(gradient: number): IParticleSystem;
  77122. /**
  77123. * Adds a new alpha remap gradient
  77124. * @param gradient defines the gradient to use (between 0 and 1)
  77125. * @param min defines the alpha remap minimal range
  77126. * @param max defines the alpha remap maximal range
  77127. * @returns the current particle system
  77128. */
  77129. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  77130. /**
  77131. * Remove a specific alpha remap gradient
  77132. * @param gradient defines the gradient to remove
  77133. * @returns the current particle system
  77134. */
  77135. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  77136. /**
  77137. * Adds a new angular speed gradient
  77138. * @param gradient defines the gradient to use (between 0 and 1)
  77139. * @param factor defines the angular speed to affect to the specified gradient
  77140. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77141. * @returns the current particle system
  77142. */
  77143. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77144. /**
  77145. * Remove a specific angular speed gradient
  77146. * @param gradient defines the gradient to remove
  77147. * @returns the current particle system
  77148. */
  77149. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  77150. /**
  77151. * Adds a new velocity gradient
  77152. * @param gradient defines the gradient to use (between 0 and 1)
  77153. * @param factor defines the velocity to affect to the specified gradient
  77154. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77155. * @returns the current particle system
  77156. */
  77157. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77158. /**
  77159. * Remove a specific velocity gradient
  77160. * @param gradient defines the gradient to remove
  77161. * @returns the current particle system
  77162. */
  77163. removeVelocityGradient(gradient: number): IParticleSystem;
  77164. /**
  77165. * Adds a new limit velocity gradient
  77166. * @param gradient defines the gradient to use (between 0 and 1)
  77167. * @param factor defines the limit velocity value to affect to the specified gradient
  77168. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77169. * @returns the current particle system
  77170. */
  77171. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77172. /**
  77173. * Remove a specific limit velocity gradient
  77174. * @param gradient defines the gradient to remove
  77175. * @returns the current particle system
  77176. */
  77177. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  77178. /**
  77179. * Adds a new drag gradient
  77180. * @param gradient defines the gradient to use (between 0 and 1)
  77181. * @param factor defines the drag value to affect to the specified gradient
  77182. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77183. * @returns the current particle system
  77184. */
  77185. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77186. /**
  77187. * Remove a specific drag gradient
  77188. * @param gradient defines the gradient to remove
  77189. * @returns the current particle system
  77190. */
  77191. removeDragGradient(gradient: number): IParticleSystem;
  77192. /**
  77193. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  77194. * @param gradient defines the gradient to use (between 0 and 1)
  77195. * @param factor defines the emit rate value to affect to the specified gradient
  77196. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77197. * @returns the current particle system
  77198. */
  77199. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77200. /**
  77201. * Remove a specific emit rate gradient
  77202. * @param gradient defines the gradient to remove
  77203. * @returns the current particle system
  77204. */
  77205. removeEmitRateGradient(gradient: number): IParticleSystem;
  77206. /**
  77207. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  77208. * @param gradient defines the gradient to use (between 0 and 1)
  77209. * @param factor defines the start size value to affect to the specified gradient
  77210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  77211. * @returns the current particle system
  77212. */
  77213. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  77214. /**
  77215. * Remove a specific start size gradient
  77216. * @param gradient defines the gradient to remove
  77217. * @returns the current particle system
  77218. */
  77219. removeStartSizeGradient(gradient: number): IParticleSystem;
  77220. private _createRampGradientTexture;
  77221. /**
  77222. * Gets the current list of ramp gradients.
  77223. * You must use addRampGradient and removeRampGradient to udpate this list
  77224. * @returns the list of ramp gradients
  77225. */
  77226. getRampGradients(): Nullable<Array<Color3Gradient>>;
  77227. /**
  77228. * Adds a new ramp gradient used to remap particle colors
  77229. * @param gradient defines the gradient to use (between 0 and 1)
  77230. * @param color defines the color to affect to the specified gradient
  77231. * @returns the current particle system
  77232. */
  77233. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  77234. /**
  77235. * Remove a specific ramp gradient
  77236. * @param gradient defines the gradient to remove
  77237. * @returns the current particle system
  77238. */
  77239. removeRampGradient(gradient: number): ParticleSystem;
  77240. /**
  77241. * Adds a new color gradient
  77242. * @param gradient defines the gradient to use (between 0 and 1)
  77243. * @param color1 defines the color to affect to the specified gradient
  77244. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  77245. * @returns this particle system
  77246. */
  77247. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  77248. /**
  77249. * Remove a specific color gradient
  77250. * @param gradient defines the gradient to remove
  77251. * @returns this particle system
  77252. */
  77253. removeColorGradient(gradient: number): IParticleSystem;
  77254. private _fetchR;
  77255. protected _reset(): void;
  77256. private _resetEffect;
  77257. private _createVertexBuffers;
  77258. private _createIndexBuffer;
  77259. /**
  77260. * Gets the maximum number of particles active at the same time.
  77261. * @returns The max number of active particles.
  77262. */
  77263. getCapacity(): number;
  77264. /**
  77265. * Gets whether there are still active particles in the system.
  77266. * @returns True if it is alive, otherwise false.
  77267. */
  77268. isAlive(): boolean;
  77269. /**
  77270. * Gets if the system has been started. (Note: this will still be true after stop is called)
  77271. * @returns True if it has been started, otherwise false.
  77272. */
  77273. isStarted(): boolean;
  77274. private _prepareSubEmitterInternalArray;
  77275. /**
  77276. * Starts the particle system and begins to emit
  77277. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  77278. */
  77279. start(delay?: number): void;
  77280. /**
  77281. * Stops the particle system.
  77282. * @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.
  77283. */
  77284. stop(stopSubEmitters?: boolean): void;
  77285. /**
  77286. * Remove all active particles
  77287. */
  77288. reset(): void;
  77289. /**
  77290. * @hidden (for internal use only)
  77291. */
  77292. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  77293. /**
  77294. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  77295. * Its lifetime will start back at 0.
  77296. */
  77297. recycleParticle: (particle: Particle) => void;
  77298. private _stopSubEmitters;
  77299. private _createParticle;
  77300. private _removeFromRoot;
  77301. private _emitFromParticle;
  77302. private _update;
  77303. /** @hidden */
  77304. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  77305. /** @hidden */
  77306. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  77307. /** @hidden */
  77308. private _getEffect;
  77309. /**
  77310. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  77311. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  77312. */
  77313. animate(preWarmOnly?: boolean): void;
  77314. private _appendParticleVertices;
  77315. /**
  77316. * Rebuilds the particle system.
  77317. */
  77318. rebuild(): void;
  77319. /**
  77320. * Is this system ready to be used/rendered
  77321. * @return true if the system is ready
  77322. */
  77323. isReady(): boolean;
  77324. private _render;
  77325. /**
  77326. * Renders the particle system in its current state.
  77327. * @returns the current number of particles
  77328. */
  77329. render(): number;
  77330. /**
  77331. * Disposes the particle system and free the associated resources
  77332. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  77333. */
  77334. dispose(disposeTexture?: boolean): void;
  77335. /**
  77336. * Clones the particle system.
  77337. * @param name The name of the cloned object
  77338. * @param newEmitter The new emitter to use
  77339. * @returns the cloned particle system
  77340. */
  77341. clone(name: string, newEmitter: any): ParticleSystem;
  77342. /**
  77343. * Serializes the particle system to a JSON object.
  77344. * @returns the JSON object
  77345. */
  77346. serialize(): any;
  77347. /** @hidden */
  77348. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  77349. /** @hidden */
  77350. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  77351. /**
  77352. * Parses a JSON object to create a particle system.
  77353. * @param parsedParticleSystem The JSON object to parse
  77354. * @param scene The scene to create the particle system in
  77355. * @param rootUrl The root url to use to load external dependencies like texture
  77356. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  77357. * @returns the Parsed particle system
  77358. */
  77359. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  77360. }
  77361. }
  77362. declare module BABYLON {
  77363. /**
  77364. * A particle represents one of the element emitted by a particle system.
  77365. * This is mainly define by its coordinates, direction, velocity and age.
  77366. */
  77367. export class Particle {
  77368. /**
  77369. * The particle system the particle belongs to.
  77370. */
  77371. particleSystem: ParticleSystem;
  77372. private static _Count;
  77373. /**
  77374. * Unique ID of the particle
  77375. */
  77376. id: number;
  77377. /**
  77378. * The world position of the particle in the scene.
  77379. */
  77380. position: Vector3;
  77381. /**
  77382. * The world direction of the particle in the scene.
  77383. */
  77384. direction: Vector3;
  77385. /**
  77386. * The color of the particle.
  77387. */
  77388. color: Color4;
  77389. /**
  77390. * The color change of the particle per step.
  77391. */
  77392. colorStep: Color4;
  77393. /**
  77394. * Defines how long will the life of the particle be.
  77395. */
  77396. lifeTime: number;
  77397. /**
  77398. * The current age of the particle.
  77399. */
  77400. age: number;
  77401. /**
  77402. * The current size of the particle.
  77403. */
  77404. size: number;
  77405. /**
  77406. * The current scale of the particle.
  77407. */
  77408. scale: Vector2;
  77409. /**
  77410. * The current angle of the particle.
  77411. */
  77412. angle: number;
  77413. /**
  77414. * Defines how fast is the angle changing.
  77415. */
  77416. angularSpeed: number;
  77417. /**
  77418. * Defines the cell index used by the particle to be rendered from a sprite.
  77419. */
  77420. cellIndex: number;
  77421. /**
  77422. * The information required to support color remapping
  77423. */
  77424. remapData: Vector4;
  77425. /** @hidden */
  77426. _randomCellOffset?: number;
  77427. /** @hidden */
  77428. _initialDirection: Nullable<Vector3>;
  77429. /** @hidden */
  77430. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  77431. /** @hidden */
  77432. _initialStartSpriteCellID: number;
  77433. /** @hidden */
  77434. _initialEndSpriteCellID: number;
  77435. /** @hidden */
  77436. _currentColorGradient: Nullable<ColorGradient>;
  77437. /** @hidden */
  77438. _currentColor1: Color4;
  77439. /** @hidden */
  77440. _currentColor2: Color4;
  77441. /** @hidden */
  77442. _currentSizeGradient: Nullable<FactorGradient>;
  77443. /** @hidden */
  77444. _currentSize1: number;
  77445. /** @hidden */
  77446. _currentSize2: number;
  77447. /** @hidden */
  77448. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  77449. /** @hidden */
  77450. _currentAngularSpeed1: number;
  77451. /** @hidden */
  77452. _currentAngularSpeed2: number;
  77453. /** @hidden */
  77454. _currentVelocityGradient: Nullable<FactorGradient>;
  77455. /** @hidden */
  77456. _currentVelocity1: number;
  77457. /** @hidden */
  77458. _currentVelocity2: number;
  77459. /** @hidden */
  77460. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  77461. /** @hidden */
  77462. _currentLimitVelocity1: number;
  77463. /** @hidden */
  77464. _currentLimitVelocity2: number;
  77465. /** @hidden */
  77466. _currentDragGradient: Nullable<FactorGradient>;
  77467. /** @hidden */
  77468. _currentDrag1: number;
  77469. /** @hidden */
  77470. _currentDrag2: number;
  77471. /** @hidden */
  77472. _randomNoiseCoordinates1: Vector3;
  77473. /** @hidden */
  77474. _randomNoiseCoordinates2: Vector3;
  77475. /**
  77476. * Creates a new instance Particle
  77477. * @param particleSystem the particle system the particle belongs to
  77478. */
  77479. constructor(
  77480. /**
  77481. * The particle system the particle belongs to.
  77482. */
  77483. particleSystem: ParticleSystem);
  77484. private updateCellInfoFromSystem;
  77485. /**
  77486. * Defines how the sprite cell index is updated for the particle
  77487. */
  77488. updateCellIndex(): void;
  77489. /** @hidden */
  77490. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  77491. /** @hidden */
  77492. _inheritParticleInfoToSubEmitters(): void;
  77493. /** @hidden */
  77494. _reset(): void;
  77495. /**
  77496. * Copy the properties of particle to another one.
  77497. * @param other the particle to copy the information to.
  77498. */
  77499. copyTo(other: Particle): void;
  77500. }
  77501. }
  77502. declare module BABYLON {
  77503. /**
  77504. * Particle emitter represents a volume emitting particles.
  77505. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  77506. */
  77507. export interface IParticleEmitterType {
  77508. /**
  77509. * Called by the particle System when the direction is computed for the created particle.
  77510. * @param worldMatrix is the world matrix of the particle system
  77511. * @param directionToUpdate is the direction vector to update with the result
  77512. * @param particle is the particle we are computed the direction for
  77513. */
  77514. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77515. /**
  77516. * Called by the particle System when the position is computed for the created particle.
  77517. * @param worldMatrix is the world matrix of the particle system
  77518. * @param positionToUpdate is the position vector to update with the result
  77519. * @param particle is the particle we are computed the position for
  77520. */
  77521. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77522. /**
  77523. * Clones the current emitter and returns a copy of it
  77524. * @returns the new emitter
  77525. */
  77526. clone(): IParticleEmitterType;
  77527. /**
  77528. * Called by the GPUParticleSystem to setup the update shader
  77529. * @param effect defines the update shader
  77530. */
  77531. applyToShader(effect: Effect): void;
  77532. /**
  77533. * Returns a string to use to update the GPU particles update shader
  77534. * @returns the effect defines string
  77535. */
  77536. getEffectDefines(): string;
  77537. /**
  77538. * Returns a string representing the class name
  77539. * @returns a string containing the class name
  77540. */
  77541. getClassName(): string;
  77542. /**
  77543. * Serializes the particle system to a JSON object.
  77544. * @returns the JSON object
  77545. */
  77546. serialize(): any;
  77547. /**
  77548. * Parse properties from a JSON object
  77549. * @param serializationObject defines the JSON object
  77550. */
  77551. parse(serializationObject: any): void;
  77552. }
  77553. }
  77554. declare module BABYLON {
  77555. /**
  77556. * Particle emitter emitting particles from the inside of a box.
  77557. * It emits the particles randomly between 2 given directions.
  77558. */
  77559. export class BoxParticleEmitter implements IParticleEmitterType {
  77560. /**
  77561. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77562. */
  77563. direction1: Vector3;
  77564. /**
  77565. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77566. */
  77567. direction2: Vector3;
  77568. /**
  77569. * 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.
  77570. */
  77571. minEmitBox: Vector3;
  77572. /**
  77573. * 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.
  77574. */
  77575. maxEmitBox: Vector3;
  77576. /**
  77577. * Creates a new instance BoxParticleEmitter
  77578. */
  77579. constructor();
  77580. /**
  77581. * Called by the particle System when the direction is computed for the created particle.
  77582. * @param worldMatrix is the world matrix of the particle system
  77583. * @param directionToUpdate is the direction vector to update with the result
  77584. * @param particle is the particle we are computed the direction for
  77585. */
  77586. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77587. /**
  77588. * Called by the particle System when the position is computed for the created particle.
  77589. * @param worldMatrix is the world matrix of the particle system
  77590. * @param positionToUpdate is the position vector to update with the result
  77591. * @param particle is the particle we are computed the position for
  77592. */
  77593. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77594. /**
  77595. * Clones the current emitter and returns a copy of it
  77596. * @returns the new emitter
  77597. */
  77598. clone(): BoxParticleEmitter;
  77599. /**
  77600. * Called by the GPUParticleSystem to setup the update shader
  77601. * @param effect defines the update shader
  77602. */
  77603. applyToShader(effect: Effect): void;
  77604. /**
  77605. * Returns a string to use to update the GPU particles update shader
  77606. * @returns a string containng the defines string
  77607. */
  77608. getEffectDefines(): string;
  77609. /**
  77610. * Returns the string "BoxParticleEmitter"
  77611. * @returns a string containing the class name
  77612. */
  77613. getClassName(): string;
  77614. /**
  77615. * Serializes the particle system to a JSON object.
  77616. * @returns the JSON object
  77617. */
  77618. serialize(): any;
  77619. /**
  77620. * Parse properties from a JSON object
  77621. * @param serializationObject defines the JSON object
  77622. */
  77623. parse(serializationObject: any): void;
  77624. }
  77625. }
  77626. declare module BABYLON {
  77627. /**
  77628. * Particle emitter emitting particles from the inside of a cone.
  77629. * It emits the particles alongside the cone volume from the base to the particle.
  77630. * The emission direction might be randomized.
  77631. */
  77632. export class ConeParticleEmitter implements IParticleEmitterType {
  77633. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  77634. directionRandomizer: number;
  77635. private _radius;
  77636. private _angle;
  77637. private _height;
  77638. /**
  77639. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  77640. */
  77641. radiusRange: number;
  77642. /**
  77643. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  77644. */
  77645. heightRange: number;
  77646. /**
  77647. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  77648. */
  77649. emitFromSpawnPointOnly: boolean;
  77650. /**
  77651. * Gets or sets the radius of the emission cone
  77652. */
  77653. radius: number;
  77654. /**
  77655. * Gets or sets the angle of the emission cone
  77656. */
  77657. angle: number;
  77658. private _buildHeight;
  77659. /**
  77660. * Creates a new instance ConeParticleEmitter
  77661. * @param radius the radius of the emission cone (1 by default)
  77662. * @param angle the cone base angle (PI by default)
  77663. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  77664. */
  77665. constructor(radius?: number, angle?: number,
  77666. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  77667. directionRandomizer?: number);
  77668. /**
  77669. * Called by the particle System when the direction is computed for the created particle.
  77670. * @param worldMatrix is the world matrix of the particle system
  77671. * @param directionToUpdate is the direction vector to update with the result
  77672. * @param particle is the particle we are computed the direction for
  77673. */
  77674. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77675. /**
  77676. * Called by the particle System when the position is computed for the created particle.
  77677. * @param worldMatrix is the world matrix of the particle system
  77678. * @param positionToUpdate is the position vector to update with the result
  77679. * @param particle is the particle we are computed the position for
  77680. */
  77681. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77682. /**
  77683. * Clones the current emitter and returns a copy of it
  77684. * @returns the new emitter
  77685. */
  77686. clone(): ConeParticleEmitter;
  77687. /**
  77688. * Called by the GPUParticleSystem to setup the update shader
  77689. * @param effect defines the update shader
  77690. */
  77691. applyToShader(effect: Effect): void;
  77692. /**
  77693. * Returns a string to use to update the GPU particles update shader
  77694. * @returns a string containng the defines string
  77695. */
  77696. getEffectDefines(): string;
  77697. /**
  77698. * Returns the string "ConeParticleEmitter"
  77699. * @returns a string containing the class name
  77700. */
  77701. getClassName(): string;
  77702. /**
  77703. * Serializes the particle system to a JSON object.
  77704. * @returns the JSON object
  77705. */
  77706. serialize(): any;
  77707. /**
  77708. * Parse properties from a JSON object
  77709. * @param serializationObject defines the JSON object
  77710. */
  77711. parse(serializationObject: any): void;
  77712. }
  77713. }
  77714. declare module BABYLON {
  77715. /**
  77716. * Particle emitter emitting particles from the inside of a cylinder.
  77717. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  77718. */
  77719. export class CylinderParticleEmitter implements IParticleEmitterType {
  77720. /**
  77721. * The radius of the emission cylinder.
  77722. */
  77723. radius: number;
  77724. /**
  77725. * The height of the emission cylinder.
  77726. */
  77727. height: number;
  77728. /**
  77729. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77730. */
  77731. radiusRange: number;
  77732. /**
  77733. * How much to randomize the particle direction [0-1].
  77734. */
  77735. directionRandomizer: number;
  77736. /**
  77737. * Creates a new instance CylinderParticleEmitter
  77738. * @param radius the radius of the emission cylinder (1 by default)
  77739. * @param height the height of the emission cylinder (1 by default)
  77740. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77741. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  77742. */
  77743. constructor(
  77744. /**
  77745. * The radius of the emission cylinder.
  77746. */
  77747. radius?: number,
  77748. /**
  77749. * The height of the emission cylinder.
  77750. */
  77751. height?: number,
  77752. /**
  77753. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77754. */
  77755. radiusRange?: number,
  77756. /**
  77757. * How much to randomize the particle direction [0-1].
  77758. */
  77759. directionRandomizer?: number);
  77760. /**
  77761. * Called by the particle System when the direction is computed for the created particle.
  77762. * @param worldMatrix is the world matrix of the particle system
  77763. * @param directionToUpdate is the direction vector to update with the result
  77764. * @param particle is the particle we are computed the direction for
  77765. */
  77766. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77767. /**
  77768. * Called by the particle System when the position is computed for the created particle.
  77769. * @param worldMatrix is the world matrix of the particle system
  77770. * @param positionToUpdate is the position vector to update with the result
  77771. * @param particle is the particle we are computed the position for
  77772. */
  77773. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77774. /**
  77775. * Clones the current emitter and returns a copy of it
  77776. * @returns the new emitter
  77777. */
  77778. clone(): CylinderParticleEmitter;
  77779. /**
  77780. * Called by the GPUParticleSystem to setup the update shader
  77781. * @param effect defines the update shader
  77782. */
  77783. applyToShader(effect: Effect): void;
  77784. /**
  77785. * Returns a string to use to update the GPU particles update shader
  77786. * @returns a string containng the defines string
  77787. */
  77788. getEffectDefines(): string;
  77789. /**
  77790. * Returns the string "CylinderParticleEmitter"
  77791. * @returns a string containing the class name
  77792. */
  77793. getClassName(): string;
  77794. /**
  77795. * Serializes the particle system to a JSON object.
  77796. * @returns the JSON object
  77797. */
  77798. serialize(): any;
  77799. /**
  77800. * Parse properties from a JSON object
  77801. * @param serializationObject defines the JSON object
  77802. */
  77803. parse(serializationObject: any): void;
  77804. }
  77805. /**
  77806. * Particle emitter emitting particles from the inside of a cylinder.
  77807. * It emits the particles randomly between two vectors.
  77808. */
  77809. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  77810. /**
  77811. * The min limit of the emission direction.
  77812. */
  77813. direction1: Vector3;
  77814. /**
  77815. * The max limit of the emission direction.
  77816. */
  77817. direction2: Vector3;
  77818. /**
  77819. * Creates a new instance CylinderDirectedParticleEmitter
  77820. * @param radius the radius of the emission cylinder (1 by default)
  77821. * @param height the height of the emission cylinder (1 by default)
  77822. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77823. * @param direction1 the min limit of the emission direction (up vector by default)
  77824. * @param direction2 the max limit of the emission direction (up vector by default)
  77825. */
  77826. constructor(radius?: number, height?: number, radiusRange?: number,
  77827. /**
  77828. * The min limit of the emission direction.
  77829. */
  77830. direction1?: Vector3,
  77831. /**
  77832. * The max limit of the emission direction.
  77833. */
  77834. direction2?: Vector3);
  77835. /**
  77836. * Called by the particle System when the direction is computed for the created particle.
  77837. * @param worldMatrix is the world matrix of the particle system
  77838. * @param directionToUpdate is the direction vector to update with the result
  77839. * @param particle is the particle we are computed the direction for
  77840. */
  77841. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77842. /**
  77843. * Clones the current emitter and returns a copy of it
  77844. * @returns the new emitter
  77845. */
  77846. clone(): CylinderDirectedParticleEmitter;
  77847. /**
  77848. * Called by the GPUParticleSystem to setup the update shader
  77849. * @param effect defines the update shader
  77850. */
  77851. applyToShader(effect: Effect): void;
  77852. /**
  77853. * Returns a string to use to update the GPU particles update shader
  77854. * @returns a string containng the defines string
  77855. */
  77856. getEffectDefines(): string;
  77857. /**
  77858. * Returns the string "CylinderDirectedParticleEmitter"
  77859. * @returns a string containing the class name
  77860. */
  77861. getClassName(): string;
  77862. /**
  77863. * Serializes the particle system to a JSON object.
  77864. * @returns the JSON object
  77865. */
  77866. serialize(): any;
  77867. /**
  77868. * Parse properties from a JSON object
  77869. * @param serializationObject defines the JSON object
  77870. */
  77871. parse(serializationObject: any): void;
  77872. }
  77873. }
  77874. declare module BABYLON {
  77875. /**
  77876. * Particle emitter emitting particles from the inside of a hemisphere.
  77877. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  77878. */
  77879. export class HemisphericParticleEmitter implements IParticleEmitterType {
  77880. /**
  77881. * The radius of the emission hemisphere.
  77882. */
  77883. radius: number;
  77884. /**
  77885. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77886. */
  77887. radiusRange: number;
  77888. /**
  77889. * How much to randomize the particle direction [0-1].
  77890. */
  77891. directionRandomizer: number;
  77892. /**
  77893. * Creates a new instance HemisphericParticleEmitter
  77894. * @param radius the radius of the emission hemisphere (1 by default)
  77895. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  77896. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  77897. */
  77898. constructor(
  77899. /**
  77900. * The radius of the emission hemisphere.
  77901. */
  77902. radius?: number,
  77903. /**
  77904. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  77905. */
  77906. radiusRange?: number,
  77907. /**
  77908. * How much to randomize the particle direction [0-1].
  77909. */
  77910. directionRandomizer?: number);
  77911. /**
  77912. * Called by the particle System when the direction is computed for the created particle.
  77913. * @param worldMatrix is the world matrix of the particle system
  77914. * @param directionToUpdate is the direction vector to update with the result
  77915. * @param particle is the particle we are computed the direction for
  77916. */
  77917. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77918. /**
  77919. * Called by the particle System when the position is computed for the created particle.
  77920. * @param worldMatrix is the world matrix of the particle system
  77921. * @param positionToUpdate is the position vector to update with the result
  77922. * @param particle is the particle we are computed the position for
  77923. */
  77924. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77925. /**
  77926. * Clones the current emitter and returns a copy of it
  77927. * @returns the new emitter
  77928. */
  77929. clone(): HemisphericParticleEmitter;
  77930. /**
  77931. * Called by the GPUParticleSystem to setup the update shader
  77932. * @param effect defines the update shader
  77933. */
  77934. applyToShader(effect: Effect): void;
  77935. /**
  77936. * Returns a string to use to update the GPU particles update shader
  77937. * @returns a string containng the defines string
  77938. */
  77939. getEffectDefines(): string;
  77940. /**
  77941. * Returns the string "HemisphericParticleEmitter"
  77942. * @returns a string containing the class name
  77943. */
  77944. getClassName(): string;
  77945. /**
  77946. * Serializes the particle system to a JSON object.
  77947. * @returns the JSON object
  77948. */
  77949. serialize(): any;
  77950. /**
  77951. * Parse properties from a JSON object
  77952. * @param serializationObject defines the JSON object
  77953. */
  77954. parse(serializationObject: any): void;
  77955. }
  77956. }
  77957. declare module BABYLON {
  77958. /**
  77959. * Particle emitter emitting particles from a point.
  77960. * It emits the particles randomly between 2 given directions.
  77961. */
  77962. export class PointParticleEmitter implements IParticleEmitterType {
  77963. /**
  77964. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77965. */
  77966. direction1: Vector3;
  77967. /**
  77968. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  77969. */
  77970. direction2: Vector3;
  77971. /**
  77972. * Creates a new instance PointParticleEmitter
  77973. */
  77974. constructor();
  77975. /**
  77976. * Called by the particle System when the direction is computed for the created particle.
  77977. * @param worldMatrix is the world matrix of the particle system
  77978. * @param directionToUpdate is the direction vector to update with the result
  77979. * @param particle is the particle we are computed the direction for
  77980. */
  77981. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  77982. /**
  77983. * Called by the particle System when the position is computed for the created particle.
  77984. * @param worldMatrix is the world matrix of the particle system
  77985. * @param positionToUpdate is the position vector to update with the result
  77986. * @param particle is the particle we are computed the position for
  77987. */
  77988. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  77989. /**
  77990. * Clones the current emitter and returns a copy of it
  77991. * @returns the new emitter
  77992. */
  77993. clone(): PointParticleEmitter;
  77994. /**
  77995. * Called by the GPUParticleSystem to setup the update shader
  77996. * @param effect defines the update shader
  77997. */
  77998. applyToShader(effect: Effect): void;
  77999. /**
  78000. * Returns a string to use to update the GPU particles update shader
  78001. * @returns a string containng the defines string
  78002. */
  78003. getEffectDefines(): string;
  78004. /**
  78005. * Returns the string "PointParticleEmitter"
  78006. * @returns a string containing the class name
  78007. */
  78008. getClassName(): string;
  78009. /**
  78010. * Serializes the particle system to a JSON object.
  78011. * @returns the JSON object
  78012. */
  78013. serialize(): any;
  78014. /**
  78015. * Parse properties from a JSON object
  78016. * @param serializationObject defines the JSON object
  78017. */
  78018. parse(serializationObject: any): void;
  78019. }
  78020. }
  78021. declare module BABYLON {
  78022. /**
  78023. * Particle emitter emitting particles from the inside of a sphere.
  78024. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  78025. */
  78026. export class SphereParticleEmitter implements IParticleEmitterType {
  78027. /**
  78028. * The radius of the emission sphere.
  78029. */
  78030. radius: number;
  78031. /**
  78032. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78033. */
  78034. radiusRange: number;
  78035. /**
  78036. * How much to randomize the particle direction [0-1].
  78037. */
  78038. directionRandomizer: number;
  78039. /**
  78040. * Creates a new instance SphereParticleEmitter
  78041. * @param radius the radius of the emission sphere (1 by default)
  78042. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78043. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  78044. */
  78045. constructor(
  78046. /**
  78047. * The radius of the emission sphere.
  78048. */
  78049. radius?: number,
  78050. /**
  78051. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  78052. */
  78053. radiusRange?: number,
  78054. /**
  78055. * How much to randomize the particle direction [0-1].
  78056. */
  78057. directionRandomizer?: number);
  78058. /**
  78059. * Called by the particle System when the direction is computed for the created particle.
  78060. * @param worldMatrix is the world matrix of the particle system
  78061. * @param directionToUpdate is the direction vector to update with the result
  78062. * @param particle is the particle we are computed the direction for
  78063. */
  78064. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78065. /**
  78066. * Called by the particle System when the position is computed for the created particle.
  78067. * @param worldMatrix is the world matrix of the particle system
  78068. * @param positionToUpdate is the position vector to update with the result
  78069. * @param particle is the particle we are computed the position for
  78070. */
  78071. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  78072. /**
  78073. * Clones the current emitter and returns a copy of it
  78074. * @returns the new emitter
  78075. */
  78076. clone(): SphereParticleEmitter;
  78077. /**
  78078. * Called by the GPUParticleSystem to setup the update shader
  78079. * @param effect defines the update shader
  78080. */
  78081. applyToShader(effect: Effect): void;
  78082. /**
  78083. * Returns a string to use to update the GPU particles update shader
  78084. * @returns a string containng the defines string
  78085. */
  78086. getEffectDefines(): string;
  78087. /**
  78088. * Returns the string "SphereParticleEmitter"
  78089. * @returns a string containing the class name
  78090. */
  78091. getClassName(): string;
  78092. /**
  78093. * Serializes the particle system to a JSON object.
  78094. * @returns the JSON object
  78095. */
  78096. serialize(): any;
  78097. /**
  78098. * Parse properties from a JSON object
  78099. * @param serializationObject defines the JSON object
  78100. */
  78101. parse(serializationObject: any): void;
  78102. }
  78103. /**
  78104. * Particle emitter emitting particles from the inside of a sphere.
  78105. * It emits the particles randomly between two vectors.
  78106. */
  78107. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  78108. /**
  78109. * The min limit of the emission direction.
  78110. */
  78111. direction1: Vector3;
  78112. /**
  78113. * The max limit of the emission direction.
  78114. */
  78115. direction2: Vector3;
  78116. /**
  78117. * Creates a new instance SphereDirectedParticleEmitter
  78118. * @param radius the radius of the emission sphere (1 by default)
  78119. * @param direction1 the min limit of the emission direction (up vector by default)
  78120. * @param direction2 the max limit of the emission direction (up vector by default)
  78121. */
  78122. constructor(radius?: number,
  78123. /**
  78124. * The min limit of the emission direction.
  78125. */
  78126. direction1?: Vector3,
  78127. /**
  78128. * The max limit of the emission direction.
  78129. */
  78130. direction2?: Vector3);
  78131. /**
  78132. * Called by the particle System when the direction is computed for the created particle.
  78133. * @param worldMatrix is the world matrix of the particle system
  78134. * @param directionToUpdate is the direction vector to update with the result
  78135. * @param particle is the particle we are computed the direction for
  78136. */
  78137. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  78138. /**
  78139. * Clones the current emitter and returns a copy of it
  78140. * @returns the new emitter
  78141. */
  78142. clone(): SphereDirectedParticleEmitter;
  78143. /**
  78144. * Called by the GPUParticleSystem to setup the update shader
  78145. * @param effect defines the update shader
  78146. */
  78147. applyToShader(effect: Effect): void;
  78148. /**
  78149. * Returns a string to use to update the GPU particles update shader
  78150. * @returns a string containng the defines string
  78151. */
  78152. getEffectDefines(): string;
  78153. /**
  78154. * Returns the string "SphereDirectedParticleEmitter"
  78155. * @returns a string containing the class name
  78156. */
  78157. getClassName(): string;
  78158. /**
  78159. * Serializes the particle system to a JSON object.
  78160. * @returns the JSON object
  78161. */
  78162. serialize(): any;
  78163. /**
  78164. * Parse properties from a JSON object
  78165. * @param serializationObject defines the JSON object
  78166. */
  78167. parse(serializationObject: any): void;
  78168. }
  78169. }
  78170. declare module BABYLON {
  78171. /**
  78172. * Interface representing a particle system in Babylon.js.
  78173. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  78174. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  78175. */
  78176. export interface IParticleSystem {
  78177. /**
  78178. * List of animations used by the particle system.
  78179. */
  78180. animations: Animation[];
  78181. /**
  78182. * The id of the Particle system.
  78183. */
  78184. id: string;
  78185. /**
  78186. * The name of the Particle system.
  78187. */
  78188. name: string;
  78189. /**
  78190. * The emitter represents the Mesh or position we are attaching the particle system to.
  78191. */
  78192. emitter: Nullable<AbstractMesh | Vector3>;
  78193. /**
  78194. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  78195. */
  78196. isBillboardBased: boolean;
  78197. /**
  78198. * The rendering group used by the Particle system to chose when to render.
  78199. */
  78200. renderingGroupId: number;
  78201. /**
  78202. * The layer mask we are rendering the particles through.
  78203. */
  78204. layerMask: number;
  78205. /**
  78206. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  78207. */
  78208. updateSpeed: number;
  78209. /**
  78210. * The amount of time the particle system is running (depends of the overall update speed).
  78211. */
  78212. targetStopDuration: number;
  78213. /**
  78214. * The texture used to render each particle. (this can be a spritesheet)
  78215. */
  78216. particleTexture: Nullable<Texture>;
  78217. /**
  78218. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  78219. */
  78220. blendMode: number;
  78221. /**
  78222. * Minimum life time of emitting particles.
  78223. */
  78224. minLifeTime: number;
  78225. /**
  78226. * Maximum life time of emitting particles.
  78227. */
  78228. maxLifeTime: number;
  78229. /**
  78230. * Minimum Size of emitting particles.
  78231. */
  78232. minSize: number;
  78233. /**
  78234. * Maximum Size of emitting particles.
  78235. */
  78236. maxSize: number;
  78237. /**
  78238. * Minimum scale of emitting particles on X axis.
  78239. */
  78240. minScaleX: number;
  78241. /**
  78242. * Maximum scale of emitting particles on X axis.
  78243. */
  78244. maxScaleX: number;
  78245. /**
  78246. * Minimum scale of emitting particles on Y axis.
  78247. */
  78248. minScaleY: number;
  78249. /**
  78250. * Maximum scale of emitting particles on Y axis.
  78251. */
  78252. maxScaleY: number;
  78253. /**
  78254. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78255. */
  78256. color1: Color4;
  78257. /**
  78258. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  78259. */
  78260. color2: Color4;
  78261. /**
  78262. * Color the particle will have at the end of its lifetime.
  78263. */
  78264. colorDead: Color4;
  78265. /**
  78266. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  78267. */
  78268. emitRate: number;
  78269. /**
  78270. * You can use gravity if you want to give an orientation to your particles.
  78271. */
  78272. gravity: Vector3;
  78273. /**
  78274. * Minimum power of emitting particles.
  78275. */
  78276. minEmitPower: number;
  78277. /**
  78278. * Maximum power of emitting particles.
  78279. */
  78280. maxEmitPower: number;
  78281. /**
  78282. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  78283. */
  78284. minAngularSpeed: number;
  78285. /**
  78286. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  78287. */
  78288. maxAngularSpeed: number;
  78289. /**
  78290. * Gets or sets the minimal initial rotation in radians.
  78291. */
  78292. minInitialRotation: number;
  78293. /**
  78294. * Gets or sets the maximal initial rotation in radians.
  78295. */
  78296. maxInitialRotation: number;
  78297. /**
  78298. * The particle emitter type defines the emitter used by the particle system.
  78299. * It can be for example box, sphere, or cone...
  78300. */
  78301. particleEmitterType: Nullable<IParticleEmitterType>;
  78302. /**
  78303. * Defines the delay in milliseconds before starting the system (0 by default)
  78304. */
  78305. startDelay: number;
  78306. /**
  78307. * 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
  78308. */
  78309. preWarmCycles: number;
  78310. /**
  78311. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  78312. */
  78313. preWarmStepOffset: number;
  78314. /**
  78315. * 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)
  78316. */
  78317. spriteCellChangeSpeed: number;
  78318. /**
  78319. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  78320. */
  78321. startSpriteCellID: number;
  78322. /**
  78323. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  78324. */
  78325. endSpriteCellID: number;
  78326. /**
  78327. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  78328. */
  78329. spriteCellWidth: number;
  78330. /**
  78331. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  78332. */
  78333. spriteCellHeight: number;
  78334. /**
  78335. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  78336. */
  78337. spriteRandomStartCell: boolean;
  78338. /**
  78339. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  78340. */
  78341. isAnimationSheetEnabled: boolean;
  78342. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  78343. translationPivot: Vector2;
  78344. /**
  78345. * Gets or sets a texture used to add random noise to particle positions
  78346. */
  78347. noiseTexture: Nullable<BaseTexture>;
  78348. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  78349. noiseStrength: Vector3;
  78350. /**
  78351. * Gets or sets the billboard mode to use when isBillboardBased = true.
  78352. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  78353. */
  78354. billboardMode: number;
  78355. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  78356. limitVelocityDamping: number;
  78357. /**
  78358. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  78359. */
  78360. beginAnimationOnStart: boolean;
  78361. /**
  78362. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  78363. */
  78364. beginAnimationFrom: number;
  78365. /**
  78366. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  78367. */
  78368. beginAnimationTo: number;
  78369. /**
  78370. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  78371. */
  78372. beginAnimationLoop: boolean;
  78373. /**
  78374. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  78375. */
  78376. disposeOnStop: boolean;
  78377. /**
  78378. * Gets the maximum number of particles active at the same time.
  78379. * @returns The max number of active particles.
  78380. */
  78381. getCapacity(): number;
  78382. /**
  78383. * Gets if the system has been started. (Note: this will still be true after stop is called)
  78384. * @returns True if it has been started, otherwise false.
  78385. */
  78386. isStarted(): boolean;
  78387. /**
  78388. * Animates the particle system for this frame.
  78389. */
  78390. animate(): void;
  78391. /**
  78392. * Renders the particle system in its current state.
  78393. * @returns the current number of particles
  78394. */
  78395. render(): number;
  78396. /**
  78397. * Dispose the particle system and frees its associated resources.
  78398. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  78399. */
  78400. dispose(disposeTexture?: boolean): void;
  78401. /**
  78402. * Clones the particle system.
  78403. * @param name The name of the cloned object
  78404. * @param newEmitter The new emitter to use
  78405. * @returns the cloned particle system
  78406. */
  78407. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  78408. /**
  78409. * Serializes the particle system to a JSON object.
  78410. * @returns the JSON object
  78411. */
  78412. serialize(): any;
  78413. /**
  78414. * Rebuild the particle system
  78415. */
  78416. rebuild(): void;
  78417. /**
  78418. * Starts the particle system and begins to emit
  78419. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  78420. */
  78421. start(delay?: number): void;
  78422. /**
  78423. * Stops the particle system.
  78424. */
  78425. stop(): void;
  78426. /**
  78427. * Remove all active particles
  78428. */
  78429. reset(): void;
  78430. /**
  78431. * Is this system ready to be used/rendered
  78432. * @return true if the system is ready
  78433. */
  78434. isReady(): boolean;
  78435. /**
  78436. * Adds a new color gradient
  78437. * @param gradient defines the gradient to use (between 0 and 1)
  78438. * @param color1 defines the color to affect to the specified gradient
  78439. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  78440. * @returns the current particle system
  78441. */
  78442. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  78443. /**
  78444. * Remove a specific color gradient
  78445. * @param gradient defines the gradient to remove
  78446. * @returns the current particle system
  78447. */
  78448. removeColorGradient(gradient: number): IParticleSystem;
  78449. /**
  78450. * Adds a new size gradient
  78451. * @param gradient defines the gradient to use (between 0 and 1)
  78452. * @param factor defines the size factor to affect to the specified gradient
  78453. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78454. * @returns the current particle system
  78455. */
  78456. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78457. /**
  78458. * Remove a specific size gradient
  78459. * @param gradient defines the gradient to remove
  78460. * @returns the current particle system
  78461. */
  78462. removeSizeGradient(gradient: number): IParticleSystem;
  78463. /**
  78464. * Gets the current list of color gradients.
  78465. * You must use addColorGradient and removeColorGradient to udpate this list
  78466. * @returns the list of color gradients
  78467. */
  78468. getColorGradients(): Nullable<Array<ColorGradient>>;
  78469. /**
  78470. * Gets the current list of size gradients.
  78471. * You must use addSizeGradient and removeSizeGradient to udpate this list
  78472. * @returns the list of size gradients
  78473. */
  78474. getSizeGradients(): Nullable<Array<FactorGradient>>;
  78475. /**
  78476. * Gets the current list of angular speed gradients.
  78477. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  78478. * @returns the list of angular speed gradients
  78479. */
  78480. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  78481. /**
  78482. * Adds a new angular speed gradient
  78483. * @param gradient defines the gradient to use (between 0 and 1)
  78484. * @param factor defines the angular speed to affect to the specified gradient
  78485. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78486. * @returns the current particle system
  78487. */
  78488. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78489. /**
  78490. * Remove a specific angular speed gradient
  78491. * @param gradient defines the gradient to remove
  78492. * @returns the current particle system
  78493. */
  78494. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  78495. /**
  78496. * Gets the current list of velocity gradients.
  78497. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  78498. * @returns the list of velocity gradients
  78499. */
  78500. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  78501. /**
  78502. * Adds a new velocity gradient
  78503. * @param gradient defines the gradient to use (between 0 and 1)
  78504. * @param factor defines the velocity to affect to the specified gradient
  78505. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78506. * @returns the current particle system
  78507. */
  78508. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78509. /**
  78510. * Remove a specific velocity gradient
  78511. * @param gradient defines the gradient to remove
  78512. * @returns the current particle system
  78513. */
  78514. removeVelocityGradient(gradient: number): IParticleSystem;
  78515. /**
  78516. * Gets the current list of limit velocity gradients.
  78517. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  78518. * @returns the list of limit velocity gradients
  78519. */
  78520. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  78521. /**
  78522. * Adds a new limit velocity gradient
  78523. * @param gradient defines the gradient to use (between 0 and 1)
  78524. * @param factor defines the limit velocity to affect to the specified gradient
  78525. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78526. * @returns the current particle system
  78527. */
  78528. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78529. /**
  78530. * Remove a specific limit velocity gradient
  78531. * @param gradient defines the gradient to remove
  78532. * @returns the current particle system
  78533. */
  78534. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  78535. /**
  78536. * Adds a new drag gradient
  78537. * @param gradient defines the gradient to use (between 0 and 1)
  78538. * @param factor defines the drag to affect to the specified gradient
  78539. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78540. * @returns the current particle system
  78541. */
  78542. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78543. /**
  78544. * Remove a specific drag gradient
  78545. * @param gradient defines the gradient to remove
  78546. * @returns the current particle system
  78547. */
  78548. removeDragGradient(gradient: number): IParticleSystem;
  78549. /**
  78550. * Gets the current list of drag gradients.
  78551. * You must use addDragGradient and removeDragGradient to udpate this list
  78552. * @returns the list of drag gradients
  78553. */
  78554. getDragGradients(): Nullable<Array<FactorGradient>>;
  78555. /**
  78556. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  78557. * @param gradient defines the gradient to use (between 0 and 1)
  78558. * @param factor defines the emit rate to affect to the specified gradient
  78559. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78560. * @returns the current particle system
  78561. */
  78562. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78563. /**
  78564. * Remove a specific emit rate gradient
  78565. * @param gradient defines the gradient to remove
  78566. * @returns the current particle system
  78567. */
  78568. removeEmitRateGradient(gradient: number): IParticleSystem;
  78569. /**
  78570. * Gets the current list of emit rate gradients.
  78571. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  78572. * @returns the list of emit rate gradients
  78573. */
  78574. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  78575. /**
  78576. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  78577. * @param gradient defines the gradient to use (between 0 and 1)
  78578. * @param factor defines the start size to affect to the specified gradient
  78579. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78580. * @returns the current particle system
  78581. */
  78582. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78583. /**
  78584. * Remove a specific start size gradient
  78585. * @param gradient defines the gradient to remove
  78586. * @returns the current particle system
  78587. */
  78588. removeStartSizeGradient(gradient: number): IParticleSystem;
  78589. /**
  78590. * Gets the current list of start size gradients.
  78591. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  78592. * @returns the list of start size gradients
  78593. */
  78594. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  78595. /**
  78596. * Adds a new life time gradient
  78597. * @param gradient defines the gradient to use (between 0 and 1)
  78598. * @param factor defines the life time factor to affect to the specified gradient
  78599. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  78600. * @returns the current particle system
  78601. */
  78602. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  78603. /**
  78604. * Remove a specific life time gradient
  78605. * @param gradient defines the gradient to remove
  78606. * @returns the current particle system
  78607. */
  78608. removeLifeTimeGradient(gradient: number): IParticleSystem;
  78609. /**
  78610. * Gets the current list of life time gradients.
  78611. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  78612. * @returns the list of life time gradients
  78613. */
  78614. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  78615. /**
  78616. * Gets the current list of color gradients.
  78617. * You must use addColorGradient and removeColorGradient to udpate this list
  78618. * @returns the list of color gradients
  78619. */
  78620. getColorGradients(): Nullable<Array<ColorGradient>>;
  78621. /**
  78622. * Adds a new ramp gradient used to remap particle colors
  78623. * @param gradient defines the gradient to use (between 0 and 1)
  78624. * @param color defines the color to affect to the specified gradient
  78625. * @returns the current particle system
  78626. */
  78627. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  78628. /**
  78629. * Gets the current list of ramp gradients.
  78630. * You must use addRampGradient and removeRampGradient to udpate this list
  78631. * @returns the list of ramp gradients
  78632. */
  78633. getRampGradients(): Nullable<Array<Color3Gradient>>;
  78634. /** Gets or sets a boolean indicating that ramp gradients must be used
  78635. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  78636. */
  78637. useRampGradients: boolean;
  78638. /**
  78639. * Adds a new color remap gradient
  78640. * @param gradient defines the gradient to use (between 0 and 1)
  78641. * @param min defines the color remap minimal range
  78642. * @param max defines the color remap maximal range
  78643. * @returns the current particle system
  78644. */
  78645. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  78646. /**
  78647. * Gets the current list of color remap gradients.
  78648. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  78649. * @returns the list of color remap gradients
  78650. */
  78651. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  78652. /**
  78653. * Adds a new alpha remap gradient
  78654. * @param gradient defines the gradient to use (between 0 and 1)
  78655. * @param min defines the alpha remap minimal range
  78656. * @param max defines the alpha remap maximal range
  78657. * @returns the current particle system
  78658. */
  78659. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  78660. /**
  78661. * Gets the current list of alpha remap gradients.
  78662. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  78663. * @returns the list of alpha remap gradients
  78664. */
  78665. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  78666. /**
  78667. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  78668. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  78669. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  78670. * @returns the emitter
  78671. */
  78672. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  78673. /**
  78674. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  78675. * @param radius The radius of the hemisphere to emit from
  78676. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  78677. * @returns the emitter
  78678. */
  78679. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  78680. /**
  78681. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  78682. * @param radius The radius of the sphere to emit from
  78683. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  78684. * @returns the emitter
  78685. */
  78686. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  78687. /**
  78688. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  78689. * @param radius The radius of the sphere to emit from
  78690. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  78691. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  78692. * @returns the emitter
  78693. */
  78694. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  78695. /**
  78696. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  78697. * @param radius The radius of the emission cylinder
  78698. * @param height The height of the emission cylinder
  78699. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  78700. * @param directionRandomizer How much to randomize the particle direction [0-1]
  78701. * @returns the emitter
  78702. */
  78703. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  78704. /**
  78705. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  78706. * @param radius The radius of the cylinder to emit from
  78707. * @param height The height of the emission cylinder
  78708. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  78709. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  78710. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  78711. * @returns the emitter
  78712. */
  78713. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  78714. /**
  78715. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  78716. * @param radius The radius of the cone to emit from
  78717. * @param angle The base angle of the cone
  78718. * @returns the emitter
  78719. */
  78720. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  78721. /**
  78722. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  78723. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  78724. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  78725. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  78726. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  78727. * @returns the emitter
  78728. */
  78729. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  78730. /**
  78731. * Get hosting scene
  78732. * @returns the scene
  78733. */
  78734. getScene(): Scene;
  78735. }
  78736. }
  78737. declare module BABYLON {
  78738. /**
  78739. * Creates an instance based on a source mesh.
  78740. */
  78741. export class InstancedMesh extends AbstractMesh {
  78742. private _sourceMesh;
  78743. private _currentLOD;
  78744. /** @hidden */
  78745. _indexInSourceMeshInstanceArray: number;
  78746. constructor(name: string, source: Mesh);
  78747. /**
  78748. * Returns the string "InstancedMesh".
  78749. */
  78750. getClassName(): string;
  78751. /** Gets the list of lights affecting that mesh */
  78752. readonly lightSources: Light[];
  78753. _resyncLightSources(): void;
  78754. _resyncLighSource(light: Light): void;
  78755. _removeLightSource(light: Light): void;
  78756. /**
  78757. * If the source mesh receives shadows
  78758. */
  78759. readonly receiveShadows: boolean;
  78760. /**
  78761. * The material of the source mesh
  78762. */
  78763. readonly material: Nullable<Material>;
  78764. /**
  78765. * Visibility of the source mesh
  78766. */
  78767. readonly visibility: number;
  78768. /**
  78769. * Skeleton of the source mesh
  78770. */
  78771. readonly skeleton: Nullable<Skeleton>;
  78772. /**
  78773. * Rendering ground id of the source mesh
  78774. */
  78775. renderingGroupId: number;
  78776. /**
  78777. * Returns the total number of vertices (integer).
  78778. */
  78779. getTotalVertices(): number;
  78780. /**
  78781. * Returns a positive integer : the total number of indices in this mesh geometry.
  78782. * @returns the numner of indices or zero if the mesh has no geometry.
  78783. */
  78784. getTotalIndices(): number;
  78785. /**
  78786. * The source mesh of the instance
  78787. */
  78788. readonly sourceMesh: Mesh;
  78789. /**
  78790. * Is this node ready to be used/rendered
  78791. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  78792. * @return {boolean} is it ready
  78793. */
  78794. isReady(completeCheck?: boolean): boolean;
  78795. /**
  78796. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  78797. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  78798. * @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.
  78799. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  78800. */
  78801. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  78802. /**
  78803. * Sets the vertex data of the mesh geometry for the requested `kind`.
  78804. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  78805. * The `data` are either a numeric array either a Float32Array.
  78806. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  78807. * 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).
  78808. * Note that a new underlying VertexBuffer object is created each call.
  78809. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  78810. *
  78811. * Possible `kind` values :
  78812. * - VertexBuffer.PositionKind
  78813. * - VertexBuffer.UVKind
  78814. * - VertexBuffer.UV2Kind
  78815. * - VertexBuffer.UV3Kind
  78816. * - VertexBuffer.UV4Kind
  78817. * - VertexBuffer.UV5Kind
  78818. * - VertexBuffer.UV6Kind
  78819. * - VertexBuffer.ColorKind
  78820. * - VertexBuffer.MatricesIndicesKind
  78821. * - VertexBuffer.MatricesIndicesExtraKind
  78822. * - VertexBuffer.MatricesWeightsKind
  78823. * - VertexBuffer.MatricesWeightsExtraKind
  78824. *
  78825. * Returns the Mesh.
  78826. */
  78827. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  78828. /**
  78829. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  78830. * If the mesh has no geometry, it is simply returned as it is.
  78831. * The `data` are either a numeric array either a Float32Array.
  78832. * No new underlying VertexBuffer object is created.
  78833. * 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.
  78834. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  78835. *
  78836. * Possible `kind` values :
  78837. * - VertexBuffer.PositionKind
  78838. * - VertexBuffer.UVKind
  78839. * - VertexBuffer.UV2Kind
  78840. * - VertexBuffer.UV3Kind
  78841. * - VertexBuffer.UV4Kind
  78842. * - VertexBuffer.UV5Kind
  78843. * - VertexBuffer.UV6Kind
  78844. * - VertexBuffer.ColorKind
  78845. * - VertexBuffer.MatricesIndicesKind
  78846. * - VertexBuffer.MatricesIndicesExtraKind
  78847. * - VertexBuffer.MatricesWeightsKind
  78848. * - VertexBuffer.MatricesWeightsExtraKind
  78849. *
  78850. * Returns the Mesh.
  78851. */
  78852. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  78853. /**
  78854. * Sets the mesh indices.
  78855. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  78856. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  78857. * This method creates a new index buffer each call.
  78858. * Returns the Mesh.
  78859. */
  78860. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  78861. /**
  78862. * Boolean : True if the mesh owns the requested kind of data.
  78863. */
  78864. isVerticesDataPresent(kind: string): boolean;
  78865. /**
  78866. * Returns an array of indices (IndicesArray).
  78867. */
  78868. getIndices(): Nullable<IndicesArray>;
  78869. readonly _positions: Nullable<Vector3[]>;
  78870. /**
  78871. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  78872. * This means the mesh underlying bounding box and sphere are recomputed.
  78873. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  78874. * @returns the current mesh
  78875. */
  78876. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  78877. /** @hidden */
  78878. _preActivate(): InstancedMesh;
  78879. /** @hidden */
  78880. _activate(renderId: number, intermediateRendering: boolean): boolean;
  78881. /** @hidden */
  78882. _postActivate(): void;
  78883. getWorldMatrix(): Matrix;
  78884. readonly isAnInstance: boolean;
  78885. /**
  78886. * Returns the current associated LOD AbstractMesh.
  78887. */
  78888. getLOD(camera: Camera): AbstractMesh;
  78889. /** @hidden */
  78890. _syncSubMeshes(): InstancedMesh;
  78891. /** @hidden */
  78892. _generatePointsArray(): boolean;
  78893. /**
  78894. * Creates a new InstancedMesh from the current mesh.
  78895. * - name (string) : the cloned mesh name
  78896. * - newParent (optional Node) : the optional Node to parent the clone to.
  78897. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  78898. *
  78899. * Returns the clone.
  78900. */
  78901. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  78902. /**
  78903. * Disposes the InstancedMesh.
  78904. * Returns nothing.
  78905. */
  78906. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  78907. }
  78908. }
  78909. declare module BABYLON {
  78910. /**
  78911. * Defines the options associated with the creation of a shader material.
  78912. */
  78913. export interface IShaderMaterialOptions {
  78914. /**
  78915. * Does the material work in alpha blend mode
  78916. */
  78917. needAlphaBlending: boolean;
  78918. /**
  78919. * Does the material work in alpha test mode
  78920. */
  78921. needAlphaTesting: boolean;
  78922. /**
  78923. * The list of attribute names used in the shader
  78924. */
  78925. attributes: string[];
  78926. /**
  78927. * The list of unifrom names used in the shader
  78928. */
  78929. uniforms: string[];
  78930. /**
  78931. * The list of UBO names used in the shader
  78932. */
  78933. uniformBuffers: string[];
  78934. /**
  78935. * The list of sampler names used in the shader
  78936. */
  78937. samplers: string[];
  78938. /**
  78939. * The list of defines used in the shader
  78940. */
  78941. defines: string[];
  78942. }
  78943. /**
  78944. * 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.
  78945. *
  78946. * This returned material effects how the mesh will look based on the code in the shaders.
  78947. *
  78948. * @see http://doc.babylonjs.com/how_to/shader_material
  78949. */
  78950. export class ShaderMaterial extends Material {
  78951. private _shaderPath;
  78952. private _options;
  78953. private _textures;
  78954. private _textureArrays;
  78955. private _floats;
  78956. private _ints;
  78957. private _floatsArrays;
  78958. private _colors3;
  78959. private _colors3Arrays;
  78960. private _colors4;
  78961. private _vectors2;
  78962. private _vectors3;
  78963. private _vectors4;
  78964. private _matrices;
  78965. private _matrices3x3;
  78966. private _matrices2x2;
  78967. private _vectors2Arrays;
  78968. private _vectors3Arrays;
  78969. private _cachedWorldViewMatrix;
  78970. private _cachedWorldViewProjectionMatrix;
  78971. private _renderId;
  78972. /**
  78973. * Instantiate a new shader material.
  78974. * 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.
  78975. * This returned material effects how the mesh will look based on the code in the shaders.
  78976. * @see http://doc.babylonjs.com/how_to/shader_material
  78977. * @param name Define the name of the material in the scene
  78978. * @param scene Define the scene the material belongs to
  78979. * @param shaderPath Defines the route to the shader code in one of three ways:
  78980. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  78981. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  78982. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  78983. * @param options Define the options used to create the shader
  78984. */
  78985. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  78986. /**
  78987. * Gets the options used to compile the shader.
  78988. * They can be modified to trigger a new compilation
  78989. */
  78990. readonly options: IShaderMaterialOptions;
  78991. /**
  78992. * Gets the current class name of the material e.g. "ShaderMaterial"
  78993. * Mainly use in serialization.
  78994. * @returns the class name
  78995. */
  78996. getClassName(): string;
  78997. /**
  78998. * Specifies if the material will require alpha blending
  78999. * @returns a boolean specifying if alpha blending is needed
  79000. */
  79001. needAlphaBlending(): boolean;
  79002. /**
  79003. * Specifies if this material should be rendered in alpha test mode
  79004. * @returns a boolean specifying if an alpha test is needed.
  79005. */
  79006. needAlphaTesting(): boolean;
  79007. private _checkUniform;
  79008. /**
  79009. * Set a texture in the shader.
  79010. * @param name Define the name of the uniform samplers as defined in the shader
  79011. * @param texture Define the texture to bind to this sampler
  79012. * @return the material itself allowing "fluent" like uniform updates
  79013. */
  79014. setTexture(name: string, texture: Texture): ShaderMaterial;
  79015. /**
  79016. * Set a texture array in the shader.
  79017. * @param name Define the name of the uniform sampler array as defined in the shader
  79018. * @param textures Define the list of textures to bind to this sampler
  79019. * @return the material itself allowing "fluent" like uniform updates
  79020. */
  79021. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  79022. /**
  79023. * Set a float in the shader.
  79024. * @param name Define the name of the uniform as defined in the shader
  79025. * @param value Define the value to give to the uniform
  79026. * @return the material itself allowing "fluent" like uniform updates
  79027. */
  79028. setFloat(name: string, value: number): ShaderMaterial;
  79029. /**
  79030. * Set a int in the shader.
  79031. * @param name Define the name of the uniform as defined in the shader
  79032. * @param value Define the value to give to the uniform
  79033. * @return the material itself allowing "fluent" like uniform updates
  79034. */
  79035. setInt(name: string, value: number): ShaderMaterial;
  79036. /**
  79037. * Set an array of floats in the shader.
  79038. * @param name Define the name of the uniform as defined in the shader
  79039. * @param value Define the value to give to the uniform
  79040. * @return the material itself allowing "fluent" like uniform updates
  79041. */
  79042. setFloats(name: string, value: number[]): ShaderMaterial;
  79043. /**
  79044. * Set a vec3 in the shader from a Color3.
  79045. * @param name Define the name of the uniform as defined in the shader
  79046. * @param value Define the value to give to the uniform
  79047. * @return the material itself allowing "fluent" like uniform updates
  79048. */
  79049. setColor3(name: string, value: Color3): ShaderMaterial;
  79050. /**
  79051. * Set a vec3 array in the shader from a Color3 array.
  79052. * @param name Define the name of the uniform as defined in the shader
  79053. * @param value Define the value to give to the uniform
  79054. * @return the material itself allowing "fluent" like uniform updates
  79055. */
  79056. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  79057. /**
  79058. * Set a vec4 in the shader from a Color4.
  79059. * @param name Define the name of the uniform as defined in the shader
  79060. * @param value Define the value to give to the uniform
  79061. * @return the material itself allowing "fluent" like uniform updates
  79062. */
  79063. setColor4(name: string, value: Color4): ShaderMaterial;
  79064. /**
  79065. * Set a vec2 in the shader from a Vector2.
  79066. * @param name Define the name of the uniform as defined in the shader
  79067. * @param value Define the value to give to the uniform
  79068. * @return the material itself allowing "fluent" like uniform updates
  79069. */
  79070. setVector2(name: string, value: Vector2): ShaderMaterial;
  79071. /**
  79072. * Set a vec3 in the shader from a Vector3.
  79073. * @param name Define the name of the uniform as defined in the shader
  79074. * @param value Define the value to give to the uniform
  79075. * @return the material itself allowing "fluent" like uniform updates
  79076. */
  79077. setVector3(name: string, value: Vector3): ShaderMaterial;
  79078. /**
  79079. * Set a vec4 in the shader from a Vector4.
  79080. * @param name Define the name of the uniform as defined in the shader
  79081. * @param value Define the value to give to the uniform
  79082. * @return the material itself allowing "fluent" like uniform updates
  79083. */
  79084. setVector4(name: string, value: Vector4): ShaderMaterial;
  79085. /**
  79086. * Set a mat4 in the shader from a Matrix.
  79087. * @param name Define the name of the uniform as defined in the shader
  79088. * @param value Define the value to give to the uniform
  79089. * @return the material itself allowing "fluent" like uniform updates
  79090. */
  79091. setMatrix(name: string, value: Matrix): ShaderMaterial;
  79092. /**
  79093. * Set a mat3 in the shader from a Float32Array.
  79094. * @param name Define the name of the uniform as defined in the shader
  79095. * @param value Define the value to give to the uniform
  79096. * @return the material itself allowing "fluent" like uniform updates
  79097. */
  79098. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  79099. /**
  79100. * Set a mat2 in the shader from a Float32Array.
  79101. * @param name Define the name of the uniform as defined in the shader
  79102. * @param value Define the value to give to the uniform
  79103. * @return the material itself allowing "fluent" like uniform updates
  79104. */
  79105. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  79106. /**
  79107. * Set a vec2 array in the shader from a number array.
  79108. * @param name Define the name of the uniform as defined in the shader
  79109. * @param value Define the value to give to the uniform
  79110. * @return the material itself allowing "fluent" like uniform updates
  79111. */
  79112. setArray2(name: string, value: number[]): ShaderMaterial;
  79113. /**
  79114. * Set a vec3 array in the shader from a number array.
  79115. * @param name Define the name of the uniform as defined in the shader
  79116. * @param value Define the value to give to the uniform
  79117. * @return the material itself allowing "fluent" like uniform updates
  79118. */
  79119. setArray3(name: string, value: number[]): ShaderMaterial;
  79120. private _checkCache;
  79121. /**
  79122. * Specifies that the submesh is ready to be used
  79123. * @param mesh defines the mesh to check
  79124. * @param subMesh defines which submesh to check
  79125. * @param useInstances specifies that instances should be used
  79126. * @returns a boolean indicating that the submesh is ready or not
  79127. */
  79128. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  79129. /**
  79130. * Checks if the material is ready to render the requested mesh
  79131. * @param mesh Define the mesh to render
  79132. * @param useInstances Define whether or not the material is used with instances
  79133. * @returns true if ready, otherwise false
  79134. */
  79135. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  79136. /**
  79137. * Binds the world matrix to the material
  79138. * @param world defines the world transformation matrix
  79139. */
  79140. bindOnlyWorldMatrix(world: Matrix): void;
  79141. /**
  79142. * Binds the material to the mesh
  79143. * @param world defines the world transformation matrix
  79144. * @param mesh defines the mesh to bind the material to
  79145. */
  79146. bind(world: Matrix, mesh?: Mesh): void;
  79147. /**
  79148. * Gets the active textures from the material
  79149. * @returns an array of textures
  79150. */
  79151. getActiveTextures(): BaseTexture[];
  79152. /**
  79153. * Specifies if the material uses a texture
  79154. * @param texture defines the texture to check against the material
  79155. * @returns a boolean specifying if the material uses the texture
  79156. */
  79157. hasTexture(texture: BaseTexture): boolean;
  79158. /**
  79159. * Makes a duplicate of the material, and gives it a new name
  79160. * @param name defines the new name for the duplicated material
  79161. * @returns the cloned material
  79162. */
  79163. clone(name: string): ShaderMaterial;
  79164. /**
  79165. * Disposes the material
  79166. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  79167. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  79168. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  79169. */
  79170. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  79171. /**
  79172. * Serializes this material in a JSON representation
  79173. * @returns the serialized material object
  79174. */
  79175. serialize(): any;
  79176. /**
  79177. * Creates a shader material from parsed shader material data
  79178. * @param source defines the JSON represnetation of the material
  79179. * @param scene defines the hosting scene
  79180. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  79181. * @returns a new material
  79182. */
  79183. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  79184. }
  79185. }
  79186. declare module BABYLON {
  79187. /** @hidden */
  79188. export var colorPixelShader: {
  79189. name: string;
  79190. shader: string;
  79191. };
  79192. }
  79193. declare module BABYLON {
  79194. /** @hidden */
  79195. export var colorVertexShader: {
  79196. name: string;
  79197. shader: string;
  79198. };
  79199. }
  79200. declare module BABYLON {
  79201. /**
  79202. * Line mesh
  79203. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  79204. */
  79205. export class LinesMesh extends Mesh {
  79206. /**
  79207. * If vertex color should be applied to the mesh
  79208. */
  79209. readonly useVertexColor?: boolean | undefined;
  79210. /**
  79211. * If vertex alpha should be applied to the mesh
  79212. */
  79213. readonly useVertexAlpha?: boolean | undefined;
  79214. /**
  79215. * Color of the line (Default: White)
  79216. */
  79217. color: Color3;
  79218. /**
  79219. * Alpha of the line (Default: 1)
  79220. */
  79221. alpha: number;
  79222. /**
  79223. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79224. * This margin is expressed in world space coordinates, so its value may vary.
  79225. * Default value is 0.1
  79226. */
  79227. intersectionThreshold: number;
  79228. private _colorShader;
  79229. private color4;
  79230. /**
  79231. * Creates a new LinesMesh
  79232. * @param name defines the name
  79233. * @param scene defines the hosting scene
  79234. * @param parent defines the parent mesh if any
  79235. * @param source defines the optional source LinesMesh used to clone data from
  79236. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  79237. * When false, achieved by calling a clone(), also passing False.
  79238. * This will make creation of children, recursive.
  79239. * @param useVertexColor defines if this LinesMesh supports vertex color
  79240. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  79241. */
  79242. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  79243. /**
  79244. * If vertex color should be applied to the mesh
  79245. */
  79246. useVertexColor?: boolean | undefined,
  79247. /**
  79248. * If vertex alpha should be applied to the mesh
  79249. */
  79250. useVertexAlpha?: boolean | undefined);
  79251. private _addClipPlaneDefine;
  79252. private _removeClipPlaneDefine;
  79253. isReady(): boolean;
  79254. /**
  79255. * Returns the string "LineMesh"
  79256. */
  79257. getClassName(): string;
  79258. /**
  79259. * @hidden
  79260. */
  79261. /**
  79262. * @hidden
  79263. */
  79264. material: Material;
  79265. /**
  79266. * @hidden
  79267. */
  79268. readonly checkCollisions: boolean;
  79269. /** @hidden */
  79270. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  79271. /** @hidden */
  79272. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  79273. /**
  79274. * Disposes of the line mesh
  79275. * @param doNotRecurse If children should be disposed
  79276. */
  79277. dispose(doNotRecurse?: boolean): void;
  79278. /**
  79279. * Returns a new LineMesh object cloned from the current one.
  79280. */
  79281. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  79282. /**
  79283. * Creates a new InstancedLinesMesh object from the mesh model.
  79284. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  79285. * @param name defines the name of the new instance
  79286. * @returns a new InstancedLinesMesh
  79287. */
  79288. createInstance(name: string): InstancedLinesMesh;
  79289. }
  79290. /**
  79291. * Creates an instance based on a source LinesMesh
  79292. */
  79293. export class InstancedLinesMesh extends InstancedMesh {
  79294. /**
  79295. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  79296. * This margin is expressed in world space coordinates, so its value may vary.
  79297. * Initilized with the intersectionThreshold value of the source LinesMesh
  79298. */
  79299. intersectionThreshold: number;
  79300. constructor(name: string, source: LinesMesh);
  79301. /**
  79302. * Returns the string "InstancedLinesMesh".
  79303. */
  79304. getClassName(): string;
  79305. }
  79306. }
  79307. declare module BABYLON {
  79308. /** @hidden */
  79309. export var linePixelShader: {
  79310. name: string;
  79311. shader: string;
  79312. };
  79313. }
  79314. declare module BABYLON {
  79315. /** @hidden */
  79316. export var lineVertexShader: {
  79317. name: string;
  79318. shader: string;
  79319. };
  79320. }
  79321. declare module BABYLON {
  79322. interface AbstractMesh {
  79323. /**
  79324. * Gets the edgesRenderer associated with the mesh
  79325. */
  79326. edgesRenderer: Nullable<EdgesRenderer>;
  79327. }
  79328. interface LinesMesh {
  79329. /**
  79330. * Enables the edge rendering mode on the mesh.
  79331. * This mode makes the mesh edges visible
  79332. * @param epsilon defines the maximal distance between two angles to detect a face
  79333. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79334. * @returns the currentAbstractMesh
  79335. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79336. */
  79337. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  79338. }
  79339. interface InstancedLinesMesh {
  79340. /**
  79341. * Enables the edge rendering mode on the mesh.
  79342. * This mode makes the mesh edges visible
  79343. * @param epsilon defines the maximal distance between two angles to detect a face
  79344. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  79345. * @returns the current InstancedLinesMesh
  79346. * @see https://www.babylonjs-playground.com/#19O9TU#0
  79347. */
  79348. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  79349. }
  79350. /**
  79351. * Defines the minimum contract an Edges renderer should follow.
  79352. */
  79353. export interface IEdgesRenderer extends IDisposable {
  79354. /**
  79355. * Gets or sets a boolean indicating if the edgesRenderer is active
  79356. */
  79357. isEnabled: boolean;
  79358. /**
  79359. * Renders the edges of the attached mesh,
  79360. */
  79361. render(): void;
  79362. /**
  79363. * Checks wether or not the edges renderer is ready to render.
  79364. * @return true if ready, otherwise false.
  79365. */
  79366. isReady(): boolean;
  79367. }
  79368. /**
  79369. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  79370. */
  79371. export class EdgesRenderer implements IEdgesRenderer {
  79372. /**
  79373. * Define the size of the edges with an orthographic camera
  79374. */
  79375. edgesWidthScalerForOrthographic: number;
  79376. /**
  79377. * Define the size of the edges with a perspective camera
  79378. */
  79379. edgesWidthScalerForPerspective: number;
  79380. protected _source: AbstractMesh;
  79381. protected _linesPositions: number[];
  79382. protected _linesNormals: number[];
  79383. protected _linesIndices: number[];
  79384. protected _epsilon: number;
  79385. protected _indicesCount: number;
  79386. protected _lineShader: ShaderMaterial;
  79387. protected _ib: DataBuffer;
  79388. protected _buffers: {
  79389. [key: string]: Nullable<VertexBuffer>;
  79390. };
  79391. protected _checkVerticesInsteadOfIndices: boolean;
  79392. private _meshRebuildObserver;
  79393. private _meshDisposeObserver;
  79394. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  79395. isEnabled: boolean;
  79396. /**
  79397. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  79398. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  79399. * @param source Mesh used to create edges
  79400. * @param epsilon sum of angles in adjacency to check for edge
  79401. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  79402. * @param generateEdgesLines - should generate Lines or only prepare resources.
  79403. */
  79404. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  79405. protected _prepareRessources(): void;
  79406. /** @hidden */
  79407. _rebuild(): void;
  79408. /**
  79409. * Releases the required resources for the edges renderer
  79410. */
  79411. dispose(): void;
  79412. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  79413. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  79414. /**
  79415. * Checks if the pair of p0 and p1 is en edge
  79416. * @param faceIndex
  79417. * @param edge
  79418. * @param faceNormals
  79419. * @param p0
  79420. * @param p1
  79421. * @private
  79422. */
  79423. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  79424. /**
  79425. * push line into the position, normal and index buffer
  79426. * @protected
  79427. */
  79428. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  79429. /**
  79430. * Generates lines edges from adjacencjes
  79431. * @private
  79432. */
  79433. _generateEdgesLines(): void;
  79434. /**
  79435. * Checks wether or not the edges renderer is ready to render.
  79436. * @return true if ready, otherwise false.
  79437. */
  79438. isReady(): boolean;
  79439. /**
  79440. * Renders the edges of the attached mesh,
  79441. */
  79442. render(): void;
  79443. }
  79444. /**
  79445. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  79446. */
  79447. export class LineEdgesRenderer extends EdgesRenderer {
  79448. /**
  79449. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  79450. * @param source LineMesh used to generate edges
  79451. * @param epsilon not important (specified angle for edge detection)
  79452. * @param checkVerticesInsteadOfIndices not important for LineMesh
  79453. */
  79454. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  79455. /**
  79456. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  79457. */
  79458. _generateEdgesLines(): void;
  79459. }
  79460. }
  79461. declare module BABYLON {
  79462. /**
  79463. * This represents the object necessary to create a rendering group.
  79464. * This is exclusively used and created by the rendering manager.
  79465. * To modify the behavior, you use the available helpers in your scene or meshes.
  79466. * @hidden
  79467. */
  79468. export class RenderingGroup {
  79469. index: number;
  79470. private static _zeroVector;
  79471. private _scene;
  79472. private _opaqueSubMeshes;
  79473. private _transparentSubMeshes;
  79474. private _alphaTestSubMeshes;
  79475. private _depthOnlySubMeshes;
  79476. private _particleSystems;
  79477. private _spriteManagers;
  79478. private _opaqueSortCompareFn;
  79479. private _alphaTestSortCompareFn;
  79480. private _transparentSortCompareFn;
  79481. private _renderOpaque;
  79482. private _renderAlphaTest;
  79483. private _renderTransparent;
  79484. /** @hidden */
  79485. _edgesRenderers: SmartArray<IEdgesRenderer>;
  79486. onBeforeTransparentRendering: () => void;
  79487. /**
  79488. * Set the opaque sort comparison function.
  79489. * If null the sub meshes will be render in the order they were created
  79490. */
  79491. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79492. /**
  79493. * Set the alpha test sort comparison function.
  79494. * If null the sub meshes will be render in the order they were created
  79495. */
  79496. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79497. /**
  79498. * Set the transparent sort comparison function.
  79499. * If null the sub meshes will be render in the order they were created
  79500. */
  79501. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  79502. /**
  79503. * Creates a new rendering group.
  79504. * @param index The rendering group index
  79505. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  79506. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  79507. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  79508. */
  79509. 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>);
  79510. /**
  79511. * Render all the sub meshes contained in the group.
  79512. * @param customRenderFunction Used to override the default render behaviour of the group.
  79513. * @returns true if rendered some submeshes.
  79514. */
  79515. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  79516. /**
  79517. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  79518. * @param subMeshes The submeshes to render
  79519. */
  79520. private renderOpaqueSorted;
  79521. /**
  79522. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  79523. * @param subMeshes The submeshes to render
  79524. */
  79525. private renderAlphaTestSorted;
  79526. /**
  79527. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  79528. * @param subMeshes The submeshes to render
  79529. */
  79530. private renderTransparentSorted;
  79531. /**
  79532. * Renders the submeshes in a specified order.
  79533. * @param subMeshes The submeshes to sort before render
  79534. * @param sortCompareFn The comparison function use to sort
  79535. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  79536. * @param transparent Specifies to activate blending if true
  79537. */
  79538. private static renderSorted;
  79539. /**
  79540. * Renders the submeshes in the order they were dispatched (no sort applied).
  79541. * @param subMeshes The submeshes to render
  79542. */
  79543. private static renderUnsorted;
  79544. /**
  79545. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79546. * are rendered back to front if in the same alpha index.
  79547. *
  79548. * @param a The first submesh
  79549. * @param b The second submesh
  79550. * @returns The result of the comparison
  79551. */
  79552. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  79553. /**
  79554. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79555. * are rendered back to front.
  79556. *
  79557. * @param a The first submesh
  79558. * @param b The second submesh
  79559. * @returns The result of the comparison
  79560. */
  79561. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  79562. /**
  79563. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  79564. * are rendered front to back (prevent overdraw).
  79565. *
  79566. * @param a The first submesh
  79567. * @param b The second submesh
  79568. * @returns The result of the comparison
  79569. */
  79570. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  79571. /**
  79572. * Resets the different lists of submeshes to prepare a new frame.
  79573. */
  79574. prepare(): void;
  79575. dispose(): void;
  79576. /**
  79577. * Inserts the submesh in its correct queue depending on its material.
  79578. * @param subMesh The submesh to dispatch
  79579. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  79580. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  79581. */
  79582. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  79583. dispatchSprites(spriteManager: ISpriteManager): void;
  79584. dispatchParticles(particleSystem: IParticleSystem): void;
  79585. private _renderParticles;
  79586. private _renderSprites;
  79587. }
  79588. }
  79589. declare module BABYLON {
  79590. /**
  79591. * Interface describing the different options available in the rendering manager
  79592. * regarding Auto Clear between groups.
  79593. */
  79594. export interface IRenderingManagerAutoClearSetup {
  79595. /**
  79596. * Defines whether or not autoclear is enable.
  79597. */
  79598. autoClear: boolean;
  79599. /**
  79600. * Defines whether or not to autoclear the depth buffer.
  79601. */
  79602. depth: boolean;
  79603. /**
  79604. * Defines whether or not to autoclear the stencil buffer.
  79605. */
  79606. stencil: boolean;
  79607. }
  79608. /**
  79609. * This class is used by the onRenderingGroupObservable
  79610. */
  79611. export class RenderingGroupInfo {
  79612. /**
  79613. * The Scene that being rendered
  79614. */
  79615. scene: Scene;
  79616. /**
  79617. * The camera currently used for the rendering pass
  79618. */
  79619. camera: Nullable<Camera>;
  79620. /**
  79621. * The ID of the renderingGroup being processed
  79622. */
  79623. renderingGroupId: number;
  79624. }
  79625. /**
  79626. * This is the manager responsible of all the rendering for meshes sprites and particles.
  79627. * It is enable to manage the different groups as well as the different necessary sort functions.
  79628. * This should not be used directly aside of the few static configurations
  79629. */
  79630. export class RenderingManager {
  79631. /**
  79632. * The max id used for rendering groups (not included)
  79633. */
  79634. static MAX_RENDERINGGROUPS: number;
  79635. /**
  79636. * The min id used for rendering groups (included)
  79637. */
  79638. static MIN_RENDERINGGROUPS: number;
  79639. /**
  79640. * Used to globally prevent autoclearing scenes.
  79641. */
  79642. static AUTOCLEAR: boolean;
  79643. /**
  79644. * @hidden
  79645. */
  79646. _useSceneAutoClearSetup: boolean;
  79647. private _scene;
  79648. private _renderingGroups;
  79649. private _depthStencilBufferAlreadyCleaned;
  79650. private _autoClearDepthStencil;
  79651. private _customOpaqueSortCompareFn;
  79652. private _customAlphaTestSortCompareFn;
  79653. private _customTransparentSortCompareFn;
  79654. private _renderingGroupInfo;
  79655. /**
  79656. * Instantiates a new rendering group for a particular scene
  79657. * @param scene Defines the scene the groups belongs to
  79658. */
  79659. constructor(scene: Scene);
  79660. private _clearDepthStencilBuffer;
  79661. /**
  79662. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  79663. * @hidden
  79664. */
  79665. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  79666. /**
  79667. * Resets the different information of the group to prepare a new frame
  79668. * @hidden
  79669. */
  79670. reset(): void;
  79671. /**
  79672. * Dispose and release the group and its associated resources.
  79673. * @hidden
  79674. */
  79675. dispose(): void;
  79676. /**
  79677. * Clear the info related to rendering groups preventing retention points during dispose.
  79678. */
  79679. freeRenderingGroups(): void;
  79680. private _prepareRenderingGroup;
  79681. /**
  79682. * Add a sprite manager to the rendering manager in order to render it this frame.
  79683. * @param spriteManager Define the sprite manager to render
  79684. */
  79685. dispatchSprites(spriteManager: ISpriteManager): void;
  79686. /**
  79687. * Add a particle system to the rendering manager in order to render it this frame.
  79688. * @param particleSystem Define the particle system to render
  79689. */
  79690. dispatchParticles(particleSystem: IParticleSystem): void;
  79691. /**
  79692. * Add a submesh to the manager in order to render it this frame
  79693. * @param subMesh The submesh to dispatch
  79694. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  79695. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  79696. */
  79697. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  79698. /**
  79699. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  79700. * This allowed control for front to back rendering or reversly depending of the special needs.
  79701. *
  79702. * @param renderingGroupId The rendering group id corresponding to its index
  79703. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  79704. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  79705. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  79706. */
  79707. 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;
  79708. /**
  79709. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  79710. *
  79711. * @param renderingGroupId The rendering group id corresponding to its index
  79712. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  79713. * @param depth Automatically clears depth between groups if true and autoClear is true.
  79714. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  79715. */
  79716. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  79717. /**
  79718. * Gets the current auto clear configuration for one rendering group of the rendering
  79719. * manager.
  79720. * @param index the rendering group index to get the information for
  79721. * @returns The auto clear setup for the requested rendering group
  79722. */
  79723. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  79724. }
  79725. }
  79726. declare module BABYLON {
  79727. /**
  79728. * This Helps creating a texture that will be created from a camera in your scene.
  79729. * It is basically a dynamic texture that could be used to create special effects for instance.
  79730. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  79731. */
  79732. export class RenderTargetTexture extends Texture {
  79733. isCube: boolean;
  79734. /**
  79735. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  79736. */
  79737. static readonly REFRESHRATE_RENDER_ONCE: number;
  79738. /**
  79739. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  79740. */
  79741. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  79742. /**
  79743. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  79744. * the central point of your effect and can save a lot of performances.
  79745. */
  79746. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  79747. /**
  79748. * Use this predicate to dynamically define the list of mesh you want to render.
  79749. * If set, the renderList property will be overwritten.
  79750. */
  79751. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  79752. private _renderList;
  79753. /**
  79754. * Use this list to define the list of mesh you want to render.
  79755. */
  79756. renderList: Nullable<Array<AbstractMesh>>;
  79757. private _hookArray;
  79758. /**
  79759. * Define if particles should be rendered in your texture.
  79760. */
  79761. renderParticles: boolean;
  79762. /**
  79763. * Define if sprites should be rendered in your texture.
  79764. */
  79765. renderSprites: boolean;
  79766. /**
  79767. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  79768. */
  79769. coordinatesMode: number;
  79770. /**
  79771. * Define the camera used to render the texture.
  79772. */
  79773. activeCamera: Nullable<Camera>;
  79774. /**
  79775. * Override the render function of the texture with your own one.
  79776. */
  79777. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  79778. /**
  79779. * Define if camera post processes should be use while rendering the texture.
  79780. */
  79781. useCameraPostProcesses: boolean;
  79782. /**
  79783. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  79784. */
  79785. ignoreCameraViewport: boolean;
  79786. private _postProcessManager;
  79787. private _postProcesses;
  79788. private _resizeObserver;
  79789. /**
  79790. * An event triggered when the texture is unbind.
  79791. */
  79792. onBeforeBindObservable: Observable<RenderTargetTexture>;
  79793. /**
  79794. * An event triggered when the texture is unbind.
  79795. */
  79796. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  79797. private _onAfterUnbindObserver;
  79798. /**
  79799. * Set a after unbind callback in the texture.
  79800. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  79801. */
  79802. onAfterUnbind: () => void;
  79803. /**
  79804. * An event triggered before rendering the texture
  79805. */
  79806. onBeforeRenderObservable: Observable<number>;
  79807. private _onBeforeRenderObserver;
  79808. /**
  79809. * Set a before render callback in the texture.
  79810. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  79811. */
  79812. onBeforeRender: (faceIndex: number) => void;
  79813. /**
  79814. * An event triggered after rendering the texture
  79815. */
  79816. onAfterRenderObservable: Observable<number>;
  79817. private _onAfterRenderObserver;
  79818. /**
  79819. * Set a after render callback in the texture.
  79820. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  79821. */
  79822. onAfterRender: (faceIndex: number) => void;
  79823. /**
  79824. * An event triggered after the texture clear
  79825. */
  79826. onClearObservable: Observable<Engine>;
  79827. private _onClearObserver;
  79828. /**
  79829. * Set a clear callback in the texture.
  79830. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  79831. */
  79832. onClear: (Engine: Engine) => void;
  79833. /**
  79834. * Define the clear color of the Render Target if it should be different from the scene.
  79835. */
  79836. clearColor: Color4;
  79837. protected _size: number | {
  79838. width: number;
  79839. height: number;
  79840. };
  79841. protected _initialSizeParameter: number | {
  79842. width: number;
  79843. height: number;
  79844. } | {
  79845. ratio: number;
  79846. };
  79847. protected _sizeRatio: Nullable<number>;
  79848. /** @hidden */
  79849. _generateMipMaps: boolean;
  79850. protected _renderingManager: RenderingManager;
  79851. /** @hidden */
  79852. _waitingRenderList: string[];
  79853. protected _doNotChangeAspectRatio: boolean;
  79854. protected _currentRefreshId: number;
  79855. protected _refreshRate: number;
  79856. protected _textureMatrix: Matrix;
  79857. protected _samples: number;
  79858. protected _renderTargetOptions: RenderTargetCreationOptions;
  79859. /**
  79860. * Gets render target creation options that were used.
  79861. */
  79862. readonly renderTargetOptions: RenderTargetCreationOptions;
  79863. protected _engine: Engine;
  79864. protected _onRatioRescale(): void;
  79865. /**
  79866. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  79867. * It must define where the camera used to render the texture is set
  79868. */
  79869. boundingBoxPosition: Vector3;
  79870. private _boundingBoxSize;
  79871. /**
  79872. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  79873. * When defined, the cubemap will switch to local mode
  79874. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  79875. * @example https://www.babylonjs-playground.com/#RNASML
  79876. */
  79877. boundingBoxSize: Vector3;
  79878. /**
  79879. * In case the RTT has been created with a depth texture, get the associated
  79880. * depth texture.
  79881. * Otherwise, return null.
  79882. */
  79883. depthStencilTexture: Nullable<InternalTexture>;
  79884. /**
  79885. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  79886. * or used a shadow, depth texture...
  79887. * @param name The friendly name of the texture
  79888. * @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)
  79889. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  79890. * @param generateMipMaps True if mip maps need to be generated after render.
  79891. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  79892. * @param type The type of the buffer in the RTT (int, half float, float...)
  79893. * @param isCube True if a cube texture needs to be created
  79894. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  79895. * @param generateDepthBuffer True to generate a depth buffer
  79896. * @param generateStencilBuffer True to generate a stencil buffer
  79897. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  79898. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  79899. * @param delayAllocation if the texture allocation should be delayed (default: false)
  79900. */
  79901. constructor(name: string, size: number | {
  79902. width: number;
  79903. height: number;
  79904. } | {
  79905. ratio: number;
  79906. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  79907. /**
  79908. * Creates a depth stencil texture.
  79909. * This is only available in WebGL 2 or with the depth texture extension available.
  79910. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  79911. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  79912. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  79913. */
  79914. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  79915. private _processSizeParameter;
  79916. /**
  79917. * Define the number of samples to use in case of MSAA.
  79918. * It defaults to one meaning no MSAA has been enabled.
  79919. */
  79920. samples: number;
  79921. /**
  79922. * Resets the refresh counter of the texture and start bak from scratch.
  79923. * Could be useful to regenerate the texture if it is setup to render only once.
  79924. */
  79925. resetRefreshCounter(): void;
  79926. /**
  79927. * Define the refresh rate of the texture or the rendering frequency.
  79928. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  79929. */
  79930. refreshRate: number;
  79931. /**
  79932. * Adds a post process to the render target rendering passes.
  79933. * @param postProcess define the post process to add
  79934. */
  79935. addPostProcess(postProcess: PostProcess): void;
  79936. /**
  79937. * Clear all the post processes attached to the render target
  79938. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  79939. */
  79940. clearPostProcesses(dispose?: boolean): void;
  79941. /**
  79942. * Remove one of the post process from the list of attached post processes to the texture
  79943. * @param postProcess define the post process to remove from the list
  79944. */
  79945. removePostProcess(postProcess: PostProcess): void;
  79946. /** @hidden */
  79947. _shouldRender(): boolean;
  79948. /**
  79949. * Gets the actual render size of the texture.
  79950. * @returns the width of the render size
  79951. */
  79952. getRenderSize(): number;
  79953. /**
  79954. * Gets the actual render width of the texture.
  79955. * @returns the width of the render size
  79956. */
  79957. getRenderWidth(): number;
  79958. /**
  79959. * Gets the actual render height of the texture.
  79960. * @returns the height of the render size
  79961. */
  79962. getRenderHeight(): number;
  79963. /**
  79964. * Get if the texture can be rescaled or not.
  79965. */
  79966. readonly canRescale: boolean;
  79967. /**
  79968. * Resize the texture using a ratio.
  79969. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  79970. */
  79971. scale(ratio: number): void;
  79972. /**
  79973. * Get the texture reflection matrix used to rotate/transform the reflection.
  79974. * @returns the reflection matrix
  79975. */
  79976. getReflectionTextureMatrix(): Matrix;
  79977. /**
  79978. * Resize the texture to a new desired size.
  79979. * Be carrefull as it will recreate all the data in the new texture.
  79980. * @param size Define the new size. It can be:
  79981. * - a number for squared texture,
  79982. * - an object containing { width: number, height: number }
  79983. * - or an object containing a ratio { ratio: number }
  79984. */
  79985. resize(size: number | {
  79986. width: number;
  79987. height: number;
  79988. } | {
  79989. ratio: number;
  79990. }): void;
  79991. /**
  79992. * Renders all the objects from the render list into the texture.
  79993. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  79994. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  79995. */
  79996. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  79997. private _bestReflectionRenderTargetDimension;
  79998. /**
  79999. * @hidden
  80000. * @param faceIndex face index to bind to if this is a cubetexture
  80001. */
  80002. _bindFrameBuffer(faceIndex?: number): void;
  80003. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  80004. private renderToTarget;
  80005. /**
  80006. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  80007. * This allowed control for front to back rendering or reversly depending of the special needs.
  80008. *
  80009. * @param renderingGroupId The rendering group id corresponding to its index
  80010. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  80011. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  80012. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  80013. */
  80014. 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;
  80015. /**
  80016. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  80017. *
  80018. * @param renderingGroupId The rendering group id corresponding to its index
  80019. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  80020. */
  80021. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  80022. /**
  80023. * Clones the texture.
  80024. * @returns the cloned texture
  80025. */
  80026. clone(): RenderTargetTexture;
  80027. /**
  80028. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80029. * @returns The JSON representation of the texture
  80030. */
  80031. serialize(): any;
  80032. /**
  80033. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  80034. */
  80035. disposeFramebufferObjects(): void;
  80036. /**
  80037. * Dispose the texture and release its associated resources.
  80038. */
  80039. dispose(): void;
  80040. /** @hidden */
  80041. _rebuild(): void;
  80042. /**
  80043. * Clear the info related to rendering groups preventing retention point in material dispose.
  80044. */
  80045. freeRenderingGroups(): void;
  80046. /**
  80047. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  80048. * @returns the view count
  80049. */
  80050. getViewCount(): number;
  80051. }
  80052. }
  80053. declare module BABYLON {
  80054. /**
  80055. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80056. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80057. * You can then easily use it as a reflectionTexture on a flat surface.
  80058. * In case the surface is not a plane, please consider relying on reflection probes.
  80059. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80060. */
  80061. export class MirrorTexture extends RenderTargetTexture {
  80062. private scene;
  80063. /**
  80064. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  80065. * 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.
  80066. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80067. */
  80068. mirrorPlane: Plane;
  80069. /**
  80070. * Define the blur ratio used to blur the reflection if needed.
  80071. */
  80072. blurRatio: number;
  80073. /**
  80074. * Define the adaptive blur kernel used to blur the reflection if needed.
  80075. * This will autocompute the closest best match for the `blurKernel`
  80076. */
  80077. adaptiveBlurKernel: number;
  80078. /**
  80079. * Define the blur kernel used to blur the reflection if needed.
  80080. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80081. */
  80082. blurKernel: number;
  80083. /**
  80084. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  80085. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80086. */
  80087. blurKernelX: number;
  80088. /**
  80089. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  80090. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  80091. */
  80092. blurKernelY: number;
  80093. private _autoComputeBlurKernel;
  80094. protected _onRatioRescale(): void;
  80095. private _updateGammaSpace;
  80096. private _imageProcessingConfigChangeObserver;
  80097. private _transformMatrix;
  80098. private _mirrorMatrix;
  80099. private _savedViewMatrix;
  80100. private _blurX;
  80101. private _blurY;
  80102. private _adaptiveBlurKernel;
  80103. private _blurKernelX;
  80104. private _blurKernelY;
  80105. private _blurRatio;
  80106. /**
  80107. * Instantiates a Mirror Texture.
  80108. * Mirror texture can be used to simulate the view from a mirror in a scene.
  80109. * It will dynamically be rendered every frame to adapt to the camera point of view.
  80110. * You can then easily use it as a reflectionTexture on a flat surface.
  80111. * In case the surface is not a plane, please consider relying on reflection probes.
  80112. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  80113. * @param name
  80114. * @param size
  80115. * @param scene
  80116. * @param generateMipMaps
  80117. * @param type
  80118. * @param samplingMode
  80119. * @param generateDepthBuffer
  80120. */
  80121. constructor(name: string, size: number | {
  80122. width: number;
  80123. height: number;
  80124. } | {
  80125. ratio: number;
  80126. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  80127. private _preparePostProcesses;
  80128. /**
  80129. * Clone the mirror texture.
  80130. * @returns the cloned texture
  80131. */
  80132. clone(): MirrorTexture;
  80133. /**
  80134. * Serialize the texture to a JSON representation you could use in Parse later on
  80135. * @returns the serialized JSON representation
  80136. */
  80137. serialize(): any;
  80138. /**
  80139. * Dispose the texture and release its associated resources.
  80140. */
  80141. dispose(): void;
  80142. }
  80143. }
  80144. declare module BABYLON {
  80145. /**
  80146. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80147. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80148. */
  80149. export class Texture extends BaseTexture {
  80150. /** @hidden */
  80151. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  80152. /** @hidden */
  80153. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  80154. /** @hidden */
  80155. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  80156. /** nearest is mag = nearest and min = nearest and mip = linear */
  80157. static readonly NEAREST_SAMPLINGMODE: number;
  80158. /** nearest is mag = nearest and min = nearest and mip = linear */
  80159. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  80160. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80161. static readonly BILINEAR_SAMPLINGMODE: number;
  80162. /** Bilinear is mag = linear and min = linear and mip = nearest */
  80163. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  80164. /** Trilinear is mag = linear and min = linear and mip = linear */
  80165. static readonly TRILINEAR_SAMPLINGMODE: number;
  80166. /** Trilinear is mag = linear and min = linear and mip = linear */
  80167. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  80168. /** mag = nearest and min = nearest and mip = nearest */
  80169. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  80170. /** mag = nearest and min = linear and mip = nearest */
  80171. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  80172. /** mag = nearest and min = linear and mip = linear */
  80173. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  80174. /** mag = nearest and min = linear and mip = none */
  80175. static readonly NEAREST_LINEAR: number;
  80176. /** mag = nearest and min = nearest and mip = none */
  80177. static readonly NEAREST_NEAREST: number;
  80178. /** mag = linear and min = nearest and mip = nearest */
  80179. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  80180. /** mag = linear and min = nearest and mip = linear */
  80181. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  80182. /** mag = linear and min = linear and mip = none */
  80183. static readonly LINEAR_LINEAR: number;
  80184. /** mag = linear and min = nearest and mip = none */
  80185. static readonly LINEAR_NEAREST: number;
  80186. /** Explicit coordinates mode */
  80187. static readonly EXPLICIT_MODE: number;
  80188. /** Spherical coordinates mode */
  80189. static readonly SPHERICAL_MODE: number;
  80190. /** Planar coordinates mode */
  80191. static readonly PLANAR_MODE: number;
  80192. /** Cubic coordinates mode */
  80193. static readonly CUBIC_MODE: number;
  80194. /** Projection coordinates mode */
  80195. static readonly PROJECTION_MODE: number;
  80196. /** Inverse Cubic coordinates mode */
  80197. static readonly SKYBOX_MODE: number;
  80198. /** Inverse Cubic coordinates mode */
  80199. static readonly INVCUBIC_MODE: number;
  80200. /** Equirectangular coordinates mode */
  80201. static readonly EQUIRECTANGULAR_MODE: number;
  80202. /** Equirectangular Fixed coordinates mode */
  80203. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  80204. /** Equirectangular Fixed Mirrored coordinates mode */
  80205. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  80206. /** Texture is not repeating outside of 0..1 UVs */
  80207. static readonly CLAMP_ADDRESSMODE: number;
  80208. /** Texture is repeating outside of 0..1 UVs */
  80209. static readonly WRAP_ADDRESSMODE: number;
  80210. /** Texture is repeating and mirrored */
  80211. static readonly MIRROR_ADDRESSMODE: number;
  80212. /**
  80213. * 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
  80214. */
  80215. static UseSerializedUrlIfAny: boolean;
  80216. /**
  80217. * Define the url of the texture.
  80218. */
  80219. url: Nullable<string>;
  80220. /**
  80221. * Define an offset on the texture to offset the u coordinates of the UVs
  80222. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80223. */
  80224. uOffset: number;
  80225. /**
  80226. * Define an offset on the texture to offset the v coordinates of the UVs
  80227. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  80228. */
  80229. vOffset: number;
  80230. /**
  80231. * Define an offset on the texture to scale the u coordinates of the UVs
  80232. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80233. */
  80234. uScale: number;
  80235. /**
  80236. * Define an offset on the texture to scale the v coordinates of the UVs
  80237. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  80238. */
  80239. vScale: number;
  80240. /**
  80241. * Define an offset on the texture to rotate around the u coordinates of the UVs
  80242. * @see http://doc.babylonjs.com/how_to/more_materials
  80243. */
  80244. uAng: number;
  80245. /**
  80246. * Define an offset on the texture to rotate around the v coordinates of the UVs
  80247. * @see http://doc.babylonjs.com/how_to/more_materials
  80248. */
  80249. vAng: number;
  80250. /**
  80251. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  80252. * @see http://doc.babylonjs.com/how_to/more_materials
  80253. */
  80254. wAng: number;
  80255. /**
  80256. * Defines the center of rotation (U)
  80257. */
  80258. uRotationCenter: number;
  80259. /**
  80260. * Defines the center of rotation (V)
  80261. */
  80262. vRotationCenter: number;
  80263. /**
  80264. * Defines the center of rotation (W)
  80265. */
  80266. wRotationCenter: number;
  80267. /**
  80268. * Are mip maps generated for this texture or not.
  80269. */
  80270. readonly noMipmap: boolean;
  80271. /**
  80272. * List of inspectable custom properties (used by the Inspector)
  80273. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80274. */
  80275. inspectableCustomProperties: Nullable<IInspectable[]>;
  80276. private _noMipmap;
  80277. /** @hidden */
  80278. _invertY: boolean;
  80279. private _rowGenerationMatrix;
  80280. private _cachedTextureMatrix;
  80281. private _projectionModeMatrix;
  80282. private _t0;
  80283. private _t1;
  80284. private _t2;
  80285. private _cachedUOffset;
  80286. private _cachedVOffset;
  80287. private _cachedUScale;
  80288. private _cachedVScale;
  80289. private _cachedUAng;
  80290. private _cachedVAng;
  80291. private _cachedWAng;
  80292. private _cachedProjectionMatrixId;
  80293. private _cachedCoordinatesMode;
  80294. /** @hidden */
  80295. protected _initialSamplingMode: number;
  80296. /** @hidden */
  80297. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  80298. private _deleteBuffer;
  80299. protected _format: Nullable<number>;
  80300. private _delayedOnLoad;
  80301. private _delayedOnError;
  80302. /**
  80303. * Observable triggered once the texture has been loaded.
  80304. */
  80305. onLoadObservable: Observable<Texture>;
  80306. protected _isBlocking: boolean;
  80307. /**
  80308. * Is the texture preventing material to render while loading.
  80309. * If false, a default texture will be used instead of the loading one during the preparation step.
  80310. */
  80311. isBlocking: boolean;
  80312. /**
  80313. * Get the current sampling mode associated with the texture.
  80314. */
  80315. readonly samplingMode: number;
  80316. /**
  80317. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  80318. */
  80319. readonly invertY: boolean;
  80320. /**
  80321. * Instantiates a new texture.
  80322. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  80323. * @see http://doc.babylonjs.com/babylon101/materials#texture
  80324. * @param url define the url of the picture to load as a texture
  80325. * @param scene define the scene the texture will belong to
  80326. * @param noMipmap define if the texture will require mip maps or not
  80327. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80328. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80329. * @param onLoad define a callback triggered when the texture has been loaded
  80330. * @param onError define a callback triggered when an error occurred during the loading session
  80331. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80332. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80333. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80334. */
  80335. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  80336. /**
  80337. * Update the url (and optional buffer) of this texture if url was null during construction.
  80338. * @param url the url of the texture
  80339. * @param buffer the buffer of the texture (defaults to null)
  80340. * @param onLoad callback called when the texture is loaded (defaults to null)
  80341. */
  80342. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  80343. /**
  80344. * Finish the loading sequence of a texture flagged as delayed load.
  80345. * @hidden
  80346. */
  80347. delayLoad(): void;
  80348. private _prepareRowForTextureGeneration;
  80349. /**
  80350. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  80351. * @returns the transform matrix of the texture.
  80352. */
  80353. getTextureMatrix(): Matrix;
  80354. /**
  80355. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  80356. * @returns The reflection texture transform
  80357. */
  80358. getReflectionTextureMatrix(): Matrix;
  80359. /**
  80360. * Clones the texture.
  80361. * @returns the cloned texture
  80362. */
  80363. clone(): Texture;
  80364. /**
  80365. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  80366. * @returns The JSON representation of the texture
  80367. */
  80368. serialize(): any;
  80369. /**
  80370. * Get the current class name of the texture useful for serialization or dynamic coding.
  80371. * @returns "Texture"
  80372. */
  80373. getClassName(): string;
  80374. /**
  80375. * Dispose the texture and release its associated resources.
  80376. */
  80377. dispose(): void;
  80378. /**
  80379. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  80380. * @param parsedTexture Define the JSON representation of the texture
  80381. * @param scene Define the scene the parsed texture should be instantiated in
  80382. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  80383. * @returns The parsed texture if successful
  80384. */
  80385. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  80386. /**
  80387. * Creates a texture from its base 64 representation.
  80388. * @param data Define the base64 payload without the data: prefix
  80389. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80390. * @param scene Define the scene the texture should belong to
  80391. * @param noMipmap Forces the texture to not create mip map information if true
  80392. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80393. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80394. * @param onLoad define a callback triggered when the texture has been loaded
  80395. * @param onError define a callback triggered when an error occurred during the loading session
  80396. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80397. * @returns the created texture
  80398. */
  80399. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  80400. /**
  80401. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  80402. * @param data Define the base64 payload without the data: prefix
  80403. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  80404. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  80405. * @param scene Define the scene the texture should belong to
  80406. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  80407. * @param noMipmap Forces the texture to not create mip map information if true
  80408. * @param invertY define if the texture needs to be inverted on the y axis during loading
  80409. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  80410. * @param onLoad define a callback triggered when the texture has been loaded
  80411. * @param onError define a callback triggered when an error occurred during the loading session
  80412. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  80413. * @returns the created texture
  80414. */
  80415. 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;
  80416. }
  80417. }
  80418. declare module BABYLON {
  80419. interface Engine {
  80420. /**
  80421. * Creates a raw texture
  80422. * @param data defines the data to store in the texture
  80423. * @param width defines the width of the texture
  80424. * @param height defines the height of the texture
  80425. * @param format defines the format of the data
  80426. * @param generateMipMaps defines if the engine should generate the mip levels
  80427. * @param invertY defines if data must be stored with Y axis inverted
  80428. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  80429. * @param compression defines the compression used (null by default)
  80430. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80431. * @returns the raw texture inside an InternalTexture
  80432. */
  80433. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  80434. /**
  80435. * Update a raw texture
  80436. * @param texture defines the texture to update
  80437. * @param data defines the data to store in the texture
  80438. * @param format defines the format of the data
  80439. * @param invertY defines if data must be stored with Y axis inverted
  80440. */
  80441. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80442. /**
  80443. * Update a raw texture
  80444. * @param texture defines the texture to update
  80445. * @param data defines the data to store in the texture
  80446. * @param format defines the format of the data
  80447. * @param invertY defines if data must be stored with Y axis inverted
  80448. * @param compression defines the compression used (null by default)
  80449. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80450. */
  80451. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  80452. /**
  80453. * Creates a new raw cube texture
  80454. * @param data defines the array of data to use to create each face
  80455. * @param size defines the size of the textures
  80456. * @param format defines the format of the data
  80457. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80458. * @param generateMipMaps defines if the engine should generate the mip levels
  80459. * @param invertY defines if data must be stored with Y axis inverted
  80460. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80461. * @param compression defines the compression used (null by default)
  80462. * @returns the cube texture as an InternalTexture
  80463. */
  80464. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  80465. /**
  80466. * Update a raw cube texture
  80467. * @param texture defines the texture to udpdate
  80468. * @param data defines the data to store
  80469. * @param format defines the data format
  80470. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80471. * @param invertY defines if data must be stored with Y axis inverted
  80472. */
  80473. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  80474. /**
  80475. * Update a raw cube texture
  80476. * @param texture defines the texture to udpdate
  80477. * @param data defines the data to store
  80478. * @param format defines the data format
  80479. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80480. * @param invertY defines if data must be stored with Y axis inverted
  80481. * @param compression defines the compression used (null by default)
  80482. */
  80483. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  80484. /**
  80485. * Update a raw cube texture
  80486. * @param texture defines the texture to udpdate
  80487. * @param data defines the data to store
  80488. * @param format defines the data format
  80489. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  80490. * @param invertY defines if data must be stored with Y axis inverted
  80491. * @param compression defines the compression used (null by default)
  80492. * @param level defines which level of the texture to update
  80493. */
  80494. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  80495. /**
  80496. * Creates a new raw cube texture from a specified url
  80497. * @param url defines the url where the data is located
  80498. * @param scene defines the current scene
  80499. * @param size defines the size of the textures
  80500. * @param format defines the format of the data
  80501. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80502. * @param noMipmap defines if the engine should avoid generating the mip levels
  80503. * @param callback defines a callback used to extract texture data from loaded data
  80504. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80505. * @param onLoad defines a callback called when texture is loaded
  80506. * @param onError defines a callback called if there is an error
  80507. * @returns the cube texture as an InternalTexture
  80508. */
  80509. 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;
  80510. /**
  80511. * Creates a new raw cube texture from a specified url
  80512. * @param url defines the url where the data is located
  80513. * @param scene defines the current scene
  80514. * @param size defines the size of the textures
  80515. * @param format defines the format of the data
  80516. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  80517. * @param noMipmap defines if the engine should avoid generating the mip levels
  80518. * @param callback defines a callback used to extract texture data from loaded data
  80519. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  80520. * @param onLoad defines a callback called when texture is loaded
  80521. * @param onError defines a callback called if there is an error
  80522. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80523. * @param invertY defines if data must be stored with Y axis inverted
  80524. * @returns the cube texture as an InternalTexture
  80525. */
  80526. 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;
  80527. /**
  80528. * Creates a new raw 3D texture
  80529. * @param data defines the data used to create the texture
  80530. * @param width defines the width of the texture
  80531. * @param height defines the height of the texture
  80532. * @param depth defines the depth of the texture
  80533. * @param format defines the format of the texture
  80534. * @param generateMipMaps defines if the engine must generate mip levels
  80535. * @param invertY defines if data must be stored with Y axis inverted
  80536. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  80537. * @param compression defines the compressed used (can be null)
  80538. * @param textureType defines the compressed used (can be null)
  80539. * @returns a new raw 3D texture (stored in an InternalTexture)
  80540. */
  80541. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  80542. /**
  80543. * Update a raw 3D texture
  80544. * @param texture defines the texture to update
  80545. * @param data defines the data to store
  80546. * @param format defines the data format
  80547. * @param invertY defines if data must be stored with Y axis inverted
  80548. */
  80549. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  80550. /**
  80551. * Update a raw 3D texture
  80552. * @param texture defines the texture to update
  80553. * @param data defines the data to store
  80554. * @param format defines the data format
  80555. * @param invertY defines if data must be stored with Y axis inverted
  80556. * @param compression defines the used compression (can be null)
  80557. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  80558. */
  80559. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  80560. }
  80561. }
  80562. declare module BABYLON {
  80563. /**
  80564. * Raw texture can help creating a texture directly from an array of data.
  80565. * This can be super useful if you either get the data from an uncompressed source or
  80566. * if you wish to create your texture pixel by pixel.
  80567. */
  80568. export class RawTexture extends Texture {
  80569. /**
  80570. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80571. */
  80572. format: number;
  80573. private _engine;
  80574. /**
  80575. * Instantiates a new RawTexture.
  80576. * Raw texture can help creating a texture directly from an array of data.
  80577. * This can be super useful if you either get the data from an uncompressed source or
  80578. * if you wish to create your texture pixel by pixel.
  80579. * @param data define the array of data to use to create the texture
  80580. * @param width define the width of the texture
  80581. * @param height define the height of the texture
  80582. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80583. * @param scene define the scene the texture belongs to
  80584. * @param generateMipMaps define whether mip maps should be generated or not
  80585. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80586. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80587. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80588. */
  80589. constructor(data: ArrayBufferView, width: number, height: number,
  80590. /**
  80591. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  80592. */
  80593. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  80594. /**
  80595. * Updates the texture underlying data.
  80596. * @param data Define the new data of the texture
  80597. */
  80598. update(data: ArrayBufferView): void;
  80599. /**
  80600. * Creates a luminance texture from some data.
  80601. * @param data Define the texture data
  80602. * @param width Define the width of the texture
  80603. * @param height Define the height of the texture
  80604. * @param scene Define the scene the texture belongs to
  80605. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80606. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80607. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80608. * @returns the luminance texture
  80609. */
  80610. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80611. /**
  80612. * Creates a luminance alpha texture from some data.
  80613. * @param data Define the texture data
  80614. * @param width Define the width of the texture
  80615. * @param height Define the height of the texture
  80616. * @param scene Define the scene the texture belongs to
  80617. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80618. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80619. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80620. * @returns the luminance alpha texture
  80621. */
  80622. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80623. /**
  80624. * Creates an alpha texture from some data.
  80625. * @param data Define the texture data
  80626. * @param width Define the width of the texture
  80627. * @param height Define the height of the texture
  80628. * @param scene Define the scene the texture belongs to
  80629. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80630. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80631. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80632. * @returns the alpha texture
  80633. */
  80634. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  80635. /**
  80636. * Creates a RGB texture from some data.
  80637. * @param data Define the texture data
  80638. * @param width Define the width of the texture
  80639. * @param height Define the height of the texture
  80640. * @param scene Define the scene the texture belongs to
  80641. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80642. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80643. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80644. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80645. * @returns the RGB alpha texture
  80646. */
  80647. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80648. /**
  80649. * Creates a RGBA texture from some data.
  80650. * @param data Define the texture data
  80651. * @param width Define the width of the texture
  80652. * @param height Define the height of the texture
  80653. * @param scene Define the scene the texture belongs to
  80654. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80655. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80656. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80657. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80658. * @returns the RGBA texture
  80659. */
  80660. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80661. /**
  80662. * Creates a R texture from some data.
  80663. * @param data Define the texture data
  80664. * @param width Define the width of the texture
  80665. * @param height Define the height of the texture
  80666. * @param scene Define the scene the texture belongs to
  80667. * @param generateMipMaps Define whether or not to create mip maps for the texture
  80668. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  80669. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  80670. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  80671. * @returns the R texture
  80672. */
  80673. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  80674. }
  80675. }
  80676. declare module BABYLON {
  80677. /**
  80678. * Defines a runtime animation
  80679. */
  80680. export class RuntimeAnimation {
  80681. private _events;
  80682. /**
  80683. * The current frame of the runtime animation
  80684. */
  80685. private _currentFrame;
  80686. /**
  80687. * The animation used by the runtime animation
  80688. */
  80689. private _animation;
  80690. /**
  80691. * The target of the runtime animation
  80692. */
  80693. private _target;
  80694. /**
  80695. * The initiating animatable
  80696. */
  80697. private _host;
  80698. /**
  80699. * The original value of the runtime animation
  80700. */
  80701. private _originalValue;
  80702. /**
  80703. * The original blend value of the runtime animation
  80704. */
  80705. private _originalBlendValue;
  80706. /**
  80707. * The offsets cache of the runtime animation
  80708. */
  80709. private _offsetsCache;
  80710. /**
  80711. * The high limits cache of the runtime animation
  80712. */
  80713. private _highLimitsCache;
  80714. /**
  80715. * Specifies if the runtime animation has been stopped
  80716. */
  80717. private _stopped;
  80718. /**
  80719. * The blending factor of the runtime animation
  80720. */
  80721. private _blendingFactor;
  80722. /**
  80723. * The BabylonJS scene
  80724. */
  80725. private _scene;
  80726. /**
  80727. * The current value of the runtime animation
  80728. */
  80729. private _currentValue;
  80730. /** @hidden */
  80731. _animationState: _IAnimationState;
  80732. /**
  80733. * The active target of the runtime animation
  80734. */
  80735. private _activeTargets;
  80736. private _currentActiveTarget;
  80737. private _directTarget;
  80738. /**
  80739. * The target path of the runtime animation
  80740. */
  80741. private _targetPath;
  80742. /**
  80743. * The weight of the runtime animation
  80744. */
  80745. private _weight;
  80746. /**
  80747. * The ratio offset of the runtime animation
  80748. */
  80749. private _ratioOffset;
  80750. /**
  80751. * The previous delay of the runtime animation
  80752. */
  80753. private _previousDelay;
  80754. /**
  80755. * The previous ratio of the runtime animation
  80756. */
  80757. private _previousRatio;
  80758. private _enableBlending;
  80759. private _keys;
  80760. private _minFrame;
  80761. private _maxFrame;
  80762. private _minValue;
  80763. private _maxValue;
  80764. private _targetIsArray;
  80765. /**
  80766. * Gets the current frame of the runtime animation
  80767. */
  80768. readonly currentFrame: number;
  80769. /**
  80770. * Gets the weight of the runtime animation
  80771. */
  80772. readonly weight: number;
  80773. /**
  80774. * Gets the current value of the runtime animation
  80775. */
  80776. readonly currentValue: any;
  80777. /**
  80778. * Gets the target path of the runtime animation
  80779. */
  80780. readonly targetPath: string;
  80781. /**
  80782. * Gets the actual target of the runtime animation
  80783. */
  80784. readonly target: any;
  80785. /** @hidden */
  80786. _onLoop: () => void;
  80787. /**
  80788. * Create a new RuntimeAnimation object
  80789. * @param target defines the target of the animation
  80790. * @param animation defines the source animation object
  80791. * @param scene defines the hosting scene
  80792. * @param host defines the initiating Animatable
  80793. */
  80794. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  80795. private _preparePath;
  80796. /**
  80797. * Gets the animation from the runtime animation
  80798. */
  80799. readonly animation: Animation;
  80800. /**
  80801. * Resets the runtime animation to the beginning
  80802. * @param restoreOriginal defines whether to restore the target property to the original value
  80803. */
  80804. reset(restoreOriginal?: boolean): void;
  80805. /**
  80806. * Specifies if the runtime animation is stopped
  80807. * @returns Boolean specifying if the runtime animation is stopped
  80808. */
  80809. isStopped(): boolean;
  80810. /**
  80811. * Disposes of the runtime animation
  80812. */
  80813. dispose(): void;
  80814. /**
  80815. * Apply the interpolated value to the target
  80816. * @param currentValue defines the value computed by the animation
  80817. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  80818. */
  80819. setValue(currentValue: any, weight: number): void;
  80820. private _getOriginalValues;
  80821. private _setValue;
  80822. /**
  80823. * Gets the loop pmode of the runtime animation
  80824. * @returns Loop Mode
  80825. */
  80826. private _getCorrectLoopMode;
  80827. /**
  80828. * Move the current animation to a given frame
  80829. * @param frame defines the frame to move to
  80830. */
  80831. goToFrame(frame: number): void;
  80832. /**
  80833. * @hidden Internal use only
  80834. */
  80835. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  80836. /**
  80837. * Execute the current animation
  80838. * @param delay defines the delay to add to the current frame
  80839. * @param from defines the lower bound of the animation range
  80840. * @param to defines the upper bound of the animation range
  80841. * @param loop defines if the current animation must loop
  80842. * @param speedRatio defines the current speed ratio
  80843. * @param weight defines the weight of the animation (default is -1 so no weight)
  80844. * @param onLoop optional callback called when animation loops
  80845. * @returns a boolean indicating if the animation is running
  80846. */
  80847. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  80848. }
  80849. }
  80850. declare module BABYLON {
  80851. /**
  80852. * Class used to store an actual running animation
  80853. */
  80854. export class Animatable {
  80855. /** defines the target object */
  80856. target: any;
  80857. /** defines the starting frame number (default is 0) */
  80858. fromFrame: number;
  80859. /** defines the ending frame number (default is 100) */
  80860. toFrame: number;
  80861. /** defines if the animation must loop (default is false) */
  80862. loopAnimation: boolean;
  80863. /** defines a callback to call when animation ends if it is not looping */
  80864. onAnimationEnd?: (() => void) | null | undefined;
  80865. /** defines a callback to call when animation loops */
  80866. onAnimationLoop?: (() => void) | null | undefined;
  80867. private _localDelayOffset;
  80868. private _pausedDelay;
  80869. private _runtimeAnimations;
  80870. private _paused;
  80871. private _scene;
  80872. private _speedRatio;
  80873. private _weight;
  80874. private _syncRoot;
  80875. /**
  80876. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  80877. * This will only apply for non looping animation (default is true)
  80878. */
  80879. disposeOnEnd: boolean;
  80880. /**
  80881. * Gets a boolean indicating if the animation has started
  80882. */
  80883. animationStarted: boolean;
  80884. /**
  80885. * Observer raised when the animation ends
  80886. */
  80887. onAnimationEndObservable: Observable<Animatable>;
  80888. /**
  80889. * Observer raised when the animation loops
  80890. */
  80891. onAnimationLoopObservable: Observable<Animatable>;
  80892. /**
  80893. * Gets the root Animatable used to synchronize and normalize animations
  80894. */
  80895. readonly syncRoot: Nullable<Animatable>;
  80896. /**
  80897. * Gets the current frame of the first RuntimeAnimation
  80898. * Used to synchronize Animatables
  80899. */
  80900. readonly masterFrame: number;
  80901. /**
  80902. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  80903. */
  80904. weight: number;
  80905. /**
  80906. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  80907. */
  80908. speedRatio: number;
  80909. /**
  80910. * Creates a new Animatable
  80911. * @param scene defines the hosting scene
  80912. * @param target defines the target object
  80913. * @param fromFrame defines the starting frame number (default is 0)
  80914. * @param toFrame defines the ending frame number (default is 100)
  80915. * @param loopAnimation defines if the animation must loop (default is false)
  80916. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  80917. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  80918. * @param animations defines a group of animation to add to the new Animatable
  80919. * @param onAnimationLoop defines a callback to call when animation loops
  80920. */
  80921. constructor(scene: Scene,
  80922. /** defines the target object */
  80923. target: any,
  80924. /** defines the starting frame number (default is 0) */
  80925. fromFrame?: number,
  80926. /** defines the ending frame number (default is 100) */
  80927. toFrame?: number,
  80928. /** defines if the animation must loop (default is false) */
  80929. loopAnimation?: boolean, speedRatio?: number,
  80930. /** defines a callback to call when animation ends if it is not looping */
  80931. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  80932. /** defines a callback to call when animation loops */
  80933. onAnimationLoop?: (() => void) | null | undefined);
  80934. /**
  80935. * Synchronize and normalize current Animatable with a source Animatable
  80936. * This is useful when using animation weights and when animations are not of the same length
  80937. * @param root defines the root Animatable to synchronize with
  80938. * @returns the current Animatable
  80939. */
  80940. syncWith(root: Animatable): Animatable;
  80941. /**
  80942. * Gets the list of runtime animations
  80943. * @returns an array of RuntimeAnimation
  80944. */
  80945. getAnimations(): RuntimeAnimation[];
  80946. /**
  80947. * Adds more animations to the current animatable
  80948. * @param target defines the target of the animations
  80949. * @param animations defines the new animations to add
  80950. */
  80951. appendAnimations(target: any, animations: Animation[]): void;
  80952. /**
  80953. * Gets the source animation for a specific property
  80954. * @param property defines the propertyu to look for
  80955. * @returns null or the source animation for the given property
  80956. */
  80957. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  80958. /**
  80959. * Gets the runtime animation for a specific property
  80960. * @param property defines the propertyu to look for
  80961. * @returns null or the runtime animation for the given property
  80962. */
  80963. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  80964. /**
  80965. * Resets the animatable to its original state
  80966. */
  80967. reset(): void;
  80968. /**
  80969. * Allows the animatable to blend with current running animations
  80970. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80971. * @param blendingSpeed defines the blending speed to use
  80972. */
  80973. enableBlending(blendingSpeed: number): void;
  80974. /**
  80975. * Disable animation blending
  80976. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80977. */
  80978. disableBlending(): void;
  80979. /**
  80980. * Jump directly to a given frame
  80981. * @param frame defines the frame to jump to
  80982. */
  80983. goToFrame(frame: number): void;
  80984. /**
  80985. * Pause the animation
  80986. */
  80987. pause(): void;
  80988. /**
  80989. * Restart the animation
  80990. */
  80991. restart(): void;
  80992. private _raiseOnAnimationEnd;
  80993. /**
  80994. * Stop and delete the current animation
  80995. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  80996. * @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)
  80997. */
  80998. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  80999. /**
  81000. * Wait asynchronously for the animation to end
  81001. * @returns a promise which will be fullfilled when the animation ends
  81002. */
  81003. waitAsync(): Promise<Animatable>;
  81004. /** @hidden */
  81005. _animate(delay: number): boolean;
  81006. }
  81007. interface Scene {
  81008. /** @hidden */
  81009. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  81010. /** @hidden */
  81011. _processLateAnimationBindingsForMatrices(holder: {
  81012. totalWeight: number;
  81013. animations: RuntimeAnimation[];
  81014. originalValue: Matrix;
  81015. }): any;
  81016. /** @hidden */
  81017. _processLateAnimationBindingsForQuaternions(holder: {
  81018. totalWeight: number;
  81019. animations: RuntimeAnimation[];
  81020. originalValue: Quaternion;
  81021. }, refQuaternion: Quaternion): Quaternion;
  81022. /** @hidden */
  81023. _processLateAnimationBindings(): void;
  81024. /**
  81025. * Will start the animation sequence of a given target
  81026. * @param target defines the target
  81027. * @param from defines from which frame should animation start
  81028. * @param to defines until which frame should animation run.
  81029. * @param weight defines the weight to apply to the animation (1.0 by default)
  81030. * @param loop defines if the animation loops
  81031. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81032. * @param onAnimationEnd defines the function to be executed when the animation ends
  81033. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81034. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81035. * @param onAnimationLoop defines the callback to call when an animation loops
  81036. * @returns the animatable object created for this animation
  81037. */
  81038. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81039. /**
  81040. * Will start the animation sequence of a given target
  81041. * @param target defines the target
  81042. * @param from defines from which frame should animation start
  81043. * @param to defines until which frame should animation run.
  81044. * @param loop defines if the animation loops
  81045. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81046. * @param onAnimationEnd defines the function to be executed when the animation ends
  81047. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81048. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81049. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  81050. * @param onAnimationLoop defines the callback to call when an animation loops
  81051. * @returns the animatable object created for this animation
  81052. */
  81053. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  81054. /**
  81055. * Will start the animation sequence of a given target and its hierarchy
  81056. * @param target defines the target
  81057. * @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.
  81058. * @param from defines from which frame should animation start
  81059. * @param to defines until which frame should animation run.
  81060. * @param loop defines if the animation loops
  81061. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  81062. * @param onAnimationEnd defines the function to be executed when the animation ends
  81063. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  81064. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  81065. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  81066. * @param onAnimationLoop defines the callback to call when an animation loops
  81067. * @returns the list of created animatables
  81068. */
  81069. 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[];
  81070. /**
  81071. * Begin a new animation on a given node
  81072. * @param target defines the target where the animation will take place
  81073. * @param animations defines the list of animations to start
  81074. * @param from defines the initial value
  81075. * @param to defines the final value
  81076. * @param loop defines if you want animation to loop (off by default)
  81077. * @param speedRatio defines the speed ratio to apply to all animations
  81078. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81079. * @param onAnimationLoop defines the callback to call when an animation loops
  81080. * @returns the list of created animatables
  81081. */
  81082. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  81083. /**
  81084. * Begin a new animation on a given node and its hierarchy
  81085. * @param target defines the root node where the animation will take place
  81086. * @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.
  81087. * @param animations defines the list of animations to start
  81088. * @param from defines the initial value
  81089. * @param to defines the final value
  81090. * @param loop defines if you want animation to loop (off by default)
  81091. * @param speedRatio defines the speed ratio to apply to all animations
  81092. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  81093. * @param onAnimationLoop defines the callback to call when an animation loops
  81094. * @returns the list of animatables created for all nodes
  81095. */
  81096. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  81097. /**
  81098. * Gets the animatable associated with a specific target
  81099. * @param target defines the target of the animatable
  81100. * @returns the required animatable if found
  81101. */
  81102. getAnimatableByTarget(target: any): Nullable<Animatable>;
  81103. /**
  81104. * Gets all animatables associated with a given target
  81105. * @param target defines the target to look animatables for
  81106. * @returns an array of Animatables
  81107. */
  81108. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  81109. /**
  81110. * Stops and removes all animations that have been applied to the scene
  81111. */
  81112. stopAllAnimations(): void;
  81113. }
  81114. interface Bone {
  81115. /**
  81116. * Copy an animation range from another bone
  81117. * @param source defines the source bone
  81118. * @param rangeName defines the range name to copy
  81119. * @param frameOffset defines the frame offset
  81120. * @param rescaleAsRequired defines if rescaling must be applied if required
  81121. * @param skelDimensionsRatio defines the scaling ratio
  81122. * @returns true if operation was successful
  81123. */
  81124. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  81125. }
  81126. }
  81127. declare module BABYLON {
  81128. /**
  81129. * Class used to handle skinning animations
  81130. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  81131. */
  81132. export class Skeleton implements IAnimatable {
  81133. /** defines the skeleton name */
  81134. name: string;
  81135. /** defines the skeleton Id */
  81136. id: string;
  81137. /**
  81138. * Defines the list of child bones
  81139. */
  81140. bones: Bone[];
  81141. /**
  81142. * Defines an estimate of the dimension of the skeleton at rest
  81143. */
  81144. dimensionsAtRest: Vector3;
  81145. /**
  81146. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  81147. */
  81148. needInitialSkinMatrix: boolean;
  81149. /**
  81150. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  81151. */
  81152. overrideMesh: Nullable<AbstractMesh>;
  81153. /**
  81154. * Gets the list of animations attached to this skeleton
  81155. */
  81156. animations: Array<Animation>;
  81157. private _scene;
  81158. private _isDirty;
  81159. private _transformMatrices;
  81160. private _transformMatrixTexture;
  81161. private _meshesWithPoseMatrix;
  81162. private _animatables;
  81163. private _identity;
  81164. private _synchronizedWithMesh;
  81165. private _ranges;
  81166. private _lastAbsoluteTransformsUpdateId;
  81167. private _canUseTextureForBones;
  81168. private _uniqueId;
  81169. /** @hidden */
  81170. _numBonesWithLinkedTransformNode: number;
  81171. /** @hidden */
  81172. _hasWaitingData: Nullable<boolean>;
  81173. /**
  81174. * Specifies if the skeleton should be serialized
  81175. */
  81176. doNotSerialize: boolean;
  81177. private _useTextureToStoreBoneMatrices;
  81178. /**
  81179. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  81180. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  81181. */
  81182. useTextureToStoreBoneMatrices: boolean;
  81183. private _animationPropertiesOverride;
  81184. /**
  81185. * Gets or sets the animation properties override
  81186. */
  81187. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81188. /**
  81189. * List of inspectable custom properties (used by the Inspector)
  81190. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81191. */
  81192. inspectableCustomProperties: IInspectable[];
  81193. /**
  81194. * An observable triggered before computing the skeleton's matrices
  81195. */
  81196. onBeforeComputeObservable: Observable<Skeleton>;
  81197. /**
  81198. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  81199. */
  81200. readonly isUsingTextureForMatrices: boolean;
  81201. /**
  81202. * Gets the unique ID of this skeleton
  81203. */
  81204. readonly uniqueId: number;
  81205. /**
  81206. * Creates a new skeleton
  81207. * @param name defines the skeleton name
  81208. * @param id defines the skeleton Id
  81209. * @param scene defines the hosting scene
  81210. */
  81211. constructor(
  81212. /** defines the skeleton name */
  81213. name: string,
  81214. /** defines the skeleton Id */
  81215. id: string, scene: Scene);
  81216. /**
  81217. * Gets the current object class name.
  81218. * @return the class name
  81219. */
  81220. getClassName(): string;
  81221. /**
  81222. * Returns an array containing the root bones
  81223. * @returns an array containing the root bones
  81224. */
  81225. getChildren(): Array<Bone>;
  81226. /**
  81227. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  81228. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  81229. * @returns a Float32Array containing matrices data
  81230. */
  81231. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  81232. /**
  81233. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  81234. * @returns a raw texture containing the data
  81235. */
  81236. getTransformMatrixTexture(): Nullable<RawTexture>;
  81237. /**
  81238. * Gets the current hosting scene
  81239. * @returns a scene object
  81240. */
  81241. getScene(): Scene;
  81242. /**
  81243. * Gets a string representing the current skeleton data
  81244. * @param fullDetails defines a boolean indicating if we want a verbose version
  81245. * @returns a string representing the current skeleton data
  81246. */
  81247. toString(fullDetails?: boolean): string;
  81248. /**
  81249. * Get bone's index searching by name
  81250. * @param name defines bone's name to search for
  81251. * @return the indice of the bone. Returns -1 if not found
  81252. */
  81253. getBoneIndexByName(name: string): number;
  81254. /**
  81255. * Creater a new animation range
  81256. * @param name defines the name of the range
  81257. * @param from defines the start key
  81258. * @param to defines the end key
  81259. */
  81260. createAnimationRange(name: string, from: number, to: number): void;
  81261. /**
  81262. * Delete a specific animation range
  81263. * @param name defines the name of the range
  81264. * @param deleteFrames defines if frames must be removed as well
  81265. */
  81266. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  81267. /**
  81268. * Gets a specific animation range
  81269. * @param name defines the name of the range to look for
  81270. * @returns the requested animation range or null if not found
  81271. */
  81272. getAnimationRange(name: string): Nullable<AnimationRange>;
  81273. /**
  81274. * Gets the list of all animation ranges defined on this skeleton
  81275. * @returns an array
  81276. */
  81277. getAnimationRanges(): Nullable<AnimationRange>[];
  81278. /**
  81279. * Copy animation range from a source skeleton.
  81280. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  81281. * @param source defines the source skeleton
  81282. * @param name defines the name of the range to copy
  81283. * @param rescaleAsRequired defines if rescaling must be applied if required
  81284. * @returns true if operation was successful
  81285. */
  81286. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  81287. /**
  81288. * Forces the skeleton to go to rest pose
  81289. */
  81290. returnToRest(): void;
  81291. private _getHighestAnimationFrame;
  81292. /**
  81293. * Begin a specific animation range
  81294. * @param name defines the name of the range to start
  81295. * @param loop defines if looping must be turned on (false by default)
  81296. * @param speedRatio defines the speed ratio to apply (1 by default)
  81297. * @param onAnimationEnd defines a callback which will be called when animation will end
  81298. * @returns a new animatable
  81299. */
  81300. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  81301. /** @hidden */
  81302. _markAsDirty(): void;
  81303. /** @hidden */
  81304. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81305. /** @hidden */
  81306. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  81307. private _computeTransformMatrices;
  81308. /**
  81309. * Build all resources required to render a skeleton
  81310. */
  81311. prepare(): void;
  81312. /**
  81313. * Gets the list of animatables currently running for this skeleton
  81314. * @returns an array of animatables
  81315. */
  81316. getAnimatables(): IAnimatable[];
  81317. /**
  81318. * Clone the current skeleton
  81319. * @param name defines the name of the new skeleton
  81320. * @param id defines the id of the new skeleton
  81321. * @returns the new skeleton
  81322. */
  81323. clone(name: string, id: string): Skeleton;
  81324. /**
  81325. * Enable animation blending for this skeleton
  81326. * @param blendingSpeed defines the blending speed to apply
  81327. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  81328. */
  81329. enableBlending(blendingSpeed?: number): void;
  81330. /**
  81331. * Releases all resources associated with the current skeleton
  81332. */
  81333. dispose(): void;
  81334. /**
  81335. * Serialize the skeleton in a JSON object
  81336. * @returns a JSON object
  81337. */
  81338. serialize(): any;
  81339. /**
  81340. * Creates a new skeleton from serialized data
  81341. * @param parsedSkeleton defines the serialized data
  81342. * @param scene defines the hosting scene
  81343. * @returns a new skeleton
  81344. */
  81345. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  81346. /**
  81347. * Compute all node absolute transforms
  81348. * @param forceUpdate defines if computation must be done even if cache is up to date
  81349. */
  81350. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  81351. /**
  81352. * Gets the root pose matrix
  81353. * @returns a matrix
  81354. */
  81355. getPoseMatrix(): Nullable<Matrix>;
  81356. /**
  81357. * Sorts bones per internal index
  81358. */
  81359. sortBones(): void;
  81360. private _sortBones;
  81361. }
  81362. }
  81363. declare module BABYLON {
  81364. /**
  81365. * Defines a target to use with MorphTargetManager
  81366. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81367. */
  81368. export class MorphTarget implements IAnimatable {
  81369. /** defines the name of the target */
  81370. name: string;
  81371. /**
  81372. * Gets or sets the list of animations
  81373. */
  81374. animations: Animation[];
  81375. private _scene;
  81376. private _positions;
  81377. private _normals;
  81378. private _tangents;
  81379. private _influence;
  81380. /**
  81381. * Observable raised when the influence changes
  81382. */
  81383. onInfluenceChanged: Observable<boolean>;
  81384. /** @hidden */
  81385. _onDataLayoutChanged: Observable<void>;
  81386. /**
  81387. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  81388. */
  81389. influence: number;
  81390. /**
  81391. * Gets or sets the id of the morph Target
  81392. */
  81393. id: string;
  81394. private _animationPropertiesOverride;
  81395. /**
  81396. * Gets or sets the animation properties override
  81397. */
  81398. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  81399. /**
  81400. * Creates a new MorphTarget
  81401. * @param name defines the name of the target
  81402. * @param influence defines the influence to use
  81403. * @param scene defines the scene the morphtarget belongs to
  81404. */
  81405. constructor(
  81406. /** defines the name of the target */
  81407. name: string, influence?: number, scene?: Nullable<Scene>);
  81408. /**
  81409. * Gets a boolean defining if the target contains position data
  81410. */
  81411. readonly hasPositions: boolean;
  81412. /**
  81413. * Gets a boolean defining if the target contains normal data
  81414. */
  81415. readonly hasNormals: boolean;
  81416. /**
  81417. * Gets a boolean defining if the target contains tangent data
  81418. */
  81419. readonly hasTangents: boolean;
  81420. /**
  81421. * Affects position data to this target
  81422. * @param data defines the position data to use
  81423. */
  81424. setPositions(data: Nullable<FloatArray>): void;
  81425. /**
  81426. * Gets the position data stored in this target
  81427. * @returns a FloatArray containing the position data (or null if not present)
  81428. */
  81429. getPositions(): Nullable<FloatArray>;
  81430. /**
  81431. * Affects normal data to this target
  81432. * @param data defines the normal data to use
  81433. */
  81434. setNormals(data: Nullable<FloatArray>): void;
  81435. /**
  81436. * Gets the normal data stored in this target
  81437. * @returns a FloatArray containing the normal data (or null if not present)
  81438. */
  81439. getNormals(): Nullable<FloatArray>;
  81440. /**
  81441. * Affects tangent data to this target
  81442. * @param data defines the tangent data to use
  81443. */
  81444. setTangents(data: Nullable<FloatArray>): void;
  81445. /**
  81446. * Gets the tangent data stored in this target
  81447. * @returns a FloatArray containing the tangent data (or null if not present)
  81448. */
  81449. getTangents(): Nullable<FloatArray>;
  81450. /**
  81451. * Serializes the current target into a Serialization object
  81452. * @returns the serialized object
  81453. */
  81454. serialize(): any;
  81455. /**
  81456. * Returns the string "MorphTarget"
  81457. * @returns "MorphTarget"
  81458. */
  81459. getClassName(): string;
  81460. /**
  81461. * Creates a new target from serialized data
  81462. * @param serializationObject defines the serialized data to use
  81463. * @returns a new MorphTarget
  81464. */
  81465. static Parse(serializationObject: any): MorphTarget;
  81466. /**
  81467. * Creates a MorphTarget from mesh data
  81468. * @param mesh defines the source mesh
  81469. * @param name defines the name to use for the new target
  81470. * @param influence defines the influence to attach to the target
  81471. * @returns a new MorphTarget
  81472. */
  81473. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  81474. }
  81475. }
  81476. declare module BABYLON {
  81477. /**
  81478. * This class is used to deform meshes using morphing between different targets
  81479. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  81480. */
  81481. export class MorphTargetManager {
  81482. private _targets;
  81483. private _targetInfluenceChangedObservers;
  81484. private _targetDataLayoutChangedObservers;
  81485. private _activeTargets;
  81486. private _scene;
  81487. private _influences;
  81488. private _supportsNormals;
  81489. private _supportsTangents;
  81490. private _vertexCount;
  81491. private _uniqueId;
  81492. private _tempInfluences;
  81493. /**
  81494. * Creates a new MorphTargetManager
  81495. * @param scene defines the current scene
  81496. */
  81497. constructor(scene?: Nullable<Scene>);
  81498. /**
  81499. * Gets the unique ID of this manager
  81500. */
  81501. readonly uniqueId: number;
  81502. /**
  81503. * Gets the number of vertices handled by this manager
  81504. */
  81505. readonly vertexCount: number;
  81506. /**
  81507. * Gets a boolean indicating if this manager supports morphing of normals
  81508. */
  81509. readonly supportsNormals: boolean;
  81510. /**
  81511. * Gets a boolean indicating if this manager supports morphing of tangents
  81512. */
  81513. readonly supportsTangents: boolean;
  81514. /**
  81515. * Gets the number of targets stored in this manager
  81516. */
  81517. readonly numTargets: number;
  81518. /**
  81519. * Gets the number of influencers (ie. the number of targets with influences > 0)
  81520. */
  81521. readonly numInfluencers: number;
  81522. /**
  81523. * Gets the list of influences (one per target)
  81524. */
  81525. readonly influences: Float32Array;
  81526. /**
  81527. * Gets the active target at specified index. An active target is a target with an influence > 0
  81528. * @param index defines the index to check
  81529. * @returns the requested target
  81530. */
  81531. getActiveTarget(index: number): MorphTarget;
  81532. /**
  81533. * Gets the target at specified index
  81534. * @param index defines the index to check
  81535. * @returns the requested target
  81536. */
  81537. getTarget(index: number): MorphTarget;
  81538. /**
  81539. * Add a new target to this manager
  81540. * @param target defines the target to add
  81541. */
  81542. addTarget(target: MorphTarget): void;
  81543. /**
  81544. * Removes a target from the manager
  81545. * @param target defines the target to remove
  81546. */
  81547. removeTarget(target: MorphTarget): void;
  81548. /**
  81549. * Serializes the current manager into a Serialization object
  81550. * @returns the serialized object
  81551. */
  81552. serialize(): any;
  81553. private _syncActiveTargets;
  81554. /**
  81555. * Syncrhonize the targets with all the meshes using this morph target manager
  81556. */
  81557. synchronize(): void;
  81558. /**
  81559. * Creates a new MorphTargetManager from serialized data
  81560. * @param serializationObject defines the serialized data
  81561. * @param scene defines the hosting scene
  81562. * @returns the new MorphTargetManager
  81563. */
  81564. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  81565. }
  81566. }
  81567. declare module BABYLON {
  81568. /**
  81569. * Class used to represent a specific level of detail of a mesh
  81570. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  81571. */
  81572. export class MeshLODLevel {
  81573. /** Defines the distance where this level should star being displayed */
  81574. distance: number;
  81575. /** Defines the mesh to use to render this level */
  81576. mesh: Nullable<Mesh>;
  81577. /**
  81578. * Creates a new LOD level
  81579. * @param distance defines the distance where this level should star being displayed
  81580. * @param mesh defines the mesh to use to render this level
  81581. */
  81582. constructor(
  81583. /** Defines the distance where this level should star being displayed */
  81584. distance: number,
  81585. /** Defines the mesh to use to render this level */
  81586. mesh: Nullable<Mesh>);
  81587. }
  81588. }
  81589. declare module BABYLON {
  81590. /**
  81591. * Mesh representing the gorund
  81592. */
  81593. export class GroundMesh extends Mesh {
  81594. /** If octree should be generated */
  81595. generateOctree: boolean;
  81596. private _heightQuads;
  81597. /** @hidden */
  81598. _subdivisionsX: number;
  81599. /** @hidden */
  81600. _subdivisionsY: number;
  81601. /** @hidden */
  81602. _width: number;
  81603. /** @hidden */
  81604. _height: number;
  81605. /** @hidden */
  81606. _minX: number;
  81607. /** @hidden */
  81608. _maxX: number;
  81609. /** @hidden */
  81610. _minZ: number;
  81611. /** @hidden */
  81612. _maxZ: number;
  81613. constructor(name: string, scene: Scene);
  81614. /**
  81615. * "GroundMesh"
  81616. * @returns "GroundMesh"
  81617. */
  81618. getClassName(): string;
  81619. /**
  81620. * The minimum of x and y subdivisions
  81621. */
  81622. readonly subdivisions: number;
  81623. /**
  81624. * X subdivisions
  81625. */
  81626. readonly subdivisionsX: number;
  81627. /**
  81628. * Y subdivisions
  81629. */
  81630. readonly subdivisionsY: number;
  81631. /**
  81632. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  81633. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  81634. * @param chunksCount the number of subdivisions for x and y
  81635. * @param octreeBlocksSize (Default: 32)
  81636. */
  81637. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  81638. /**
  81639. * Returns a height (y) value in the Worl system :
  81640. * the ground altitude at the coordinates (x, z) expressed in the World system.
  81641. * @param x x coordinate
  81642. * @param z z coordinate
  81643. * @returns the ground y position if (x, z) are outside the ground surface.
  81644. */
  81645. getHeightAtCoordinates(x: number, z: number): number;
  81646. /**
  81647. * Returns a normalized vector (Vector3) orthogonal to the ground
  81648. * at the ground coordinates (x, z) expressed in the World system.
  81649. * @param x x coordinate
  81650. * @param z z coordinate
  81651. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  81652. */
  81653. getNormalAtCoordinates(x: number, z: number): Vector3;
  81654. /**
  81655. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  81656. * at the ground coordinates (x, z) expressed in the World system.
  81657. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  81658. * @param x x coordinate
  81659. * @param z z coordinate
  81660. * @param ref vector to store the result
  81661. * @returns the GroundMesh.
  81662. */
  81663. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  81664. /**
  81665. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  81666. * if the ground has been updated.
  81667. * This can be used in the render loop.
  81668. * @returns the GroundMesh.
  81669. */
  81670. updateCoordinateHeights(): GroundMesh;
  81671. private _getFacetAt;
  81672. private _initHeightQuads;
  81673. private _computeHeightQuads;
  81674. /**
  81675. * Serializes this ground mesh
  81676. * @param serializationObject object to write serialization to
  81677. */
  81678. serialize(serializationObject: any): void;
  81679. /**
  81680. * Parses a serialized ground mesh
  81681. * @param parsedMesh the serialized mesh
  81682. * @param scene the scene to create the ground mesh in
  81683. * @returns the created ground mesh
  81684. */
  81685. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  81686. }
  81687. }
  81688. declare module BABYLON {
  81689. /**
  81690. * Interface for Physics-Joint data
  81691. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81692. */
  81693. export interface PhysicsJointData {
  81694. /**
  81695. * The main pivot of the joint
  81696. */
  81697. mainPivot?: Vector3;
  81698. /**
  81699. * The connected pivot of the joint
  81700. */
  81701. connectedPivot?: Vector3;
  81702. /**
  81703. * The main axis of the joint
  81704. */
  81705. mainAxis?: Vector3;
  81706. /**
  81707. * The connected axis of the joint
  81708. */
  81709. connectedAxis?: Vector3;
  81710. /**
  81711. * The collision of the joint
  81712. */
  81713. collision?: boolean;
  81714. /**
  81715. * Native Oimo/Cannon/Energy data
  81716. */
  81717. nativeParams?: any;
  81718. }
  81719. /**
  81720. * This is a holder class for the physics joint created by the physics plugin
  81721. * It holds a set of functions to control the underlying joint
  81722. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81723. */
  81724. export class PhysicsJoint {
  81725. /**
  81726. * The type of the physics joint
  81727. */
  81728. type: number;
  81729. /**
  81730. * The data for the physics joint
  81731. */
  81732. jointData: PhysicsJointData;
  81733. private _physicsJoint;
  81734. protected _physicsPlugin: IPhysicsEnginePlugin;
  81735. /**
  81736. * Initializes the physics joint
  81737. * @param type The type of the physics joint
  81738. * @param jointData The data for the physics joint
  81739. */
  81740. constructor(
  81741. /**
  81742. * The type of the physics joint
  81743. */
  81744. type: number,
  81745. /**
  81746. * The data for the physics joint
  81747. */
  81748. jointData: PhysicsJointData);
  81749. /**
  81750. * Gets the physics joint
  81751. */
  81752. /**
  81753. * Sets the physics joint
  81754. */
  81755. physicsJoint: any;
  81756. /**
  81757. * Sets the physics plugin
  81758. */
  81759. physicsPlugin: IPhysicsEnginePlugin;
  81760. /**
  81761. * Execute a function that is physics-plugin specific.
  81762. * @param {Function} func the function that will be executed.
  81763. * It accepts two parameters: the physics world and the physics joint
  81764. */
  81765. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  81766. /**
  81767. * Distance-Joint type
  81768. */
  81769. static DistanceJoint: number;
  81770. /**
  81771. * Hinge-Joint type
  81772. */
  81773. static HingeJoint: number;
  81774. /**
  81775. * Ball-and-Socket joint type
  81776. */
  81777. static BallAndSocketJoint: number;
  81778. /**
  81779. * Wheel-Joint type
  81780. */
  81781. static WheelJoint: number;
  81782. /**
  81783. * Slider-Joint type
  81784. */
  81785. static SliderJoint: number;
  81786. /**
  81787. * Prismatic-Joint type
  81788. */
  81789. static PrismaticJoint: number;
  81790. /**
  81791. * Universal-Joint type
  81792. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  81793. */
  81794. static UniversalJoint: number;
  81795. /**
  81796. * Hinge-Joint 2 type
  81797. */
  81798. static Hinge2Joint: number;
  81799. /**
  81800. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  81801. */
  81802. static PointToPointJoint: number;
  81803. /**
  81804. * Spring-Joint type
  81805. */
  81806. static SpringJoint: number;
  81807. /**
  81808. * Lock-Joint type
  81809. */
  81810. static LockJoint: number;
  81811. }
  81812. /**
  81813. * A class representing a physics distance joint
  81814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81815. */
  81816. export class DistanceJoint extends PhysicsJoint {
  81817. /**
  81818. *
  81819. * @param jointData The data for the Distance-Joint
  81820. */
  81821. constructor(jointData: DistanceJointData);
  81822. /**
  81823. * Update the predefined distance.
  81824. * @param maxDistance The maximum preferred distance
  81825. * @param minDistance The minimum preferred distance
  81826. */
  81827. updateDistance(maxDistance: number, minDistance?: number): void;
  81828. }
  81829. /**
  81830. * Represents a Motor-Enabled Joint
  81831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81832. */
  81833. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  81834. /**
  81835. * Initializes the Motor-Enabled Joint
  81836. * @param type The type of the joint
  81837. * @param jointData The physica joint data for the joint
  81838. */
  81839. constructor(type: number, jointData: PhysicsJointData);
  81840. /**
  81841. * Set the motor values.
  81842. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81843. * @param force the force to apply
  81844. * @param maxForce max force for this motor.
  81845. */
  81846. setMotor(force?: number, maxForce?: number): void;
  81847. /**
  81848. * Set the motor's limits.
  81849. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81850. * @param upperLimit The upper limit of the motor
  81851. * @param lowerLimit The lower limit of the motor
  81852. */
  81853. setLimit(upperLimit: number, lowerLimit?: number): void;
  81854. }
  81855. /**
  81856. * This class represents a single physics Hinge-Joint
  81857. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81858. */
  81859. export class HingeJoint extends MotorEnabledJoint {
  81860. /**
  81861. * Initializes the Hinge-Joint
  81862. * @param jointData The joint data for the Hinge-Joint
  81863. */
  81864. constructor(jointData: PhysicsJointData);
  81865. /**
  81866. * Set the motor values.
  81867. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81868. * @param {number} force the force to apply
  81869. * @param {number} maxForce max force for this motor.
  81870. */
  81871. setMotor(force?: number, maxForce?: number): void;
  81872. /**
  81873. * Set the motor's limits.
  81874. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81875. * @param upperLimit The upper limit of the motor
  81876. * @param lowerLimit The lower limit of the motor
  81877. */
  81878. setLimit(upperLimit: number, lowerLimit?: number): void;
  81879. }
  81880. /**
  81881. * This class represents a dual hinge physics joint (same as wheel joint)
  81882. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81883. */
  81884. export class Hinge2Joint extends MotorEnabledJoint {
  81885. /**
  81886. * Initializes the Hinge2-Joint
  81887. * @param jointData The joint data for the Hinge2-Joint
  81888. */
  81889. constructor(jointData: PhysicsJointData);
  81890. /**
  81891. * Set the motor values.
  81892. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81893. * @param {number} targetSpeed the speed the motor is to reach
  81894. * @param {number} maxForce max force for this motor.
  81895. * @param {motorIndex} the motor's index, 0 or 1.
  81896. */
  81897. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  81898. /**
  81899. * Set the motor limits.
  81900. * Attention, this function is plugin specific. Engines won't react 100% the same.
  81901. * @param {number} upperLimit the upper limit
  81902. * @param {number} lowerLimit lower limit
  81903. * @param {motorIndex} the motor's index, 0 or 1.
  81904. */
  81905. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  81906. }
  81907. /**
  81908. * Interface for a motor enabled joint
  81909. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81910. */
  81911. export interface IMotorEnabledJoint {
  81912. /**
  81913. * Physics joint
  81914. */
  81915. physicsJoint: any;
  81916. /**
  81917. * Sets the motor of the motor-enabled joint
  81918. * @param force The force of the motor
  81919. * @param maxForce The maximum force of the motor
  81920. * @param motorIndex The index of the motor
  81921. */
  81922. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  81923. /**
  81924. * Sets the limit of the motor
  81925. * @param upperLimit The upper limit of the motor
  81926. * @param lowerLimit The lower limit of the motor
  81927. * @param motorIndex The index of the motor
  81928. */
  81929. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  81930. }
  81931. /**
  81932. * Joint data for a Distance-Joint
  81933. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81934. */
  81935. export interface DistanceJointData extends PhysicsJointData {
  81936. /**
  81937. * Max distance the 2 joint objects can be apart
  81938. */
  81939. maxDistance: number;
  81940. }
  81941. /**
  81942. * Joint data from a spring joint
  81943. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81944. */
  81945. export interface SpringJointData extends PhysicsJointData {
  81946. /**
  81947. * Length of the spring
  81948. */
  81949. length: number;
  81950. /**
  81951. * Stiffness of the spring
  81952. */
  81953. stiffness: number;
  81954. /**
  81955. * Damping of the spring
  81956. */
  81957. damping: number;
  81958. /** this callback will be called when applying the force to the impostors. */
  81959. forceApplicationCallback: () => void;
  81960. }
  81961. }
  81962. declare module BABYLON {
  81963. /**
  81964. * Holds the data for the raycast result
  81965. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  81966. */
  81967. export class PhysicsRaycastResult {
  81968. private _hasHit;
  81969. private _hitDistance;
  81970. private _hitNormalWorld;
  81971. private _hitPointWorld;
  81972. private _rayFromWorld;
  81973. private _rayToWorld;
  81974. /**
  81975. * Gets if there was a hit
  81976. */
  81977. readonly hasHit: boolean;
  81978. /**
  81979. * Gets the distance from the hit
  81980. */
  81981. readonly hitDistance: number;
  81982. /**
  81983. * Gets the hit normal/direction in the world
  81984. */
  81985. readonly hitNormalWorld: Vector3;
  81986. /**
  81987. * Gets the hit point in the world
  81988. */
  81989. readonly hitPointWorld: Vector3;
  81990. /**
  81991. * Gets the ray "start point" of the ray in the world
  81992. */
  81993. readonly rayFromWorld: Vector3;
  81994. /**
  81995. * Gets the ray "end point" of the ray in the world
  81996. */
  81997. readonly rayToWorld: Vector3;
  81998. /**
  81999. * Sets the hit data (normal & point in world space)
  82000. * @param hitNormalWorld defines the normal in world space
  82001. * @param hitPointWorld defines the point in world space
  82002. */
  82003. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  82004. /**
  82005. * Sets the distance from the start point to the hit point
  82006. * @param distance
  82007. */
  82008. setHitDistance(distance: number): void;
  82009. /**
  82010. * Calculates the distance manually
  82011. */
  82012. calculateHitDistance(): void;
  82013. /**
  82014. * Resets all the values to default
  82015. * @param from The from point on world space
  82016. * @param to The to point on world space
  82017. */
  82018. reset(from?: Vector3, to?: Vector3): void;
  82019. }
  82020. /**
  82021. * Interface for the size containing width and height
  82022. */
  82023. interface IXYZ {
  82024. /**
  82025. * X
  82026. */
  82027. x: number;
  82028. /**
  82029. * Y
  82030. */
  82031. y: number;
  82032. /**
  82033. * Z
  82034. */
  82035. z: number;
  82036. }
  82037. }
  82038. declare module BABYLON {
  82039. /**
  82040. * Interface used to describe a physics joint
  82041. */
  82042. export interface PhysicsImpostorJoint {
  82043. /** Defines the main impostor to which the joint is linked */
  82044. mainImpostor: PhysicsImpostor;
  82045. /** Defines the impostor that is connected to the main impostor using this joint */
  82046. connectedImpostor: PhysicsImpostor;
  82047. /** Defines the joint itself */
  82048. joint: PhysicsJoint;
  82049. }
  82050. /** @hidden */
  82051. export interface IPhysicsEnginePlugin {
  82052. world: any;
  82053. name: string;
  82054. setGravity(gravity: Vector3): void;
  82055. setTimeStep(timeStep: number): void;
  82056. getTimeStep(): number;
  82057. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  82058. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  82059. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  82060. generatePhysicsBody(impostor: PhysicsImpostor): void;
  82061. removePhysicsBody(impostor: PhysicsImpostor): void;
  82062. generateJoint(joint: PhysicsImpostorJoint): void;
  82063. removeJoint(joint: PhysicsImpostorJoint): void;
  82064. isSupported(): boolean;
  82065. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  82066. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  82067. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  82068. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  82069. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  82070. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  82071. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  82072. getBodyMass(impostor: PhysicsImpostor): number;
  82073. getBodyFriction(impostor: PhysicsImpostor): number;
  82074. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  82075. getBodyRestitution(impostor: PhysicsImpostor): number;
  82076. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  82077. getBodyPressure?(impostor: PhysicsImpostor): number;
  82078. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  82079. getBodyStiffness?(impostor: PhysicsImpostor): number;
  82080. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  82081. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  82082. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  82083. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  82084. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  82085. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  82086. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  82087. sleepBody(impostor: PhysicsImpostor): void;
  82088. wakeUpBody(impostor: PhysicsImpostor): void;
  82089. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82090. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  82091. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  82092. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  82093. getRadius(impostor: PhysicsImpostor): number;
  82094. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  82095. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  82096. dispose(): void;
  82097. }
  82098. /**
  82099. * Interface used to define a physics engine
  82100. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  82101. */
  82102. export interface IPhysicsEngine {
  82103. /**
  82104. * Gets the gravity vector used by the simulation
  82105. */
  82106. gravity: Vector3;
  82107. /**
  82108. * Sets the gravity vector used by the simulation
  82109. * @param gravity defines the gravity vector to use
  82110. */
  82111. setGravity(gravity: Vector3): void;
  82112. /**
  82113. * Set the time step of the physics engine.
  82114. * Default is 1/60.
  82115. * To slow it down, enter 1/600 for example.
  82116. * To speed it up, 1/30
  82117. * @param newTimeStep the new timestep to apply to this world.
  82118. */
  82119. setTimeStep(newTimeStep: number): void;
  82120. /**
  82121. * Get the time step of the physics engine.
  82122. * @returns the current time step
  82123. */
  82124. getTimeStep(): number;
  82125. /**
  82126. * Release all resources
  82127. */
  82128. dispose(): void;
  82129. /**
  82130. * Gets the name of the current physics plugin
  82131. * @returns the name of the plugin
  82132. */
  82133. getPhysicsPluginName(): string;
  82134. /**
  82135. * Adding a new impostor for the impostor tracking.
  82136. * This will be done by the impostor itself.
  82137. * @param impostor the impostor to add
  82138. */
  82139. addImpostor(impostor: PhysicsImpostor): void;
  82140. /**
  82141. * Remove an impostor from the engine.
  82142. * This impostor and its mesh will not longer be updated by the physics engine.
  82143. * @param impostor the impostor to remove
  82144. */
  82145. removeImpostor(impostor: PhysicsImpostor): void;
  82146. /**
  82147. * Add a joint to the physics engine
  82148. * @param mainImpostor defines the main impostor to which the joint is added.
  82149. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  82150. * @param joint defines the joint that will connect both impostors.
  82151. */
  82152. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82153. /**
  82154. * Removes a joint from the simulation
  82155. * @param mainImpostor defines the impostor used with the joint
  82156. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  82157. * @param joint defines the joint to remove
  82158. */
  82159. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  82160. /**
  82161. * Gets the current plugin used to run the simulation
  82162. * @returns current plugin
  82163. */
  82164. getPhysicsPlugin(): IPhysicsEnginePlugin;
  82165. /**
  82166. * Gets the list of physic impostors
  82167. * @returns an array of PhysicsImpostor
  82168. */
  82169. getImpostors(): Array<PhysicsImpostor>;
  82170. /**
  82171. * Gets the impostor for a physics enabled object
  82172. * @param object defines the object impersonated by the impostor
  82173. * @returns the PhysicsImpostor or null if not found
  82174. */
  82175. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  82176. /**
  82177. * Gets the impostor for a physics body object
  82178. * @param body defines physics body used by the impostor
  82179. * @returns the PhysicsImpostor or null if not found
  82180. */
  82181. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  82182. /**
  82183. * Does a raycast in the physics world
  82184. * @param from when should the ray start?
  82185. * @param to when should the ray end?
  82186. * @returns PhysicsRaycastResult
  82187. */
  82188. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  82189. /**
  82190. * Called by the scene. No need to call it.
  82191. * @param delta defines the timespam between frames
  82192. */
  82193. _step(delta: number): void;
  82194. }
  82195. }
  82196. declare module BABYLON {
  82197. /**
  82198. * The interface for the physics imposter parameters
  82199. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82200. */
  82201. export interface PhysicsImpostorParameters {
  82202. /**
  82203. * The mass of the physics imposter
  82204. */
  82205. mass: number;
  82206. /**
  82207. * The friction of the physics imposter
  82208. */
  82209. friction?: number;
  82210. /**
  82211. * The coefficient of restitution of the physics imposter
  82212. */
  82213. restitution?: number;
  82214. /**
  82215. * The native options of the physics imposter
  82216. */
  82217. nativeOptions?: any;
  82218. /**
  82219. * Specifies if the parent should be ignored
  82220. */
  82221. ignoreParent?: boolean;
  82222. /**
  82223. * Specifies if bi-directional transformations should be disabled
  82224. */
  82225. disableBidirectionalTransformation?: boolean;
  82226. /**
  82227. * The pressure inside the physics imposter, soft object only
  82228. */
  82229. pressure?: number;
  82230. /**
  82231. * The stiffness the physics imposter, soft object only
  82232. */
  82233. stiffness?: number;
  82234. /**
  82235. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  82236. */
  82237. velocityIterations?: number;
  82238. /**
  82239. * The number of iterations used in maintaining consistent vertex positions, soft object only
  82240. */
  82241. positionIterations?: number;
  82242. /**
  82243. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  82244. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  82245. * Add to fix multiple points
  82246. */
  82247. fixedPoints?: number;
  82248. /**
  82249. * The collision margin around a soft object
  82250. */
  82251. margin?: number;
  82252. /**
  82253. * The collision margin around a soft object
  82254. */
  82255. damping?: number;
  82256. /**
  82257. * The path for a rope based on an extrusion
  82258. */
  82259. path?: any;
  82260. /**
  82261. * The shape of an extrusion used for a rope based on an extrusion
  82262. */
  82263. shape?: any;
  82264. }
  82265. /**
  82266. * Interface for a physics-enabled object
  82267. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82268. */
  82269. export interface IPhysicsEnabledObject {
  82270. /**
  82271. * The position of the physics-enabled object
  82272. */
  82273. position: Vector3;
  82274. /**
  82275. * The rotation of the physics-enabled object
  82276. */
  82277. rotationQuaternion: Nullable<Quaternion>;
  82278. /**
  82279. * The scale of the physics-enabled object
  82280. */
  82281. scaling: Vector3;
  82282. /**
  82283. * The rotation of the physics-enabled object
  82284. */
  82285. rotation?: Vector3;
  82286. /**
  82287. * The parent of the physics-enabled object
  82288. */
  82289. parent?: any;
  82290. /**
  82291. * The bounding info of the physics-enabled object
  82292. * @returns The bounding info of the physics-enabled object
  82293. */
  82294. getBoundingInfo(): BoundingInfo;
  82295. /**
  82296. * Computes the world matrix
  82297. * @param force Specifies if the world matrix should be computed by force
  82298. * @returns A world matrix
  82299. */
  82300. computeWorldMatrix(force: boolean): Matrix;
  82301. /**
  82302. * Gets the world matrix
  82303. * @returns A world matrix
  82304. */
  82305. getWorldMatrix?(): Matrix;
  82306. /**
  82307. * Gets the child meshes
  82308. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  82309. * @returns An array of abstract meshes
  82310. */
  82311. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  82312. /**
  82313. * Gets the vertex data
  82314. * @param kind The type of vertex data
  82315. * @returns A nullable array of numbers, or a float32 array
  82316. */
  82317. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  82318. /**
  82319. * Gets the indices from the mesh
  82320. * @returns A nullable array of index arrays
  82321. */
  82322. getIndices?(): Nullable<IndicesArray>;
  82323. /**
  82324. * Gets the scene from the mesh
  82325. * @returns the indices array or null
  82326. */
  82327. getScene?(): Scene;
  82328. /**
  82329. * Gets the absolute position from the mesh
  82330. * @returns the absolute position
  82331. */
  82332. getAbsolutePosition(): Vector3;
  82333. /**
  82334. * Gets the absolute pivot point from the mesh
  82335. * @returns the absolute pivot point
  82336. */
  82337. getAbsolutePivotPoint(): Vector3;
  82338. /**
  82339. * Rotates the mesh
  82340. * @param axis The axis of rotation
  82341. * @param amount The amount of rotation
  82342. * @param space The space of the rotation
  82343. * @returns The rotation transform node
  82344. */
  82345. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  82346. /**
  82347. * Translates the mesh
  82348. * @param axis The axis of translation
  82349. * @param distance The distance of translation
  82350. * @param space The space of the translation
  82351. * @returns The transform node
  82352. */
  82353. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  82354. /**
  82355. * Sets the absolute position of the mesh
  82356. * @param absolutePosition The absolute position of the mesh
  82357. * @returns The transform node
  82358. */
  82359. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  82360. /**
  82361. * Gets the class name of the mesh
  82362. * @returns The class name
  82363. */
  82364. getClassName(): string;
  82365. }
  82366. /**
  82367. * Represents a physics imposter
  82368. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  82369. */
  82370. export class PhysicsImpostor {
  82371. /**
  82372. * The physics-enabled object used as the physics imposter
  82373. */
  82374. object: IPhysicsEnabledObject;
  82375. /**
  82376. * The type of the physics imposter
  82377. */
  82378. type: number;
  82379. private _options;
  82380. private _scene?;
  82381. /**
  82382. * The default object size of the imposter
  82383. */
  82384. static DEFAULT_OBJECT_SIZE: Vector3;
  82385. /**
  82386. * The identity quaternion of the imposter
  82387. */
  82388. static IDENTITY_QUATERNION: Quaternion;
  82389. /** @hidden */
  82390. _pluginData: any;
  82391. private _physicsEngine;
  82392. private _physicsBody;
  82393. private _bodyUpdateRequired;
  82394. private _onBeforePhysicsStepCallbacks;
  82395. private _onAfterPhysicsStepCallbacks;
  82396. /** @hidden */
  82397. _onPhysicsCollideCallbacks: Array<{
  82398. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  82399. otherImpostors: Array<PhysicsImpostor>;
  82400. }>;
  82401. private _deltaPosition;
  82402. private _deltaRotation;
  82403. private _deltaRotationConjugated;
  82404. /** hidden */
  82405. _isFromLine: boolean;
  82406. private _parent;
  82407. private _isDisposed;
  82408. private static _tmpVecs;
  82409. private static _tmpQuat;
  82410. /**
  82411. * Specifies if the physics imposter is disposed
  82412. */
  82413. readonly isDisposed: boolean;
  82414. /**
  82415. * Gets the mass of the physics imposter
  82416. */
  82417. mass: number;
  82418. /**
  82419. * Gets the coefficient of friction
  82420. */
  82421. /**
  82422. * Sets the coefficient of friction
  82423. */
  82424. friction: number;
  82425. /**
  82426. * Gets the coefficient of restitution
  82427. */
  82428. /**
  82429. * Sets the coefficient of restitution
  82430. */
  82431. restitution: number;
  82432. /**
  82433. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  82434. */
  82435. /**
  82436. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  82437. */
  82438. pressure: number;
  82439. /**
  82440. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82441. */
  82442. /**
  82443. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  82444. */
  82445. stiffness: number;
  82446. /**
  82447. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82448. */
  82449. /**
  82450. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  82451. */
  82452. velocityIterations: number;
  82453. /**
  82454. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82455. */
  82456. /**
  82457. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  82458. */
  82459. positionIterations: number;
  82460. /**
  82461. * The unique id of the physics imposter
  82462. * set by the physics engine when adding this impostor to the array
  82463. */
  82464. uniqueId: number;
  82465. /**
  82466. * @hidden
  82467. */
  82468. soft: boolean;
  82469. /**
  82470. * @hidden
  82471. */
  82472. segments: number;
  82473. private _joints;
  82474. /**
  82475. * Initializes the physics imposter
  82476. * @param object The physics-enabled object used as the physics imposter
  82477. * @param type The type of the physics imposter
  82478. * @param _options The options for the physics imposter
  82479. * @param _scene The Babylon scene
  82480. */
  82481. constructor(
  82482. /**
  82483. * The physics-enabled object used as the physics imposter
  82484. */
  82485. object: IPhysicsEnabledObject,
  82486. /**
  82487. * The type of the physics imposter
  82488. */
  82489. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  82490. /**
  82491. * This function will completly initialize this impostor.
  82492. * It will create a new body - but only if this mesh has no parent.
  82493. * If it has, this impostor will not be used other than to define the impostor
  82494. * of the child mesh.
  82495. * @hidden
  82496. */
  82497. _init(): void;
  82498. private _getPhysicsParent;
  82499. /**
  82500. * Should a new body be generated.
  82501. * @returns boolean specifying if body initialization is required
  82502. */
  82503. isBodyInitRequired(): boolean;
  82504. /**
  82505. * Sets the updated scaling
  82506. * @param updated Specifies if the scaling is updated
  82507. */
  82508. setScalingUpdated(): void;
  82509. /**
  82510. * Force a regeneration of this or the parent's impostor's body.
  82511. * Use under cautious - This will remove all joints already implemented.
  82512. */
  82513. forceUpdate(): void;
  82514. /**
  82515. * Gets the body that holds this impostor. Either its own, or its parent.
  82516. */
  82517. /**
  82518. * Set the physics body. Used mainly by the physics engine/plugin
  82519. */
  82520. physicsBody: any;
  82521. /**
  82522. * Get the parent of the physics imposter
  82523. * @returns Physics imposter or null
  82524. */
  82525. /**
  82526. * Sets the parent of the physics imposter
  82527. */
  82528. parent: Nullable<PhysicsImpostor>;
  82529. /**
  82530. * Resets the update flags
  82531. */
  82532. resetUpdateFlags(): void;
  82533. /**
  82534. * Gets the object extend size
  82535. * @returns the object extend size
  82536. */
  82537. getObjectExtendSize(): Vector3;
  82538. /**
  82539. * Gets the object center
  82540. * @returns The object center
  82541. */
  82542. getObjectCenter(): Vector3;
  82543. /**
  82544. * Get a specific parametes from the options parameter
  82545. * @param paramName The object parameter name
  82546. * @returns The object parameter
  82547. */
  82548. getParam(paramName: string): any;
  82549. /**
  82550. * Sets a specific parameter in the options given to the physics plugin
  82551. * @param paramName The parameter name
  82552. * @param value The value of the parameter
  82553. */
  82554. setParam(paramName: string, value: number): void;
  82555. /**
  82556. * Specifically change the body's mass option. Won't recreate the physics body object
  82557. * @param mass The mass of the physics imposter
  82558. */
  82559. setMass(mass: number): void;
  82560. /**
  82561. * Gets the linear velocity
  82562. * @returns linear velocity or null
  82563. */
  82564. getLinearVelocity(): Nullable<Vector3>;
  82565. /**
  82566. * Sets the linear velocity
  82567. * @param velocity linear velocity or null
  82568. */
  82569. setLinearVelocity(velocity: Nullable<Vector3>): void;
  82570. /**
  82571. * Gets the angular velocity
  82572. * @returns angular velocity or null
  82573. */
  82574. getAngularVelocity(): Nullable<Vector3>;
  82575. /**
  82576. * Sets the angular velocity
  82577. * @param velocity The velocity or null
  82578. */
  82579. setAngularVelocity(velocity: Nullable<Vector3>): void;
  82580. /**
  82581. * Execute a function with the physics plugin native code
  82582. * Provide a function the will have two variables - the world object and the physics body object
  82583. * @param func The function to execute with the physics plugin native code
  82584. */
  82585. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  82586. /**
  82587. * Register a function that will be executed before the physics world is stepping forward
  82588. * @param func The function to execute before the physics world is stepped forward
  82589. */
  82590. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82591. /**
  82592. * Unregister a function that will be executed before the physics world is stepping forward
  82593. * @param func The function to execute before the physics world is stepped forward
  82594. */
  82595. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82596. /**
  82597. * Register a function that will be executed after the physics step
  82598. * @param func The function to execute after physics step
  82599. */
  82600. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82601. /**
  82602. * Unregisters a function that will be executed after the physics step
  82603. * @param func The function to execute after physics step
  82604. */
  82605. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  82606. /**
  82607. * register a function that will be executed when this impostor collides against a different body
  82608. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  82609. * @param func Callback that is executed on collision
  82610. */
  82611. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  82612. /**
  82613. * Unregisters the physics imposter on contact
  82614. * @param collideAgainst The physics object to collide against
  82615. * @param func Callback to execute on collision
  82616. */
  82617. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  82618. private _tmpQuat;
  82619. private _tmpQuat2;
  82620. /**
  82621. * Get the parent rotation
  82622. * @returns The parent rotation
  82623. */
  82624. getParentsRotation(): Quaternion;
  82625. /**
  82626. * this function is executed by the physics engine.
  82627. */
  82628. beforeStep: () => void;
  82629. /**
  82630. * this function is executed by the physics engine
  82631. */
  82632. afterStep: () => void;
  82633. /**
  82634. * Legacy collision detection event support
  82635. */
  82636. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  82637. /**
  82638. * event and body object due to cannon's event-based architecture.
  82639. */
  82640. onCollide: (e: {
  82641. body: any;
  82642. }) => void;
  82643. /**
  82644. * Apply a force
  82645. * @param force The force to apply
  82646. * @param contactPoint The contact point for the force
  82647. * @returns The physics imposter
  82648. */
  82649. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  82650. /**
  82651. * Apply an impulse
  82652. * @param force The impulse force
  82653. * @param contactPoint The contact point for the impulse force
  82654. * @returns The physics imposter
  82655. */
  82656. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  82657. /**
  82658. * A help function to create a joint
  82659. * @param otherImpostor A physics imposter used to create a joint
  82660. * @param jointType The type of joint
  82661. * @param jointData The data for the joint
  82662. * @returns The physics imposter
  82663. */
  82664. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  82665. /**
  82666. * Add a joint to this impostor with a different impostor
  82667. * @param otherImpostor A physics imposter used to add a joint
  82668. * @param joint The joint to add
  82669. * @returns The physics imposter
  82670. */
  82671. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  82672. /**
  82673. * Add an anchor to a cloth impostor
  82674. * @param otherImpostor rigid impostor to anchor to
  82675. * @param width ratio across width from 0 to 1
  82676. * @param height ratio up height from 0 to 1
  82677. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  82678. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  82679. * @returns impostor the soft imposter
  82680. */
  82681. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  82682. /**
  82683. * Add a hook to a rope impostor
  82684. * @param otherImpostor rigid impostor to anchor to
  82685. * @param length ratio across rope from 0 to 1
  82686. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  82687. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  82688. * @returns impostor the rope imposter
  82689. */
  82690. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  82691. /**
  82692. * Will keep this body still, in a sleep mode.
  82693. * @returns the physics imposter
  82694. */
  82695. sleep(): PhysicsImpostor;
  82696. /**
  82697. * Wake the body up.
  82698. * @returns The physics imposter
  82699. */
  82700. wakeUp(): PhysicsImpostor;
  82701. /**
  82702. * Clones the physics imposter
  82703. * @param newObject The physics imposter clones to this physics-enabled object
  82704. * @returns A nullable physics imposter
  82705. */
  82706. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  82707. /**
  82708. * Disposes the physics imposter
  82709. */
  82710. dispose(): void;
  82711. /**
  82712. * Sets the delta position
  82713. * @param position The delta position amount
  82714. */
  82715. setDeltaPosition(position: Vector3): void;
  82716. /**
  82717. * Sets the delta rotation
  82718. * @param rotation The delta rotation amount
  82719. */
  82720. setDeltaRotation(rotation: Quaternion): void;
  82721. /**
  82722. * Gets the box size of the physics imposter and stores the result in the input parameter
  82723. * @param result Stores the box size
  82724. * @returns The physics imposter
  82725. */
  82726. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  82727. /**
  82728. * Gets the radius of the physics imposter
  82729. * @returns Radius of the physics imposter
  82730. */
  82731. getRadius(): number;
  82732. /**
  82733. * Sync a bone with this impostor
  82734. * @param bone The bone to sync to the impostor.
  82735. * @param boneMesh The mesh that the bone is influencing.
  82736. * @param jointPivot The pivot of the joint / bone in local space.
  82737. * @param distToJoint Optional distance from the impostor to the joint.
  82738. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  82739. */
  82740. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  82741. /**
  82742. * Sync impostor to a bone
  82743. * @param bone The bone that the impostor will be synced to.
  82744. * @param boneMesh The mesh that the bone is influencing.
  82745. * @param jointPivot The pivot of the joint / bone in local space.
  82746. * @param distToJoint Optional distance from the impostor to the joint.
  82747. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  82748. * @param boneAxis Optional vector3 axis the bone is aligned with
  82749. */
  82750. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  82751. /**
  82752. * No-Imposter type
  82753. */
  82754. static NoImpostor: number;
  82755. /**
  82756. * Sphere-Imposter type
  82757. */
  82758. static SphereImpostor: number;
  82759. /**
  82760. * Box-Imposter type
  82761. */
  82762. static BoxImpostor: number;
  82763. /**
  82764. * Plane-Imposter type
  82765. */
  82766. static PlaneImpostor: number;
  82767. /**
  82768. * Mesh-imposter type
  82769. */
  82770. static MeshImpostor: number;
  82771. /**
  82772. * Cylinder-Imposter type
  82773. */
  82774. static CylinderImpostor: number;
  82775. /**
  82776. * Particle-Imposter type
  82777. */
  82778. static ParticleImpostor: number;
  82779. /**
  82780. * Heightmap-Imposter type
  82781. */
  82782. static HeightmapImpostor: number;
  82783. /**
  82784. * ConvexHull-Impostor type (Ammo.js plugin only)
  82785. */
  82786. static ConvexHullImpostor: number;
  82787. /**
  82788. * Rope-Imposter type
  82789. */
  82790. static RopeImpostor: number;
  82791. /**
  82792. * Cloth-Imposter type
  82793. */
  82794. static ClothImpostor: number;
  82795. /**
  82796. * Softbody-Imposter type
  82797. */
  82798. static SoftbodyImpostor: number;
  82799. }
  82800. }
  82801. declare module BABYLON {
  82802. /**
  82803. * @hidden
  82804. **/
  82805. export class _CreationDataStorage {
  82806. closePath?: boolean;
  82807. closeArray?: boolean;
  82808. idx: number[];
  82809. dashSize: number;
  82810. gapSize: number;
  82811. path3D: Path3D;
  82812. pathArray: Vector3[][];
  82813. arc: number;
  82814. radius: number;
  82815. cap: number;
  82816. tessellation: number;
  82817. }
  82818. /**
  82819. * @hidden
  82820. **/
  82821. class _InstanceDataStorage {
  82822. visibleInstances: any;
  82823. batchCache: _InstancesBatch;
  82824. instancesBufferSize: number;
  82825. instancesBuffer: Nullable<Buffer>;
  82826. instancesData: Float32Array;
  82827. overridenInstanceCount: number;
  82828. isFrozen: boolean;
  82829. previousBatch: _InstancesBatch;
  82830. hardwareInstancedRendering: boolean;
  82831. sideOrientation: number;
  82832. }
  82833. /**
  82834. * @hidden
  82835. **/
  82836. export class _InstancesBatch {
  82837. mustReturn: boolean;
  82838. visibleInstances: Nullable<InstancedMesh[]>[];
  82839. renderSelf: boolean[];
  82840. hardwareInstancedRendering: boolean[];
  82841. }
  82842. /**
  82843. * Class used to represent renderable models
  82844. */
  82845. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  82846. /**
  82847. * Mesh side orientation : usually the external or front surface
  82848. */
  82849. static readonly FRONTSIDE: number;
  82850. /**
  82851. * Mesh side orientation : usually the internal or back surface
  82852. */
  82853. static readonly BACKSIDE: number;
  82854. /**
  82855. * Mesh side orientation : both internal and external or front and back surfaces
  82856. */
  82857. static readonly DOUBLESIDE: number;
  82858. /**
  82859. * Mesh side orientation : by default, `FRONTSIDE`
  82860. */
  82861. static readonly DEFAULTSIDE: number;
  82862. /**
  82863. * Mesh cap setting : no cap
  82864. */
  82865. static readonly NO_CAP: number;
  82866. /**
  82867. * Mesh cap setting : one cap at the beginning of the mesh
  82868. */
  82869. static readonly CAP_START: number;
  82870. /**
  82871. * Mesh cap setting : one cap at the end of the mesh
  82872. */
  82873. static readonly CAP_END: number;
  82874. /**
  82875. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  82876. */
  82877. static readonly CAP_ALL: number;
  82878. /**
  82879. * Mesh pattern setting : no flip or rotate
  82880. */
  82881. static readonly NO_FLIP: number;
  82882. /**
  82883. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  82884. */
  82885. static readonly FLIP_TILE: number;
  82886. /**
  82887. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  82888. */
  82889. static readonly ROTATE_TILE: number;
  82890. /**
  82891. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  82892. */
  82893. static readonly FLIP_ROW: number;
  82894. /**
  82895. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  82896. */
  82897. static readonly ROTATE_ROW: number;
  82898. /**
  82899. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  82900. */
  82901. static readonly FLIP_N_ROTATE_TILE: number;
  82902. /**
  82903. * Mesh pattern setting : rotate pattern and rotate
  82904. */
  82905. static readonly FLIP_N_ROTATE_ROW: number;
  82906. /**
  82907. * Mesh tile positioning : part tiles same on left/right or top/bottom
  82908. */
  82909. static readonly CENTER: number;
  82910. /**
  82911. * Mesh tile positioning : part tiles on left
  82912. */
  82913. static readonly LEFT: number;
  82914. /**
  82915. * Mesh tile positioning : part tiles on right
  82916. */
  82917. static readonly RIGHT: number;
  82918. /**
  82919. * Mesh tile positioning : part tiles on top
  82920. */
  82921. static readonly TOP: number;
  82922. /**
  82923. * Mesh tile positioning : part tiles on bottom
  82924. */
  82925. static readonly BOTTOM: number;
  82926. /**
  82927. * Gets the default side orientation.
  82928. * @param orientation the orientation to value to attempt to get
  82929. * @returns the default orientation
  82930. * @hidden
  82931. */
  82932. static _GetDefaultSideOrientation(orientation?: number): number;
  82933. private _internalMeshDataInfo;
  82934. /**
  82935. * An event triggered before rendering the mesh
  82936. */
  82937. readonly onBeforeRenderObservable: Observable<Mesh>;
  82938. /**
  82939. * An event triggered before binding the mesh
  82940. */
  82941. readonly onBeforeBindObservable: Observable<Mesh>;
  82942. /**
  82943. * An event triggered after rendering the mesh
  82944. */
  82945. readonly onAfterRenderObservable: Observable<Mesh>;
  82946. /**
  82947. * An event triggered before drawing the mesh
  82948. */
  82949. readonly onBeforeDrawObservable: Observable<Mesh>;
  82950. private _onBeforeDrawObserver;
  82951. /**
  82952. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  82953. */
  82954. onBeforeDraw: () => void;
  82955. /**
  82956. * Gets the delay loading state of the mesh (when delay loading is turned on)
  82957. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  82958. */
  82959. delayLoadState: number;
  82960. /**
  82961. * Gets the list of instances created from this mesh
  82962. * it is not supposed to be modified manually.
  82963. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  82964. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  82965. */
  82966. instances: InstancedMesh[];
  82967. /**
  82968. * Gets the file containing delay loading data for this mesh
  82969. */
  82970. delayLoadingFile: string;
  82971. /** @hidden */
  82972. _binaryInfo: any;
  82973. /**
  82974. * User defined function used to change how LOD level selection is done
  82975. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  82976. */
  82977. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  82978. /**
  82979. * Gets or sets the morph target manager
  82980. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  82981. */
  82982. morphTargetManager: Nullable<MorphTargetManager>;
  82983. /** @hidden */
  82984. _creationDataStorage: Nullable<_CreationDataStorage>;
  82985. /** @hidden */
  82986. _geometry: Nullable<Geometry>;
  82987. /** @hidden */
  82988. _delayInfo: Array<string>;
  82989. /** @hidden */
  82990. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  82991. /** @hidden */
  82992. _instanceDataStorage: _InstanceDataStorage;
  82993. private _effectiveMaterial;
  82994. /** @hidden */
  82995. _shouldGenerateFlatShading: boolean;
  82996. /** @hidden */
  82997. _originalBuilderSideOrientation: number;
  82998. /**
  82999. * Use this property to change the original side orientation defined at construction time
  83000. */
  83001. overrideMaterialSideOrientation: Nullable<number>;
  83002. /**
  83003. * Gets the source mesh (the one used to clone this one from)
  83004. */
  83005. readonly source: Nullable<Mesh>;
  83006. /**
  83007. * Gets or sets a boolean indicating that this mesh does not use index buffer
  83008. */
  83009. isUnIndexed: boolean;
  83010. /**
  83011. * @constructor
  83012. * @param name The value used by scene.getMeshByName() to do a lookup.
  83013. * @param scene The scene to add this mesh to.
  83014. * @param parent The parent of this mesh, if it has one
  83015. * @param source An optional Mesh from which geometry is shared, cloned.
  83016. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83017. * When false, achieved by calling a clone(), also passing False.
  83018. * This will make creation of children, recursive.
  83019. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  83020. */
  83021. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  83022. /**
  83023. * Gets the class name
  83024. * @returns the string "Mesh".
  83025. */
  83026. getClassName(): string;
  83027. /** @hidden */
  83028. readonly _isMesh: boolean;
  83029. /**
  83030. * Returns a description of this mesh
  83031. * @param fullDetails define if full details about this mesh must be used
  83032. * @returns a descriptive string representing this mesh
  83033. */
  83034. toString(fullDetails?: boolean): string;
  83035. /** @hidden */
  83036. _unBindEffect(): void;
  83037. /**
  83038. * Gets a boolean indicating if this mesh has LOD
  83039. */
  83040. readonly hasLODLevels: boolean;
  83041. /**
  83042. * Gets the list of MeshLODLevel associated with the current mesh
  83043. * @returns an array of MeshLODLevel
  83044. */
  83045. getLODLevels(): MeshLODLevel[];
  83046. private _sortLODLevels;
  83047. /**
  83048. * Add a mesh as LOD level triggered at the given distance.
  83049. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83050. * @param distance The distance from the center of the object to show this level
  83051. * @param mesh The mesh to be added as LOD level (can be null)
  83052. * @return This mesh (for chaining)
  83053. */
  83054. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  83055. /**
  83056. * Returns the LOD level mesh at the passed distance or null if not found.
  83057. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83058. * @param distance The distance from the center of the object to show this level
  83059. * @returns a Mesh or `null`
  83060. */
  83061. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  83062. /**
  83063. * Remove a mesh from the LOD array
  83064. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83065. * @param mesh defines the mesh to be removed
  83066. * @return This mesh (for chaining)
  83067. */
  83068. removeLODLevel(mesh: Mesh): Mesh;
  83069. /**
  83070. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  83071. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  83072. * @param camera defines the camera to use to compute distance
  83073. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  83074. * @return This mesh (for chaining)
  83075. */
  83076. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  83077. /**
  83078. * Gets the mesh internal Geometry object
  83079. */
  83080. readonly geometry: Nullable<Geometry>;
  83081. /**
  83082. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  83083. * @returns the total number of vertices
  83084. */
  83085. getTotalVertices(): number;
  83086. /**
  83087. * Returns the content of an associated vertex buffer
  83088. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83089. * - VertexBuffer.PositionKind
  83090. * - VertexBuffer.UVKind
  83091. * - VertexBuffer.UV2Kind
  83092. * - VertexBuffer.UV3Kind
  83093. * - VertexBuffer.UV4Kind
  83094. * - VertexBuffer.UV5Kind
  83095. * - VertexBuffer.UV6Kind
  83096. * - VertexBuffer.ColorKind
  83097. * - VertexBuffer.MatricesIndicesKind
  83098. * - VertexBuffer.MatricesIndicesExtraKind
  83099. * - VertexBuffer.MatricesWeightsKind
  83100. * - VertexBuffer.MatricesWeightsExtraKind
  83101. * @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
  83102. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  83103. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  83104. */
  83105. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  83106. /**
  83107. * Returns the mesh VertexBuffer object from the requested `kind`
  83108. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83109. * - VertexBuffer.PositionKind
  83110. * - VertexBuffer.NormalKind
  83111. * - VertexBuffer.UVKind
  83112. * - VertexBuffer.UV2Kind
  83113. * - VertexBuffer.UV3Kind
  83114. * - VertexBuffer.UV4Kind
  83115. * - VertexBuffer.UV5Kind
  83116. * - VertexBuffer.UV6Kind
  83117. * - VertexBuffer.ColorKind
  83118. * - VertexBuffer.MatricesIndicesKind
  83119. * - VertexBuffer.MatricesIndicesExtraKind
  83120. * - VertexBuffer.MatricesWeightsKind
  83121. * - VertexBuffer.MatricesWeightsExtraKind
  83122. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  83123. */
  83124. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  83125. /**
  83126. * Tests if a specific vertex buffer is associated with this mesh
  83127. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83128. * - VertexBuffer.PositionKind
  83129. * - VertexBuffer.NormalKind
  83130. * - VertexBuffer.UVKind
  83131. * - VertexBuffer.UV2Kind
  83132. * - VertexBuffer.UV3Kind
  83133. * - VertexBuffer.UV4Kind
  83134. * - VertexBuffer.UV5Kind
  83135. * - VertexBuffer.UV6Kind
  83136. * - VertexBuffer.ColorKind
  83137. * - VertexBuffer.MatricesIndicesKind
  83138. * - VertexBuffer.MatricesIndicesExtraKind
  83139. * - VertexBuffer.MatricesWeightsKind
  83140. * - VertexBuffer.MatricesWeightsExtraKind
  83141. * @returns a boolean
  83142. */
  83143. isVerticesDataPresent(kind: string): boolean;
  83144. /**
  83145. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  83146. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  83147. * - VertexBuffer.PositionKind
  83148. * - VertexBuffer.UVKind
  83149. * - VertexBuffer.UV2Kind
  83150. * - VertexBuffer.UV3Kind
  83151. * - VertexBuffer.UV4Kind
  83152. * - VertexBuffer.UV5Kind
  83153. * - VertexBuffer.UV6Kind
  83154. * - VertexBuffer.ColorKind
  83155. * - VertexBuffer.MatricesIndicesKind
  83156. * - VertexBuffer.MatricesIndicesExtraKind
  83157. * - VertexBuffer.MatricesWeightsKind
  83158. * - VertexBuffer.MatricesWeightsExtraKind
  83159. * @returns a boolean
  83160. */
  83161. isVertexBufferUpdatable(kind: string): boolean;
  83162. /**
  83163. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  83164. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  83165. * - VertexBuffer.PositionKind
  83166. * - VertexBuffer.NormalKind
  83167. * - VertexBuffer.UVKind
  83168. * - VertexBuffer.UV2Kind
  83169. * - VertexBuffer.UV3Kind
  83170. * - VertexBuffer.UV4Kind
  83171. * - VertexBuffer.UV5Kind
  83172. * - VertexBuffer.UV6Kind
  83173. * - VertexBuffer.ColorKind
  83174. * - VertexBuffer.MatricesIndicesKind
  83175. * - VertexBuffer.MatricesIndicesExtraKind
  83176. * - VertexBuffer.MatricesWeightsKind
  83177. * - VertexBuffer.MatricesWeightsExtraKind
  83178. * @returns an array of strings
  83179. */
  83180. getVerticesDataKinds(): string[];
  83181. /**
  83182. * Returns a positive integer : the total number of indices in this mesh geometry.
  83183. * @returns the numner of indices or zero if the mesh has no geometry.
  83184. */
  83185. getTotalIndices(): number;
  83186. /**
  83187. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83188. * @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.
  83189. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  83190. * @returns the indices array or an empty array if the mesh has no geometry
  83191. */
  83192. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  83193. readonly isBlocked: boolean;
  83194. /**
  83195. * Determine if the current mesh is ready to be rendered
  83196. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83197. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  83198. * @returns true if all associated assets are ready (material, textures, shaders)
  83199. */
  83200. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  83201. /**
  83202. * 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.
  83203. */
  83204. readonly areNormalsFrozen: boolean;
  83205. /**
  83206. * 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.
  83207. * @returns the current mesh
  83208. */
  83209. freezeNormals(): Mesh;
  83210. /**
  83211. * 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
  83212. * @returns the current mesh
  83213. */
  83214. unfreezeNormals(): Mesh;
  83215. /**
  83216. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  83217. */
  83218. overridenInstanceCount: number;
  83219. /** @hidden */
  83220. _preActivate(): Mesh;
  83221. /** @hidden */
  83222. _preActivateForIntermediateRendering(renderId: number): Mesh;
  83223. /** @hidden */
  83224. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  83225. /**
  83226. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83227. * This means the mesh underlying bounding box and sphere are recomputed.
  83228. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83229. * @returns the current mesh
  83230. */
  83231. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  83232. /** @hidden */
  83233. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  83234. /**
  83235. * This function will subdivide the mesh into multiple submeshes
  83236. * @param count defines the expected number of submeshes
  83237. */
  83238. subdivide(count: number): void;
  83239. /**
  83240. * Copy a FloatArray into a specific associated vertex buffer
  83241. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83242. * - VertexBuffer.PositionKind
  83243. * - VertexBuffer.UVKind
  83244. * - VertexBuffer.UV2Kind
  83245. * - VertexBuffer.UV3Kind
  83246. * - VertexBuffer.UV4Kind
  83247. * - VertexBuffer.UV5Kind
  83248. * - VertexBuffer.UV6Kind
  83249. * - VertexBuffer.ColorKind
  83250. * - VertexBuffer.MatricesIndicesKind
  83251. * - VertexBuffer.MatricesIndicesExtraKind
  83252. * - VertexBuffer.MatricesWeightsKind
  83253. * - VertexBuffer.MatricesWeightsExtraKind
  83254. * @param data defines the data source
  83255. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83256. * @param stride defines the data stride size (can be null)
  83257. * @returns the current mesh
  83258. */
  83259. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  83260. /**
  83261. * Flags an associated vertex buffer as updatable
  83262. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  83263. * - VertexBuffer.PositionKind
  83264. * - VertexBuffer.UVKind
  83265. * - VertexBuffer.UV2Kind
  83266. * - VertexBuffer.UV3Kind
  83267. * - VertexBuffer.UV4Kind
  83268. * - VertexBuffer.UV5Kind
  83269. * - VertexBuffer.UV6Kind
  83270. * - VertexBuffer.ColorKind
  83271. * - VertexBuffer.MatricesIndicesKind
  83272. * - VertexBuffer.MatricesIndicesExtraKind
  83273. * - VertexBuffer.MatricesWeightsKind
  83274. * - VertexBuffer.MatricesWeightsExtraKind
  83275. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  83276. */
  83277. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  83278. /**
  83279. * Sets the mesh global Vertex Buffer
  83280. * @param buffer defines the buffer to use
  83281. * @returns the current mesh
  83282. */
  83283. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  83284. /**
  83285. * Update a specific associated vertex buffer
  83286. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  83287. * - VertexBuffer.PositionKind
  83288. * - VertexBuffer.UVKind
  83289. * - VertexBuffer.UV2Kind
  83290. * - VertexBuffer.UV3Kind
  83291. * - VertexBuffer.UV4Kind
  83292. * - VertexBuffer.UV5Kind
  83293. * - VertexBuffer.UV6Kind
  83294. * - VertexBuffer.ColorKind
  83295. * - VertexBuffer.MatricesIndicesKind
  83296. * - VertexBuffer.MatricesIndicesExtraKind
  83297. * - VertexBuffer.MatricesWeightsKind
  83298. * - VertexBuffer.MatricesWeightsExtraKind
  83299. * @param data defines the data source
  83300. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  83301. * @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)
  83302. * @returns the current mesh
  83303. */
  83304. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  83305. /**
  83306. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  83307. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  83308. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  83309. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  83310. * @returns the current mesh
  83311. */
  83312. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  83313. /**
  83314. * Creates a un-shared specific occurence of the geometry for the mesh.
  83315. * @returns the current mesh
  83316. */
  83317. makeGeometryUnique(): Mesh;
  83318. /**
  83319. * Set the index buffer of this mesh
  83320. * @param indices defines the source data
  83321. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  83322. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  83323. * @returns the current mesh
  83324. */
  83325. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  83326. /**
  83327. * Update the current index buffer
  83328. * @param indices defines the source data
  83329. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  83330. * @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)
  83331. * @returns the current mesh
  83332. */
  83333. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  83334. /**
  83335. * Invert the geometry to move from a right handed system to a left handed one.
  83336. * @returns the current mesh
  83337. */
  83338. toLeftHanded(): Mesh;
  83339. /** @hidden */
  83340. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  83341. /** @hidden */
  83342. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  83343. /**
  83344. * Registers for this mesh a javascript function called just before the rendering process
  83345. * @param func defines the function to call before rendering this mesh
  83346. * @returns the current mesh
  83347. */
  83348. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83349. /**
  83350. * Disposes a previously registered javascript function called before the rendering
  83351. * @param func defines the function to remove
  83352. * @returns the current mesh
  83353. */
  83354. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  83355. /**
  83356. * Registers for this mesh a javascript function called just after the rendering is complete
  83357. * @param func defines the function to call after rendering this mesh
  83358. * @returns the current mesh
  83359. */
  83360. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83361. /**
  83362. * Disposes a previously registered javascript function called after the rendering.
  83363. * @param func defines the function to remove
  83364. * @returns the current mesh
  83365. */
  83366. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  83367. /** @hidden */
  83368. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  83369. /** @hidden */
  83370. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  83371. /** @hidden */
  83372. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  83373. /** @hidden */
  83374. _freeze(): void;
  83375. /** @hidden */
  83376. _unFreeze(): void;
  83377. /**
  83378. * 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
  83379. * @param subMesh defines the subMesh to render
  83380. * @param enableAlphaMode defines if alpha mode can be changed
  83381. * @returns the current mesh
  83382. */
  83383. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  83384. private _onBeforeDraw;
  83385. /**
  83386. * Renormalize the mesh and patch it up if there are no weights
  83387. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  83388. * However in the case of zero weights then we set just a single influence to 1.
  83389. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  83390. */
  83391. cleanMatrixWeights(): void;
  83392. private normalizeSkinFourWeights;
  83393. private normalizeSkinWeightsAndExtra;
  83394. /**
  83395. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  83396. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  83397. * the user know there was an issue with importing the mesh
  83398. * @returns a validation object with skinned, valid and report string
  83399. */
  83400. validateSkinning(): {
  83401. skinned: boolean;
  83402. valid: boolean;
  83403. report: string;
  83404. };
  83405. /** @hidden */
  83406. _checkDelayState(): Mesh;
  83407. private _queueLoad;
  83408. /**
  83409. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  83410. * A mesh is in the frustum if its bounding box intersects the frustum
  83411. * @param frustumPlanes defines the frustum to test
  83412. * @returns true if the mesh is in the frustum planes
  83413. */
  83414. isInFrustum(frustumPlanes: Plane[]): boolean;
  83415. /**
  83416. * Sets the mesh material by the material or multiMaterial `id` property
  83417. * @param id is a string identifying the material or the multiMaterial
  83418. * @returns the current mesh
  83419. */
  83420. setMaterialByID(id: string): Mesh;
  83421. /**
  83422. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  83423. * @returns an array of IAnimatable
  83424. */
  83425. getAnimatables(): IAnimatable[];
  83426. /**
  83427. * Modifies the mesh geometry according to the passed transformation matrix.
  83428. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  83429. * The mesh normals are modified using the same transformation.
  83430. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83431. * @param transform defines the transform matrix to use
  83432. * @see http://doc.babylonjs.com/resources/baking_transformations
  83433. * @returns the current mesh
  83434. */
  83435. bakeTransformIntoVertices(transform: Matrix): Mesh;
  83436. /**
  83437. * Modifies the mesh geometry according to its own current World Matrix.
  83438. * The mesh World Matrix is then reset.
  83439. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  83440. * Note that, under the hood, this method sets a new VertexBuffer each call.
  83441. * @see http://doc.babylonjs.com/resources/baking_transformations
  83442. * @returns the current mesh
  83443. */
  83444. bakeCurrentTransformIntoVertices(): Mesh;
  83445. /** @hidden */
  83446. readonly _positions: Nullable<Vector3[]>;
  83447. /** @hidden */
  83448. _resetPointsArrayCache(): Mesh;
  83449. /** @hidden */
  83450. _generatePointsArray(): boolean;
  83451. /**
  83452. * Returns a new Mesh object generated from the current mesh properties.
  83453. * This method must not get confused with createInstance()
  83454. * @param name is a string, the name given to the new mesh
  83455. * @param newParent can be any Node object (default `null`)
  83456. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  83457. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  83458. * @returns a new mesh
  83459. */
  83460. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  83461. /**
  83462. * Releases resources associated with this mesh.
  83463. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  83464. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  83465. */
  83466. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  83467. /**
  83468. * Modifies the mesh geometry according to a displacement map.
  83469. * 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.
  83470. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83471. * @param url is a string, the URL from the image file is to be downloaded.
  83472. * @param minHeight is the lower limit of the displacement.
  83473. * @param maxHeight is the upper limit of the displacement.
  83474. * @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.
  83475. * @param uvOffset is an optional vector2 used to offset UV.
  83476. * @param uvScale is an optional vector2 used to scale UV.
  83477. * @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.
  83478. * @returns the Mesh.
  83479. */
  83480. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83481. /**
  83482. * Modifies the mesh geometry according to a displacementMap buffer.
  83483. * 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.
  83484. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  83485. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  83486. * @param heightMapWidth is the width of the buffer image.
  83487. * @param heightMapHeight is the height of the buffer image.
  83488. * @param minHeight is the lower limit of the displacement.
  83489. * @param maxHeight is the upper limit of the displacement.
  83490. * @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.
  83491. * @param uvOffset is an optional vector2 used to offset UV.
  83492. * @param uvScale is an optional vector2 used to scale UV.
  83493. * @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.
  83494. * @returns the Mesh.
  83495. */
  83496. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  83497. /**
  83498. * Modify the mesh to get a flat shading rendering.
  83499. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  83500. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  83501. * @returns current mesh
  83502. */
  83503. convertToFlatShadedMesh(): Mesh;
  83504. /**
  83505. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  83506. * In other words, more vertices, no more indices and a single bigger VBO.
  83507. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  83508. * @returns current mesh
  83509. */
  83510. convertToUnIndexedMesh(): Mesh;
  83511. /**
  83512. * Inverses facet orientations.
  83513. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83514. * @param flipNormals will also inverts the normals
  83515. * @returns current mesh
  83516. */
  83517. flipFaces(flipNormals?: boolean): Mesh;
  83518. /**
  83519. * Increase the number of facets and hence vertices in a mesh
  83520. * Vertex normals are interpolated from existing vertex normals
  83521. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83522. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  83523. */
  83524. increaseVertices(numberPerEdge: number): void;
  83525. /**
  83526. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  83527. * This will undo any application of covertToFlatShadedMesh
  83528. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  83529. */
  83530. forceSharedVertices(): void;
  83531. /** @hidden */
  83532. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  83533. /** @hidden */
  83534. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  83535. /**
  83536. * Creates a new InstancedMesh object from the mesh model.
  83537. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  83538. * @param name defines the name of the new instance
  83539. * @returns a new InstancedMesh
  83540. */
  83541. createInstance(name: string): InstancedMesh;
  83542. /**
  83543. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  83544. * After this call, all the mesh instances have the same submeshes than the current mesh.
  83545. * @returns the current mesh
  83546. */
  83547. synchronizeInstances(): Mesh;
  83548. /**
  83549. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  83550. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  83551. * This should be used together with the simplification to avoid disappearing triangles.
  83552. * @param successCallback an optional success callback to be called after the optimization finished.
  83553. * @returns the current mesh
  83554. */
  83555. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  83556. /**
  83557. * Serialize current mesh
  83558. * @param serializationObject defines the object which will receive the serialization data
  83559. */
  83560. serialize(serializationObject: any): void;
  83561. /** @hidden */
  83562. _syncGeometryWithMorphTargetManager(): void;
  83563. /** @hidden */
  83564. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  83565. /**
  83566. * Returns a new Mesh object parsed from the source provided.
  83567. * @param parsedMesh is the source
  83568. * @param scene defines the hosting scene
  83569. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  83570. * @returns a new Mesh
  83571. */
  83572. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  83573. /**
  83574. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  83575. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83576. * @param name defines the name of the mesh to create
  83577. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  83578. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  83579. * @param closePath creates a seam between the first and the last points of each path of the path array
  83580. * @param offset is taken in account only if the `pathArray` is containing a single path
  83581. * @param scene defines the hosting scene
  83582. * @param updatable defines if the mesh must be flagged as updatable
  83583. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83584. * @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)
  83585. * @returns a new Mesh
  83586. */
  83587. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  83588. /**
  83589. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  83590. * @param name defines the name of the mesh to create
  83591. * @param radius sets the radius size (float) of the polygon (default 0.5)
  83592. * @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
  83593. * @param scene defines the hosting scene
  83594. * @param updatable defines if the mesh must be flagged as updatable
  83595. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83596. * @returns a new Mesh
  83597. */
  83598. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  83599. /**
  83600. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  83601. * @param name defines the name of the mesh to create
  83602. * @param size sets the size (float) of each box side (default 1)
  83603. * @param scene defines the hosting scene
  83604. * @param updatable defines if the mesh must be flagged as updatable
  83605. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83606. * @returns a new Mesh
  83607. */
  83608. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  83609. /**
  83610. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  83611. * @param name defines the name of the mesh to create
  83612. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  83613. * @param diameter sets the diameter size (float) of the sphere (default 1)
  83614. * @param scene defines the hosting scene
  83615. * @param updatable defines if the mesh must be flagged as updatable
  83616. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83617. * @returns a new Mesh
  83618. */
  83619. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83620. /**
  83621. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  83622. * @param name defines the name of the mesh to create
  83623. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  83624. * @param diameter sets the diameter size (float) of the sphere (default 1)
  83625. * @param scene defines the hosting scene
  83626. * @returns a new Mesh
  83627. */
  83628. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  83629. /**
  83630. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  83631. * @param name defines the name of the mesh to create
  83632. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  83633. * @param diameterTop set the top cap diameter (floats, default 1)
  83634. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  83635. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  83636. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  83637. * @param scene defines the hosting scene
  83638. * @param updatable defines if the mesh must be flagged as updatable
  83639. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83640. * @returns a new Mesh
  83641. */
  83642. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  83643. /**
  83644. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  83645. * @param name defines the name of the mesh to create
  83646. * @param diameter sets the diameter size (float) of the torus (default 1)
  83647. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  83648. * @param tessellation sets the number of torus sides (postive integer, default 16)
  83649. * @param scene defines the hosting scene
  83650. * @param updatable defines if the mesh must be flagged as updatable
  83651. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83652. * @returns a new Mesh
  83653. */
  83654. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83655. /**
  83656. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  83657. * @param name defines the name of the mesh to create
  83658. * @param radius sets the global radius size (float) of the torus knot (default 2)
  83659. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  83660. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  83661. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  83662. * @param p the number of windings on X axis (positive integers, default 2)
  83663. * @param q the number of windings on Y axis (positive integers, default 3)
  83664. * @param scene defines the hosting scene
  83665. * @param updatable defines if the mesh must be flagged as updatable
  83666. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83667. * @returns a new Mesh
  83668. */
  83669. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83670. /**
  83671. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  83672. * @param name defines the name of the mesh to create
  83673. * @param points is an array successive Vector3
  83674. * @param scene defines the hosting scene
  83675. * @param updatable defines if the mesh must be flagged as updatable
  83676. * @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).
  83677. * @returns a new Mesh
  83678. */
  83679. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  83680. /**
  83681. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  83682. * @param name defines the name of the mesh to create
  83683. * @param points is an array successive Vector3
  83684. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  83685. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  83686. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  83687. * @param scene defines the hosting scene
  83688. * @param updatable defines if the mesh must be flagged as updatable
  83689. * @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)
  83690. * @returns a new Mesh
  83691. */
  83692. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  83693. /**
  83694. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  83695. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  83696. * 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.
  83697. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83698. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  83699. * Remember you can only change the shape positions, not their number when updating a polygon.
  83700. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  83701. * @param name defines the name of the mesh to create
  83702. * @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
  83703. * @param scene defines the hosting scene
  83704. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  83705. * @param updatable defines if the mesh must be flagged as updatable
  83706. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83707. * @param earcutInjection can be used to inject your own earcut reference
  83708. * @returns a new Mesh
  83709. */
  83710. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  83711. /**
  83712. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  83713. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  83714. * @param name defines the name of the mesh to create
  83715. * @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
  83716. * @param depth defines the height of extrusion
  83717. * @param scene defines the hosting scene
  83718. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  83719. * @param updatable defines if the mesh must be flagged as updatable
  83720. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83721. * @param earcutInjection can be used to inject your own earcut reference
  83722. * @returns a new Mesh
  83723. */
  83724. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  83725. /**
  83726. * Creates an extruded shape mesh.
  83727. * 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
  83728. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83729. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  83730. * @param name defines the name of the mesh to create
  83731. * @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
  83732. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  83733. * @param scale is the value to scale the shape
  83734. * @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
  83735. * @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
  83736. * @param scene defines the hosting scene
  83737. * @param updatable defines if the mesh must be flagged as updatable
  83738. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83739. * @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)
  83740. * @returns a new Mesh
  83741. */
  83742. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  83743. /**
  83744. * Creates an custom extruded shape mesh.
  83745. * The custom extrusion is a parametric shape.
  83746. * It has no predefined shape. Its final shape will depend on the input parameters.
  83747. * Please consider using the same method from the MeshBuilder class instead
  83748. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  83749. * @param name defines the name of the mesh to create
  83750. * @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
  83751. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  83752. * @param scaleFunction is a custom Javascript function called on each path point
  83753. * @param rotationFunction is a custom Javascript function called on each path point
  83754. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  83755. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  83756. * @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
  83757. * @param scene defines the hosting scene
  83758. * @param updatable defines if the mesh must be flagged as updatable
  83759. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83760. * @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)
  83761. * @returns a new Mesh
  83762. */
  83763. 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;
  83764. /**
  83765. * Creates lathe mesh.
  83766. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  83767. * Please consider using the same method from the MeshBuilder class instead
  83768. * @param name defines the name of the mesh to create
  83769. * @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
  83770. * @param radius is the radius value of the lathe
  83771. * @param tessellation is the side number of the lathe.
  83772. * @param scene defines the hosting scene
  83773. * @param updatable defines if the mesh must be flagged as updatable
  83774. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83775. * @returns a new Mesh
  83776. */
  83777. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83778. /**
  83779. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  83780. * @param name defines the name of the mesh to create
  83781. * @param size sets the size (float) of both sides of the plane at once (default 1)
  83782. * @param scene defines the hosting scene
  83783. * @param updatable defines if the mesh must be flagged as updatable
  83784. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83785. * @returns a new Mesh
  83786. */
  83787. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  83788. /**
  83789. * Creates a ground mesh.
  83790. * Please consider using the same method from the MeshBuilder class instead
  83791. * @param name defines the name of the mesh to create
  83792. * @param width set the width of the ground
  83793. * @param height set the height of the ground
  83794. * @param subdivisions sets the number of subdivisions per side
  83795. * @param scene defines the hosting scene
  83796. * @param updatable defines if the mesh must be flagged as updatable
  83797. * @returns a new Mesh
  83798. */
  83799. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  83800. /**
  83801. * Creates a tiled ground mesh.
  83802. * Please consider using the same method from the MeshBuilder class instead
  83803. * @param name defines the name of the mesh to create
  83804. * @param xmin set the ground minimum X coordinate
  83805. * @param zmin set the ground minimum Y coordinate
  83806. * @param xmax set the ground maximum X coordinate
  83807. * @param zmax set the ground maximum Z coordinate
  83808. * @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
  83809. * @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
  83810. * @param scene defines the hosting scene
  83811. * @param updatable defines if the mesh must be flagged as updatable
  83812. * @returns a new Mesh
  83813. */
  83814. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  83815. w: number;
  83816. h: number;
  83817. }, precision: {
  83818. w: number;
  83819. h: number;
  83820. }, scene: Scene, updatable?: boolean): Mesh;
  83821. /**
  83822. * Creates a ground mesh from a height map.
  83823. * Please consider using the same method from the MeshBuilder class instead
  83824. * @see http://doc.babylonjs.com/babylon101/height_map
  83825. * @param name defines the name of the mesh to create
  83826. * @param url sets the URL of the height map image resource
  83827. * @param width set the ground width size
  83828. * @param height set the ground height size
  83829. * @param subdivisions sets the number of subdivision per side
  83830. * @param minHeight is the minimum altitude on the ground
  83831. * @param maxHeight is the maximum altitude on the ground
  83832. * @param scene defines the hosting scene
  83833. * @param updatable defines if the mesh must be flagged as updatable
  83834. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  83835. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  83836. * @returns a new Mesh
  83837. */
  83838. 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;
  83839. /**
  83840. * Creates a tube mesh.
  83841. * The tube is a parametric shape.
  83842. * It has no predefined shape. Its final shape will depend on the input parameters.
  83843. * Please consider using the same method from the MeshBuilder class instead
  83844. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  83845. * @param name defines the name of the mesh to create
  83846. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  83847. * @param radius sets the tube radius size
  83848. * @param tessellation is the number of sides on the tubular surface
  83849. * @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
  83850. * @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
  83851. * @param scene defines the hosting scene
  83852. * @param updatable defines if the mesh must be flagged as updatable
  83853. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  83854. * @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)
  83855. * @returns a new Mesh
  83856. */
  83857. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  83858. (i: number, distance: number): number;
  83859. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  83860. /**
  83861. * Creates a polyhedron mesh.
  83862. * Please consider using the same method from the MeshBuilder class instead.
  83863. * * 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
  83864. * * The parameter `size` (positive float, default 1) sets the polygon size
  83865. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  83866. * * 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`
  83867. * * 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
  83868. * * 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)`)
  83869. * * 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
  83870. * * 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
  83871. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83872. * * If you create a double-sided mesh, you can choose what parts of 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
  83873. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83874. * @param name defines the name of the mesh to create
  83875. * @param options defines the options used to create the mesh
  83876. * @param scene defines the hosting scene
  83877. * @returns a new Mesh
  83878. */
  83879. static CreatePolyhedron(name: string, options: {
  83880. type?: number;
  83881. size?: number;
  83882. sizeX?: number;
  83883. sizeY?: number;
  83884. sizeZ?: number;
  83885. custom?: any;
  83886. faceUV?: Vector4[];
  83887. faceColors?: Color4[];
  83888. updatable?: boolean;
  83889. sideOrientation?: number;
  83890. }, scene: Scene): Mesh;
  83891. /**
  83892. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  83893. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  83894. * * 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`)
  83895. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  83896. * * 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
  83897. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  83898. * * If you create a double-sided mesh, you can choose what parts of 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
  83899. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  83900. * @param name defines the name of the mesh
  83901. * @param options defines the options used to create the mesh
  83902. * @param scene defines the hosting scene
  83903. * @returns a new Mesh
  83904. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  83905. */
  83906. static CreateIcoSphere(name: string, options: {
  83907. radius?: number;
  83908. flat?: boolean;
  83909. subdivisions?: number;
  83910. sideOrientation?: number;
  83911. updatable?: boolean;
  83912. }, scene: Scene): Mesh;
  83913. /**
  83914. * Creates a decal mesh.
  83915. * Please consider using the same method from the MeshBuilder class instead.
  83916. * A decal is a mesh usually applied as a model onto the surface of another mesh
  83917. * @param name defines the name of the mesh
  83918. * @param sourceMesh defines the mesh receiving the decal
  83919. * @param position sets the position of the decal in world coordinates
  83920. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  83921. * @param size sets the decal scaling
  83922. * @param angle sets the angle to rotate the decal
  83923. * @returns a new Mesh
  83924. */
  83925. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  83926. /**
  83927. * Prepare internal position array for software CPU skinning
  83928. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  83929. */
  83930. setPositionsForCPUSkinning(): Float32Array;
  83931. /**
  83932. * Prepare internal normal array for software CPU skinning
  83933. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  83934. */
  83935. setNormalsForCPUSkinning(): Float32Array;
  83936. /**
  83937. * Updates the vertex buffer by applying transformation from the bones
  83938. * @param skeleton defines the skeleton to apply to current mesh
  83939. * @returns the current mesh
  83940. */
  83941. applySkeleton(skeleton: Skeleton): Mesh;
  83942. /**
  83943. * 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
  83944. * @param meshes defines the list of meshes to scan
  83945. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  83946. */
  83947. static MinMax(meshes: AbstractMesh[]): {
  83948. min: Vector3;
  83949. max: Vector3;
  83950. };
  83951. /**
  83952. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  83953. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  83954. * @returns a vector3
  83955. */
  83956. static Center(meshesOrMinMaxVector: {
  83957. min: Vector3;
  83958. max: Vector3;
  83959. } | AbstractMesh[]): Vector3;
  83960. /**
  83961. * Merge the array of meshes into a single mesh for performance reasons.
  83962. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  83963. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  83964. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  83965. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  83966. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  83967. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  83968. * @returns a new mesh
  83969. */
  83970. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  83971. /** @hidden */
  83972. addInstance(instance: InstancedMesh): void;
  83973. /** @hidden */
  83974. removeInstance(instance: InstancedMesh): void;
  83975. }
  83976. }
  83977. declare module BABYLON {
  83978. /**
  83979. * Base class for the main features of a material in Babylon.js
  83980. */
  83981. export class Material implements IAnimatable {
  83982. /**
  83983. * Returns the triangle fill mode
  83984. */
  83985. static readonly TriangleFillMode: number;
  83986. /**
  83987. * Returns the wireframe mode
  83988. */
  83989. static readonly WireFrameFillMode: number;
  83990. /**
  83991. * Returns the point fill mode
  83992. */
  83993. static readonly PointFillMode: number;
  83994. /**
  83995. * Returns the point list draw mode
  83996. */
  83997. static readonly PointListDrawMode: number;
  83998. /**
  83999. * Returns the line list draw mode
  84000. */
  84001. static readonly LineListDrawMode: number;
  84002. /**
  84003. * Returns the line loop draw mode
  84004. */
  84005. static readonly LineLoopDrawMode: number;
  84006. /**
  84007. * Returns the line strip draw mode
  84008. */
  84009. static readonly LineStripDrawMode: number;
  84010. /**
  84011. * Returns the triangle strip draw mode
  84012. */
  84013. static readonly TriangleStripDrawMode: number;
  84014. /**
  84015. * Returns the triangle fan draw mode
  84016. */
  84017. static readonly TriangleFanDrawMode: number;
  84018. /**
  84019. * Stores the clock-wise side orientation
  84020. */
  84021. static readonly ClockWiseSideOrientation: number;
  84022. /**
  84023. * Stores the counter clock-wise side orientation
  84024. */
  84025. static readonly CounterClockWiseSideOrientation: number;
  84026. /**
  84027. * The dirty texture flag value
  84028. */
  84029. static readonly TextureDirtyFlag: number;
  84030. /**
  84031. * The dirty light flag value
  84032. */
  84033. static readonly LightDirtyFlag: number;
  84034. /**
  84035. * The dirty fresnel flag value
  84036. */
  84037. static readonly FresnelDirtyFlag: number;
  84038. /**
  84039. * The dirty attribute flag value
  84040. */
  84041. static readonly AttributesDirtyFlag: number;
  84042. /**
  84043. * The dirty misc flag value
  84044. */
  84045. static readonly MiscDirtyFlag: number;
  84046. /**
  84047. * The all dirty flag value
  84048. */
  84049. static readonly AllDirtyFlag: number;
  84050. /**
  84051. * The ID of the material
  84052. */
  84053. id: string;
  84054. /**
  84055. * Gets or sets the unique id of the material
  84056. */
  84057. uniqueId: number;
  84058. /**
  84059. * The name of the material
  84060. */
  84061. name: string;
  84062. /**
  84063. * Gets or sets user defined metadata
  84064. */
  84065. metadata: any;
  84066. /**
  84067. * For internal use only. Please do not use.
  84068. */
  84069. reservedDataStore: any;
  84070. /**
  84071. * Specifies if the ready state should be checked on each call
  84072. */
  84073. checkReadyOnEveryCall: boolean;
  84074. /**
  84075. * Specifies if the ready state should be checked once
  84076. */
  84077. checkReadyOnlyOnce: boolean;
  84078. /**
  84079. * The state of the material
  84080. */
  84081. state: string;
  84082. /**
  84083. * The alpha value of the material
  84084. */
  84085. protected _alpha: number;
  84086. /**
  84087. * List of inspectable custom properties (used by the Inspector)
  84088. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84089. */
  84090. inspectableCustomProperties: IInspectable[];
  84091. /**
  84092. * Sets the alpha value of the material
  84093. */
  84094. /**
  84095. * Gets the alpha value of the material
  84096. */
  84097. alpha: number;
  84098. /**
  84099. * Specifies if back face culling is enabled
  84100. */
  84101. protected _backFaceCulling: boolean;
  84102. /**
  84103. * Sets the back-face culling state
  84104. */
  84105. /**
  84106. * Gets the back-face culling state
  84107. */
  84108. backFaceCulling: boolean;
  84109. /**
  84110. * Stores the value for side orientation
  84111. */
  84112. sideOrientation: number;
  84113. /**
  84114. * Callback triggered when the material is compiled
  84115. */
  84116. onCompiled: Nullable<(effect: Effect) => void>;
  84117. /**
  84118. * Callback triggered when an error occurs
  84119. */
  84120. onError: Nullable<(effect: Effect, errors: string) => void>;
  84121. /**
  84122. * Callback triggered to get the render target textures
  84123. */
  84124. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  84125. /**
  84126. * Gets a boolean indicating that current material needs to register RTT
  84127. */
  84128. readonly hasRenderTargetTextures: boolean;
  84129. /**
  84130. * Specifies if the material should be serialized
  84131. */
  84132. doNotSerialize: boolean;
  84133. /**
  84134. * @hidden
  84135. */
  84136. _storeEffectOnSubMeshes: boolean;
  84137. /**
  84138. * Stores the animations for the material
  84139. */
  84140. animations: Nullable<Array<Animation>>;
  84141. /**
  84142. * An event triggered when the material is disposed
  84143. */
  84144. onDisposeObservable: Observable<Material>;
  84145. /**
  84146. * An observer which watches for dispose events
  84147. */
  84148. private _onDisposeObserver;
  84149. private _onUnBindObservable;
  84150. /**
  84151. * Called during a dispose event
  84152. */
  84153. onDispose: () => void;
  84154. private _onBindObservable;
  84155. /**
  84156. * An event triggered when the material is bound
  84157. */
  84158. readonly onBindObservable: Observable<AbstractMesh>;
  84159. /**
  84160. * An observer which watches for bind events
  84161. */
  84162. private _onBindObserver;
  84163. /**
  84164. * Called during a bind event
  84165. */
  84166. onBind: (Mesh: AbstractMesh) => void;
  84167. /**
  84168. * An event triggered when the material is unbound
  84169. */
  84170. readonly onUnBindObservable: Observable<Material>;
  84171. /**
  84172. * Stores the value of the alpha mode
  84173. */
  84174. private _alphaMode;
  84175. /**
  84176. * Sets the value of the alpha mode.
  84177. *
  84178. * | Value | Type | Description |
  84179. * | --- | --- | --- |
  84180. * | 0 | ALPHA_DISABLE | |
  84181. * | 1 | ALPHA_ADD | |
  84182. * | 2 | ALPHA_COMBINE | |
  84183. * | 3 | ALPHA_SUBTRACT | |
  84184. * | 4 | ALPHA_MULTIPLY | |
  84185. * | 5 | ALPHA_MAXIMIZED | |
  84186. * | 6 | ALPHA_ONEONE | |
  84187. * | 7 | ALPHA_PREMULTIPLIED | |
  84188. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  84189. * | 9 | ALPHA_INTERPOLATE | |
  84190. * | 10 | ALPHA_SCREENMODE | |
  84191. *
  84192. */
  84193. /**
  84194. * Gets the value of the alpha mode
  84195. */
  84196. alphaMode: number;
  84197. /**
  84198. * Stores the state of the need depth pre-pass value
  84199. */
  84200. private _needDepthPrePass;
  84201. /**
  84202. * Sets the need depth pre-pass value
  84203. */
  84204. /**
  84205. * Gets the depth pre-pass value
  84206. */
  84207. needDepthPrePass: boolean;
  84208. /**
  84209. * Specifies if depth writing should be disabled
  84210. */
  84211. disableDepthWrite: boolean;
  84212. /**
  84213. * Specifies if depth writing should be forced
  84214. */
  84215. forceDepthWrite: boolean;
  84216. /**
  84217. * Specifies if there should be a separate pass for culling
  84218. */
  84219. separateCullingPass: boolean;
  84220. /**
  84221. * Stores the state specifing if fog should be enabled
  84222. */
  84223. private _fogEnabled;
  84224. /**
  84225. * Sets the state for enabling fog
  84226. */
  84227. /**
  84228. * Gets the value of the fog enabled state
  84229. */
  84230. fogEnabled: boolean;
  84231. /**
  84232. * Stores the size of points
  84233. */
  84234. pointSize: number;
  84235. /**
  84236. * Stores the z offset value
  84237. */
  84238. zOffset: number;
  84239. /**
  84240. * Gets a value specifying if wireframe mode is enabled
  84241. */
  84242. /**
  84243. * Sets the state of wireframe mode
  84244. */
  84245. wireframe: boolean;
  84246. /**
  84247. * Gets the value specifying if point clouds are enabled
  84248. */
  84249. /**
  84250. * Sets the state of point cloud mode
  84251. */
  84252. pointsCloud: boolean;
  84253. /**
  84254. * Gets the material fill mode
  84255. */
  84256. /**
  84257. * Sets the material fill mode
  84258. */
  84259. fillMode: number;
  84260. /**
  84261. * @hidden
  84262. * Stores the effects for the material
  84263. */
  84264. _effect: Nullable<Effect>;
  84265. /**
  84266. * @hidden
  84267. * Specifies if the material was previously ready
  84268. */
  84269. _wasPreviouslyReady: boolean;
  84270. /**
  84271. * Specifies if uniform buffers should be used
  84272. */
  84273. private _useUBO;
  84274. /**
  84275. * Stores a reference to the scene
  84276. */
  84277. private _scene;
  84278. /**
  84279. * Stores the fill mode state
  84280. */
  84281. private _fillMode;
  84282. /**
  84283. * Specifies if the depth write state should be cached
  84284. */
  84285. private _cachedDepthWriteState;
  84286. /**
  84287. * Stores the uniform buffer
  84288. */
  84289. protected _uniformBuffer: UniformBuffer;
  84290. /** @hidden */
  84291. _indexInSceneMaterialArray: number;
  84292. /** @hidden */
  84293. meshMap: Nullable<{
  84294. [id: string]: AbstractMesh | undefined;
  84295. }>;
  84296. /**
  84297. * Creates a material instance
  84298. * @param name defines the name of the material
  84299. * @param scene defines the scene to reference
  84300. * @param doNotAdd specifies if the material should be added to the scene
  84301. */
  84302. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  84303. /**
  84304. * Returns a string representation of the current material
  84305. * @param fullDetails defines a boolean indicating which levels of logging is desired
  84306. * @returns a string with material information
  84307. */
  84308. toString(fullDetails?: boolean): string;
  84309. /**
  84310. * Gets the class name of the material
  84311. * @returns a string with the class name of the material
  84312. */
  84313. getClassName(): string;
  84314. /**
  84315. * Specifies if updates for the material been locked
  84316. */
  84317. readonly isFrozen: boolean;
  84318. /**
  84319. * Locks updates for the material
  84320. */
  84321. freeze(): void;
  84322. /**
  84323. * Unlocks updates for the material
  84324. */
  84325. unfreeze(): void;
  84326. /**
  84327. * Specifies if the material is ready to be used
  84328. * @param mesh defines the mesh to check
  84329. * @param useInstances specifies if instances should be used
  84330. * @returns a boolean indicating if the material is ready to be used
  84331. */
  84332. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  84333. /**
  84334. * Specifies that the submesh is ready to be used
  84335. * @param mesh defines the mesh to check
  84336. * @param subMesh defines which submesh to check
  84337. * @param useInstances specifies that instances should be used
  84338. * @returns a boolean indicating that the submesh is ready or not
  84339. */
  84340. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  84341. /**
  84342. * Returns the material effect
  84343. * @returns the effect associated with the material
  84344. */
  84345. getEffect(): Nullable<Effect>;
  84346. /**
  84347. * Returns the current scene
  84348. * @returns a Scene
  84349. */
  84350. getScene(): Scene;
  84351. /**
  84352. * Specifies if the material will require alpha blending
  84353. * @returns a boolean specifying if alpha blending is needed
  84354. */
  84355. needAlphaBlending(): boolean;
  84356. /**
  84357. * Specifies if the mesh will require alpha blending
  84358. * @param mesh defines the mesh to check
  84359. * @returns a boolean specifying if alpha blending is needed for the mesh
  84360. */
  84361. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  84362. /**
  84363. * Specifies if this material should be rendered in alpha test mode
  84364. * @returns a boolean specifying if an alpha test is needed.
  84365. */
  84366. needAlphaTesting(): boolean;
  84367. /**
  84368. * Gets the texture used for the alpha test
  84369. * @returns the texture to use for alpha testing
  84370. */
  84371. getAlphaTestTexture(): Nullable<BaseTexture>;
  84372. /**
  84373. * Marks the material to indicate that it needs to be re-calculated
  84374. */
  84375. markDirty(): void;
  84376. /** @hidden */
  84377. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  84378. /**
  84379. * Binds the material to the mesh
  84380. * @param world defines the world transformation matrix
  84381. * @param mesh defines the mesh to bind the material to
  84382. */
  84383. bind(world: Matrix, mesh?: Mesh): void;
  84384. /**
  84385. * Binds the submesh to the material
  84386. * @param world defines the world transformation matrix
  84387. * @param mesh defines the mesh containing the submesh
  84388. * @param subMesh defines the submesh to bind the material to
  84389. */
  84390. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  84391. /**
  84392. * Binds the world matrix to the material
  84393. * @param world defines the world transformation matrix
  84394. */
  84395. bindOnlyWorldMatrix(world: Matrix): void;
  84396. /**
  84397. * Binds the scene's uniform buffer to the effect.
  84398. * @param effect defines the effect to bind to the scene uniform buffer
  84399. * @param sceneUbo defines the uniform buffer storing scene data
  84400. */
  84401. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  84402. /**
  84403. * Binds the view matrix to the effect
  84404. * @param effect defines the effect to bind the view matrix to
  84405. */
  84406. bindView(effect: Effect): void;
  84407. /**
  84408. * Binds the view projection matrix to the effect
  84409. * @param effect defines the effect to bind the view projection matrix to
  84410. */
  84411. bindViewProjection(effect: Effect): void;
  84412. /**
  84413. * Specifies if material alpha testing should be turned on for the mesh
  84414. * @param mesh defines the mesh to check
  84415. */
  84416. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  84417. /**
  84418. * Processes to execute after binding the material to a mesh
  84419. * @param mesh defines the rendered mesh
  84420. */
  84421. protected _afterBind(mesh?: Mesh): void;
  84422. /**
  84423. * Unbinds the material from the mesh
  84424. */
  84425. unbind(): void;
  84426. /**
  84427. * Gets the active textures from the material
  84428. * @returns an array of textures
  84429. */
  84430. getActiveTextures(): BaseTexture[];
  84431. /**
  84432. * Specifies if the material uses a texture
  84433. * @param texture defines the texture to check against the material
  84434. * @returns a boolean specifying if the material uses the texture
  84435. */
  84436. hasTexture(texture: BaseTexture): boolean;
  84437. /**
  84438. * Makes a duplicate of the material, and gives it a new name
  84439. * @param name defines the new name for the duplicated material
  84440. * @returns the cloned material
  84441. */
  84442. clone(name: string): Nullable<Material>;
  84443. /**
  84444. * Gets the meshes bound to the material
  84445. * @returns an array of meshes bound to the material
  84446. */
  84447. getBindedMeshes(): AbstractMesh[];
  84448. /**
  84449. * Force shader compilation
  84450. * @param mesh defines the mesh associated with this material
  84451. * @param onCompiled defines a function to execute once the material is compiled
  84452. * @param options defines the options to configure the compilation
  84453. */
  84454. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  84455. clipPlane: boolean;
  84456. }>): void;
  84457. /**
  84458. * Force shader compilation
  84459. * @param mesh defines the mesh that will use this material
  84460. * @param options defines additional options for compiling the shaders
  84461. * @returns a promise that resolves when the compilation completes
  84462. */
  84463. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  84464. clipPlane: boolean;
  84465. }>): Promise<void>;
  84466. private static readonly _AllDirtyCallBack;
  84467. private static readonly _ImageProcessingDirtyCallBack;
  84468. private static readonly _TextureDirtyCallBack;
  84469. private static readonly _FresnelDirtyCallBack;
  84470. private static readonly _MiscDirtyCallBack;
  84471. private static readonly _LightsDirtyCallBack;
  84472. private static readonly _AttributeDirtyCallBack;
  84473. private static _FresnelAndMiscDirtyCallBack;
  84474. private static _TextureAndMiscDirtyCallBack;
  84475. private static readonly _DirtyCallbackArray;
  84476. private static readonly _RunDirtyCallBacks;
  84477. /**
  84478. * Marks a define in the material to indicate that it needs to be re-computed
  84479. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  84480. */
  84481. markAsDirty(flag: number): void;
  84482. /**
  84483. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  84484. * @param func defines a function which checks material defines against the submeshes
  84485. */
  84486. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  84487. /**
  84488. * Indicates that we need to re-calculated for all submeshes
  84489. */
  84490. protected _markAllSubMeshesAsAllDirty(): void;
  84491. /**
  84492. * Indicates that image processing needs to be re-calculated for all submeshes
  84493. */
  84494. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  84495. /**
  84496. * Indicates that textures need to be re-calculated for all submeshes
  84497. */
  84498. protected _markAllSubMeshesAsTexturesDirty(): void;
  84499. /**
  84500. * Indicates that fresnel needs to be re-calculated for all submeshes
  84501. */
  84502. protected _markAllSubMeshesAsFresnelDirty(): void;
  84503. /**
  84504. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  84505. */
  84506. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  84507. /**
  84508. * Indicates that lights need to be re-calculated for all submeshes
  84509. */
  84510. protected _markAllSubMeshesAsLightsDirty(): void;
  84511. /**
  84512. * Indicates that attributes need to be re-calculated for all submeshes
  84513. */
  84514. protected _markAllSubMeshesAsAttributesDirty(): void;
  84515. /**
  84516. * Indicates that misc needs to be re-calculated for all submeshes
  84517. */
  84518. protected _markAllSubMeshesAsMiscDirty(): void;
  84519. /**
  84520. * Indicates that textures and misc need to be re-calculated for all submeshes
  84521. */
  84522. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  84523. /**
  84524. * Disposes the material
  84525. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  84526. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  84527. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  84528. */
  84529. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  84530. /** @hidden */
  84531. private releaseVertexArrayObject;
  84532. /**
  84533. * Serializes this material
  84534. * @returns the serialized material object
  84535. */
  84536. serialize(): any;
  84537. /**
  84538. * Creates a material from parsed material data
  84539. * @param parsedMaterial defines parsed material data
  84540. * @param scene defines the hosting scene
  84541. * @param rootUrl defines the root URL to use to load textures
  84542. * @returns a new material
  84543. */
  84544. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  84545. }
  84546. }
  84547. declare module BABYLON {
  84548. /**
  84549. * Base class for submeshes
  84550. */
  84551. export class BaseSubMesh {
  84552. /** @hidden */
  84553. _materialDefines: Nullable<MaterialDefines>;
  84554. /** @hidden */
  84555. _materialEffect: Nullable<Effect>;
  84556. /**
  84557. * Gets associated effect
  84558. */
  84559. readonly effect: Nullable<Effect>;
  84560. /**
  84561. * Sets associated effect (effect used to render this submesh)
  84562. * @param effect defines the effect to associate with
  84563. * @param defines defines the set of defines used to compile this effect
  84564. */
  84565. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  84566. }
  84567. /**
  84568. * Defines a subdivision inside a mesh
  84569. */
  84570. export class SubMesh extends BaseSubMesh implements ICullable {
  84571. /** the material index to use */
  84572. materialIndex: number;
  84573. /** vertex index start */
  84574. verticesStart: number;
  84575. /** vertices count */
  84576. verticesCount: number;
  84577. /** index start */
  84578. indexStart: number;
  84579. /** indices count */
  84580. indexCount: number;
  84581. /** @hidden */
  84582. _linesIndexCount: number;
  84583. private _mesh;
  84584. private _renderingMesh;
  84585. private _boundingInfo;
  84586. private _linesIndexBuffer;
  84587. /** @hidden */
  84588. _lastColliderWorldVertices: Nullable<Vector3[]>;
  84589. /** @hidden */
  84590. _trianglePlanes: Plane[];
  84591. /** @hidden */
  84592. _lastColliderTransformMatrix: Nullable<Matrix>;
  84593. /** @hidden */
  84594. _renderId: number;
  84595. /** @hidden */
  84596. _alphaIndex: number;
  84597. /** @hidden */
  84598. _distanceToCamera: number;
  84599. /** @hidden */
  84600. _id: number;
  84601. private _currentMaterial;
  84602. /**
  84603. * Add a new submesh to a mesh
  84604. * @param materialIndex defines the material index to use
  84605. * @param verticesStart defines vertex index start
  84606. * @param verticesCount defines vertices count
  84607. * @param indexStart defines index start
  84608. * @param indexCount defines indices count
  84609. * @param mesh defines the parent mesh
  84610. * @param renderingMesh defines an optional rendering mesh
  84611. * @param createBoundingBox defines if bounding box should be created for this submesh
  84612. * @returns the new submesh
  84613. */
  84614. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  84615. /**
  84616. * Creates a new submesh
  84617. * @param materialIndex defines the material index to use
  84618. * @param verticesStart defines vertex index start
  84619. * @param verticesCount defines vertices count
  84620. * @param indexStart defines index start
  84621. * @param indexCount defines indices count
  84622. * @param mesh defines the parent mesh
  84623. * @param renderingMesh defines an optional rendering mesh
  84624. * @param createBoundingBox defines if bounding box should be created for this submesh
  84625. */
  84626. constructor(
  84627. /** the material index to use */
  84628. materialIndex: number,
  84629. /** vertex index start */
  84630. verticesStart: number,
  84631. /** vertices count */
  84632. verticesCount: number,
  84633. /** index start */
  84634. indexStart: number,
  84635. /** indices count */
  84636. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  84637. /**
  84638. * Returns true if this submesh covers the entire parent mesh
  84639. * @ignorenaming
  84640. */
  84641. readonly IsGlobal: boolean;
  84642. /**
  84643. * Returns the submesh BoudingInfo object
  84644. * @returns current bounding info (or mesh's one if the submesh is global)
  84645. */
  84646. getBoundingInfo(): BoundingInfo;
  84647. /**
  84648. * Sets the submesh BoundingInfo
  84649. * @param boundingInfo defines the new bounding info to use
  84650. * @returns the SubMesh
  84651. */
  84652. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  84653. /**
  84654. * Returns the mesh of the current submesh
  84655. * @return the parent mesh
  84656. */
  84657. getMesh(): AbstractMesh;
  84658. /**
  84659. * Returns the rendering mesh of the submesh
  84660. * @returns the rendering mesh (could be different from parent mesh)
  84661. */
  84662. getRenderingMesh(): Mesh;
  84663. /**
  84664. * Returns the submesh material
  84665. * @returns null or the current material
  84666. */
  84667. getMaterial(): Nullable<Material>;
  84668. /**
  84669. * Sets a new updated BoundingInfo object to the submesh
  84670. * @param data defines an optional position array to use to determine the bounding info
  84671. * @returns the SubMesh
  84672. */
  84673. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  84674. /** @hidden */
  84675. _checkCollision(collider: Collider): boolean;
  84676. /**
  84677. * Updates the submesh BoundingInfo
  84678. * @param world defines the world matrix to use to update the bounding info
  84679. * @returns the submesh
  84680. */
  84681. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  84682. /**
  84683. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  84684. * @param frustumPlanes defines the frustum planes
  84685. * @returns true if the submesh is intersecting with the frustum
  84686. */
  84687. isInFrustum(frustumPlanes: Plane[]): boolean;
  84688. /**
  84689. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  84690. * @param frustumPlanes defines the frustum planes
  84691. * @returns true if the submesh is inside the frustum
  84692. */
  84693. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84694. /**
  84695. * Renders the submesh
  84696. * @param enableAlphaMode defines if alpha needs to be used
  84697. * @returns the submesh
  84698. */
  84699. render(enableAlphaMode: boolean): SubMesh;
  84700. /**
  84701. * @hidden
  84702. */
  84703. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  84704. /**
  84705. * Checks if the submesh intersects with a ray
  84706. * @param ray defines the ray to test
  84707. * @returns true is the passed ray intersects the submesh bounding box
  84708. */
  84709. canIntersects(ray: Ray): boolean;
  84710. /**
  84711. * Intersects current submesh with a ray
  84712. * @param ray defines the ray to test
  84713. * @param positions defines mesh's positions array
  84714. * @param indices defines mesh's indices array
  84715. * @param fastCheck defines if only bounding info should be used
  84716. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84717. * @returns intersection info or null if no intersection
  84718. */
  84719. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  84720. /** @hidden */
  84721. private _intersectLines;
  84722. /** @hidden */
  84723. private _intersectUnIndexedLines;
  84724. /** @hidden */
  84725. private _intersectTriangles;
  84726. /** @hidden */
  84727. private _intersectUnIndexedTriangles;
  84728. /** @hidden */
  84729. _rebuild(): void;
  84730. /**
  84731. * Creates a new submesh from the passed mesh
  84732. * @param newMesh defines the new hosting mesh
  84733. * @param newRenderingMesh defines an optional rendering mesh
  84734. * @returns the new submesh
  84735. */
  84736. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  84737. /**
  84738. * Release associated resources
  84739. */
  84740. dispose(): void;
  84741. /**
  84742. * Gets the class name
  84743. * @returns the string "SubMesh".
  84744. */
  84745. getClassName(): string;
  84746. /**
  84747. * Creates a new submesh from indices data
  84748. * @param materialIndex the index of the main mesh material
  84749. * @param startIndex the index where to start the copy in the mesh indices array
  84750. * @param indexCount the number of indices to copy then from the startIndex
  84751. * @param mesh the main mesh to create the submesh from
  84752. * @param renderingMesh the optional rendering mesh
  84753. * @returns a new submesh
  84754. */
  84755. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  84756. }
  84757. }
  84758. declare module BABYLON {
  84759. /**
  84760. * Class used to store geometry data (vertex buffers + index buffer)
  84761. */
  84762. export class Geometry implements IGetSetVerticesData {
  84763. /**
  84764. * Gets or sets the ID of the geometry
  84765. */
  84766. id: string;
  84767. /**
  84768. * Gets or sets the unique ID of the geometry
  84769. */
  84770. uniqueId: number;
  84771. /**
  84772. * Gets the delay loading state of the geometry (none by default which means not delayed)
  84773. */
  84774. delayLoadState: number;
  84775. /**
  84776. * Gets the file containing the data to load when running in delay load state
  84777. */
  84778. delayLoadingFile: Nullable<string>;
  84779. /**
  84780. * Callback called when the geometry is updated
  84781. */
  84782. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  84783. private _scene;
  84784. private _engine;
  84785. private _meshes;
  84786. private _totalVertices;
  84787. /** @hidden */
  84788. _indices: IndicesArray;
  84789. /** @hidden */
  84790. _vertexBuffers: {
  84791. [key: string]: VertexBuffer;
  84792. };
  84793. private _isDisposed;
  84794. private _extend;
  84795. private _boundingBias;
  84796. /** @hidden */
  84797. _delayInfo: Array<string>;
  84798. private _indexBuffer;
  84799. private _indexBufferIsUpdatable;
  84800. /** @hidden */
  84801. _boundingInfo: Nullable<BoundingInfo>;
  84802. /** @hidden */
  84803. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  84804. /** @hidden */
  84805. _softwareSkinningFrameId: number;
  84806. private _vertexArrayObjects;
  84807. private _updatable;
  84808. /** @hidden */
  84809. _positions: Nullable<Vector3[]>;
  84810. /**
  84811. * 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
  84812. */
  84813. /**
  84814. * 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
  84815. */
  84816. boundingBias: Vector2;
  84817. /**
  84818. * Static function used to attach a new empty geometry to a mesh
  84819. * @param mesh defines the mesh to attach the geometry to
  84820. * @returns the new Geometry
  84821. */
  84822. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  84823. /**
  84824. * Creates a new geometry
  84825. * @param id defines the unique ID
  84826. * @param scene defines the hosting scene
  84827. * @param vertexData defines the VertexData used to get geometry data
  84828. * @param updatable defines if geometry must be updatable (false by default)
  84829. * @param mesh defines the mesh that will be associated with the geometry
  84830. */
  84831. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  84832. /**
  84833. * Gets the current extend of the geometry
  84834. */
  84835. readonly extend: {
  84836. minimum: Vector3;
  84837. maximum: Vector3;
  84838. };
  84839. /**
  84840. * Gets the hosting scene
  84841. * @returns the hosting Scene
  84842. */
  84843. getScene(): Scene;
  84844. /**
  84845. * Gets the hosting engine
  84846. * @returns the hosting Engine
  84847. */
  84848. getEngine(): Engine;
  84849. /**
  84850. * Defines if the geometry is ready to use
  84851. * @returns true if the geometry is ready to be used
  84852. */
  84853. isReady(): boolean;
  84854. /**
  84855. * Gets a value indicating that the geometry should not be serialized
  84856. */
  84857. readonly doNotSerialize: boolean;
  84858. /** @hidden */
  84859. _rebuild(): void;
  84860. /**
  84861. * Affects all geometry data in one call
  84862. * @param vertexData defines the geometry data
  84863. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  84864. */
  84865. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  84866. /**
  84867. * Set specific vertex data
  84868. * @param kind defines the data kind (Position, normal, etc...)
  84869. * @param data defines the vertex data to use
  84870. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  84871. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  84872. */
  84873. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  84874. /**
  84875. * Removes a specific vertex data
  84876. * @param kind defines the data kind (Position, normal, etc...)
  84877. */
  84878. removeVerticesData(kind: string): void;
  84879. /**
  84880. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  84881. * @param buffer defines the vertex buffer to use
  84882. * @param totalVertices defines the total number of vertices for position kind (could be null)
  84883. */
  84884. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  84885. /**
  84886. * Update a specific vertex buffer
  84887. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  84888. * It will do nothing if the buffer is not updatable
  84889. * @param kind defines the data kind (Position, normal, etc...)
  84890. * @param data defines the data to use
  84891. * @param offset defines the offset in the target buffer where to store the data
  84892. * @param useBytes set to true if the offset is in bytes
  84893. */
  84894. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  84895. /**
  84896. * Update a specific vertex buffer
  84897. * This function will create a new buffer if the current one is not updatable
  84898. * @param kind defines the data kind (Position, normal, etc...)
  84899. * @param data defines the data to use
  84900. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  84901. */
  84902. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  84903. private _updateBoundingInfo;
  84904. /** @hidden */
  84905. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  84906. /**
  84907. * Gets total number of vertices
  84908. * @returns the total number of vertices
  84909. */
  84910. getTotalVertices(): number;
  84911. /**
  84912. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  84913. * @param kind defines the data kind (Position, normal, etc...)
  84914. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84915. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84916. * @returns a float array containing vertex data
  84917. */
  84918. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  84919. /**
  84920. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  84921. * @param kind defines the data kind (Position, normal, etc...)
  84922. * @returns true if the vertex buffer with the specified kind is updatable
  84923. */
  84924. isVertexBufferUpdatable(kind: string): boolean;
  84925. /**
  84926. * Gets a specific vertex buffer
  84927. * @param kind defines the data kind (Position, normal, etc...)
  84928. * @returns a VertexBuffer
  84929. */
  84930. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  84931. /**
  84932. * Returns all vertex buffers
  84933. * @return an object holding all vertex buffers indexed by kind
  84934. */
  84935. getVertexBuffers(): Nullable<{
  84936. [key: string]: VertexBuffer;
  84937. }>;
  84938. /**
  84939. * Gets a boolean indicating if specific vertex buffer is present
  84940. * @param kind defines the data kind (Position, normal, etc...)
  84941. * @returns true if data is present
  84942. */
  84943. isVerticesDataPresent(kind: string): boolean;
  84944. /**
  84945. * Gets a list of all attached data kinds (Position, normal, etc...)
  84946. * @returns a list of string containing all kinds
  84947. */
  84948. getVerticesDataKinds(): string[];
  84949. /**
  84950. * Update index buffer
  84951. * @param indices defines the indices to store in the index buffer
  84952. * @param offset defines the offset in the target buffer where to store the data
  84953. * @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)
  84954. */
  84955. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  84956. /**
  84957. * Creates a new index buffer
  84958. * @param indices defines the indices to store in the index buffer
  84959. * @param totalVertices defines the total number of vertices (could be null)
  84960. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  84961. */
  84962. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  84963. /**
  84964. * Return the total number of indices
  84965. * @returns the total number of indices
  84966. */
  84967. getTotalIndices(): number;
  84968. /**
  84969. * Gets the index buffer array
  84970. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  84971. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84972. * @returns the index buffer array
  84973. */
  84974. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  84975. /**
  84976. * Gets the index buffer
  84977. * @return the index buffer
  84978. */
  84979. getIndexBuffer(): Nullable<DataBuffer>;
  84980. /** @hidden */
  84981. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  84982. /**
  84983. * Release the associated resources for a specific mesh
  84984. * @param mesh defines the source mesh
  84985. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  84986. */
  84987. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  84988. /**
  84989. * Apply current geometry to a given mesh
  84990. * @param mesh defines the mesh to apply geometry to
  84991. */
  84992. applyToMesh(mesh: Mesh): void;
  84993. private _updateExtend;
  84994. private _applyToMesh;
  84995. private notifyUpdate;
  84996. /**
  84997. * Load the geometry if it was flagged as delay loaded
  84998. * @param scene defines the hosting scene
  84999. * @param onLoaded defines a callback called when the geometry is loaded
  85000. */
  85001. load(scene: Scene, onLoaded?: () => void): void;
  85002. private _queueLoad;
  85003. /**
  85004. * Invert the geometry to move from a right handed system to a left handed one.
  85005. */
  85006. toLeftHanded(): void;
  85007. /** @hidden */
  85008. _resetPointsArrayCache(): void;
  85009. /** @hidden */
  85010. _generatePointsArray(): boolean;
  85011. /**
  85012. * Gets a value indicating if the geometry is disposed
  85013. * @returns true if the geometry was disposed
  85014. */
  85015. isDisposed(): boolean;
  85016. private _disposeVertexArrayObjects;
  85017. /**
  85018. * Free all associated resources
  85019. */
  85020. dispose(): void;
  85021. /**
  85022. * Clone the current geometry into a new geometry
  85023. * @param id defines the unique ID of the new geometry
  85024. * @returns a new geometry object
  85025. */
  85026. copy(id: string): Geometry;
  85027. /**
  85028. * Serialize the current geometry info (and not the vertices data) into a JSON object
  85029. * @return a JSON representation of the current geometry data (without the vertices data)
  85030. */
  85031. serialize(): any;
  85032. private toNumberArray;
  85033. /**
  85034. * Serialize all vertices data into a JSON oject
  85035. * @returns a JSON representation of the current geometry data
  85036. */
  85037. serializeVerticeData(): any;
  85038. /**
  85039. * Extracts a clone of a mesh geometry
  85040. * @param mesh defines the source mesh
  85041. * @param id defines the unique ID of the new geometry object
  85042. * @returns the new geometry object
  85043. */
  85044. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  85045. /**
  85046. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  85047. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  85048. * Be aware Math.random() could cause collisions, but:
  85049. * "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"
  85050. * @returns a string containing a new GUID
  85051. */
  85052. static RandomId(): string;
  85053. /** @hidden */
  85054. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  85055. private static _CleanMatricesWeights;
  85056. /**
  85057. * Create a new geometry from persisted data (Using .babylon file format)
  85058. * @param parsedVertexData defines the persisted data
  85059. * @param scene defines the hosting scene
  85060. * @param rootUrl defines the root url to use to load assets (like delayed data)
  85061. * @returns the new geometry object
  85062. */
  85063. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  85064. }
  85065. }
  85066. declare module BABYLON {
  85067. /**
  85068. * Define an interface for all classes that will get and set the data on vertices
  85069. */
  85070. export interface IGetSetVerticesData {
  85071. /**
  85072. * Gets a boolean indicating if specific vertex data is present
  85073. * @param kind defines the vertex data kind to use
  85074. * @returns true is data kind is present
  85075. */
  85076. isVerticesDataPresent(kind: string): boolean;
  85077. /**
  85078. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  85079. * @param kind defines the data kind (Position, normal, etc...)
  85080. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  85081. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85082. * @returns a float array containing vertex data
  85083. */
  85084. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  85085. /**
  85086. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85087. * @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.
  85088. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  85089. * @returns the indices array or an empty array if the mesh has no geometry
  85090. */
  85091. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  85092. /**
  85093. * Set specific vertex data
  85094. * @param kind defines the data kind (Position, normal, etc...)
  85095. * @param data defines the vertex data to use
  85096. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  85097. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  85098. */
  85099. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  85100. /**
  85101. * Update a specific associated vertex buffer
  85102. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85103. * - VertexBuffer.PositionKind
  85104. * - VertexBuffer.UVKind
  85105. * - VertexBuffer.UV2Kind
  85106. * - VertexBuffer.UV3Kind
  85107. * - VertexBuffer.UV4Kind
  85108. * - VertexBuffer.UV5Kind
  85109. * - VertexBuffer.UV6Kind
  85110. * - VertexBuffer.ColorKind
  85111. * - VertexBuffer.MatricesIndicesKind
  85112. * - VertexBuffer.MatricesIndicesExtraKind
  85113. * - VertexBuffer.MatricesWeightsKind
  85114. * - VertexBuffer.MatricesWeightsExtraKind
  85115. * @param data defines the data source
  85116. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85117. * @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)
  85118. */
  85119. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  85120. /**
  85121. * Creates a new index buffer
  85122. * @param indices defines the indices to store in the index buffer
  85123. * @param totalVertices defines the total number of vertices (could be null)
  85124. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  85125. */
  85126. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  85127. }
  85128. /**
  85129. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  85130. */
  85131. export class VertexData {
  85132. /**
  85133. * Mesh side orientation : usually the external or front surface
  85134. */
  85135. static readonly FRONTSIDE: number;
  85136. /**
  85137. * Mesh side orientation : usually the internal or back surface
  85138. */
  85139. static readonly BACKSIDE: number;
  85140. /**
  85141. * Mesh side orientation : both internal and external or front and back surfaces
  85142. */
  85143. static readonly DOUBLESIDE: number;
  85144. /**
  85145. * Mesh side orientation : by default, `FRONTSIDE`
  85146. */
  85147. static readonly DEFAULTSIDE: number;
  85148. /**
  85149. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  85150. */
  85151. positions: Nullable<FloatArray>;
  85152. /**
  85153. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  85154. */
  85155. normals: Nullable<FloatArray>;
  85156. /**
  85157. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  85158. */
  85159. tangents: Nullable<FloatArray>;
  85160. /**
  85161. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85162. */
  85163. uvs: Nullable<FloatArray>;
  85164. /**
  85165. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85166. */
  85167. uvs2: Nullable<FloatArray>;
  85168. /**
  85169. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85170. */
  85171. uvs3: Nullable<FloatArray>;
  85172. /**
  85173. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85174. */
  85175. uvs4: Nullable<FloatArray>;
  85176. /**
  85177. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85178. */
  85179. uvs5: Nullable<FloatArray>;
  85180. /**
  85181. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  85182. */
  85183. uvs6: Nullable<FloatArray>;
  85184. /**
  85185. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  85186. */
  85187. colors: Nullable<FloatArray>;
  85188. /**
  85189. * 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).
  85190. */
  85191. matricesIndices: Nullable<FloatArray>;
  85192. /**
  85193. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  85194. */
  85195. matricesWeights: Nullable<FloatArray>;
  85196. /**
  85197. * An array extending the number of possible indices
  85198. */
  85199. matricesIndicesExtra: Nullable<FloatArray>;
  85200. /**
  85201. * An array extending the number of possible weights when the number of indices is extended
  85202. */
  85203. matricesWeightsExtra: Nullable<FloatArray>;
  85204. /**
  85205. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  85206. */
  85207. indices: Nullable<IndicesArray>;
  85208. /**
  85209. * Uses the passed data array to set the set the values for the specified kind of data
  85210. * @param data a linear array of floating numbers
  85211. * @param kind the type of data that is being set, eg positions, colors etc
  85212. */
  85213. set(data: FloatArray, kind: string): void;
  85214. /**
  85215. * Associates the vertexData to the passed Mesh.
  85216. * Sets it as updatable or not (default `false`)
  85217. * @param mesh the mesh the vertexData is applied to
  85218. * @param updatable when used and having the value true allows new data to update the vertexData
  85219. * @returns the VertexData
  85220. */
  85221. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  85222. /**
  85223. * Associates the vertexData to the passed Geometry.
  85224. * Sets it as updatable or not (default `false`)
  85225. * @param geometry the geometry the vertexData is applied to
  85226. * @param updatable when used and having the value true allows new data to update the vertexData
  85227. * @returns VertexData
  85228. */
  85229. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  85230. /**
  85231. * Updates the associated mesh
  85232. * @param mesh the mesh to be updated
  85233. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85234. * @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
  85235. * @returns VertexData
  85236. */
  85237. updateMesh(mesh: Mesh): VertexData;
  85238. /**
  85239. * Updates the associated geometry
  85240. * @param geometry the geometry to be updated
  85241. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  85242. * @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
  85243. * @returns VertexData.
  85244. */
  85245. updateGeometry(geometry: Geometry): VertexData;
  85246. private _applyTo;
  85247. private _update;
  85248. /**
  85249. * Transforms each position and each normal of the vertexData according to the passed Matrix
  85250. * @param matrix the transforming matrix
  85251. * @returns the VertexData
  85252. */
  85253. transform(matrix: Matrix): VertexData;
  85254. /**
  85255. * Merges the passed VertexData into the current one
  85256. * @param other the VertexData to be merged into the current one
  85257. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  85258. * @returns the modified VertexData
  85259. */
  85260. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  85261. private _mergeElement;
  85262. private _validate;
  85263. /**
  85264. * Serializes the VertexData
  85265. * @returns a serialized object
  85266. */
  85267. serialize(): any;
  85268. /**
  85269. * Extracts the vertexData from a mesh
  85270. * @param mesh the mesh from which to extract the VertexData
  85271. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  85272. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85273. * @returns the object VertexData associated to the passed mesh
  85274. */
  85275. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85276. /**
  85277. * Extracts the vertexData from the geometry
  85278. * @param geometry the geometry from which to extract the VertexData
  85279. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  85280. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  85281. * @returns the object VertexData associated to the passed mesh
  85282. */
  85283. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  85284. private static _ExtractFrom;
  85285. /**
  85286. * Creates the VertexData for a Ribbon
  85287. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  85288. * * pathArray array of paths, each of which an array of successive Vector3
  85289. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  85290. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  85291. * * 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
  85292. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85293. * * 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)
  85294. * * 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)
  85295. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  85296. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  85297. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  85298. * @returns the VertexData of the ribbon
  85299. */
  85300. static CreateRibbon(options: {
  85301. pathArray: Vector3[][];
  85302. closeArray?: boolean;
  85303. closePath?: boolean;
  85304. offset?: number;
  85305. sideOrientation?: number;
  85306. frontUVs?: Vector4;
  85307. backUVs?: Vector4;
  85308. invertUV?: boolean;
  85309. uvs?: Vector2[];
  85310. colors?: Color4[];
  85311. }): VertexData;
  85312. /**
  85313. * Creates the VertexData for a box
  85314. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85315. * * size sets the width, height and depth of the box to the value of size, optional default 1
  85316. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  85317. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  85318. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  85319. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85320. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85321. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85322. * * 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)
  85323. * * 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)
  85324. * @returns the VertexData of the box
  85325. */
  85326. static CreateBox(options: {
  85327. size?: number;
  85328. width?: number;
  85329. height?: number;
  85330. depth?: number;
  85331. faceUV?: Vector4[];
  85332. faceColors?: Color4[];
  85333. sideOrientation?: number;
  85334. frontUVs?: Vector4;
  85335. backUVs?: Vector4;
  85336. }): VertexData;
  85337. /**
  85338. * Creates the VertexData for a tiled box
  85339. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85340. * * faceTiles sets the pattern, tile size and number of tiles for a face
  85341. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  85342. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  85343. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85344. * @returns the VertexData of the box
  85345. */
  85346. static CreateTiledBox(options: {
  85347. pattern?: number;
  85348. width?: number;
  85349. height?: number;
  85350. depth?: number;
  85351. tileSize?: number;
  85352. tileWidth?: number;
  85353. tileHeight?: number;
  85354. alignHorizontal?: number;
  85355. alignVertical?: number;
  85356. faceUV?: Vector4[];
  85357. faceColors?: Color4[];
  85358. sideOrientation?: number;
  85359. }): VertexData;
  85360. /**
  85361. * Creates the VertexData for a tiled plane
  85362. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85363. * * pattern a limited pattern arrangement depending on the number
  85364. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  85365. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  85366. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  85367. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85368. * * 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)
  85369. * * 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)
  85370. * @returns the VertexData of the tiled plane
  85371. */
  85372. static CreateTiledPlane(options: {
  85373. pattern?: number;
  85374. tileSize?: number;
  85375. tileWidth?: number;
  85376. tileHeight?: number;
  85377. size?: number;
  85378. width?: number;
  85379. height?: number;
  85380. alignHorizontal?: number;
  85381. alignVertical?: number;
  85382. sideOrientation?: number;
  85383. frontUVs?: Vector4;
  85384. backUVs?: Vector4;
  85385. }): VertexData;
  85386. /**
  85387. * Creates the VertexData for an ellipsoid, defaults to a sphere
  85388. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85389. * * segments sets the number of horizontal strips optional, default 32
  85390. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  85391. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  85392. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  85393. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  85394. * * 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
  85395. * * 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
  85396. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85397. * * 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)
  85398. * * 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)
  85399. * @returns the VertexData of the ellipsoid
  85400. */
  85401. static CreateSphere(options: {
  85402. segments?: number;
  85403. diameter?: number;
  85404. diameterX?: number;
  85405. diameterY?: number;
  85406. diameterZ?: number;
  85407. arc?: number;
  85408. slice?: number;
  85409. sideOrientation?: number;
  85410. frontUVs?: Vector4;
  85411. backUVs?: Vector4;
  85412. }): VertexData;
  85413. /**
  85414. * Creates the VertexData for a cylinder, cone or prism
  85415. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85416. * * height sets the height (y direction) of the cylinder, optional, default 2
  85417. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  85418. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  85419. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  85420. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85421. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  85422. * * 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
  85423. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85424. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85425. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  85426. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  85427. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85428. * * 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)
  85429. * * 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)
  85430. * @returns the VertexData of the cylinder, cone or prism
  85431. */
  85432. static CreateCylinder(options: {
  85433. height?: number;
  85434. diameterTop?: number;
  85435. diameterBottom?: number;
  85436. diameter?: number;
  85437. tessellation?: number;
  85438. subdivisions?: number;
  85439. arc?: number;
  85440. faceColors?: Color4[];
  85441. faceUV?: Vector4[];
  85442. hasRings?: boolean;
  85443. enclose?: boolean;
  85444. sideOrientation?: number;
  85445. frontUVs?: Vector4;
  85446. backUVs?: Vector4;
  85447. }): VertexData;
  85448. /**
  85449. * Creates the VertexData for a torus
  85450. * @param options an object used to set the following optional parameters for the box, required but can be empty
  85451. * * diameter the diameter of the torus, optional default 1
  85452. * * thickness the diameter of the tube forming the torus, optional default 0.5
  85453. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  85454. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85455. * * 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)
  85456. * * 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)
  85457. * @returns the VertexData of the torus
  85458. */
  85459. static CreateTorus(options: {
  85460. diameter?: number;
  85461. thickness?: number;
  85462. tessellation?: number;
  85463. sideOrientation?: number;
  85464. frontUVs?: Vector4;
  85465. backUVs?: Vector4;
  85466. }): VertexData;
  85467. /**
  85468. * Creates the VertexData of the LineSystem
  85469. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  85470. * - lines an array of lines, each line being an array of successive Vector3
  85471. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  85472. * @returns the VertexData of the LineSystem
  85473. */
  85474. static CreateLineSystem(options: {
  85475. lines: Vector3[][];
  85476. colors?: Nullable<Color4[][]>;
  85477. }): VertexData;
  85478. /**
  85479. * Create the VertexData for a DashedLines
  85480. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  85481. * - points an array successive Vector3
  85482. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  85483. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  85484. * - dashNb the intended total number of dashes, optional, default 200
  85485. * @returns the VertexData for the DashedLines
  85486. */
  85487. static CreateDashedLines(options: {
  85488. points: Vector3[];
  85489. dashSize?: number;
  85490. gapSize?: number;
  85491. dashNb?: number;
  85492. }): VertexData;
  85493. /**
  85494. * Creates the VertexData for a Ground
  85495. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85496. * - width the width (x direction) of the ground, optional, default 1
  85497. * - height the height (z direction) of the ground, optional, default 1
  85498. * - subdivisions the number of subdivisions per side, optional, default 1
  85499. * @returns the VertexData of the Ground
  85500. */
  85501. static CreateGround(options: {
  85502. width?: number;
  85503. height?: number;
  85504. subdivisions?: number;
  85505. subdivisionsX?: number;
  85506. subdivisionsY?: number;
  85507. }): VertexData;
  85508. /**
  85509. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  85510. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  85511. * * xmin the ground minimum X coordinate, optional, default -1
  85512. * * zmin the ground minimum Z coordinate, optional, default -1
  85513. * * xmax the ground maximum X coordinate, optional, default 1
  85514. * * zmax the ground maximum Z coordinate, optional, default 1
  85515. * * 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}
  85516. * * 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}
  85517. * @returns the VertexData of the TiledGround
  85518. */
  85519. static CreateTiledGround(options: {
  85520. xmin: number;
  85521. zmin: number;
  85522. xmax: number;
  85523. zmax: number;
  85524. subdivisions?: {
  85525. w: number;
  85526. h: number;
  85527. };
  85528. precision?: {
  85529. w: number;
  85530. h: number;
  85531. };
  85532. }): VertexData;
  85533. /**
  85534. * Creates the VertexData of the Ground designed from a heightmap
  85535. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  85536. * * width the width (x direction) of the ground
  85537. * * height the height (z direction) of the ground
  85538. * * subdivisions the number of subdivisions per side
  85539. * * minHeight the minimum altitude on the ground, optional, default 0
  85540. * * maxHeight the maximum altitude on the ground, optional default 1
  85541. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  85542. * * buffer the array holding the image color data
  85543. * * bufferWidth the width of image
  85544. * * bufferHeight the height of image
  85545. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  85546. * @returns the VertexData of the Ground designed from a heightmap
  85547. */
  85548. static CreateGroundFromHeightMap(options: {
  85549. width: number;
  85550. height: number;
  85551. subdivisions: number;
  85552. minHeight: number;
  85553. maxHeight: number;
  85554. colorFilter: Color3;
  85555. buffer: Uint8Array;
  85556. bufferWidth: number;
  85557. bufferHeight: number;
  85558. alphaFilter: number;
  85559. }): VertexData;
  85560. /**
  85561. * Creates the VertexData for a Plane
  85562. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  85563. * * size sets the width and height of the plane to the value of size, optional default 1
  85564. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  85565. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  85566. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85567. * * 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)
  85568. * * 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)
  85569. * @returns the VertexData of the box
  85570. */
  85571. static CreatePlane(options: {
  85572. size?: number;
  85573. width?: number;
  85574. height?: number;
  85575. sideOrientation?: number;
  85576. frontUVs?: Vector4;
  85577. backUVs?: Vector4;
  85578. }): VertexData;
  85579. /**
  85580. * Creates the VertexData of the Disc or regular Polygon
  85581. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  85582. * * radius the radius of the disc, optional default 0.5
  85583. * * tessellation the number of polygon sides, optional, default 64
  85584. * * 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
  85585. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85586. * * 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)
  85587. * * 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)
  85588. * @returns the VertexData of the box
  85589. */
  85590. static CreateDisc(options: {
  85591. radius?: number;
  85592. tessellation?: number;
  85593. arc?: number;
  85594. sideOrientation?: number;
  85595. frontUVs?: Vector4;
  85596. backUVs?: Vector4;
  85597. }): VertexData;
  85598. /**
  85599. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  85600. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  85601. * @param polygon a mesh built from polygonTriangulation.build()
  85602. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85603. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85604. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85605. * @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)
  85606. * @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)
  85607. * @returns the VertexData of the Polygon
  85608. */
  85609. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  85610. /**
  85611. * Creates the VertexData of the IcoSphere
  85612. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  85613. * * radius the radius of the IcoSphere, optional default 1
  85614. * * radiusX allows stretching in the x direction, optional, default radius
  85615. * * radiusY allows stretching in the y direction, optional, default radius
  85616. * * radiusZ allows stretching in the z direction, optional, default radius
  85617. * * flat when true creates a flat shaded mesh, optional, default true
  85618. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85619. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85620. * * 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)
  85621. * * 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)
  85622. * @returns the VertexData of the IcoSphere
  85623. */
  85624. static CreateIcoSphere(options: {
  85625. radius?: number;
  85626. radiusX?: number;
  85627. radiusY?: number;
  85628. radiusZ?: number;
  85629. flat?: boolean;
  85630. subdivisions?: number;
  85631. sideOrientation?: number;
  85632. frontUVs?: Vector4;
  85633. backUVs?: Vector4;
  85634. }): VertexData;
  85635. /**
  85636. * Creates the VertexData for a Polyhedron
  85637. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  85638. * * type provided types are:
  85639. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  85640. * * 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)
  85641. * * size the size of the IcoSphere, optional default 1
  85642. * * sizeX allows stretching in the x direction, optional, default size
  85643. * * sizeY allows stretching in the y direction, optional, default size
  85644. * * sizeZ allows stretching in the z direction, optional, default size
  85645. * * 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
  85646. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  85647. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  85648. * * flat when true creates a flat shaded mesh, optional, default true
  85649. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  85650. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85651. * * 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)
  85652. * * 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)
  85653. * @returns the VertexData of the Polyhedron
  85654. */
  85655. static CreatePolyhedron(options: {
  85656. type?: number;
  85657. size?: number;
  85658. sizeX?: number;
  85659. sizeY?: number;
  85660. sizeZ?: number;
  85661. custom?: any;
  85662. faceUV?: Vector4[];
  85663. faceColors?: Color4[];
  85664. flat?: boolean;
  85665. sideOrientation?: number;
  85666. frontUVs?: Vector4;
  85667. backUVs?: Vector4;
  85668. }): VertexData;
  85669. /**
  85670. * Creates the VertexData for a TorusKnot
  85671. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  85672. * * radius the radius of the torus knot, optional, default 2
  85673. * * tube the thickness of the tube, optional, default 0.5
  85674. * * radialSegments the number of sides on each tube segments, optional, default 32
  85675. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  85676. * * p the number of windings around the z axis, optional, default 2
  85677. * * q the number of windings around the x axis, optional, default 3
  85678. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  85679. * * 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)
  85680. * * 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)
  85681. * @returns the VertexData of the Torus Knot
  85682. */
  85683. static CreateTorusKnot(options: {
  85684. radius?: number;
  85685. tube?: number;
  85686. radialSegments?: number;
  85687. tubularSegments?: number;
  85688. p?: number;
  85689. q?: number;
  85690. sideOrientation?: number;
  85691. frontUVs?: Vector4;
  85692. backUVs?: Vector4;
  85693. }): VertexData;
  85694. /**
  85695. * Compute normals for given positions and indices
  85696. * @param positions an array of vertex positions, [...., x, y, z, ......]
  85697. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  85698. * @param normals an array of vertex normals, [...., x, y, z, ......]
  85699. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  85700. * * facetNormals : optional array of facet normals (vector3)
  85701. * * facetPositions : optional array of facet positions (vector3)
  85702. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  85703. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  85704. * * bInfo : optional bounding info, required for facetPartitioning computation
  85705. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  85706. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  85707. * * useRightHandedSystem: optional boolean to for right handed system computation
  85708. * * depthSort : optional boolean to enable the facet depth sort computation
  85709. * * distanceTo : optional Vector3 to compute the facet depth from this location
  85710. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  85711. */
  85712. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  85713. facetNormals?: any;
  85714. facetPositions?: any;
  85715. facetPartitioning?: any;
  85716. ratio?: number;
  85717. bInfo?: any;
  85718. bbSize?: Vector3;
  85719. subDiv?: any;
  85720. useRightHandedSystem?: boolean;
  85721. depthSort?: boolean;
  85722. distanceTo?: Vector3;
  85723. depthSortedFacets?: any;
  85724. }): void;
  85725. /** @hidden */
  85726. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  85727. /**
  85728. * Applies VertexData created from the imported parameters to the geometry
  85729. * @param parsedVertexData the parsed data from an imported file
  85730. * @param geometry the geometry to apply the VertexData to
  85731. */
  85732. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  85733. }
  85734. }
  85735. declare module BABYLON {
  85736. /**
  85737. * Class containing static functions to help procedurally build meshes
  85738. */
  85739. export class DiscBuilder {
  85740. /**
  85741. * Creates a plane polygonal mesh. By default, this is a disc
  85742. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  85743. * * 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
  85744. * * 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
  85745. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  85746. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  85747. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  85748. * @param name defines the name of the mesh
  85749. * @param options defines the options used to create the mesh
  85750. * @param scene defines the hosting scene
  85751. * @returns the plane polygonal mesh
  85752. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  85753. */
  85754. static CreateDisc(name: string, options: {
  85755. radius?: number;
  85756. tessellation?: number;
  85757. arc?: number;
  85758. updatable?: boolean;
  85759. sideOrientation?: number;
  85760. frontUVs?: Vector4;
  85761. backUVs?: Vector4;
  85762. }, scene?: Nullable<Scene>): Mesh;
  85763. }
  85764. }
  85765. declare module BABYLON {
  85766. /**
  85767. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  85768. *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.
  85769. * The SPS is also a particle system. It provides some methods to manage the particles.
  85770. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  85771. *
  85772. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  85773. */
  85774. export class SolidParticleSystem implements IDisposable {
  85775. /**
  85776. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  85777. * Example : var p = SPS.particles[i];
  85778. */
  85779. particles: SolidParticle[];
  85780. /**
  85781. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  85782. */
  85783. nbParticles: number;
  85784. /**
  85785. * If the particles must ever face the camera (default false). Useful for planar particles.
  85786. */
  85787. billboard: boolean;
  85788. /**
  85789. * Recompute normals when adding a shape
  85790. */
  85791. recomputeNormals: boolean;
  85792. /**
  85793. * This a counter ofr your own usage. It's not set by any SPS functions.
  85794. */
  85795. counter: number;
  85796. /**
  85797. * The SPS name. This name is also given to the underlying mesh.
  85798. */
  85799. name: string;
  85800. /**
  85801. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  85802. */
  85803. mesh: Mesh;
  85804. /**
  85805. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  85806. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  85807. */
  85808. vars: any;
  85809. /**
  85810. * This array is populated when the SPS is set as 'pickable'.
  85811. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  85812. * Each element of this array is an object `{idx: int, faceId: int}`.
  85813. * `idx` is the picked particle index in the `SPS.particles` array
  85814. * `faceId` is the picked face index counted within this particle.
  85815. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  85816. */
  85817. pickedParticles: {
  85818. idx: number;
  85819. faceId: number;
  85820. }[];
  85821. /**
  85822. * This array is populated when `enableDepthSort` is set to true.
  85823. * Each element of this array is an instance of the class DepthSortedParticle.
  85824. */
  85825. depthSortedParticles: DepthSortedParticle[];
  85826. /**
  85827. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  85828. * @hidden
  85829. */
  85830. _bSphereOnly: boolean;
  85831. /**
  85832. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  85833. * @hidden
  85834. */
  85835. _bSphereRadiusFactor: number;
  85836. private _scene;
  85837. private _positions;
  85838. private _indices;
  85839. private _normals;
  85840. private _colors;
  85841. private _uvs;
  85842. private _indices32;
  85843. private _positions32;
  85844. private _normals32;
  85845. private _fixedNormal32;
  85846. private _colors32;
  85847. private _uvs32;
  85848. private _index;
  85849. private _updatable;
  85850. private _pickable;
  85851. private _isVisibilityBoxLocked;
  85852. private _alwaysVisible;
  85853. private _depthSort;
  85854. private _shapeCounter;
  85855. private _copy;
  85856. private _color;
  85857. private _computeParticleColor;
  85858. private _computeParticleTexture;
  85859. private _computeParticleRotation;
  85860. private _computeParticleVertex;
  85861. private _computeBoundingBox;
  85862. private _depthSortParticles;
  85863. private _camera;
  85864. private _mustUnrotateFixedNormals;
  85865. private _particlesIntersect;
  85866. private _needs32Bits;
  85867. /**
  85868. * Creates a SPS (Solid Particle System) object.
  85869. * @param name (String) is the SPS name, this will be the underlying mesh name.
  85870. * @param scene (Scene) is the scene in which the SPS is added.
  85871. * @param options defines the options of the sps e.g.
  85872. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  85873. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  85874. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  85875. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  85876. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  85877. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  85878. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  85879. */
  85880. constructor(name: string, scene: Scene, options?: {
  85881. updatable?: boolean;
  85882. isPickable?: boolean;
  85883. enableDepthSort?: boolean;
  85884. particleIntersection?: boolean;
  85885. boundingSphereOnly?: boolean;
  85886. bSphereRadiusFactor?: number;
  85887. });
  85888. /**
  85889. * Builds the SPS underlying mesh. Returns a standard Mesh.
  85890. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  85891. * @returns the created mesh
  85892. */
  85893. buildMesh(): Mesh;
  85894. /**
  85895. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  85896. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  85897. * Thus the particles generated from `digest()` have their property `position` set yet.
  85898. * @param mesh ( Mesh ) is the mesh to be digested
  85899. * @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
  85900. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  85901. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  85902. * @returns the current SPS
  85903. */
  85904. digest(mesh: Mesh, options?: {
  85905. facetNb?: number;
  85906. number?: number;
  85907. delta?: number;
  85908. }): SolidParticleSystem;
  85909. private _unrotateFixedNormals;
  85910. private _resetCopy;
  85911. private _meshBuilder;
  85912. private _posToShape;
  85913. private _uvsToShapeUV;
  85914. private _addParticle;
  85915. /**
  85916. * Adds some particles to the SPS from the model shape. Returns the shape id.
  85917. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  85918. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  85919. * @param nb (positive integer) the number of particles to be created from this model
  85920. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  85921. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  85922. * @returns the number of shapes in the system
  85923. */
  85924. addShape(mesh: Mesh, nb: number, options?: {
  85925. positionFunction?: any;
  85926. vertexFunction?: any;
  85927. }): number;
  85928. private _rebuildParticle;
  85929. /**
  85930. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  85931. * @returns the SPS.
  85932. */
  85933. rebuildMesh(): SolidParticleSystem;
  85934. /**
  85935. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  85936. * This method calls `updateParticle()` for each particle of the SPS.
  85937. * For an animated SPS, it is usually called within the render loop.
  85938. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  85939. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  85940. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  85941. * @returns the SPS.
  85942. */
  85943. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  85944. /**
  85945. * Disposes the SPS.
  85946. */
  85947. dispose(): void;
  85948. /**
  85949. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  85950. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85951. * @returns the SPS.
  85952. */
  85953. refreshVisibleSize(): SolidParticleSystem;
  85954. /**
  85955. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  85956. * @param size the size (float) of the visibility box
  85957. * note : this doesn't lock the SPS mesh bounding box.
  85958. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85959. */
  85960. setVisibilityBox(size: number): void;
  85961. /**
  85962. * Gets whether the SPS as always visible or not
  85963. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85964. */
  85965. /**
  85966. * Sets the SPS as always visible or not
  85967. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85968. */
  85969. isAlwaysVisible: boolean;
  85970. /**
  85971. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  85972. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85973. */
  85974. /**
  85975. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  85976. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  85977. */
  85978. isVisibilityBoxLocked: boolean;
  85979. /**
  85980. * Tells to `setParticles()` to compute the particle rotations or not.
  85981. * Default value : true. The SPS is faster when it's set to false.
  85982. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  85983. */
  85984. /**
  85985. * Gets if `setParticles()` computes the particle rotations or not.
  85986. * Default value : true. The SPS is faster when it's set to false.
  85987. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  85988. */
  85989. computeParticleRotation: boolean;
  85990. /**
  85991. * Tells to `setParticles()` to compute the particle colors or not.
  85992. * Default value : true. The SPS is faster when it's set to false.
  85993. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  85994. */
  85995. /**
  85996. * Gets if `setParticles()` computes the particle colors or not.
  85997. * Default value : true. The SPS is faster when it's set to false.
  85998. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  85999. */
  86000. computeParticleColor: boolean;
  86001. /**
  86002. * Gets if `setParticles()` computes the particle textures or not.
  86003. * Default value : true. The SPS is faster when it's set to false.
  86004. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  86005. */
  86006. computeParticleTexture: boolean;
  86007. /**
  86008. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  86009. * Default value : false. The SPS is faster when it's set to false.
  86010. * Note : the particle custom vertex positions aren't stored values.
  86011. */
  86012. /**
  86013. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  86014. * Default value : false. The SPS is faster when it's set to false.
  86015. * Note : the particle custom vertex positions aren't stored values.
  86016. */
  86017. computeParticleVertex: boolean;
  86018. /**
  86019. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  86020. */
  86021. /**
  86022. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  86023. */
  86024. computeBoundingBox: boolean;
  86025. /**
  86026. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  86027. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86028. * Default : `true`
  86029. */
  86030. /**
  86031. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  86032. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  86033. * Default : `true`
  86034. */
  86035. depthSortParticles: boolean;
  86036. /**
  86037. * This function does nothing. It may be overwritten to set all the particle first values.
  86038. * The SPS doesn't call this function, you may have to call it by your own.
  86039. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86040. */
  86041. initParticles(): void;
  86042. /**
  86043. * This function does nothing. It may be overwritten to recycle a particle.
  86044. * The SPS doesn't call this function, you may have to call it by your own.
  86045. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86046. * @param particle The particle to recycle
  86047. * @returns the recycled particle
  86048. */
  86049. recycleParticle(particle: SolidParticle): SolidParticle;
  86050. /**
  86051. * Updates a particle : this function should be overwritten by the user.
  86052. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  86053. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  86054. * @example : just set a particle position or velocity and recycle conditions
  86055. * @param particle The particle to update
  86056. * @returns the updated particle
  86057. */
  86058. updateParticle(particle: SolidParticle): SolidParticle;
  86059. /**
  86060. * Updates a vertex of a particle : it can be overwritten by the user.
  86061. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  86062. * @param particle the current particle
  86063. * @param vertex the current index of the current particle
  86064. * @param pt the index of the current vertex in the particle shape
  86065. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  86066. * @example : just set a vertex particle position
  86067. * @returns the updated vertex
  86068. */
  86069. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  86070. /**
  86071. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  86072. * This does nothing and may be overwritten by the user.
  86073. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86074. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86075. * @param update the boolean update value actually passed to setParticles()
  86076. */
  86077. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86078. /**
  86079. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  86080. * This will be passed three parameters.
  86081. * This does nothing and may be overwritten by the user.
  86082. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86083. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  86084. * @param update the boolean update value actually passed to setParticles()
  86085. */
  86086. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  86087. }
  86088. }
  86089. declare module BABYLON {
  86090. /**
  86091. * Represents one particle of a solid particle system.
  86092. */
  86093. export class SolidParticle {
  86094. /**
  86095. * particle global index
  86096. */
  86097. idx: number;
  86098. /**
  86099. * The color of the particle
  86100. */
  86101. color: Nullable<Color4>;
  86102. /**
  86103. * The world space position of the particle.
  86104. */
  86105. position: Vector3;
  86106. /**
  86107. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  86108. */
  86109. rotation: Vector3;
  86110. /**
  86111. * The world space rotation quaternion of the particle.
  86112. */
  86113. rotationQuaternion: Nullable<Quaternion>;
  86114. /**
  86115. * The scaling of the particle.
  86116. */
  86117. scaling: Vector3;
  86118. /**
  86119. * The uvs of the particle.
  86120. */
  86121. uvs: Vector4;
  86122. /**
  86123. * The current speed of the particle.
  86124. */
  86125. velocity: Vector3;
  86126. /**
  86127. * The pivot point in the particle local space.
  86128. */
  86129. pivot: Vector3;
  86130. /**
  86131. * Must the particle be translated from its pivot point in its local space ?
  86132. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  86133. * Default : false
  86134. */
  86135. translateFromPivot: boolean;
  86136. /**
  86137. * Is the particle active or not ?
  86138. */
  86139. alive: boolean;
  86140. /**
  86141. * Is the particle visible or not ?
  86142. */
  86143. isVisible: boolean;
  86144. /**
  86145. * Index of this particle in the global "positions" array (Internal use)
  86146. * @hidden
  86147. */
  86148. _pos: number;
  86149. /**
  86150. * @hidden Index of this particle in the global "indices" array (Internal use)
  86151. */
  86152. _ind: number;
  86153. /**
  86154. * @hidden ModelShape of this particle (Internal use)
  86155. */
  86156. _model: ModelShape;
  86157. /**
  86158. * ModelShape id of this particle
  86159. */
  86160. shapeId: number;
  86161. /**
  86162. * Index of the particle in its shape id (Internal use)
  86163. */
  86164. idxInShape: number;
  86165. /**
  86166. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  86167. */
  86168. _modelBoundingInfo: BoundingInfo;
  86169. /**
  86170. * @hidden Particle BoundingInfo object (Internal use)
  86171. */
  86172. _boundingInfo: BoundingInfo;
  86173. /**
  86174. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  86175. */
  86176. _sps: SolidParticleSystem;
  86177. /**
  86178. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  86179. */
  86180. _stillInvisible: boolean;
  86181. /**
  86182. * @hidden Last computed particle rotation matrix
  86183. */
  86184. _rotationMatrix: number[];
  86185. /**
  86186. * Parent particle Id, if any.
  86187. * Default null.
  86188. */
  86189. parentId: Nullable<number>;
  86190. /**
  86191. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  86192. * The possible values are :
  86193. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86194. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86195. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86196. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86197. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86198. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  86199. * */
  86200. cullingStrategy: number;
  86201. /**
  86202. * @hidden Internal global position in the SPS.
  86203. */
  86204. _globalPosition: Vector3;
  86205. /**
  86206. * Creates a Solid Particle object.
  86207. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  86208. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  86209. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  86210. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  86211. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  86212. * @param shapeId (integer) is the model shape identifier in the SPS.
  86213. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  86214. * @param sps defines the sps it is associated to
  86215. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  86216. */
  86217. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  86218. /**
  86219. * Legacy support, changed scale to scaling
  86220. */
  86221. /**
  86222. * Legacy support, changed scale to scaling
  86223. */
  86224. scale: Vector3;
  86225. /**
  86226. * Legacy support, changed quaternion to rotationQuaternion
  86227. */
  86228. /**
  86229. * Legacy support, changed quaternion to rotationQuaternion
  86230. */
  86231. quaternion: Nullable<Quaternion>;
  86232. /**
  86233. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  86234. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  86235. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  86236. * @returns true if it intersects
  86237. */
  86238. intersectsMesh(target: Mesh | SolidParticle): boolean;
  86239. /**
  86240. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  86241. * A particle is in the frustum if its bounding box intersects the frustum
  86242. * @param frustumPlanes defines the frustum to test
  86243. * @returns true if the particle is in the frustum planes
  86244. */
  86245. isInFrustum(frustumPlanes: Plane[]): boolean;
  86246. /**
  86247. * get the rotation matrix of the particle
  86248. * @hidden
  86249. */
  86250. getRotationMatrix(m: Matrix): void;
  86251. }
  86252. /**
  86253. * Represents the shape of the model used by one particle of a solid particle system.
  86254. * SPS internal tool, don't use it manually.
  86255. */
  86256. export class ModelShape {
  86257. /**
  86258. * The shape id
  86259. * @hidden
  86260. */
  86261. shapeID: number;
  86262. /**
  86263. * flat array of model positions (internal use)
  86264. * @hidden
  86265. */
  86266. _shape: Vector3[];
  86267. /**
  86268. * flat array of model UVs (internal use)
  86269. * @hidden
  86270. */
  86271. _shapeUV: number[];
  86272. /**
  86273. * length of the shape in the model indices array (internal use)
  86274. * @hidden
  86275. */
  86276. _indicesLength: number;
  86277. /**
  86278. * Custom position function (internal use)
  86279. * @hidden
  86280. */
  86281. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  86282. /**
  86283. * Custom vertex function (internal use)
  86284. * @hidden
  86285. */
  86286. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  86287. /**
  86288. * 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.
  86289. * SPS internal tool, don't use it manually.
  86290. * @hidden
  86291. */
  86292. 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>);
  86293. }
  86294. /**
  86295. * Represents a Depth Sorted Particle in the solid particle system.
  86296. */
  86297. export class DepthSortedParticle {
  86298. /**
  86299. * Index of the particle in the "indices" array
  86300. */
  86301. ind: number;
  86302. /**
  86303. * Length of the particle shape in the "indices" array
  86304. */
  86305. indicesLength: number;
  86306. /**
  86307. * Squared distance from the particle to the camera
  86308. */
  86309. sqDistance: number;
  86310. }
  86311. }
  86312. declare module BABYLON {
  86313. /**
  86314. * @hidden
  86315. */
  86316. export class _MeshCollisionData {
  86317. _checkCollisions: boolean;
  86318. _collisionMask: number;
  86319. _collisionGroup: number;
  86320. _collider: Nullable<Collider>;
  86321. _oldPositionForCollisions: Vector3;
  86322. _diffPositionForCollisions: Vector3;
  86323. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  86324. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  86325. }
  86326. }
  86327. declare module BABYLON {
  86328. /** @hidden */
  86329. class _FacetDataStorage {
  86330. facetPositions: Vector3[];
  86331. facetNormals: Vector3[];
  86332. facetPartitioning: number[][];
  86333. facetNb: number;
  86334. partitioningSubdivisions: number;
  86335. partitioningBBoxRatio: number;
  86336. facetDataEnabled: boolean;
  86337. facetParameters: any;
  86338. bbSize: Vector3;
  86339. subDiv: {
  86340. max: number;
  86341. X: number;
  86342. Y: number;
  86343. Z: number;
  86344. };
  86345. facetDepthSort: boolean;
  86346. facetDepthSortEnabled: boolean;
  86347. depthSortedIndices: IndicesArray;
  86348. depthSortedFacets: {
  86349. ind: number;
  86350. sqDistance: number;
  86351. }[];
  86352. facetDepthSortFunction: (f1: {
  86353. ind: number;
  86354. sqDistance: number;
  86355. }, f2: {
  86356. ind: number;
  86357. sqDistance: number;
  86358. }) => number;
  86359. facetDepthSortFrom: Vector3;
  86360. facetDepthSortOrigin: Vector3;
  86361. invertedMatrix: Matrix;
  86362. }
  86363. /**
  86364. * @hidden
  86365. **/
  86366. class _InternalAbstractMeshDataInfo {
  86367. _hasVertexAlpha: boolean;
  86368. _useVertexColors: boolean;
  86369. _numBoneInfluencers: number;
  86370. _applyFog: boolean;
  86371. _receiveShadows: boolean;
  86372. _facetData: _FacetDataStorage;
  86373. _visibility: number;
  86374. _skeleton: Nullable<Skeleton>;
  86375. _layerMask: number;
  86376. _computeBonesUsingShaders: boolean;
  86377. _isActive: boolean;
  86378. _onlyForInstances: boolean;
  86379. _isActiveIntermediate: boolean;
  86380. _onlyForInstancesIntermediate: boolean;
  86381. }
  86382. /**
  86383. * Class used to store all common mesh properties
  86384. */
  86385. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  86386. /** No occlusion */
  86387. static OCCLUSION_TYPE_NONE: number;
  86388. /** Occlusion set to optimisitic */
  86389. static OCCLUSION_TYPE_OPTIMISTIC: number;
  86390. /** Occlusion set to strict */
  86391. static OCCLUSION_TYPE_STRICT: number;
  86392. /** Use an accurante occlusion algorithm */
  86393. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  86394. /** Use a conservative occlusion algorithm */
  86395. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  86396. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  86397. * Test order :
  86398. * Is the bounding sphere outside the frustum ?
  86399. * If not, are the bounding box vertices outside the frustum ?
  86400. * It not, then the cullable object is in the frustum.
  86401. */
  86402. static readonly CULLINGSTRATEGY_STANDARD: number;
  86403. /** Culling strategy : Bounding Sphere Only.
  86404. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  86405. * It's also less accurate than the standard because some not visible objects can still be selected.
  86406. * Test : is the bounding sphere outside the frustum ?
  86407. * If not, then the cullable object is in the frustum.
  86408. */
  86409. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  86410. /** Culling strategy : Optimistic Inclusion.
  86411. * This in an inclusion test first, then the standard exclusion test.
  86412. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  86413. * 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.
  86414. * Anyway, it's as accurate as the standard strategy.
  86415. * Test :
  86416. * Is the cullable object bounding sphere center in the frustum ?
  86417. * If not, apply the default culling strategy.
  86418. */
  86419. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  86420. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  86421. * This in an inclusion test first, then the bounding sphere only exclusion test.
  86422. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  86423. * 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.
  86424. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  86425. * Test :
  86426. * Is the cullable object bounding sphere center in the frustum ?
  86427. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  86428. */
  86429. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  86430. /**
  86431. * No billboard
  86432. */
  86433. static readonly BILLBOARDMODE_NONE: number;
  86434. /** Billboard on X axis */
  86435. static readonly BILLBOARDMODE_X: number;
  86436. /** Billboard on Y axis */
  86437. static readonly BILLBOARDMODE_Y: number;
  86438. /** Billboard on Z axis */
  86439. static readonly BILLBOARDMODE_Z: number;
  86440. /** Billboard on all axes */
  86441. static readonly BILLBOARDMODE_ALL: number;
  86442. /** @hidden */
  86443. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  86444. /**
  86445. * The culling strategy to use to check whether the mesh must be rendered or not.
  86446. * This value can be changed at any time and will be used on the next render mesh selection.
  86447. * The possible values are :
  86448. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  86449. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  86450. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  86451. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  86452. * Please read each static variable documentation to get details about the culling process.
  86453. * */
  86454. cullingStrategy: number;
  86455. /**
  86456. * Gets the number of facets in the mesh
  86457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86458. */
  86459. readonly facetNb: number;
  86460. /**
  86461. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  86462. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86463. */
  86464. partitioningSubdivisions: number;
  86465. /**
  86466. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  86467. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  86468. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  86469. */
  86470. partitioningBBoxRatio: number;
  86471. /**
  86472. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  86473. * Works only for updatable meshes.
  86474. * Doesn't work with multi-materials
  86475. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86476. */
  86477. mustDepthSortFacets: boolean;
  86478. /**
  86479. * The location (Vector3) where the facet depth sort must be computed from.
  86480. * By default, the active camera position.
  86481. * Used only when facet depth sort is enabled
  86482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  86483. */
  86484. facetDepthSortFrom: Vector3;
  86485. /**
  86486. * gets a boolean indicating if facetData is enabled
  86487. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  86488. */
  86489. readonly isFacetDataEnabled: boolean;
  86490. /** @hidden */
  86491. _updateNonUniformScalingState(value: boolean): boolean;
  86492. /**
  86493. * An event triggered when this mesh collides with another one
  86494. */
  86495. onCollideObservable: Observable<AbstractMesh>;
  86496. /** Set a function to call when this mesh collides with another one */
  86497. onCollide: () => void;
  86498. /**
  86499. * An event triggered when the collision's position changes
  86500. */
  86501. onCollisionPositionChangeObservable: Observable<Vector3>;
  86502. /** Set a function to call when the collision's position changes */
  86503. onCollisionPositionChange: () => void;
  86504. /**
  86505. * An event triggered when material is changed
  86506. */
  86507. onMaterialChangedObservable: Observable<AbstractMesh>;
  86508. /**
  86509. * Gets or sets the orientation for POV movement & rotation
  86510. */
  86511. definedFacingForward: boolean;
  86512. /** @hidden */
  86513. _occlusionQuery: Nullable<WebGLQuery>;
  86514. /** @hidden */
  86515. _renderingGroup: Nullable<RenderingGroup>;
  86516. /**
  86517. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86518. */
  86519. /**
  86520. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  86521. */
  86522. visibility: number;
  86523. /** Gets or sets the alpha index used to sort transparent meshes
  86524. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  86525. */
  86526. alphaIndex: number;
  86527. /**
  86528. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  86529. */
  86530. isVisible: boolean;
  86531. /**
  86532. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  86533. */
  86534. isPickable: boolean;
  86535. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  86536. showSubMeshesBoundingBox: boolean;
  86537. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  86538. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  86539. */
  86540. isBlocker: boolean;
  86541. /**
  86542. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  86543. */
  86544. enablePointerMoveEvents: boolean;
  86545. /**
  86546. * Specifies the rendering group id for this mesh (0 by default)
  86547. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  86548. */
  86549. renderingGroupId: number;
  86550. private _material;
  86551. /** Gets or sets current material */
  86552. material: Nullable<Material>;
  86553. /**
  86554. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  86555. * @see http://doc.babylonjs.com/babylon101/shadows
  86556. */
  86557. receiveShadows: boolean;
  86558. /** Defines color to use when rendering outline */
  86559. outlineColor: Color3;
  86560. /** Define width to use when rendering outline */
  86561. outlineWidth: number;
  86562. /** Defines color to use when rendering overlay */
  86563. overlayColor: Color3;
  86564. /** Defines alpha to use when rendering overlay */
  86565. overlayAlpha: number;
  86566. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  86567. hasVertexAlpha: boolean;
  86568. /** 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) */
  86569. useVertexColors: boolean;
  86570. /**
  86571. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  86572. */
  86573. computeBonesUsingShaders: boolean;
  86574. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  86575. numBoneInfluencers: number;
  86576. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  86577. applyFog: boolean;
  86578. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  86579. useOctreeForRenderingSelection: boolean;
  86580. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  86581. useOctreeForPicking: boolean;
  86582. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  86583. useOctreeForCollisions: boolean;
  86584. /**
  86585. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  86586. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  86587. */
  86588. layerMask: number;
  86589. /**
  86590. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  86591. */
  86592. alwaysSelectAsActiveMesh: boolean;
  86593. /**
  86594. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  86595. */
  86596. doNotSyncBoundingInfo: boolean;
  86597. /**
  86598. * Gets or sets the current action manager
  86599. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  86600. */
  86601. actionManager: Nullable<AbstractActionManager>;
  86602. private _meshCollisionData;
  86603. /**
  86604. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  86605. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86606. */
  86607. ellipsoid: Vector3;
  86608. /**
  86609. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  86610. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86611. */
  86612. ellipsoidOffset: Vector3;
  86613. /**
  86614. * Gets or sets a collision mask used to mask collisions (default is -1).
  86615. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  86616. */
  86617. collisionMask: number;
  86618. /**
  86619. * Gets or sets the current collision group mask (-1 by default).
  86620. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  86621. */
  86622. collisionGroup: number;
  86623. /**
  86624. * Defines edge width used when edgesRenderer is enabled
  86625. * @see https://www.babylonjs-playground.com/#10OJSG#13
  86626. */
  86627. edgesWidth: number;
  86628. /**
  86629. * Defines edge color used when edgesRenderer is enabled
  86630. * @see https://www.babylonjs-playground.com/#10OJSG#13
  86631. */
  86632. edgesColor: Color4;
  86633. /** @hidden */
  86634. _edgesRenderer: Nullable<IEdgesRenderer>;
  86635. /** @hidden */
  86636. _masterMesh: Nullable<AbstractMesh>;
  86637. /** @hidden */
  86638. _boundingInfo: Nullable<BoundingInfo>;
  86639. /** @hidden */
  86640. _renderId: number;
  86641. /**
  86642. * Gets or sets the list of subMeshes
  86643. * @see http://doc.babylonjs.com/how_to/multi_materials
  86644. */
  86645. subMeshes: SubMesh[];
  86646. /** @hidden */
  86647. _intersectionsInProgress: AbstractMesh[];
  86648. /** @hidden */
  86649. _unIndexed: boolean;
  86650. /** @hidden */
  86651. _lightSources: Light[];
  86652. /** Gets the list of lights affecting that mesh */
  86653. readonly lightSources: Light[];
  86654. /** @hidden */
  86655. readonly _positions: Nullable<Vector3[]>;
  86656. /** @hidden */
  86657. _waitingData: {
  86658. lods: Nullable<any>;
  86659. actions: Nullable<any>;
  86660. freezeWorldMatrix: Nullable<boolean>;
  86661. };
  86662. /** @hidden */
  86663. _bonesTransformMatrices: Nullable<Float32Array>;
  86664. /**
  86665. * Gets or sets a skeleton to apply skining transformations
  86666. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  86667. */
  86668. skeleton: Nullable<Skeleton>;
  86669. /**
  86670. * An event triggered when the mesh is rebuilt.
  86671. */
  86672. onRebuildObservable: Observable<AbstractMesh>;
  86673. /**
  86674. * Creates a new AbstractMesh
  86675. * @param name defines the name of the mesh
  86676. * @param scene defines the hosting scene
  86677. */
  86678. constructor(name: string, scene?: Nullable<Scene>);
  86679. /**
  86680. * Returns the string "AbstractMesh"
  86681. * @returns "AbstractMesh"
  86682. */
  86683. getClassName(): string;
  86684. /**
  86685. * Gets a string representation of the current mesh
  86686. * @param fullDetails defines a boolean indicating if full details must be included
  86687. * @returns a string representation of the current mesh
  86688. */
  86689. toString(fullDetails?: boolean): string;
  86690. /**
  86691. * @hidden
  86692. */
  86693. protected _getEffectiveParent(): Nullable<Node>;
  86694. /** @hidden */
  86695. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  86696. /** @hidden */
  86697. _rebuild(): void;
  86698. /** @hidden */
  86699. _resyncLightSources(): void;
  86700. /** @hidden */
  86701. _resyncLighSource(light: Light): void;
  86702. /** @hidden */
  86703. _unBindEffect(): void;
  86704. /** @hidden */
  86705. _removeLightSource(light: Light): void;
  86706. private _markSubMeshesAsDirty;
  86707. /** @hidden */
  86708. _markSubMeshesAsLightDirty(): void;
  86709. /** @hidden */
  86710. _markSubMeshesAsAttributesDirty(): void;
  86711. /** @hidden */
  86712. _markSubMeshesAsMiscDirty(): void;
  86713. /**
  86714. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  86715. */
  86716. scaling: Vector3;
  86717. /**
  86718. * Returns true if the mesh is blocked. Implemented by child classes
  86719. */
  86720. readonly isBlocked: boolean;
  86721. /**
  86722. * Returns the mesh itself by default. Implemented by child classes
  86723. * @param camera defines the camera to use to pick the right LOD level
  86724. * @returns the currentAbstractMesh
  86725. */
  86726. getLOD(camera: Camera): Nullable<AbstractMesh>;
  86727. /**
  86728. * Returns 0 by default. Implemented by child classes
  86729. * @returns an integer
  86730. */
  86731. getTotalVertices(): number;
  86732. /**
  86733. * Returns a positive integer : the total number of indices in this mesh geometry.
  86734. * @returns the numner of indices or zero if the mesh has no geometry.
  86735. */
  86736. getTotalIndices(): number;
  86737. /**
  86738. * Returns null by default. Implemented by child classes
  86739. * @returns null
  86740. */
  86741. getIndices(): Nullable<IndicesArray>;
  86742. /**
  86743. * Returns the array of the requested vertex data kind. Implemented by child classes
  86744. * @param kind defines the vertex data kind to use
  86745. * @returns null
  86746. */
  86747. getVerticesData(kind: string): Nullable<FloatArray>;
  86748. /**
  86749. * Sets the vertex data of the mesh geometry for the requested `kind`.
  86750. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  86751. * Note that a new underlying VertexBuffer object is created each call.
  86752. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  86753. * @param kind defines vertex data kind:
  86754. * * VertexBuffer.PositionKind
  86755. * * VertexBuffer.UVKind
  86756. * * VertexBuffer.UV2Kind
  86757. * * VertexBuffer.UV3Kind
  86758. * * VertexBuffer.UV4Kind
  86759. * * VertexBuffer.UV5Kind
  86760. * * VertexBuffer.UV6Kind
  86761. * * VertexBuffer.ColorKind
  86762. * * VertexBuffer.MatricesIndicesKind
  86763. * * VertexBuffer.MatricesIndicesExtraKind
  86764. * * VertexBuffer.MatricesWeightsKind
  86765. * * VertexBuffer.MatricesWeightsExtraKind
  86766. * @param data defines the data source
  86767. * @param updatable defines if the data must be flagged as updatable (or static)
  86768. * @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
  86769. * @returns the current mesh
  86770. */
  86771. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  86772. /**
  86773. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  86774. * If the mesh has no geometry, it is simply returned as it is.
  86775. * @param kind defines vertex data kind:
  86776. * * VertexBuffer.PositionKind
  86777. * * VertexBuffer.UVKind
  86778. * * VertexBuffer.UV2Kind
  86779. * * VertexBuffer.UV3Kind
  86780. * * VertexBuffer.UV4Kind
  86781. * * VertexBuffer.UV5Kind
  86782. * * VertexBuffer.UV6Kind
  86783. * * VertexBuffer.ColorKind
  86784. * * VertexBuffer.MatricesIndicesKind
  86785. * * VertexBuffer.MatricesIndicesExtraKind
  86786. * * VertexBuffer.MatricesWeightsKind
  86787. * * VertexBuffer.MatricesWeightsExtraKind
  86788. * @param data defines the data source
  86789. * @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
  86790. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  86791. * @returns the current mesh
  86792. */
  86793. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  86794. /**
  86795. * Sets the mesh indices,
  86796. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  86797. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  86798. * @param totalVertices Defines the total number of vertices
  86799. * @returns the current mesh
  86800. */
  86801. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  86802. /**
  86803. * Gets a boolean indicating if specific vertex data is present
  86804. * @param kind defines the vertex data kind to use
  86805. * @returns true is data kind is present
  86806. */
  86807. isVerticesDataPresent(kind: string): boolean;
  86808. /**
  86809. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  86810. * @returns a BoundingInfo
  86811. */
  86812. getBoundingInfo(): BoundingInfo;
  86813. /**
  86814. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  86815. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  86816. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  86817. * @returns the current mesh
  86818. */
  86819. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  86820. /**
  86821. * Overwrite the current bounding info
  86822. * @param boundingInfo defines the new bounding info
  86823. * @returns the current mesh
  86824. */
  86825. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  86826. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  86827. readonly useBones: boolean;
  86828. /** @hidden */
  86829. _preActivate(): void;
  86830. /** @hidden */
  86831. _preActivateForIntermediateRendering(renderId: number): void;
  86832. /** @hidden */
  86833. _activate(renderId: number, intermediateRendering: boolean): boolean;
  86834. /** @hidden */
  86835. _postActivate(): void;
  86836. /** @hidden */
  86837. _freeze(): void;
  86838. /** @hidden */
  86839. _unFreeze(): void;
  86840. /**
  86841. * Gets the current world matrix
  86842. * @returns a Matrix
  86843. */
  86844. getWorldMatrix(): Matrix;
  86845. /** @hidden */
  86846. _getWorldMatrixDeterminant(): number;
  86847. /**
  86848. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  86849. */
  86850. readonly isAnInstance: boolean;
  86851. /**
  86852. * Perform relative position change from the point of view of behind the front of the mesh.
  86853. * This is performed taking into account the meshes current rotation, so you do not have to care.
  86854. * Supports definition of mesh facing forward or backward
  86855. * @param amountRight defines the distance on the right axis
  86856. * @param amountUp defines the distance on the up axis
  86857. * @param amountForward defines the distance on the forward axis
  86858. * @returns the current mesh
  86859. */
  86860. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  86861. /**
  86862. * Calculate relative position change from the point of view of behind the front of the mesh.
  86863. * This is performed taking into account the meshes current rotation, so you do not have to care.
  86864. * Supports definition of mesh facing forward or backward
  86865. * @param amountRight defines the distance on the right axis
  86866. * @param amountUp defines the distance on the up axis
  86867. * @param amountForward defines the distance on the forward axis
  86868. * @returns the new displacement vector
  86869. */
  86870. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  86871. /**
  86872. * Perform relative rotation change from the point of view of behind the front of the mesh.
  86873. * Supports definition of mesh facing forward or backward
  86874. * @param flipBack defines the flip
  86875. * @param twirlClockwise defines the twirl
  86876. * @param tiltRight defines the tilt
  86877. * @returns the current mesh
  86878. */
  86879. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  86880. /**
  86881. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  86882. * Supports definition of mesh facing forward or backward.
  86883. * @param flipBack defines the flip
  86884. * @param twirlClockwise defines the twirl
  86885. * @param tiltRight defines the tilt
  86886. * @returns the new rotation vector
  86887. */
  86888. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  86889. /**
  86890. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  86891. * This means the mesh underlying bounding box and sphere are recomputed.
  86892. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  86893. * @returns the current mesh
  86894. */
  86895. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  86896. /** @hidden */
  86897. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  86898. /** @hidden */
  86899. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  86900. /** @hidden */
  86901. _updateBoundingInfo(): AbstractMesh;
  86902. /** @hidden */
  86903. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  86904. /** @hidden */
  86905. protected _afterComputeWorldMatrix(): void;
  86906. /** @hidden */
  86907. readonly _effectiveMesh: AbstractMesh;
  86908. /**
  86909. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  86910. * A mesh is in the frustum if its bounding box intersects the frustum
  86911. * @param frustumPlanes defines the frustum to test
  86912. * @returns true if the mesh is in the frustum planes
  86913. */
  86914. isInFrustum(frustumPlanes: Plane[]): boolean;
  86915. /**
  86916. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  86917. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  86918. * @param frustumPlanes defines the frustum to test
  86919. * @returns true if the mesh is completely in the frustum planes
  86920. */
  86921. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  86922. /**
  86923. * True if the mesh intersects another mesh or a SolidParticle object
  86924. * @param mesh defines a target mesh or SolidParticle to test
  86925. * @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)
  86926. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  86927. * @returns true if there is an intersection
  86928. */
  86929. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  86930. /**
  86931. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  86932. * @param point defines the point to test
  86933. * @returns true if there is an intersection
  86934. */
  86935. intersectsPoint(point: Vector3): boolean;
  86936. /**
  86937. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  86938. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86939. */
  86940. checkCollisions: boolean;
  86941. /**
  86942. * Gets Collider object used to compute collisions (not physics)
  86943. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86944. */
  86945. readonly collider: Nullable<Collider>;
  86946. /**
  86947. * Move the mesh using collision engine
  86948. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  86949. * @param displacement defines the requested displacement vector
  86950. * @returns the current mesh
  86951. */
  86952. moveWithCollisions(displacement: Vector3): AbstractMesh;
  86953. private _onCollisionPositionChange;
  86954. /** @hidden */
  86955. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  86956. /** @hidden */
  86957. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  86958. /** @hidden */
  86959. _checkCollision(collider: Collider): AbstractMesh;
  86960. /** @hidden */
  86961. _generatePointsArray(): boolean;
  86962. /**
  86963. * Checks if the passed Ray intersects with the mesh
  86964. * @param ray defines the ray to use
  86965. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  86966. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  86967. * @returns the picking info
  86968. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  86969. */
  86970. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  86971. /**
  86972. * Clones the current mesh
  86973. * @param name defines the mesh name
  86974. * @param newParent defines the new mesh parent
  86975. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  86976. * @returns the new mesh
  86977. */
  86978. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86979. /**
  86980. * Disposes all the submeshes of the current meshnp
  86981. * @returns the current mesh
  86982. */
  86983. releaseSubMeshes(): AbstractMesh;
  86984. /**
  86985. * Releases resources associated with this abstract mesh.
  86986. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  86987. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  86988. */
  86989. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  86990. /**
  86991. * Adds the passed mesh as a child to the current mesh
  86992. * @param mesh defines the child mesh
  86993. * @returns the current mesh
  86994. */
  86995. addChild(mesh: AbstractMesh): AbstractMesh;
  86996. /**
  86997. * Removes the passed mesh from the current mesh children list
  86998. * @param mesh defines the child mesh
  86999. * @returns the current mesh
  87000. */
  87001. removeChild(mesh: AbstractMesh): AbstractMesh;
  87002. /** @hidden */
  87003. private _initFacetData;
  87004. /**
  87005. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  87006. * This method can be called within the render loop.
  87007. * 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
  87008. * @returns the current mesh
  87009. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87010. */
  87011. updateFacetData(): AbstractMesh;
  87012. /**
  87013. * Returns the facetLocalNormals array.
  87014. * The normals are expressed in the mesh local spac
  87015. * @returns an array of Vector3
  87016. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87017. */
  87018. getFacetLocalNormals(): Vector3[];
  87019. /**
  87020. * Returns the facetLocalPositions array.
  87021. * The facet positions are expressed in the mesh local space
  87022. * @returns an array of Vector3
  87023. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87024. */
  87025. getFacetLocalPositions(): Vector3[];
  87026. /**
  87027. * Returns the facetLocalPartioning array
  87028. * @returns an array of array of numbers
  87029. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87030. */
  87031. getFacetLocalPartitioning(): number[][];
  87032. /**
  87033. * Returns the i-th facet position in the world system.
  87034. * This method allocates a new Vector3 per call
  87035. * @param i defines the facet index
  87036. * @returns a new Vector3
  87037. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87038. */
  87039. getFacetPosition(i: number): Vector3;
  87040. /**
  87041. * Sets the reference Vector3 with the i-th facet position in the world system
  87042. * @param i defines the facet index
  87043. * @param ref defines the target vector
  87044. * @returns the current mesh
  87045. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87046. */
  87047. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  87048. /**
  87049. * Returns the i-th facet normal in the world system.
  87050. * This method allocates a new Vector3 per call
  87051. * @param i defines the facet index
  87052. * @returns a new Vector3
  87053. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87054. */
  87055. getFacetNormal(i: number): Vector3;
  87056. /**
  87057. * Sets the reference Vector3 with the i-th facet normal in the world system
  87058. * @param i defines the facet index
  87059. * @param ref defines the target vector
  87060. * @returns the current mesh
  87061. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87062. */
  87063. getFacetNormalToRef(i: number, ref: Vector3): this;
  87064. /**
  87065. * 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)
  87066. * @param x defines x coordinate
  87067. * @param y defines y coordinate
  87068. * @param z defines z coordinate
  87069. * @returns the array of facet indexes
  87070. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87071. */
  87072. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  87073. /**
  87074. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  87075. * @param projected sets as the (x,y,z) world projection on the facet
  87076. * @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
  87077. * @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
  87078. * @param x defines x coordinate
  87079. * @param y defines y coordinate
  87080. * @param z defines z coordinate
  87081. * @returns the face index if found (or null instead)
  87082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87083. */
  87084. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87085. /**
  87086. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  87087. * @param projected sets as the (x,y,z) local projection on the facet
  87088. * @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
  87089. * @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
  87090. * @param x defines x coordinate
  87091. * @param y defines y coordinate
  87092. * @param z defines z coordinate
  87093. * @returns the face index if found (or null instead)
  87094. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87095. */
  87096. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  87097. /**
  87098. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  87099. * @returns the parameters
  87100. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87101. */
  87102. getFacetDataParameters(): any;
  87103. /**
  87104. * Disables the feature FacetData and frees the related memory
  87105. * @returns the current mesh
  87106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  87107. */
  87108. disableFacetData(): AbstractMesh;
  87109. /**
  87110. * Updates the AbstractMesh indices array
  87111. * @param indices defines the data source
  87112. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  87113. * @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)
  87114. * @returns the current mesh
  87115. */
  87116. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  87117. /**
  87118. * Creates new normals data for the mesh
  87119. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  87120. * @returns the current mesh
  87121. */
  87122. createNormals(updatable: boolean): AbstractMesh;
  87123. /**
  87124. * Align the mesh with a normal
  87125. * @param normal defines the normal to use
  87126. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  87127. * @returns the current mesh
  87128. */
  87129. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  87130. /** @hidden */
  87131. _checkOcclusionQuery(): boolean;
  87132. /**
  87133. * Disables the mesh edge rendering mode
  87134. * @returns the currentAbstractMesh
  87135. */
  87136. disableEdgesRendering(): AbstractMesh;
  87137. /**
  87138. * Enables the edge rendering mode on the mesh.
  87139. * This mode makes the mesh edges visible
  87140. * @param epsilon defines the maximal distance between two angles to detect a face
  87141. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  87142. * @returns the currentAbstractMesh
  87143. * @see https://www.babylonjs-playground.com/#19O9TU#0
  87144. */
  87145. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  87146. }
  87147. }
  87148. declare module BABYLON {
  87149. /**
  87150. * Interface used to define ActionEvent
  87151. */
  87152. export interface IActionEvent {
  87153. /** The mesh or sprite that triggered the action */
  87154. source: any;
  87155. /** The X mouse cursor position at the time of the event */
  87156. pointerX: number;
  87157. /** The Y mouse cursor position at the time of the event */
  87158. pointerY: number;
  87159. /** The mesh that is currently pointed at (can be null) */
  87160. meshUnderPointer: Nullable<AbstractMesh>;
  87161. /** the original (browser) event that triggered the ActionEvent */
  87162. sourceEvent?: any;
  87163. /** additional data for the event */
  87164. additionalData?: any;
  87165. }
  87166. /**
  87167. * ActionEvent is the event being sent when an action is triggered.
  87168. */
  87169. export class ActionEvent implements IActionEvent {
  87170. /** The mesh or sprite that triggered the action */
  87171. source: any;
  87172. /** The X mouse cursor position at the time of the event */
  87173. pointerX: number;
  87174. /** The Y mouse cursor position at the time of the event */
  87175. pointerY: number;
  87176. /** The mesh that is currently pointed at (can be null) */
  87177. meshUnderPointer: Nullable<AbstractMesh>;
  87178. /** the original (browser) event that triggered the ActionEvent */
  87179. sourceEvent?: any;
  87180. /** additional data for the event */
  87181. additionalData?: any;
  87182. /**
  87183. * Creates a new ActionEvent
  87184. * @param source The mesh or sprite that triggered the action
  87185. * @param pointerX The X mouse cursor position at the time of the event
  87186. * @param pointerY The Y mouse cursor position at the time of the event
  87187. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  87188. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  87189. * @param additionalData additional data for the event
  87190. */
  87191. constructor(
  87192. /** The mesh or sprite that triggered the action */
  87193. source: any,
  87194. /** The X mouse cursor position at the time of the event */
  87195. pointerX: number,
  87196. /** The Y mouse cursor position at the time of the event */
  87197. pointerY: number,
  87198. /** The mesh that is currently pointed at (can be null) */
  87199. meshUnderPointer: Nullable<AbstractMesh>,
  87200. /** the original (browser) event that triggered the ActionEvent */
  87201. sourceEvent?: any,
  87202. /** additional data for the event */
  87203. additionalData?: any);
  87204. /**
  87205. * Helper function to auto-create an ActionEvent from a source mesh.
  87206. * @param source The source mesh that triggered the event
  87207. * @param evt The original (browser) event
  87208. * @param additionalData additional data for the event
  87209. * @returns the new ActionEvent
  87210. */
  87211. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  87212. /**
  87213. * Helper function to auto-create an ActionEvent from a source sprite
  87214. * @param source The source sprite that triggered the event
  87215. * @param scene Scene associated with the sprite
  87216. * @param evt The original (browser) event
  87217. * @param additionalData additional data for the event
  87218. * @returns the new ActionEvent
  87219. */
  87220. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  87221. /**
  87222. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  87223. * @param scene the scene where the event occurred
  87224. * @param evt The original (browser) event
  87225. * @returns the new ActionEvent
  87226. */
  87227. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  87228. /**
  87229. * Helper function to auto-create an ActionEvent from a primitive
  87230. * @param prim defines the target primitive
  87231. * @param pointerPos defines the pointer position
  87232. * @param evt The original (browser) event
  87233. * @param additionalData additional data for the event
  87234. * @returns the new ActionEvent
  87235. */
  87236. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  87237. }
  87238. }
  87239. declare module BABYLON {
  87240. /**
  87241. * Abstract class used to decouple action Manager from scene and meshes.
  87242. * Do not instantiate.
  87243. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  87244. */
  87245. export abstract class AbstractActionManager implements IDisposable {
  87246. /** Gets the list of active triggers */
  87247. static Triggers: {
  87248. [key: string]: number;
  87249. };
  87250. /** Gets the cursor to use when hovering items */
  87251. hoverCursor: string;
  87252. /** Gets the list of actions */
  87253. actions: IAction[];
  87254. /**
  87255. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  87256. */
  87257. isRecursive: boolean;
  87258. /**
  87259. * Releases all associated resources
  87260. */
  87261. abstract dispose(): void;
  87262. /**
  87263. * Does this action manager has pointer triggers
  87264. */
  87265. abstract readonly hasPointerTriggers: boolean;
  87266. /**
  87267. * Does this action manager has pick triggers
  87268. */
  87269. abstract readonly hasPickTriggers: boolean;
  87270. /**
  87271. * Process a specific trigger
  87272. * @param trigger defines the trigger to process
  87273. * @param evt defines the event details to be processed
  87274. */
  87275. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  87276. /**
  87277. * Does this action manager handles actions of any of the given triggers
  87278. * @param triggers defines the triggers to be tested
  87279. * @return a boolean indicating whether one (or more) of the triggers is handled
  87280. */
  87281. abstract hasSpecificTriggers(triggers: number[]): boolean;
  87282. /**
  87283. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  87284. * speed.
  87285. * @param triggerA defines the trigger to be tested
  87286. * @param triggerB defines the trigger to be tested
  87287. * @return a boolean indicating whether one (or more) of the triggers is handled
  87288. */
  87289. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  87290. /**
  87291. * Does this action manager handles actions of a given trigger
  87292. * @param trigger defines the trigger to be tested
  87293. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  87294. * @return whether the trigger is handled
  87295. */
  87296. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  87297. /**
  87298. * Serialize this manager to a JSON object
  87299. * @param name defines the property name to store this manager
  87300. * @returns a JSON representation of this manager
  87301. */
  87302. abstract serialize(name: string): any;
  87303. /**
  87304. * Registers an action to this action manager
  87305. * @param action defines the action to be registered
  87306. * @return the action amended (prepared) after registration
  87307. */
  87308. abstract registerAction(action: IAction): Nullable<IAction>;
  87309. /**
  87310. * Unregisters an action to this action manager
  87311. * @param action defines the action to be unregistered
  87312. * @return a boolean indicating whether the action has been unregistered
  87313. */
  87314. abstract unregisterAction(action: IAction): Boolean;
  87315. /**
  87316. * Does exist one action manager with at least one trigger
  87317. **/
  87318. static readonly HasTriggers: boolean;
  87319. /**
  87320. * Does exist one action manager with at least one pick trigger
  87321. **/
  87322. static readonly HasPickTriggers: boolean;
  87323. /**
  87324. * Does exist one action manager that handles actions of a given trigger
  87325. * @param trigger defines the trigger to be tested
  87326. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  87327. **/
  87328. static HasSpecificTrigger(trigger: number): boolean;
  87329. }
  87330. }
  87331. declare module BABYLON {
  87332. /**
  87333. * Defines how a node can be built from a string name.
  87334. */
  87335. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  87336. /**
  87337. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  87338. */
  87339. export class Node implements IBehaviorAware<Node> {
  87340. /** @hidden */
  87341. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  87342. private static _NodeConstructors;
  87343. /**
  87344. * Add a new node constructor
  87345. * @param type defines the type name of the node to construct
  87346. * @param constructorFunc defines the constructor function
  87347. */
  87348. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  87349. /**
  87350. * Returns a node constructor based on type name
  87351. * @param type defines the type name
  87352. * @param name defines the new node name
  87353. * @param scene defines the hosting scene
  87354. * @param options defines optional options to transmit to constructors
  87355. * @returns the new constructor or null
  87356. */
  87357. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  87358. /**
  87359. * Gets or sets the name of the node
  87360. */
  87361. name: string;
  87362. /**
  87363. * Gets or sets the id of the node
  87364. */
  87365. id: string;
  87366. /**
  87367. * Gets or sets the unique id of the node
  87368. */
  87369. uniqueId: number;
  87370. /**
  87371. * Gets or sets a string used to store user defined state for the node
  87372. */
  87373. state: string;
  87374. /**
  87375. * Gets or sets an object used to store user defined information for the node
  87376. */
  87377. metadata: any;
  87378. /**
  87379. * For internal use only. Please do not use.
  87380. */
  87381. reservedDataStore: any;
  87382. /**
  87383. * List of inspectable custom properties (used by the Inspector)
  87384. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87385. */
  87386. inspectableCustomProperties: IInspectable[];
  87387. /**
  87388. * Gets or sets a boolean used to define if the node must be serialized
  87389. */
  87390. doNotSerialize: boolean;
  87391. /** @hidden */
  87392. _isDisposed: boolean;
  87393. /**
  87394. * Gets a list of Animations associated with the node
  87395. */
  87396. animations: Animation[];
  87397. protected _ranges: {
  87398. [name: string]: Nullable<AnimationRange>;
  87399. };
  87400. /**
  87401. * Callback raised when the node is ready to be used
  87402. */
  87403. onReady: Nullable<(node: Node) => void>;
  87404. private _isEnabled;
  87405. private _isParentEnabled;
  87406. private _isReady;
  87407. /** @hidden */
  87408. _currentRenderId: number;
  87409. private _parentUpdateId;
  87410. /** @hidden */
  87411. _childUpdateId: number;
  87412. /** @hidden */
  87413. _waitingParentId: Nullable<string>;
  87414. /** @hidden */
  87415. _scene: Scene;
  87416. /** @hidden */
  87417. _cache: any;
  87418. private _parentNode;
  87419. private _children;
  87420. /** @hidden */
  87421. _worldMatrix: Matrix;
  87422. /** @hidden */
  87423. _worldMatrixDeterminant: number;
  87424. /** @hidden */
  87425. _worldMatrixDeterminantIsDirty: boolean;
  87426. /** @hidden */
  87427. private _sceneRootNodesIndex;
  87428. /**
  87429. * Gets a boolean indicating if the node has been disposed
  87430. * @returns true if the node was disposed
  87431. */
  87432. isDisposed(): boolean;
  87433. /**
  87434. * Gets or sets the parent of the node (without keeping the current position in the scene)
  87435. * @see https://doc.babylonjs.com/how_to/parenting
  87436. */
  87437. parent: Nullable<Node>;
  87438. private addToSceneRootNodes;
  87439. private removeFromSceneRootNodes;
  87440. private _animationPropertiesOverride;
  87441. /**
  87442. * Gets or sets the animation properties override
  87443. */
  87444. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  87445. /**
  87446. * Gets a string idenfifying the name of the class
  87447. * @returns "Node" string
  87448. */
  87449. getClassName(): string;
  87450. /** @hidden */
  87451. readonly _isNode: boolean;
  87452. /**
  87453. * An event triggered when the mesh is disposed
  87454. */
  87455. onDisposeObservable: Observable<Node>;
  87456. private _onDisposeObserver;
  87457. /**
  87458. * Sets a callback that will be raised when the node will be disposed
  87459. */
  87460. onDispose: () => void;
  87461. /**
  87462. * Creates a new Node
  87463. * @param name the name and id to be given to this node
  87464. * @param scene the scene this node will be added to
  87465. * @param addToRootNodes the node will be added to scene.rootNodes
  87466. */
  87467. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  87468. /**
  87469. * Gets the scene of the node
  87470. * @returns a scene
  87471. */
  87472. getScene(): Scene;
  87473. /**
  87474. * Gets the engine of the node
  87475. * @returns a Engine
  87476. */
  87477. getEngine(): Engine;
  87478. private _behaviors;
  87479. /**
  87480. * Attach a behavior to the node
  87481. * @see http://doc.babylonjs.com/features/behaviour
  87482. * @param behavior defines the behavior to attach
  87483. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  87484. * @returns the current Node
  87485. */
  87486. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  87487. /**
  87488. * Remove an attached behavior
  87489. * @see http://doc.babylonjs.com/features/behaviour
  87490. * @param behavior defines the behavior to attach
  87491. * @returns the current Node
  87492. */
  87493. removeBehavior(behavior: Behavior<Node>): Node;
  87494. /**
  87495. * Gets the list of attached behaviors
  87496. * @see http://doc.babylonjs.com/features/behaviour
  87497. */
  87498. readonly behaviors: Behavior<Node>[];
  87499. /**
  87500. * Gets an attached behavior by name
  87501. * @param name defines the name of the behavior to look for
  87502. * @see http://doc.babylonjs.com/features/behaviour
  87503. * @returns null if behavior was not found else the requested behavior
  87504. */
  87505. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  87506. /**
  87507. * Returns the latest update of the World matrix
  87508. * @returns a Matrix
  87509. */
  87510. getWorldMatrix(): Matrix;
  87511. /** @hidden */
  87512. _getWorldMatrixDeterminant(): number;
  87513. /**
  87514. * Returns directly the latest state of the mesh World matrix.
  87515. * A Matrix is returned.
  87516. */
  87517. readonly worldMatrixFromCache: Matrix;
  87518. /** @hidden */
  87519. _initCache(): void;
  87520. /** @hidden */
  87521. updateCache(force?: boolean): void;
  87522. /** @hidden */
  87523. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  87524. /** @hidden */
  87525. _updateCache(ignoreParentClass?: boolean): void;
  87526. /** @hidden */
  87527. _isSynchronized(): boolean;
  87528. /** @hidden */
  87529. _markSyncedWithParent(): void;
  87530. /** @hidden */
  87531. isSynchronizedWithParent(): boolean;
  87532. /** @hidden */
  87533. isSynchronized(): boolean;
  87534. /**
  87535. * Is this node ready to be used/rendered
  87536. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  87537. * @return true if the node is ready
  87538. */
  87539. isReady(completeCheck?: boolean): boolean;
  87540. /**
  87541. * Is this node enabled?
  87542. * 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
  87543. * @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
  87544. * @return whether this node (and its parent) is enabled
  87545. */
  87546. isEnabled(checkAncestors?: boolean): boolean;
  87547. /** @hidden */
  87548. protected _syncParentEnabledState(): void;
  87549. /**
  87550. * Set the enabled state of this node
  87551. * @param value defines the new enabled state
  87552. */
  87553. setEnabled(value: boolean): void;
  87554. /**
  87555. * Is this node a descendant of the given node?
  87556. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  87557. * @param ancestor defines the parent node to inspect
  87558. * @returns a boolean indicating if this node is a descendant of the given node
  87559. */
  87560. isDescendantOf(ancestor: Node): boolean;
  87561. /** @hidden */
  87562. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  87563. /**
  87564. * Will return all nodes that have this node as ascendant
  87565. * @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
  87566. * @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
  87567. * @return all children nodes of all types
  87568. */
  87569. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  87570. /**
  87571. * Get all child-meshes of this node
  87572. * @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)
  87573. * @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
  87574. * @returns an array of AbstractMesh
  87575. */
  87576. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  87577. /**
  87578. * Get all direct children of this node
  87579. * @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
  87580. * @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)
  87581. * @returns an array of Node
  87582. */
  87583. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  87584. /** @hidden */
  87585. _setReady(state: boolean): void;
  87586. /**
  87587. * Get an animation by name
  87588. * @param name defines the name of the animation to look for
  87589. * @returns null if not found else the requested animation
  87590. */
  87591. getAnimationByName(name: string): Nullable<Animation>;
  87592. /**
  87593. * Creates an animation range for this node
  87594. * @param name defines the name of the range
  87595. * @param from defines the starting key
  87596. * @param to defines the end key
  87597. */
  87598. createAnimationRange(name: string, from: number, to: number): void;
  87599. /**
  87600. * Delete a specific animation range
  87601. * @param name defines the name of the range to delete
  87602. * @param deleteFrames defines if animation frames from the range must be deleted as well
  87603. */
  87604. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  87605. /**
  87606. * Get an animation range by name
  87607. * @param name defines the name of the animation range to look for
  87608. * @returns null if not found else the requested animation range
  87609. */
  87610. getAnimationRange(name: string): Nullable<AnimationRange>;
  87611. /**
  87612. * Gets the list of all animation ranges defined on this node
  87613. * @returns an array
  87614. */
  87615. getAnimationRanges(): Nullable<AnimationRange>[];
  87616. /**
  87617. * Will start the animation sequence
  87618. * @param name defines the range frames for animation sequence
  87619. * @param loop defines if the animation should loop (false by default)
  87620. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  87621. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  87622. * @returns the object created for this animation. If range does not exist, it will return null
  87623. */
  87624. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  87625. /**
  87626. * Serialize animation ranges into a JSON compatible object
  87627. * @returns serialization object
  87628. */
  87629. serializeAnimationRanges(): any;
  87630. /**
  87631. * Computes the world matrix of the node
  87632. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  87633. * @returns the world matrix
  87634. */
  87635. computeWorldMatrix(force?: boolean): Matrix;
  87636. /**
  87637. * Releases resources associated with this node.
  87638. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  87639. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  87640. */
  87641. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  87642. /**
  87643. * Parse animation range data from a serialization object and store them into a given node
  87644. * @param node defines where to store the animation ranges
  87645. * @param parsedNode defines the serialization object to read data from
  87646. * @param scene defines the hosting scene
  87647. */
  87648. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  87649. /**
  87650. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  87651. * @param includeDescendants Include bounding info from descendants as well (true by default)
  87652. * @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
  87653. * @returns the new bounding vectors
  87654. */
  87655. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  87656. min: Vector3;
  87657. max: Vector3;
  87658. };
  87659. }
  87660. }
  87661. declare module BABYLON {
  87662. /**
  87663. * @hidden
  87664. */
  87665. export class _IAnimationState {
  87666. key: number;
  87667. repeatCount: number;
  87668. workValue?: any;
  87669. loopMode?: number;
  87670. offsetValue?: any;
  87671. highLimitValue?: any;
  87672. }
  87673. /**
  87674. * Class used to store any kind of animation
  87675. */
  87676. export class Animation {
  87677. /**Name of the animation */
  87678. name: string;
  87679. /**Property to animate */
  87680. targetProperty: string;
  87681. /**The frames per second of the animation */
  87682. framePerSecond: number;
  87683. /**The data type of the animation */
  87684. dataType: number;
  87685. /**The loop mode of the animation */
  87686. loopMode?: number | undefined;
  87687. /**Specifies if blending should be enabled */
  87688. enableBlending?: boolean | undefined;
  87689. /**
  87690. * Use matrix interpolation instead of using direct key value when animating matrices
  87691. */
  87692. static AllowMatricesInterpolation: boolean;
  87693. /**
  87694. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  87695. */
  87696. static AllowMatrixDecomposeForInterpolation: boolean;
  87697. /**
  87698. * Stores the key frames of the animation
  87699. */
  87700. private _keys;
  87701. /**
  87702. * Stores the easing function of the animation
  87703. */
  87704. private _easingFunction;
  87705. /**
  87706. * @hidden Internal use only
  87707. */
  87708. _runtimeAnimations: RuntimeAnimation[];
  87709. /**
  87710. * The set of event that will be linked to this animation
  87711. */
  87712. private _events;
  87713. /**
  87714. * Stores an array of target property paths
  87715. */
  87716. targetPropertyPath: string[];
  87717. /**
  87718. * Stores the blending speed of the animation
  87719. */
  87720. blendingSpeed: number;
  87721. /**
  87722. * Stores the animation ranges for the animation
  87723. */
  87724. private _ranges;
  87725. /**
  87726. * @hidden Internal use
  87727. */
  87728. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  87729. /**
  87730. * Sets up an animation
  87731. * @param property The property to animate
  87732. * @param animationType The animation type to apply
  87733. * @param framePerSecond The frames per second of the animation
  87734. * @param easingFunction The easing function used in the animation
  87735. * @returns The created animation
  87736. */
  87737. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  87738. /**
  87739. * Create and start an animation on a node
  87740. * @param name defines the name of the global animation that will be run on all nodes
  87741. * @param node defines the root node where the animation will take place
  87742. * @param targetProperty defines property to animate
  87743. * @param framePerSecond defines the number of frame per second yo use
  87744. * @param totalFrame defines the number of frames in total
  87745. * @param from defines the initial value
  87746. * @param to defines the final value
  87747. * @param loopMode defines which loop mode you want to use (off by default)
  87748. * @param easingFunction defines the easing function to use (linear by default)
  87749. * @param onAnimationEnd defines the callback to call when animation end
  87750. * @returns the animatable created for this animation
  87751. */
  87752. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  87753. /**
  87754. * Create and start an animation on a node and its descendants
  87755. * @param name defines the name of the global animation that will be run on all nodes
  87756. * @param node defines the root node where the animation will take place
  87757. * @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
  87758. * @param targetProperty defines property to animate
  87759. * @param framePerSecond defines the number of frame per second to use
  87760. * @param totalFrame defines the number of frames in total
  87761. * @param from defines the initial value
  87762. * @param to defines the final value
  87763. * @param loopMode defines which loop mode you want to use (off by default)
  87764. * @param easingFunction defines the easing function to use (linear by default)
  87765. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  87766. * @returns the list of animatables created for all nodes
  87767. * @example https://www.babylonjs-playground.com/#MH0VLI
  87768. */
  87769. 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[]>;
  87770. /**
  87771. * Creates a new animation, merges it with the existing animations and starts it
  87772. * @param name Name of the animation
  87773. * @param node Node which contains the scene that begins the animations
  87774. * @param targetProperty Specifies which property to animate
  87775. * @param framePerSecond The frames per second of the animation
  87776. * @param totalFrame The total number of frames
  87777. * @param from The frame at the beginning of the animation
  87778. * @param to The frame at the end of the animation
  87779. * @param loopMode Specifies the loop mode of the animation
  87780. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  87781. * @param onAnimationEnd Callback to run once the animation is complete
  87782. * @returns Nullable animation
  87783. */
  87784. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  87785. /**
  87786. * Transition property of an host to the target Value
  87787. * @param property The property to transition
  87788. * @param targetValue The target Value of the property
  87789. * @param host The object where the property to animate belongs
  87790. * @param scene Scene used to run the animation
  87791. * @param frameRate Framerate (in frame/s) to use
  87792. * @param transition The transition type we want to use
  87793. * @param duration The duration of the animation, in milliseconds
  87794. * @param onAnimationEnd Callback trigger at the end of the animation
  87795. * @returns Nullable animation
  87796. */
  87797. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  87798. /**
  87799. * Return the array of runtime animations currently using this animation
  87800. */
  87801. readonly runtimeAnimations: RuntimeAnimation[];
  87802. /**
  87803. * Specifies if any of the runtime animations are currently running
  87804. */
  87805. readonly hasRunningRuntimeAnimations: boolean;
  87806. /**
  87807. * Initializes the animation
  87808. * @param name Name of the animation
  87809. * @param targetProperty Property to animate
  87810. * @param framePerSecond The frames per second of the animation
  87811. * @param dataType The data type of the animation
  87812. * @param loopMode The loop mode of the animation
  87813. * @param enableBlending Specifies if blending should be enabled
  87814. */
  87815. constructor(
  87816. /**Name of the animation */
  87817. name: string,
  87818. /**Property to animate */
  87819. targetProperty: string,
  87820. /**The frames per second of the animation */
  87821. framePerSecond: number,
  87822. /**The data type of the animation */
  87823. dataType: number,
  87824. /**The loop mode of the animation */
  87825. loopMode?: number | undefined,
  87826. /**Specifies if blending should be enabled */
  87827. enableBlending?: boolean | undefined);
  87828. /**
  87829. * Converts the animation to a string
  87830. * @param fullDetails support for multiple levels of logging within scene loading
  87831. * @returns String form of the animation
  87832. */
  87833. toString(fullDetails?: boolean): string;
  87834. /**
  87835. * Add an event to this animation
  87836. * @param event Event to add
  87837. */
  87838. addEvent(event: AnimationEvent): void;
  87839. /**
  87840. * Remove all events found at the given frame
  87841. * @param frame The frame to remove events from
  87842. */
  87843. removeEvents(frame: number): void;
  87844. /**
  87845. * Retrieves all the events from the animation
  87846. * @returns Events from the animation
  87847. */
  87848. getEvents(): AnimationEvent[];
  87849. /**
  87850. * Creates an animation range
  87851. * @param name Name of the animation range
  87852. * @param from Starting frame of the animation range
  87853. * @param to Ending frame of the animation
  87854. */
  87855. createRange(name: string, from: number, to: number): void;
  87856. /**
  87857. * Deletes an animation range by name
  87858. * @param name Name of the animation range to delete
  87859. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  87860. */
  87861. deleteRange(name: string, deleteFrames?: boolean): void;
  87862. /**
  87863. * Gets the animation range by name, or null if not defined
  87864. * @param name Name of the animation range
  87865. * @returns Nullable animation range
  87866. */
  87867. getRange(name: string): Nullable<AnimationRange>;
  87868. /**
  87869. * Gets the key frames from the animation
  87870. * @returns The key frames of the animation
  87871. */
  87872. getKeys(): Array<IAnimationKey>;
  87873. /**
  87874. * Gets the highest frame rate of the animation
  87875. * @returns Highest frame rate of the animation
  87876. */
  87877. getHighestFrame(): number;
  87878. /**
  87879. * Gets the easing function of the animation
  87880. * @returns Easing function of the animation
  87881. */
  87882. getEasingFunction(): IEasingFunction;
  87883. /**
  87884. * Sets the easing function of the animation
  87885. * @param easingFunction A custom mathematical formula for animation
  87886. */
  87887. setEasingFunction(easingFunction: EasingFunction): void;
  87888. /**
  87889. * Interpolates a scalar linearly
  87890. * @param startValue Start value of the animation curve
  87891. * @param endValue End value of the animation curve
  87892. * @param gradient Scalar amount to interpolate
  87893. * @returns Interpolated scalar value
  87894. */
  87895. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  87896. /**
  87897. * Interpolates a scalar cubically
  87898. * @param startValue Start value of the animation curve
  87899. * @param outTangent End tangent of the animation
  87900. * @param endValue End value of the animation curve
  87901. * @param inTangent Start tangent of the animation curve
  87902. * @param gradient Scalar amount to interpolate
  87903. * @returns Interpolated scalar value
  87904. */
  87905. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  87906. /**
  87907. * Interpolates a quaternion using a spherical linear interpolation
  87908. * @param startValue Start value of the animation curve
  87909. * @param endValue End value of the animation curve
  87910. * @param gradient Scalar amount to interpolate
  87911. * @returns Interpolated quaternion value
  87912. */
  87913. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  87914. /**
  87915. * Interpolates a quaternion cubically
  87916. * @param startValue Start value of the animation curve
  87917. * @param outTangent End tangent of the animation curve
  87918. * @param endValue End value of the animation curve
  87919. * @param inTangent Start tangent of the animation curve
  87920. * @param gradient Scalar amount to interpolate
  87921. * @returns Interpolated quaternion value
  87922. */
  87923. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  87924. /**
  87925. * Interpolates a Vector3 linearl
  87926. * @param startValue Start value of the animation curve
  87927. * @param endValue End value of the animation curve
  87928. * @param gradient Scalar amount to interpolate
  87929. * @returns Interpolated scalar value
  87930. */
  87931. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  87932. /**
  87933. * Interpolates a Vector3 cubically
  87934. * @param startValue Start value of the animation curve
  87935. * @param outTangent End tangent of the animation
  87936. * @param endValue End value of the animation curve
  87937. * @param inTangent Start tangent of the animation curve
  87938. * @param gradient Scalar amount to interpolate
  87939. * @returns InterpolatedVector3 value
  87940. */
  87941. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  87942. /**
  87943. * Interpolates a Vector2 linearly
  87944. * @param startValue Start value of the animation curve
  87945. * @param endValue End value of the animation curve
  87946. * @param gradient Scalar amount to interpolate
  87947. * @returns Interpolated Vector2 value
  87948. */
  87949. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  87950. /**
  87951. * Interpolates a Vector2 cubically
  87952. * @param startValue Start value of the animation curve
  87953. * @param outTangent End tangent of the animation
  87954. * @param endValue End value of the animation curve
  87955. * @param inTangent Start tangent of the animation curve
  87956. * @param gradient Scalar amount to interpolate
  87957. * @returns Interpolated Vector2 value
  87958. */
  87959. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  87960. /**
  87961. * Interpolates a size linearly
  87962. * @param startValue Start value of the animation curve
  87963. * @param endValue End value of the animation curve
  87964. * @param gradient Scalar amount to interpolate
  87965. * @returns Interpolated Size value
  87966. */
  87967. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  87968. /**
  87969. * Interpolates a Color3 linearly
  87970. * @param startValue Start value of the animation curve
  87971. * @param endValue End value of the animation curve
  87972. * @param gradient Scalar amount to interpolate
  87973. * @returns Interpolated Color3 value
  87974. */
  87975. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  87976. /**
  87977. * @hidden Internal use only
  87978. */
  87979. _getKeyValue(value: any): any;
  87980. /**
  87981. * @hidden Internal use only
  87982. */
  87983. _interpolate(currentFrame: number, state: _IAnimationState): any;
  87984. /**
  87985. * Defines the function to use to interpolate matrices
  87986. * @param startValue defines the start matrix
  87987. * @param endValue defines the end matrix
  87988. * @param gradient defines the gradient between both matrices
  87989. * @param result defines an optional target matrix where to store the interpolation
  87990. * @returns the interpolated matrix
  87991. */
  87992. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  87993. /**
  87994. * Makes a copy of the animation
  87995. * @returns Cloned animation
  87996. */
  87997. clone(): Animation;
  87998. /**
  87999. * Sets the key frames of the animation
  88000. * @param values The animation key frames to set
  88001. */
  88002. setKeys(values: Array<IAnimationKey>): void;
  88003. /**
  88004. * Serializes the animation to an object
  88005. * @returns Serialized object
  88006. */
  88007. serialize(): any;
  88008. /**
  88009. * Float animation type
  88010. */
  88011. private static _ANIMATIONTYPE_FLOAT;
  88012. /**
  88013. * Vector3 animation type
  88014. */
  88015. private static _ANIMATIONTYPE_VECTOR3;
  88016. /**
  88017. * Quaternion animation type
  88018. */
  88019. private static _ANIMATIONTYPE_QUATERNION;
  88020. /**
  88021. * Matrix animation type
  88022. */
  88023. private static _ANIMATIONTYPE_MATRIX;
  88024. /**
  88025. * Color3 animation type
  88026. */
  88027. private static _ANIMATIONTYPE_COLOR3;
  88028. /**
  88029. * Vector2 animation type
  88030. */
  88031. private static _ANIMATIONTYPE_VECTOR2;
  88032. /**
  88033. * Size animation type
  88034. */
  88035. private static _ANIMATIONTYPE_SIZE;
  88036. /**
  88037. * Relative Loop Mode
  88038. */
  88039. private static _ANIMATIONLOOPMODE_RELATIVE;
  88040. /**
  88041. * Cycle Loop Mode
  88042. */
  88043. private static _ANIMATIONLOOPMODE_CYCLE;
  88044. /**
  88045. * Constant Loop Mode
  88046. */
  88047. private static _ANIMATIONLOOPMODE_CONSTANT;
  88048. /**
  88049. * Get the float animation type
  88050. */
  88051. static readonly ANIMATIONTYPE_FLOAT: number;
  88052. /**
  88053. * Get the Vector3 animation type
  88054. */
  88055. static readonly ANIMATIONTYPE_VECTOR3: number;
  88056. /**
  88057. * Get the Vector2 animation type
  88058. */
  88059. static readonly ANIMATIONTYPE_VECTOR2: number;
  88060. /**
  88061. * Get the Size animation type
  88062. */
  88063. static readonly ANIMATIONTYPE_SIZE: number;
  88064. /**
  88065. * Get the Quaternion animation type
  88066. */
  88067. static readonly ANIMATIONTYPE_QUATERNION: number;
  88068. /**
  88069. * Get the Matrix animation type
  88070. */
  88071. static readonly ANIMATIONTYPE_MATRIX: number;
  88072. /**
  88073. * Get the Color3 animation type
  88074. */
  88075. static readonly ANIMATIONTYPE_COLOR3: number;
  88076. /**
  88077. * Get the Relative Loop Mode
  88078. */
  88079. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  88080. /**
  88081. * Get the Cycle Loop Mode
  88082. */
  88083. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  88084. /**
  88085. * Get the Constant Loop Mode
  88086. */
  88087. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  88088. /** @hidden */
  88089. static _UniversalLerp(left: any, right: any, amount: number): any;
  88090. /**
  88091. * Parses an animation object and creates an animation
  88092. * @param parsedAnimation Parsed animation object
  88093. * @returns Animation object
  88094. */
  88095. static Parse(parsedAnimation: any): Animation;
  88096. /**
  88097. * Appends the serialized animations from the source animations
  88098. * @param source Source containing the animations
  88099. * @param destination Target to store the animations
  88100. */
  88101. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  88102. }
  88103. }
  88104. declare module BABYLON {
  88105. /**
  88106. * Base class of all the textures in babylon.
  88107. * It groups all the common properties the materials, post process, lights... might need
  88108. * in order to make a correct use of the texture.
  88109. */
  88110. export class BaseTexture implements IAnimatable {
  88111. /**
  88112. * Default anisotropic filtering level for the application.
  88113. * It is set to 4 as a good tradeoff between perf and quality.
  88114. */
  88115. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  88116. /**
  88117. * Gets or sets the unique id of the texture
  88118. */
  88119. uniqueId: number;
  88120. /**
  88121. * Define the name of the texture.
  88122. */
  88123. name: string;
  88124. /**
  88125. * Gets or sets an object used to store user defined information.
  88126. */
  88127. metadata: any;
  88128. /**
  88129. * For internal use only. Please do not use.
  88130. */
  88131. reservedDataStore: any;
  88132. private _hasAlpha;
  88133. /**
  88134. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  88135. */
  88136. hasAlpha: boolean;
  88137. /**
  88138. * Defines if the alpha value should be determined via the rgb values.
  88139. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  88140. */
  88141. getAlphaFromRGB: boolean;
  88142. /**
  88143. * Intensity or strength of the texture.
  88144. * It is commonly used by materials to fine tune the intensity of the texture
  88145. */
  88146. level: number;
  88147. /**
  88148. * Define the UV chanel to use starting from 0 and defaulting to 0.
  88149. * This is part of the texture as textures usually maps to one uv set.
  88150. */
  88151. coordinatesIndex: number;
  88152. private _coordinatesMode;
  88153. /**
  88154. * How a texture is mapped.
  88155. *
  88156. * | Value | Type | Description |
  88157. * | ----- | ----------------------------------- | ----------- |
  88158. * | 0 | EXPLICIT_MODE | |
  88159. * | 1 | SPHERICAL_MODE | |
  88160. * | 2 | PLANAR_MODE | |
  88161. * | 3 | CUBIC_MODE | |
  88162. * | 4 | PROJECTION_MODE | |
  88163. * | 5 | SKYBOX_MODE | |
  88164. * | 6 | INVCUBIC_MODE | |
  88165. * | 7 | EQUIRECTANGULAR_MODE | |
  88166. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  88167. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  88168. */
  88169. coordinatesMode: number;
  88170. /**
  88171. * | Value | Type | Description |
  88172. * | ----- | ------------------ | ----------- |
  88173. * | 0 | CLAMP_ADDRESSMODE | |
  88174. * | 1 | WRAP_ADDRESSMODE | |
  88175. * | 2 | MIRROR_ADDRESSMODE | |
  88176. */
  88177. wrapU: number;
  88178. /**
  88179. * | Value | Type | Description |
  88180. * | ----- | ------------------ | ----------- |
  88181. * | 0 | CLAMP_ADDRESSMODE | |
  88182. * | 1 | WRAP_ADDRESSMODE | |
  88183. * | 2 | MIRROR_ADDRESSMODE | |
  88184. */
  88185. wrapV: number;
  88186. /**
  88187. * | Value | Type | Description |
  88188. * | ----- | ------------------ | ----------- |
  88189. * | 0 | CLAMP_ADDRESSMODE | |
  88190. * | 1 | WRAP_ADDRESSMODE | |
  88191. * | 2 | MIRROR_ADDRESSMODE | |
  88192. */
  88193. wrapR: number;
  88194. /**
  88195. * With compliant hardware and browser (supporting anisotropic filtering)
  88196. * this defines the level of anisotropic filtering in the texture.
  88197. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  88198. */
  88199. anisotropicFilteringLevel: number;
  88200. /**
  88201. * Define if the texture is a cube texture or if false a 2d texture.
  88202. */
  88203. isCube: boolean;
  88204. /**
  88205. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  88206. */
  88207. is3D: boolean;
  88208. /**
  88209. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  88210. * HDR texture are usually stored in linear space.
  88211. * This only impacts the PBR and Background materials
  88212. */
  88213. gammaSpace: boolean;
  88214. /**
  88215. * Gets whether or not the texture contains RGBD data.
  88216. */
  88217. readonly isRGBD: boolean;
  88218. /**
  88219. * Is Z inverted in the texture (useful in a cube texture).
  88220. */
  88221. invertZ: boolean;
  88222. /**
  88223. * Are mip maps generated for this texture or not.
  88224. */
  88225. readonly noMipmap: boolean;
  88226. /**
  88227. * @hidden
  88228. */
  88229. lodLevelInAlpha: boolean;
  88230. /**
  88231. * With prefiltered texture, defined the offset used during the prefiltering steps.
  88232. */
  88233. lodGenerationOffset: number;
  88234. /**
  88235. * With prefiltered texture, defined the scale used during the prefiltering steps.
  88236. */
  88237. lodGenerationScale: number;
  88238. /**
  88239. * Define if the texture is a render target.
  88240. */
  88241. isRenderTarget: boolean;
  88242. /**
  88243. * Define the unique id of the texture in the scene.
  88244. */
  88245. readonly uid: string;
  88246. /**
  88247. * Return a string representation of the texture.
  88248. * @returns the texture as a string
  88249. */
  88250. toString(): string;
  88251. /**
  88252. * Get the class name of the texture.
  88253. * @returns "BaseTexture"
  88254. */
  88255. getClassName(): string;
  88256. /**
  88257. * Define the list of animation attached to the texture.
  88258. */
  88259. animations: Animation[];
  88260. /**
  88261. * An event triggered when the texture is disposed.
  88262. */
  88263. onDisposeObservable: Observable<BaseTexture>;
  88264. private _onDisposeObserver;
  88265. /**
  88266. * Callback triggered when the texture has been disposed.
  88267. * Kept for back compatibility, you can use the onDisposeObservable instead.
  88268. */
  88269. onDispose: () => void;
  88270. /**
  88271. * Define the current state of the loading sequence when in delayed load mode.
  88272. */
  88273. delayLoadState: number;
  88274. private _scene;
  88275. /** @hidden */
  88276. _texture: Nullable<InternalTexture>;
  88277. private _uid;
  88278. /**
  88279. * Define if the texture is preventinga material to render or not.
  88280. * If not and the texture is not ready, the engine will use a default black texture instead.
  88281. */
  88282. readonly isBlocking: boolean;
  88283. /**
  88284. * Instantiates a new BaseTexture.
  88285. * Base class of all the textures in babylon.
  88286. * It groups all the common properties the materials, post process, lights... might need
  88287. * in order to make a correct use of the texture.
  88288. * @param scene Define the scene the texture blongs to
  88289. */
  88290. constructor(scene: Nullable<Scene>);
  88291. /**
  88292. * Get the scene the texture belongs to.
  88293. * @returns the scene or null if undefined
  88294. */
  88295. getScene(): Nullable<Scene>;
  88296. /**
  88297. * Get the texture transform matrix used to offset tile the texture for istance.
  88298. * @returns the transformation matrix
  88299. */
  88300. getTextureMatrix(): Matrix;
  88301. /**
  88302. * Get the texture reflection matrix used to rotate/transform the reflection.
  88303. * @returns the reflection matrix
  88304. */
  88305. getReflectionTextureMatrix(): Matrix;
  88306. /**
  88307. * Get the underlying lower level texture from Babylon.
  88308. * @returns the insternal texture
  88309. */
  88310. getInternalTexture(): Nullable<InternalTexture>;
  88311. /**
  88312. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  88313. * @returns true if ready or not blocking
  88314. */
  88315. isReadyOrNotBlocking(): boolean;
  88316. /**
  88317. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  88318. * @returns true if fully ready
  88319. */
  88320. isReady(): boolean;
  88321. private _cachedSize;
  88322. /**
  88323. * Get the size of the texture.
  88324. * @returns the texture size.
  88325. */
  88326. getSize(): ISize;
  88327. /**
  88328. * Get the base size of the texture.
  88329. * It can be different from the size if the texture has been resized for POT for instance
  88330. * @returns the base size
  88331. */
  88332. getBaseSize(): ISize;
  88333. /**
  88334. * Update the sampling mode of the texture.
  88335. * Default is Trilinear mode.
  88336. *
  88337. * | Value | Type | Description |
  88338. * | ----- | ------------------ | ----------- |
  88339. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  88340. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  88341. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  88342. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  88343. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  88344. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  88345. * | 7 | NEAREST_LINEAR | |
  88346. * | 8 | NEAREST_NEAREST | |
  88347. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  88348. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  88349. * | 11 | LINEAR_LINEAR | |
  88350. * | 12 | LINEAR_NEAREST | |
  88351. *
  88352. * > _mag_: magnification filter (close to the viewer)
  88353. * > _min_: minification filter (far from the viewer)
  88354. * > _mip_: filter used between mip map levels
  88355. *@param samplingMode Define the new sampling mode of the texture
  88356. */
  88357. updateSamplingMode(samplingMode: number): void;
  88358. /**
  88359. * Scales the texture if is `canRescale()`
  88360. * @param ratio the resize factor we want to use to rescale
  88361. */
  88362. scale(ratio: number): void;
  88363. /**
  88364. * Get if the texture can rescale.
  88365. */
  88366. readonly canRescale: boolean;
  88367. /** @hidden */
  88368. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  88369. /** @hidden */
  88370. _rebuild(): void;
  88371. /**
  88372. * Triggers the load sequence in delayed load mode.
  88373. */
  88374. delayLoad(): void;
  88375. /**
  88376. * Clones the texture.
  88377. * @returns the cloned texture
  88378. */
  88379. clone(): Nullable<BaseTexture>;
  88380. /**
  88381. * Get the texture underlying type (INT, FLOAT...)
  88382. */
  88383. readonly textureType: number;
  88384. /**
  88385. * Get the texture underlying format (RGB, RGBA...)
  88386. */
  88387. readonly textureFormat: number;
  88388. /**
  88389. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  88390. * This will returns an RGBA array buffer containing either in values (0-255) or
  88391. * float values (0-1) depending of the underlying buffer type.
  88392. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  88393. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  88394. * @param buffer defines a user defined buffer to fill with data (can be null)
  88395. * @returns The Array buffer containing the pixels data.
  88396. */
  88397. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  88398. /**
  88399. * Release and destroy the underlying lower level texture aka internalTexture.
  88400. */
  88401. releaseInternalTexture(): void;
  88402. /**
  88403. * Get the polynomial representation of the texture data.
  88404. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  88405. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  88406. */
  88407. sphericalPolynomial: Nullable<SphericalPolynomial>;
  88408. /** @hidden */
  88409. readonly _lodTextureHigh: Nullable<BaseTexture>;
  88410. /** @hidden */
  88411. readonly _lodTextureMid: Nullable<BaseTexture>;
  88412. /** @hidden */
  88413. readonly _lodTextureLow: Nullable<BaseTexture>;
  88414. /**
  88415. * Dispose the texture and release its associated resources.
  88416. */
  88417. dispose(): void;
  88418. /**
  88419. * Serialize the texture into a JSON representation that can be parsed later on.
  88420. * @returns the JSON representation of the texture
  88421. */
  88422. serialize(): any;
  88423. /**
  88424. * Helper function to be called back once a list of texture contains only ready textures.
  88425. * @param textures Define the list of textures to wait for
  88426. * @param callback Define the callback triggered once the entire list will be ready
  88427. */
  88428. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  88429. }
  88430. }
  88431. declare module BABYLON {
  88432. /**
  88433. * Uniform buffer objects.
  88434. *
  88435. * Handles blocks of uniform on the GPU.
  88436. *
  88437. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88438. *
  88439. * For more information, please refer to :
  88440. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88441. */
  88442. export class UniformBuffer {
  88443. private _engine;
  88444. private _buffer;
  88445. private _data;
  88446. private _bufferData;
  88447. private _dynamic?;
  88448. private _uniformLocations;
  88449. private _uniformSizes;
  88450. private _uniformLocationPointer;
  88451. private _needSync;
  88452. private _noUBO;
  88453. private _currentEffect;
  88454. private static _MAX_UNIFORM_SIZE;
  88455. private static _tempBuffer;
  88456. /**
  88457. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  88458. * This is dynamic to allow compat with webgl 1 and 2.
  88459. * You will need to pass the name of the uniform as well as the value.
  88460. */
  88461. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  88462. /**
  88463. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  88464. * This is dynamic to allow compat with webgl 1 and 2.
  88465. * You will need to pass the name of the uniform as well as the value.
  88466. */
  88467. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  88468. /**
  88469. * Lambda to Update a single float in a uniform buffer.
  88470. * This is dynamic to allow compat with webgl 1 and 2.
  88471. * You will need to pass the name of the uniform as well as the value.
  88472. */
  88473. updateFloat: (name: string, x: number) => void;
  88474. /**
  88475. * Lambda to Update a vec2 of float in a uniform buffer.
  88476. * This is dynamic to allow compat with webgl 1 and 2.
  88477. * You will need to pass the name of the uniform as well as the value.
  88478. */
  88479. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  88480. /**
  88481. * Lambda to Update a vec3 of float in a uniform buffer.
  88482. * This is dynamic to allow compat with webgl 1 and 2.
  88483. * You will need to pass the name of the uniform as well as the value.
  88484. */
  88485. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  88486. /**
  88487. * Lambda to Update a vec4 of float in a uniform buffer.
  88488. * This is dynamic to allow compat with webgl 1 and 2.
  88489. * You will need to pass the name of the uniform as well as the value.
  88490. */
  88491. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  88492. /**
  88493. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  88494. * This is dynamic to allow compat with webgl 1 and 2.
  88495. * You will need to pass the name of the uniform as well as the value.
  88496. */
  88497. updateMatrix: (name: string, mat: Matrix) => void;
  88498. /**
  88499. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  88500. * This is dynamic to allow compat with webgl 1 and 2.
  88501. * You will need to pass the name of the uniform as well as the value.
  88502. */
  88503. updateVector3: (name: string, vector: Vector3) => void;
  88504. /**
  88505. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  88506. * This is dynamic to allow compat with webgl 1 and 2.
  88507. * You will need to pass the name of the uniform as well as the value.
  88508. */
  88509. updateVector4: (name: string, vector: Vector4) => void;
  88510. /**
  88511. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  88512. * This is dynamic to allow compat with webgl 1 and 2.
  88513. * You will need to pass the name of the uniform as well as the value.
  88514. */
  88515. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  88516. /**
  88517. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  88518. * This is dynamic to allow compat with webgl 1 and 2.
  88519. * You will need to pass the name of the uniform as well as the value.
  88520. */
  88521. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  88522. /**
  88523. * Instantiates a new Uniform buffer objects.
  88524. *
  88525. * Handles blocks of uniform on the GPU.
  88526. *
  88527. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  88528. *
  88529. * For more information, please refer to :
  88530. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  88531. * @param engine Define the engine the buffer is associated with
  88532. * @param data Define the data contained in the buffer
  88533. * @param dynamic Define if the buffer is updatable
  88534. */
  88535. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  88536. /**
  88537. * Indicates if the buffer is using the WebGL2 UBO implementation,
  88538. * or just falling back on setUniformXXX calls.
  88539. */
  88540. readonly useUbo: boolean;
  88541. /**
  88542. * Indicates if the WebGL underlying uniform buffer is in sync
  88543. * with the javascript cache data.
  88544. */
  88545. readonly isSync: boolean;
  88546. /**
  88547. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88548. * Also, a dynamic UniformBuffer will disable cache verification and always
  88549. * update the underlying WebGL uniform buffer to the GPU.
  88550. * @returns if Dynamic, otherwise false
  88551. */
  88552. isDynamic(): boolean;
  88553. /**
  88554. * The data cache on JS side.
  88555. * @returns the underlying data as a float array
  88556. */
  88557. getData(): Float32Array;
  88558. /**
  88559. * The underlying WebGL Uniform buffer.
  88560. * @returns the webgl buffer
  88561. */
  88562. getBuffer(): Nullable<DataBuffer>;
  88563. /**
  88564. * std140 layout specifies how to align data within an UBO structure.
  88565. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88566. * for specs.
  88567. */
  88568. private _fillAlignment;
  88569. /**
  88570. * Adds an uniform in the buffer.
  88571. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88572. * for the layout to be correct !
  88573. * @param name Name of the uniform, as used in the uniform block in the shader.
  88574. * @param size Data size, or data directly.
  88575. */
  88576. addUniform(name: string, size: number | number[]): void;
  88577. /**
  88578. * Adds a Matrix 4x4 to the uniform buffer.
  88579. * @param name Name of the uniform, as used in the uniform block in the shader.
  88580. * @param mat A 4x4 matrix.
  88581. */
  88582. addMatrix(name: string, mat: Matrix): void;
  88583. /**
  88584. * Adds a vec2 to the uniform buffer.
  88585. * @param name Name of the uniform, as used in the uniform block in the shader.
  88586. * @param x Define the x component value of the vec2
  88587. * @param y Define the y component value of the vec2
  88588. */
  88589. addFloat2(name: string, x: number, y: number): void;
  88590. /**
  88591. * Adds a vec3 to the uniform buffer.
  88592. * @param name Name of the uniform, as used in the uniform block in the shader.
  88593. * @param x Define the x component value of the vec3
  88594. * @param y Define the y component value of the vec3
  88595. * @param z Define the z component value of the vec3
  88596. */
  88597. addFloat3(name: string, x: number, y: number, z: number): void;
  88598. /**
  88599. * Adds a vec3 to the uniform buffer.
  88600. * @param name Name of the uniform, as used in the uniform block in the shader.
  88601. * @param color Define the vec3 from a Color
  88602. */
  88603. addColor3(name: string, color: Color3): void;
  88604. /**
  88605. * Adds a vec4 to the uniform buffer.
  88606. * @param name Name of the uniform, as used in the uniform block in the shader.
  88607. * @param color Define the rgb components from a Color
  88608. * @param alpha Define the a component of the vec4
  88609. */
  88610. addColor4(name: string, color: Color3, alpha: number): void;
  88611. /**
  88612. * Adds a vec3 to the uniform buffer.
  88613. * @param name Name of the uniform, as used in the uniform block in the shader.
  88614. * @param vector Define the vec3 components from a Vector
  88615. */
  88616. addVector3(name: string, vector: Vector3): void;
  88617. /**
  88618. * Adds a Matrix 3x3 to the uniform buffer.
  88619. * @param name Name of the uniform, as used in the uniform block in the shader.
  88620. */
  88621. addMatrix3x3(name: string): void;
  88622. /**
  88623. * Adds a Matrix 2x2 to the uniform buffer.
  88624. * @param name Name of the uniform, as used in the uniform block in the shader.
  88625. */
  88626. addMatrix2x2(name: string): void;
  88627. /**
  88628. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88629. */
  88630. create(): void;
  88631. /** @hidden */
  88632. _rebuild(): void;
  88633. /**
  88634. * Updates the WebGL Uniform Buffer on the GPU.
  88635. * If the `dynamic` flag is set to true, no cache comparison is done.
  88636. * Otherwise, the buffer will be updated only if the cache differs.
  88637. */
  88638. update(): void;
  88639. /**
  88640. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88641. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88642. * @param data Define the flattened data
  88643. * @param size Define the size of the data.
  88644. */
  88645. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88646. private _updateMatrix3x3ForUniform;
  88647. private _updateMatrix3x3ForEffect;
  88648. private _updateMatrix2x2ForEffect;
  88649. private _updateMatrix2x2ForUniform;
  88650. private _updateFloatForEffect;
  88651. private _updateFloatForUniform;
  88652. private _updateFloat2ForEffect;
  88653. private _updateFloat2ForUniform;
  88654. private _updateFloat3ForEffect;
  88655. private _updateFloat3ForUniform;
  88656. private _updateFloat4ForEffect;
  88657. private _updateFloat4ForUniform;
  88658. private _updateMatrixForEffect;
  88659. private _updateMatrixForUniform;
  88660. private _updateVector3ForEffect;
  88661. private _updateVector3ForUniform;
  88662. private _updateVector4ForEffect;
  88663. private _updateVector4ForUniform;
  88664. private _updateColor3ForEffect;
  88665. private _updateColor3ForUniform;
  88666. private _updateColor4ForEffect;
  88667. private _updateColor4ForUniform;
  88668. /**
  88669. * Sets a sampler uniform on the effect.
  88670. * @param name Define the name of the sampler.
  88671. * @param texture Define the texture to set in the sampler
  88672. */
  88673. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88674. /**
  88675. * Directly updates the value of the uniform in the cache AND on the GPU.
  88676. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88677. * @param data Define the flattened data
  88678. */
  88679. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88680. /**
  88681. * Binds this uniform buffer to an effect.
  88682. * @param effect Define the effect to bind the buffer to
  88683. * @param name Name of the uniform block in the shader.
  88684. */
  88685. bindToEffect(effect: Effect, name: string): void;
  88686. /**
  88687. * Disposes the uniform buffer.
  88688. */
  88689. dispose(): void;
  88690. }
  88691. }
  88692. declare module BABYLON {
  88693. /**
  88694. * Class used to work with sound analyzer using fast fourier transform (FFT)
  88695. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  88696. */
  88697. export class Analyser {
  88698. /**
  88699. * Gets or sets the smoothing
  88700. * @ignorenaming
  88701. */
  88702. SMOOTHING: number;
  88703. /**
  88704. * Gets or sets the FFT table size
  88705. * @ignorenaming
  88706. */
  88707. FFT_SIZE: number;
  88708. /**
  88709. * Gets or sets the bar graph amplitude
  88710. * @ignorenaming
  88711. */
  88712. BARGRAPHAMPLITUDE: number;
  88713. /**
  88714. * Gets or sets the position of the debug canvas
  88715. * @ignorenaming
  88716. */
  88717. DEBUGCANVASPOS: {
  88718. x: number;
  88719. y: number;
  88720. };
  88721. /**
  88722. * Gets or sets the debug canvas size
  88723. * @ignorenaming
  88724. */
  88725. DEBUGCANVASSIZE: {
  88726. width: number;
  88727. height: number;
  88728. };
  88729. private _byteFreqs;
  88730. private _byteTime;
  88731. private _floatFreqs;
  88732. private _webAudioAnalyser;
  88733. private _debugCanvas;
  88734. private _debugCanvasContext;
  88735. private _scene;
  88736. private _registerFunc;
  88737. private _audioEngine;
  88738. /**
  88739. * Creates a new analyser
  88740. * @param scene defines hosting scene
  88741. */
  88742. constructor(scene: Scene);
  88743. /**
  88744. * Get the number of data values you will have to play with for the visualization
  88745. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  88746. * @returns a number
  88747. */
  88748. getFrequencyBinCount(): number;
  88749. /**
  88750. * Gets the current frequency data as a byte array
  88751. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  88752. * @returns a Uint8Array
  88753. */
  88754. getByteFrequencyData(): Uint8Array;
  88755. /**
  88756. * Gets the current waveform as a byte array
  88757. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  88758. * @returns a Uint8Array
  88759. */
  88760. getByteTimeDomainData(): Uint8Array;
  88761. /**
  88762. * Gets the current frequency data as a float array
  88763. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  88764. * @returns a Float32Array
  88765. */
  88766. getFloatFrequencyData(): Float32Array;
  88767. /**
  88768. * Renders the debug canvas
  88769. */
  88770. drawDebugCanvas(): void;
  88771. /**
  88772. * Stops rendering the debug canvas and removes it
  88773. */
  88774. stopDebugCanvas(): void;
  88775. /**
  88776. * Connects two audio nodes
  88777. * @param inputAudioNode defines first node to connect
  88778. * @param outputAudioNode defines second node to connect
  88779. */
  88780. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  88781. /**
  88782. * Releases all associated resources
  88783. */
  88784. dispose(): void;
  88785. }
  88786. }
  88787. declare module BABYLON {
  88788. /**
  88789. * This represents an audio engine and it is responsible
  88790. * to play, synchronize and analyse sounds throughout the application.
  88791. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  88792. */
  88793. export interface IAudioEngine extends IDisposable {
  88794. /**
  88795. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  88796. */
  88797. readonly canUseWebAudio: boolean;
  88798. /**
  88799. * Gets the current AudioContext if available.
  88800. */
  88801. readonly audioContext: Nullable<AudioContext>;
  88802. /**
  88803. * The master gain node defines the global audio volume of your audio engine.
  88804. */
  88805. readonly masterGain: GainNode;
  88806. /**
  88807. * Gets whether or not mp3 are supported by your browser.
  88808. */
  88809. readonly isMP3supported: boolean;
  88810. /**
  88811. * Gets whether or not ogg are supported by your browser.
  88812. */
  88813. readonly isOGGsupported: boolean;
  88814. /**
  88815. * Defines if Babylon should emit a warning if WebAudio is not supported.
  88816. * @ignoreNaming
  88817. */
  88818. WarnedWebAudioUnsupported: boolean;
  88819. /**
  88820. * Defines if the audio engine relies on a custom unlocked button.
  88821. * In this case, the embedded button will not be displayed.
  88822. */
  88823. useCustomUnlockedButton: boolean;
  88824. /**
  88825. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  88826. */
  88827. readonly unlocked: boolean;
  88828. /**
  88829. * Event raised when audio has been unlocked on the browser.
  88830. */
  88831. onAudioUnlockedObservable: Observable<AudioEngine>;
  88832. /**
  88833. * Event raised when audio has been locked on the browser.
  88834. */
  88835. onAudioLockedObservable: Observable<AudioEngine>;
  88836. /**
  88837. * Flags the audio engine in Locked state.
  88838. * This happens due to new browser policies preventing audio to autoplay.
  88839. */
  88840. lock(): void;
  88841. /**
  88842. * Unlocks the audio engine once a user action has been done on the dom.
  88843. * This is helpful to resume play once browser policies have been satisfied.
  88844. */
  88845. unlock(): void;
  88846. }
  88847. /**
  88848. * This represents the default audio engine used in babylon.
  88849. * It is responsible to play, synchronize and analyse sounds throughout the application.
  88850. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  88851. */
  88852. export class AudioEngine implements IAudioEngine {
  88853. private _audioContext;
  88854. private _audioContextInitialized;
  88855. private _muteButton;
  88856. private _hostElement;
  88857. /**
  88858. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  88859. */
  88860. canUseWebAudio: boolean;
  88861. /**
  88862. * The master gain node defines the global audio volume of your audio engine.
  88863. */
  88864. masterGain: GainNode;
  88865. /**
  88866. * Defines if Babylon should emit a warning if WebAudio is not supported.
  88867. * @ignoreNaming
  88868. */
  88869. WarnedWebAudioUnsupported: boolean;
  88870. /**
  88871. * Gets whether or not mp3 are supported by your browser.
  88872. */
  88873. isMP3supported: boolean;
  88874. /**
  88875. * Gets whether or not ogg are supported by your browser.
  88876. */
  88877. isOGGsupported: boolean;
  88878. /**
  88879. * Gets whether audio has been unlocked on the device.
  88880. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  88881. * a user interaction has happened.
  88882. */
  88883. unlocked: boolean;
  88884. /**
  88885. * Defines if the audio engine relies on a custom unlocked button.
  88886. * In this case, the embedded button will not be displayed.
  88887. */
  88888. useCustomUnlockedButton: boolean;
  88889. /**
  88890. * Event raised when audio has been unlocked on the browser.
  88891. */
  88892. onAudioUnlockedObservable: Observable<AudioEngine>;
  88893. /**
  88894. * Event raised when audio has been locked on the browser.
  88895. */
  88896. onAudioLockedObservable: Observable<AudioEngine>;
  88897. /**
  88898. * Gets the current AudioContext if available.
  88899. */
  88900. readonly audioContext: Nullable<AudioContext>;
  88901. private _connectedAnalyser;
  88902. /**
  88903. * Instantiates a new audio engine.
  88904. *
  88905. * There should be only one per page as some browsers restrict the number
  88906. * of audio contexts you can create.
  88907. * @param hostElement defines the host element where to display the mute icon if necessary
  88908. */
  88909. constructor(hostElement?: Nullable<HTMLElement>);
  88910. /**
  88911. * Flags the audio engine in Locked state.
  88912. * This happens due to new browser policies preventing audio to autoplay.
  88913. */
  88914. lock(): void;
  88915. /**
  88916. * Unlocks the audio engine once a user action has been done on the dom.
  88917. * This is helpful to resume play once browser policies have been satisfied.
  88918. */
  88919. unlock(): void;
  88920. private _resumeAudioContext;
  88921. private _initializeAudioContext;
  88922. private _tryToRun;
  88923. private _triggerRunningState;
  88924. private _triggerSuspendedState;
  88925. private _displayMuteButton;
  88926. private _moveButtonToTopLeft;
  88927. private _onResize;
  88928. private _hideMuteButton;
  88929. /**
  88930. * Destroy and release the resources associated with the audio ccontext.
  88931. */
  88932. dispose(): void;
  88933. /**
  88934. * Gets the global volume sets on the master gain.
  88935. * @returns the global volume if set or -1 otherwise
  88936. */
  88937. getGlobalVolume(): number;
  88938. /**
  88939. * Sets the global volume of your experience (sets on the master gain).
  88940. * @param newVolume Defines the new global volume of the application
  88941. */
  88942. setGlobalVolume(newVolume: number): void;
  88943. /**
  88944. * Connect the audio engine to an audio analyser allowing some amazing
  88945. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  88946. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  88947. * @param analyser The analyser to connect to the engine
  88948. */
  88949. connectToAnalyser(analyser: Analyser): void;
  88950. }
  88951. }
  88952. declare module BABYLON {
  88953. /**
  88954. * Interface used to present a loading screen while loading a scene
  88955. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88956. */
  88957. export interface ILoadingScreen {
  88958. /**
  88959. * Function called to display the loading screen
  88960. */
  88961. displayLoadingUI: () => void;
  88962. /**
  88963. * Function called to hide the loading screen
  88964. */
  88965. hideLoadingUI: () => void;
  88966. /**
  88967. * Gets or sets the color to use for the background
  88968. */
  88969. loadingUIBackgroundColor: string;
  88970. /**
  88971. * Gets or sets the text to display while loading
  88972. */
  88973. loadingUIText: string;
  88974. }
  88975. /**
  88976. * Class used for the default loading screen
  88977. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88978. */
  88979. export class DefaultLoadingScreen implements ILoadingScreen {
  88980. private _renderingCanvas;
  88981. private _loadingText;
  88982. private _loadingDivBackgroundColor;
  88983. private _loadingDiv;
  88984. private _loadingTextDiv;
  88985. /** Gets or sets the logo url to use for the default loading screen */
  88986. static DefaultLogoUrl: string;
  88987. /** Gets or sets the spinner url to use for the default loading screen */
  88988. static DefaultSpinnerUrl: string;
  88989. /**
  88990. * Creates a new default loading screen
  88991. * @param _renderingCanvas defines the canvas used to render the scene
  88992. * @param _loadingText defines the default text to display
  88993. * @param _loadingDivBackgroundColor defines the default background color
  88994. */
  88995. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  88996. /**
  88997. * Function called to display the loading screen
  88998. */
  88999. displayLoadingUI(): void;
  89000. /**
  89001. * Function called to hide the loading screen
  89002. */
  89003. hideLoadingUI(): void;
  89004. /**
  89005. * Gets or sets the text to display while loading
  89006. */
  89007. loadingUIText: string;
  89008. /**
  89009. * Gets or sets the color to use for the background
  89010. */
  89011. loadingUIBackgroundColor: string;
  89012. private _resizeLoadingUI;
  89013. }
  89014. }
  89015. declare module BABYLON {
  89016. /** @hidden */
  89017. export class WebGLPipelineContext implements IPipelineContext {
  89018. engine: Engine;
  89019. program: Nullable<WebGLProgram>;
  89020. context?: WebGLRenderingContext;
  89021. vertexShader?: WebGLShader;
  89022. fragmentShader?: WebGLShader;
  89023. isParallelCompiled: boolean;
  89024. onCompiled?: () => void;
  89025. transformFeedback?: WebGLTransformFeedback | null;
  89026. readonly isAsync: boolean;
  89027. readonly isReady: boolean;
  89028. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  89029. }
  89030. }
  89031. declare module BABYLON {
  89032. /** @hidden */
  89033. export class WebGLDataBuffer extends DataBuffer {
  89034. private _buffer;
  89035. constructor(resource: WebGLBuffer);
  89036. readonly underlyingResource: any;
  89037. }
  89038. }
  89039. declare module BABYLON {
  89040. /**
  89041. * Settings for finer control over video usage
  89042. */
  89043. export interface VideoTextureSettings {
  89044. /**
  89045. * Applies `autoplay` to video, if specified
  89046. */
  89047. autoPlay?: boolean;
  89048. /**
  89049. * Applies `loop` to video, if specified
  89050. */
  89051. loop?: boolean;
  89052. /**
  89053. * Automatically updates internal texture from video at every frame in the render loop
  89054. */
  89055. autoUpdateTexture: boolean;
  89056. /**
  89057. * Image src displayed during the video loading or until the user interacts with the video.
  89058. */
  89059. poster?: string;
  89060. }
  89061. /**
  89062. * If you want to display a video in your scene, this is the special texture for that.
  89063. * This special texture works similar to other textures, with the exception of a few parameters.
  89064. * @see https://doc.babylonjs.com/how_to/video_texture
  89065. */
  89066. export class VideoTexture extends Texture {
  89067. /**
  89068. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  89069. */
  89070. readonly autoUpdateTexture: boolean;
  89071. /**
  89072. * The video instance used by the texture internally
  89073. */
  89074. readonly video: HTMLVideoElement;
  89075. private _onUserActionRequestedObservable;
  89076. /**
  89077. * Event triggerd when a dom action is required by the user to play the video.
  89078. * This happens due to recent changes in browser policies preventing video to auto start.
  89079. */
  89080. readonly onUserActionRequestedObservable: Observable<Texture>;
  89081. private _generateMipMaps;
  89082. private _engine;
  89083. private _stillImageCaptured;
  89084. private _displayingPosterTexture;
  89085. private _settings;
  89086. private _createInternalTextureOnEvent;
  89087. /**
  89088. * Creates a video texture.
  89089. * If you want to display a video in your scene, this is the special texture for that.
  89090. * This special texture works similar to other textures, with the exception of a few parameters.
  89091. * @see https://doc.babylonjs.com/how_to/video_texture
  89092. * @param name optional name, will detect from video source, if not defined
  89093. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  89094. * @param scene is obviously the current scene.
  89095. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  89096. * @param invertY is false by default but can be used to invert video on Y axis
  89097. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  89098. * @param settings allows finer control over video usage
  89099. */
  89100. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  89101. private _getName;
  89102. private _getVideo;
  89103. private _createInternalTexture;
  89104. private reset;
  89105. /**
  89106. * @hidden Internal method to initiate `update`.
  89107. */
  89108. _rebuild(): void;
  89109. /**
  89110. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  89111. */
  89112. update(): void;
  89113. /**
  89114. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  89115. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  89116. */
  89117. updateTexture(isVisible: boolean): void;
  89118. protected _updateInternalTexture: () => void;
  89119. /**
  89120. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  89121. * @param url New url.
  89122. */
  89123. updateURL(url: string): void;
  89124. /**
  89125. * Dispose the texture and release its associated resources.
  89126. */
  89127. dispose(): void;
  89128. /**
  89129. * Creates a video texture straight from a stream.
  89130. * @param scene Define the scene the texture should be created in
  89131. * @param stream Define the stream the texture should be created from
  89132. * @returns The created video texture as a promise
  89133. */
  89134. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  89135. /**
  89136. * Creates a video texture straight from your WebCam video feed.
  89137. * @param scene Define the scene the texture should be created in
  89138. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89139. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89140. * @returns The created video texture as a promise
  89141. */
  89142. static CreateFromWebCamAsync(scene: Scene, constraints: {
  89143. minWidth: number;
  89144. maxWidth: number;
  89145. minHeight: number;
  89146. maxHeight: number;
  89147. deviceId: string;
  89148. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  89149. /**
  89150. * Creates a video texture straight from your WebCam video feed.
  89151. * @param scene Define the scene the texture should be created in
  89152. * @param onReady Define a callback to triggered once the texture will be ready
  89153. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  89154. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  89155. */
  89156. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  89157. minWidth: number;
  89158. maxWidth: number;
  89159. minHeight: number;
  89160. maxHeight: number;
  89161. deviceId: string;
  89162. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  89163. }
  89164. }
  89165. declare module BABYLON {
  89166. /**
  89167. * Interface for attribute information associated with buffer instanciation
  89168. */
  89169. export class InstancingAttributeInfo {
  89170. /**
  89171. * Index/offset of the attribute in the vertex shader
  89172. */
  89173. index: number;
  89174. /**
  89175. * size of the attribute, 1, 2, 3 or 4
  89176. */
  89177. attributeSize: number;
  89178. /**
  89179. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  89180. * default is FLOAT
  89181. */
  89182. attribyteType: number;
  89183. /**
  89184. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  89185. */
  89186. normalized: boolean;
  89187. /**
  89188. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  89189. */
  89190. offset: number;
  89191. /**
  89192. * Name of the GLSL attribute, for debugging purpose only
  89193. */
  89194. attributeName: string;
  89195. }
  89196. /**
  89197. * Define options used to create a depth texture
  89198. */
  89199. export class DepthTextureCreationOptions {
  89200. /** Specifies whether or not a stencil should be allocated in the texture */
  89201. generateStencil?: boolean;
  89202. /** Specifies whether or not bilinear filtering is enable on the texture */
  89203. bilinearFiltering?: boolean;
  89204. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  89205. comparisonFunction?: number;
  89206. /** Specifies if the created texture is a cube texture */
  89207. isCube?: boolean;
  89208. }
  89209. /**
  89210. * Class used to describe the capabilities of the engine relatively to the current browser
  89211. */
  89212. export class EngineCapabilities {
  89213. /** Maximum textures units per fragment shader */
  89214. maxTexturesImageUnits: number;
  89215. /** Maximum texture units per vertex shader */
  89216. maxVertexTextureImageUnits: number;
  89217. /** Maximum textures units in the entire pipeline */
  89218. maxCombinedTexturesImageUnits: number;
  89219. /** Maximum texture size */
  89220. maxTextureSize: number;
  89221. /** Maximum cube texture size */
  89222. maxCubemapTextureSize: number;
  89223. /** Maximum render texture size */
  89224. maxRenderTextureSize: number;
  89225. /** Maximum number of vertex attributes */
  89226. maxVertexAttribs: number;
  89227. /** Maximum number of varyings */
  89228. maxVaryingVectors: number;
  89229. /** Maximum number of uniforms per vertex shader */
  89230. maxVertexUniformVectors: number;
  89231. /** Maximum number of uniforms per fragment shader */
  89232. maxFragmentUniformVectors: number;
  89233. /** Defines if standard derivates (dx/dy) are supported */
  89234. standardDerivatives: boolean;
  89235. /** Defines if s3tc texture compression is supported */
  89236. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  89237. /** Defines if pvrtc texture compression is supported */
  89238. pvrtc: any;
  89239. /** Defines if etc1 texture compression is supported */
  89240. etc1: any;
  89241. /** Defines if etc2 texture compression is supported */
  89242. etc2: any;
  89243. /** Defines if astc texture compression is supported */
  89244. astc: any;
  89245. /** Defines if float textures are supported */
  89246. textureFloat: boolean;
  89247. /** Defines if vertex array objects are supported */
  89248. vertexArrayObject: boolean;
  89249. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  89250. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  89251. /** Gets the maximum level of anisotropy supported */
  89252. maxAnisotropy: number;
  89253. /** Defines if instancing is supported */
  89254. instancedArrays: boolean;
  89255. /** Defines if 32 bits indices are supported */
  89256. uintIndices: boolean;
  89257. /** Defines if high precision shaders are supported */
  89258. highPrecisionShaderSupported: boolean;
  89259. /** Defines if depth reading in the fragment shader is supported */
  89260. fragmentDepthSupported: boolean;
  89261. /** Defines if float texture linear filtering is supported*/
  89262. textureFloatLinearFiltering: boolean;
  89263. /** Defines if rendering to float textures is supported */
  89264. textureFloatRender: boolean;
  89265. /** Defines if half float textures are supported*/
  89266. textureHalfFloat: boolean;
  89267. /** Defines if half float texture linear filtering is supported*/
  89268. textureHalfFloatLinearFiltering: boolean;
  89269. /** Defines if rendering to half float textures is supported */
  89270. textureHalfFloatRender: boolean;
  89271. /** Defines if textureLOD shader command is supported */
  89272. textureLOD: boolean;
  89273. /** Defines if draw buffers extension is supported */
  89274. drawBuffersExtension: boolean;
  89275. /** Defines if depth textures are supported */
  89276. depthTextureExtension: boolean;
  89277. /** Defines if float color buffer are supported */
  89278. colorBufferFloat: boolean;
  89279. /** Gets disjoint timer query extension (null if not supported) */
  89280. timerQuery: EXT_disjoint_timer_query;
  89281. /** Defines if timestamp can be used with timer query */
  89282. canUseTimestampForTimerQuery: boolean;
  89283. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  89284. multiview: any;
  89285. /** Function used to let the system compiles shaders in background */
  89286. parallelShaderCompile: {
  89287. COMPLETION_STATUS_KHR: number;
  89288. };
  89289. }
  89290. /** Interface defining initialization parameters for Engine class */
  89291. export interface EngineOptions extends WebGLContextAttributes {
  89292. /**
  89293. * Defines if the engine should no exceed a specified device ratio
  89294. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  89295. */
  89296. limitDeviceRatio?: number;
  89297. /**
  89298. * Defines if webvr should be enabled automatically
  89299. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89300. */
  89301. autoEnableWebVR?: boolean;
  89302. /**
  89303. * Defines if webgl2 should be turned off even if supported
  89304. * @see http://doc.babylonjs.com/features/webgl2
  89305. */
  89306. disableWebGL2Support?: boolean;
  89307. /**
  89308. * Defines if webaudio should be initialized as well
  89309. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89310. */
  89311. audioEngine?: boolean;
  89312. /**
  89313. * Defines if animations should run using a deterministic lock step
  89314. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89315. */
  89316. deterministicLockstep?: boolean;
  89317. /** Defines the maximum steps to use with deterministic lock step mode */
  89318. lockstepMaxSteps?: number;
  89319. /**
  89320. * Defines that engine should ignore context lost events
  89321. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  89322. */
  89323. doNotHandleContextLost?: boolean;
  89324. /**
  89325. * Defines that engine should ignore modifying touch action attribute and style
  89326. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  89327. */
  89328. doNotHandleTouchAction?: boolean;
  89329. /**
  89330. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  89331. */
  89332. useHighPrecisionFloats?: boolean;
  89333. }
  89334. /**
  89335. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  89336. */
  89337. export class Engine {
  89338. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  89339. static ExceptionList: ({
  89340. key: string;
  89341. capture: string;
  89342. captureConstraint: number;
  89343. targets: string[];
  89344. } | {
  89345. key: string;
  89346. capture: null;
  89347. captureConstraint: null;
  89348. targets: string[];
  89349. })[];
  89350. /** Gets the list of created engines */
  89351. static readonly Instances: Engine[];
  89352. /**
  89353. * Gets the latest created engine
  89354. */
  89355. static readonly LastCreatedEngine: Nullable<Engine>;
  89356. /**
  89357. * Gets the latest created scene
  89358. */
  89359. static readonly LastCreatedScene: Nullable<Scene>;
  89360. /**
  89361. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  89362. * @param flag defines which part of the materials must be marked as dirty
  89363. * @param predicate defines a predicate used to filter which materials should be affected
  89364. */
  89365. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  89366. /**
  89367. * Hidden
  89368. */
  89369. static _TextureLoaders: IInternalTextureLoader[];
  89370. /** Defines that alpha blending is disabled */
  89371. static readonly ALPHA_DISABLE: number;
  89372. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  89373. static readonly ALPHA_ADD: number;
  89374. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  89375. static readonly ALPHA_COMBINE: number;
  89376. /** Defines that alpha blending to DEST - SRC * DEST */
  89377. static readonly ALPHA_SUBTRACT: number;
  89378. /** Defines that alpha blending to SRC * DEST */
  89379. static readonly ALPHA_MULTIPLY: number;
  89380. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  89381. static readonly ALPHA_MAXIMIZED: number;
  89382. /** Defines that alpha blending to SRC + DEST */
  89383. static readonly ALPHA_ONEONE: number;
  89384. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  89385. static readonly ALPHA_PREMULTIPLIED: number;
  89386. /**
  89387. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  89388. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  89389. */
  89390. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  89391. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  89392. static readonly ALPHA_INTERPOLATE: number;
  89393. /**
  89394. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  89395. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  89396. */
  89397. static readonly ALPHA_SCREENMODE: number;
  89398. /** Defines that the ressource is not delayed*/
  89399. static readonly DELAYLOADSTATE_NONE: number;
  89400. /** Defines that the ressource was successfully delay loaded */
  89401. static readonly DELAYLOADSTATE_LOADED: number;
  89402. /** Defines that the ressource is currently delay loading */
  89403. static readonly DELAYLOADSTATE_LOADING: number;
  89404. /** Defines that the ressource is delayed and has not started loading */
  89405. static readonly DELAYLOADSTATE_NOTLOADED: number;
  89406. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  89407. static readonly NEVER: number;
  89408. /** 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 */
  89409. static readonly ALWAYS: number;
  89410. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  89411. static readonly LESS: number;
  89412. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  89413. static readonly EQUAL: number;
  89414. /** 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 */
  89415. static readonly LEQUAL: number;
  89416. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  89417. static readonly GREATER: number;
  89418. /** 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 */
  89419. static readonly GEQUAL: number;
  89420. /** 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 */
  89421. static readonly NOTEQUAL: number;
  89422. /** Passed to stencilOperation to specify that stencil value must be kept */
  89423. static readonly KEEP: number;
  89424. /** Passed to stencilOperation to specify that stencil value must be replaced */
  89425. static readonly REPLACE: number;
  89426. /** Passed to stencilOperation to specify that stencil value must be incremented */
  89427. static readonly INCR: number;
  89428. /** Passed to stencilOperation to specify that stencil value must be decremented */
  89429. static readonly DECR: number;
  89430. /** Passed to stencilOperation to specify that stencil value must be inverted */
  89431. static readonly INVERT: number;
  89432. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  89433. static readonly INCR_WRAP: number;
  89434. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  89435. static readonly DECR_WRAP: number;
  89436. /** Texture is not repeating outside of 0..1 UVs */
  89437. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  89438. /** Texture is repeating outside of 0..1 UVs */
  89439. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  89440. /** Texture is repeating and mirrored */
  89441. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  89442. /** ALPHA */
  89443. static readonly TEXTUREFORMAT_ALPHA: number;
  89444. /** LUMINANCE */
  89445. static readonly TEXTUREFORMAT_LUMINANCE: number;
  89446. /** LUMINANCE_ALPHA */
  89447. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  89448. /** RGB */
  89449. static readonly TEXTUREFORMAT_RGB: number;
  89450. /** RGBA */
  89451. static readonly TEXTUREFORMAT_RGBA: number;
  89452. /** RED */
  89453. static readonly TEXTUREFORMAT_RED: number;
  89454. /** RED (2nd reference) */
  89455. static readonly TEXTUREFORMAT_R: number;
  89456. /** RG */
  89457. static readonly TEXTUREFORMAT_RG: number;
  89458. /** RED_INTEGER */
  89459. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  89460. /** RED_INTEGER (2nd reference) */
  89461. static readonly TEXTUREFORMAT_R_INTEGER: number;
  89462. /** RG_INTEGER */
  89463. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  89464. /** RGB_INTEGER */
  89465. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  89466. /** RGBA_INTEGER */
  89467. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  89468. /** UNSIGNED_BYTE */
  89469. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  89470. /** UNSIGNED_BYTE (2nd reference) */
  89471. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  89472. /** FLOAT */
  89473. static readonly TEXTURETYPE_FLOAT: number;
  89474. /** HALF_FLOAT */
  89475. static readonly TEXTURETYPE_HALF_FLOAT: number;
  89476. /** BYTE */
  89477. static readonly TEXTURETYPE_BYTE: number;
  89478. /** SHORT */
  89479. static readonly TEXTURETYPE_SHORT: number;
  89480. /** UNSIGNED_SHORT */
  89481. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  89482. /** INT */
  89483. static readonly TEXTURETYPE_INT: number;
  89484. /** UNSIGNED_INT */
  89485. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  89486. /** UNSIGNED_SHORT_4_4_4_4 */
  89487. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  89488. /** UNSIGNED_SHORT_5_5_5_1 */
  89489. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  89490. /** UNSIGNED_SHORT_5_6_5 */
  89491. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  89492. /** UNSIGNED_INT_2_10_10_10_REV */
  89493. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  89494. /** UNSIGNED_INT_24_8 */
  89495. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  89496. /** UNSIGNED_INT_10F_11F_11F_REV */
  89497. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  89498. /** UNSIGNED_INT_5_9_9_9_REV */
  89499. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  89500. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  89501. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  89502. /** nearest is mag = nearest and min = nearest and mip = linear */
  89503. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  89504. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89505. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  89506. /** Trilinear is mag = linear and min = linear and mip = linear */
  89507. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  89508. /** nearest is mag = nearest and min = nearest and mip = linear */
  89509. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  89510. /** Bilinear is mag = linear and min = linear and mip = nearest */
  89511. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  89512. /** Trilinear is mag = linear and min = linear and mip = linear */
  89513. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  89514. /** mag = nearest and min = nearest and mip = nearest */
  89515. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  89516. /** mag = nearest and min = linear and mip = nearest */
  89517. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  89518. /** mag = nearest and min = linear and mip = linear */
  89519. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  89520. /** mag = nearest and min = linear and mip = none */
  89521. static readonly TEXTURE_NEAREST_LINEAR: number;
  89522. /** mag = nearest and min = nearest and mip = none */
  89523. static readonly TEXTURE_NEAREST_NEAREST: number;
  89524. /** mag = linear and min = nearest and mip = nearest */
  89525. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  89526. /** mag = linear and min = nearest and mip = linear */
  89527. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  89528. /** mag = linear and min = linear and mip = none */
  89529. static readonly TEXTURE_LINEAR_LINEAR: number;
  89530. /** mag = linear and min = nearest and mip = none */
  89531. static readonly TEXTURE_LINEAR_NEAREST: number;
  89532. /** Explicit coordinates mode */
  89533. static readonly TEXTURE_EXPLICIT_MODE: number;
  89534. /** Spherical coordinates mode */
  89535. static readonly TEXTURE_SPHERICAL_MODE: number;
  89536. /** Planar coordinates mode */
  89537. static readonly TEXTURE_PLANAR_MODE: number;
  89538. /** Cubic coordinates mode */
  89539. static readonly TEXTURE_CUBIC_MODE: number;
  89540. /** Projection coordinates mode */
  89541. static readonly TEXTURE_PROJECTION_MODE: number;
  89542. /** Skybox coordinates mode */
  89543. static readonly TEXTURE_SKYBOX_MODE: number;
  89544. /** Inverse Cubic coordinates mode */
  89545. static readonly TEXTURE_INVCUBIC_MODE: number;
  89546. /** Equirectangular coordinates mode */
  89547. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  89548. /** Equirectangular Fixed coordinates mode */
  89549. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  89550. /** Equirectangular Fixed Mirrored coordinates mode */
  89551. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  89552. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  89553. static readonly SCALEMODE_FLOOR: number;
  89554. /** Defines that texture rescaling will look for the nearest power of 2 size */
  89555. static readonly SCALEMODE_NEAREST: number;
  89556. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  89557. static readonly SCALEMODE_CEILING: number;
  89558. /**
  89559. * Returns the current npm package of the sdk
  89560. */
  89561. static readonly NpmPackage: string;
  89562. /**
  89563. * Returns the current version of the framework
  89564. */
  89565. static readonly Version: string;
  89566. /**
  89567. * Returns a string describing the current engine
  89568. */
  89569. readonly description: string;
  89570. /**
  89571. * Gets or sets the epsilon value used by collision engine
  89572. */
  89573. static CollisionsEpsilon: number;
  89574. /**
  89575. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  89576. */
  89577. static ShadersRepository: string;
  89578. /**
  89579. * Method called to create the default loading screen.
  89580. * This can be overriden in your own app.
  89581. * @param canvas The rendering canvas element
  89582. * @returns The loading screen
  89583. */
  89584. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  89585. /**
  89586. * Method called to create the default rescale post process on each engine.
  89587. */
  89588. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  89589. /**
  89590. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  89591. */
  89592. forcePOTTextures: boolean;
  89593. /**
  89594. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  89595. */
  89596. isFullscreen: boolean;
  89597. /**
  89598. * Gets a boolean indicating if the pointer is currently locked
  89599. */
  89600. isPointerLock: boolean;
  89601. /**
  89602. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  89603. */
  89604. cullBackFaces: boolean;
  89605. /**
  89606. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  89607. */
  89608. renderEvenInBackground: boolean;
  89609. /**
  89610. * Gets or sets a boolean indicating that cache can be kept between frames
  89611. */
  89612. preventCacheWipeBetweenFrames: boolean;
  89613. /**
  89614. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  89615. **/
  89616. enableOfflineSupport: boolean;
  89617. /**
  89618. * 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)
  89619. **/
  89620. disableManifestCheck: boolean;
  89621. /**
  89622. * Gets the list of created scenes
  89623. */
  89624. scenes: Scene[];
  89625. /**
  89626. * Event raised when a new scene is created
  89627. */
  89628. onNewSceneAddedObservable: Observable<Scene>;
  89629. /**
  89630. * Gets the list of created postprocesses
  89631. */
  89632. postProcesses: PostProcess[];
  89633. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  89634. validateShaderPrograms: boolean;
  89635. /**
  89636. * Observable event triggered each time the rendering canvas is resized
  89637. */
  89638. onResizeObservable: Observable<Engine>;
  89639. /**
  89640. * Observable event triggered each time the canvas loses focus
  89641. */
  89642. onCanvasBlurObservable: Observable<Engine>;
  89643. /**
  89644. * Observable event triggered each time the canvas gains focus
  89645. */
  89646. onCanvasFocusObservable: Observable<Engine>;
  89647. /**
  89648. * Observable event triggered each time the canvas receives pointerout event
  89649. */
  89650. onCanvasPointerOutObservable: Observable<PointerEvent>;
  89651. /**
  89652. * Observable event triggered before each texture is initialized
  89653. */
  89654. onBeforeTextureInitObservable: Observable<Texture>;
  89655. /**
  89656. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  89657. */
  89658. disableUniformBuffers: boolean;
  89659. /** @hidden */
  89660. _uniformBuffers: UniformBuffer[];
  89661. /**
  89662. * Gets a boolean indicating that the engine supports uniform buffers
  89663. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  89664. */
  89665. readonly supportsUniformBuffers: boolean;
  89666. /**
  89667. * Observable raised when the engine begins a new frame
  89668. */
  89669. onBeginFrameObservable: Observable<Engine>;
  89670. /**
  89671. * If set, will be used to request the next animation frame for the render loop
  89672. */
  89673. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  89674. /**
  89675. * Observable raised when the engine ends the current frame
  89676. */
  89677. onEndFrameObservable: Observable<Engine>;
  89678. /**
  89679. * Observable raised when the engine is about to compile a shader
  89680. */
  89681. onBeforeShaderCompilationObservable: Observable<Engine>;
  89682. /**
  89683. * Observable raised when the engine has jsut compiled a shader
  89684. */
  89685. onAfterShaderCompilationObservable: Observable<Engine>;
  89686. /** @hidden */
  89687. _gl: WebGLRenderingContext;
  89688. private _renderingCanvas;
  89689. private _windowIsBackground;
  89690. private _webGLVersion;
  89691. protected _highPrecisionShadersAllowed: boolean;
  89692. /** @hidden */
  89693. readonly _shouldUseHighPrecisionShader: boolean;
  89694. /**
  89695. * Gets a boolean indicating that only power of 2 textures are supported
  89696. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  89697. */
  89698. readonly needPOTTextures: boolean;
  89699. /** @hidden */
  89700. _badOS: boolean;
  89701. /** @hidden */
  89702. _badDesktopOS: boolean;
  89703. /**
  89704. * Gets the audio engine
  89705. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  89706. * @ignorenaming
  89707. */
  89708. static audioEngine: IAudioEngine;
  89709. /**
  89710. * Default AudioEngine factory responsible of creating the Audio Engine.
  89711. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  89712. */
  89713. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  89714. /**
  89715. * Default offline support factory responsible of creating a tool used to store data locally.
  89716. * By default, this will create a Database object if the workload has been embedded.
  89717. */
  89718. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  89719. private _onFocus;
  89720. private _onBlur;
  89721. private _onCanvasPointerOut;
  89722. private _onCanvasBlur;
  89723. private _onCanvasFocus;
  89724. private _onFullscreenChange;
  89725. private _onPointerLockChange;
  89726. private _hardwareScalingLevel;
  89727. /** @hidden */
  89728. _caps: EngineCapabilities;
  89729. private _pointerLockRequested;
  89730. private _isStencilEnable;
  89731. private _colorWrite;
  89732. private _loadingScreen;
  89733. /** @hidden */
  89734. _drawCalls: PerfCounter;
  89735. private _glVersion;
  89736. private _glRenderer;
  89737. private _glVendor;
  89738. private _videoTextureSupported;
  89739. private _renderingQueueLaunched;
  89740. private _activeRenderLoops;
  89741. private _deterministicLockstep;
  89742. private _lockstepMaxSteps;
  89743. /**
  89744. * Observable signaled when a context lost event is raised
  89745. */
  89746. onContextLostObservable: Observable<Engine>;
  89747. /**
  89748. * Observable signaled when a context restored event is raised
  89749. */
  89750. onContextRestoredObservable: Observable<Engine>;
  89751. private _onContextLost;
  89752. private _onContextRestored;
  89753. private _contextWasLost;
  89754. /** @hidden */
  89755. _doNotHandleContextLost: boolean;
  89756. /**
  89757. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  89758. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  89759. */
  89760. doNotHandleContextLost: boolean;
  89761. private _performanceMonitor;
  89762. private _fps;
  89763. private _deltaTime;
  89764. /**
  89765. * Turn this value on if you want to pause FPS computation when in background
  89766. */
  89767. disablePerformanceMonitorInBackground: boolean;
  89768. /**
  89769. * Gets the performance monitor attached to this engine
  89770. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  89771. */
  89772. readonly performanceMonitor: PerformanceMonitor;
  89773. /**
  89774. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  89775. */
  89776. disableVertexArrayObjects: boolean;
  89777. /** @hidden */
  89778. protected _depthCullingState: _DepthCullingState;
  89779. /** @hidden */
  89780. protected _stencilState: _StencilState;
  89781. /** @hidden */
  89782. protected _alphaState: _AlphaState;
  89783. /** @hidden */
  89784. protected _alphaMode: number;
  89785. /** @hidden */
  89786. _internalTexturesCache: InternalTexture[];
  89787. /** @hidden */
  89788. protected _activeChannel: number;
  89789. private _currentTextureChannel;
  89790. /** @hidden */
  89791. protected _boundTexturesCache: {
  89792. [key: string]: Nullable<InternalTexture>;
  89793. };
  89794. /** @hidden */
  89795. protected _currentEffect: Nullable<Effect>;
  89796. /** @hidden */
  89797. protected _currentProgram: Nullable<WebGLProgram>;
  89798. private _compiledEffects;
  89799. private _vertexAttribArraysEnabled;
  89800. /** @hidden */
  89801. protected _cachedViewport: Nullable<Viewport>;
  89802. private _cachedVertexArrayObject;
  89803. /** @hidden */
  89804. protected _cachedVertexBuffers: any;
  89805. /** @hidden */
  89806. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  89807. /** @hidden */
  89808. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  89809. /** @hidden */
  89810. _currentRenderTarget: Nullable<InternalTexture>;
  89811. private _uintIndicesCurrentlySet;
  89812. private _currentBoundBuffer;
  89813. /** @hidden */
  89814. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  89815. private _currentBufferPointers;
  89816. private _currentInstanceLocations;
  89817. private _currentInstanceBuffers;
  89818. private _textureUnits;
  89819. /** @hidden */
  89820. _workingCanvas: Nullable<HTMLCanvasElement>;
  89821. /** @hidden */
  89822. _workingContext: Nullable<CanvasRenderingContext2D>;
  89823. private _rescalePostProcess;
  89824. private _dummyFramebuffer;
  89825. private _externalData;
  89826. /** @hidden */
  89827. _bindedRenderFunction: any;
  89828. private _vaoRecordInProgress;
  89829. private _mustWipeVertexAttributes;
  89830. private _emptyTexture;
  89831. private _emptyCubeTexture;
  89832. private _emptyTexture3D;
  89833. /** @hidden */
  89834. _frameHandler: number;
  89835. private _nextFreeTextureSlots;
  89836. private _maxSimultaneousTextures;
  89837. private _activeRequests;
  89838. private _texturesSupported;
  89839. /** @hidden */
  89840. _textureFormatInUse: Nullable<string>;
  89841. /**
  89842. * Gets the list of texture formats supported
  89843. */
  89844. readonly texturesSupported: Array<string>;
  89845. /**
  89846. * Gets the list of texture formats in use
  89847. */
  89848. readonly textureFormatInUse: Nullable<string>;
  89849. /**
  89850. * Gets the current viewport
  89851. */
  89852. readonly currentViewport: Nullable<Viewport>;
  89853. /**
  89854. * Gets the default empty texture
  89855. */
  89856. readonly emptyTexture: InternalTexture;
  89857. /**
  89858. * Gets the default empty 3D texture
  89859. */
  89860. readonly emptyTexture3D: InternalTexture;
  89861. /**
  89862. * Gets the default empty cube texture
  89863. */
  89864. readonly emptyCubeTexture: InternalTexture;
  89865. /**
  89866. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  89867. */
  89868. readonly premultipliedAlpha: boolean;
  89869. /**
  89870. * Creates a new engine
  89871. * @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
  89872. * @param antialias defines enable antialiasing (default: false)
  89873. * @param options defines further options to be sent to the getContext() function
  89874. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  89875. */
  89876. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  89877. /**
  89878. * Initializes a webVR display and starts listening to display change events
  89879. * The onVRDisplayChangedObservable will be notified upon these changes
  89880. * @returns The onVRDisplayChangedObservable
  89881. */
  89882. initWebVR(): Observable<IDisplayChangedEventArgs>;
  89883. /** @hidden */
  89884. _prepareVRComponent(): void;
  89885. /** @hidden */
  89886. _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  89887. /** @hidden */
  89888. _submitVRFrame(): void;
  89889. /**
  89890. * Call this function to leave webVR mode
  89891. * Will do nothing if webVR is not supported or if there is no webVR device
  89892. * @see http://doc.babylonjs.com/how_to/webvr_camera
  89893. */
  89894. disableVR(): void;
  89895. /**
  89896. * Gets a boolean indicating that the system is in VR mode and is presenting
  89897. * @returns true if VR mode is engaged
  89898. */
  89899. isVRPresenting(): boolean;
  89900. /** @hidden */
  89901. _requestVRFrame(): void;
  89902. private _disableTouchAction;
  89903. private _rebuildInternalTextures;
  89904. private _rebuildEffects;
  89905. /**
  89906. * Gets a boolean indicating if all created effects are ready
  89907. * @returns true if all effects are ready
  89908. */
  89909. areAllEffectsReady(): boolean;
  89910. private _rebuildBuffers;
  89911. private _initGLContext;
  89912. /**
  89913. * Gets version of the current webGL context
  89914. */
  89915. readonly webGLVersion: number;
  89916. /**
  89917. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  89918. */
  89919. readonly isStencilEnable: boolean;
  89920. /** @hidden */
  89921. _prepareWorkingCanvas(): void;
  89922. /**
  89923. * Reset the texture cache to empty state
  89924. */
  89925. resetTextureCache(): void;
  89926. /**
  89927. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  89928. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89929. * @returns true if engine is in deterministic lock step mode
  89930. */
  89931. isDeterministicLockStep(): boolean;
  89932. /**
  89933. * Gets the max steps when engine is running in deterministic lock step
  89934. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  89935. * @returns the max steps
  89936. */
  89937. getLockstepMaxSteps(): number;
  89938. /**
  89939. * Gets an object containing information about the current webGL context
  89940. * @returns an object containing the vender, the renderer and the version of the current webGL context
  89941. */
  89942. getGlInfo(): {
  89943. vendor: string;
  89944. renderer: string;
  89945. version: string;
  89946. };
  89947. /**
  89948. * Gets current aspect ratio
  89949. * @param camera defines the camera to use to get the aspect ratio
  89950. * @param useScreen defines if screen size must be used (or the current render target if any)
  89951. * @returns a number defining the aspect ratio
  89952. */
  89953. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  89954. /**
  89955. * Gets current screen aspect ratio
  89956. * @returns a number defining the aspect ratio
  89957. */
  89958. getScreenAspectRatio(): number;
  89959. /**
  89960. * Gets the current render width
  89961. * @param useScreen defines if screen size must be used (or the current render target if any)
  89962. * @returns a number defining the current render width
  89963. */
  89964. getRenderWidth(useScreen?: boolean): number;
  89965. /**
  89966. * Gets the current render height
  89967. * @param useScreen defines if screen size must be used (or the current render target if any)
  89968. * @returns a number defining the current render height
  89969. */
  89970. getRenderHeight(useScreen?: boolean): number;
  89971. /**
  89972. * Gets the HTML canvas attached with the current webGL context
  89973. * @returns a HTML canvas
  89974. */
  89975. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  89976. /**
  89977. * Gets the client rect of the HTML canvas attached with the current webGL context
  89978. * @returns a client rectanglee
  89979. */
  89980. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  89981. /**
  89982. * Defines the hardware scaling level.
  89983. * By default the hardware scaling level is computed from the window device ratio.
  89984. * 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.
  89985. * @param level defines the level to use
  89986. */
  89987. setHardwareScalingLevel(level: number): void;
  89988. /**
  89989. * Gets the current hardware scaling level.
  89990. * By default the hardware scaling level is computed from the window device ratio.
  89991. * 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.
  89992. * @returns a number indicating the current hardware scaling level
  89993. */
  89994. getHardwareScalingLevel(): number;
  89995. /**
  89996. * Gets the list of loaded textures
  89997. * @returns an array containing all loaded textures
  89998. */
  89999. getLoadedTexturesCache(): InternalTexture[];
  90000. /**
  90001. * Gets the object containing all engine capabilities
  90002. * @returns the EngineCapabilities object
  90003. */
  90004. getCaps(): EngineCapabilities;
  90005. /**
  90006. * Gets the current depth function
  90007. * @returns a number defining the depth function
  90008. */
  90009. getDepthFunction(): Nullable<number>;
  90010. /**
  90011. * Sets the current depth function
  90012. * @param depthFunc defines the function to use
  90013. */
  90014. setDepthFunction(depthFunc: number): void;
  90015. /**
  90016. * Sets the current depth function to GREATER
  90017. */
  90018. setDepthFunctionToGreater(): void;
  90019. /**
  90020. * Sets the current depth function to GEQUAL
  90021. */
  90022. setDepthFunctionToGreaterOrEqual(): void;
  90023. /**
  90024. * Sets the current depth function to LESS
  90025. */
  90026. setDepthFunctionToLess(): void;
  90027. private _cachedStencilBuffer;
  90028. private _cachedStencilFunction;
  90029. private _cachedStencilMask;
  90030. private _cachedStencilOperationPass;
  90031. private _cachedStencilOperationFail;
  90032. private _cachedStencilOperationDepthFail;
  90033. private _cachedStencilReference;
  90034. /**
  90035. * Caches the the state of the stencil buffer
  90036. */
  90037. cacheStencilState(): void;
  90038. /**
  90039. * Restores the state of the stencil buffer
  90040. */
  90041. restoreStencilState(): void;
  90042. /**
  90043. * Sets the current depth function to LEQUAL
  90044. */
  90045. setDepthFunctionToLessOrEqual(): void;
  90046. /**
  90047. * Gets a boolean indicating if stencil buffer is enabled
  90048. * @returns the current stencil buffer state
  90049. */
  90050. getStencilBuffer(): boolean;
  90051. /**
  90052. * Enable or disable the stencil buffer
  90053. * @param enable defines if the stencil buffer must be enabled or disabled
  90054. */
  90055. setStencilBuffer(enable: boolean): void;
  90056. /**
  90057. * Gets the current stencil mask
  90058. * @returns a number defining the new stencil mask to use
  90059. */
  90060. getStencilMask(): number;
  90061. /**
  90062. * Sets the current stencil mask
  90063. * @param mask defines the new stencil mask to use
  90064. */
  90065. setStencilMask(mask: number): void;
  90066. /**
  90067. * Gets the current stencil function
  90068. * @returns a number defining the stencil function to use
  90069. */
  90070. getStencilFunction(): number;
  90071. /**
  90072. * Gets the current stencil reference value
  90073. * @returns a number defining the stencil reference value to use
  90074. */
  90075. getStencilFunctionReference(): number;
  90076. /**
  90077. * Gets the current stencil mask
  90078. * @returns a number defining the stencil mask to use
  90079. */
  90080. getStencilFunctionMask(): number;
  90081. /**
  90082. * Sets the current stencil function
  90083. * @param stencilFunc defines the new stencil function to use
  90084. */
  90085. setStencilFunction(stencilFunc: number): void;
  90086. /**
  90087. * Sets the current stencil reference
  90088. * @param reference defines the new stencil reference to use
  90089. */
  90090. setStencilFunctionReference(reference: number): void;
  90091. /**
  90092. * Sets the current stencil mask
  90093. * @param mask defines the new stencil mask to use
  90094. */
  90095. setStencilFunctionMask(mask: number): void;
  90096. /**
  90097. * Gets the current stencil operation when stencil fails
  90098. * @returns a number defining stencil operation to use when stencil fails
  90099. */
  90100. getStencilOperationFail(): number;
  90101. /**
  90102. * Gets the current stencil operation when depth fails
  90103. * @returns a number defining stencil operation to use when depth fails
  90104. */
  90105. getStencilOperationDepthFail(): number;
  90106. /**
  90107. * Gets the current stencil operation when stencil passes
  90108. * @returns a number defining stencil operation to use when stencil passes
  90109. */
  90110. getStencilOperationPass(): number;
  90111. /**
  90112. * Sets the stencil operation to use when stencil fails
  90113. * @param operation defines the stencil operation to use when stencil fails
  90114. */
  90115. setStencilOperationFail(operation: number): void;
  90116. /**
  90117. * Sets the stencil operation to use when depth fails
  90118. * @param operation defines the stencil operation to use when depth fails
  90119. */
  90120. setStencilOperationDepthFail(operation: number): void;
  90121. /**
  90122. * Sets the stencil operation to use when stencil passes
  90123. * @param operation defines the stencil operation to use when stencil passes
  90124. */
  90125. setStencilOperationPass(operation: number): void;
  90126. /**
  90127. * Sets a boolean indicating if the dithering state is enabled or disabled
  90128. * @param value defines the dithering state
  90129. */
  90130. setDitheringState(value: boolean): void;
  90131. /**
  90132. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  90133. * @param value defines the rasterizer state
  90134. */
  90135. setRasterizerState(value: boolean): void;
  90136. /**
  90137. * stop executing a render loop function and remove it from the execution array
  90138. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  90139. */
  90140. stopRenderLoop(renderFunction?: () => void): void;
  90141. /** @hidden */
  90142. _renderLoop(): void;
  90143. /**
  90144. * Register and execute a render loop. The engine can have more than one render function
  90145. * @param renderFunction defines the function to continuously execute
  90146. */
  90147. runRenderLoop(renderFunction: () => void): void;
  90148. /**
  90149. * Toggle full screen mode
  90150. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90151. */
  90152. switchFullscreen(requestPointerLock: boolean): void;
  90153. /**
  90154. * Enters full screen mode
  90155. * @param requestPointerLock defines if a pointer lock should be requested from the user
  90156. */
  90157. enterFullscreen(requestPointerLock: boolean): void;
  90158. /**
  90159. * Exits full screen mode
  90160. */
  90161. exitFullscreen(): void;
  90162. /**
  90163. * Clear the current render buffer or the current render target (if any is set up)
  90164. * @param color defines the color to use
  90165. * @param backBuffer defines if the back buffer must be cleared
  90166. * @param depth defines if the depth buffer must be cleared
  90167. * @param stencil defines if the stencil buffer must be cleared
  90168. */
  90169. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  90170. /**
  90171. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  90172. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90173. * @param y defines the y-coordinate of the corner of the clear rectangle
  90174. * @param width defines the width of the clear rectangle
  90175. * @param height defines the height of the clear rectangle
  90176. * @param clearColor defines the clear color
  90177. */
  90178. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  90179. /**
  90180. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  90181. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  90182. * @param y defines the y-coordinate of the corner of the clear rectangle
  90183. * @param width defines the width of the clear rectangle
  90184. * @param height defines the height of the clear rectangle
  90185. */
  90186. enableScissor(x: number, y: number, width: number, height: number): void;
  90187. /**
  90188. * Disable previously set scissor test rectangle
  90189. */
  90190. disableScissor(): void;
  90191. private _viewportCached;
  90192. /** @hidden */
  90193. _viewport(x: number, y: number, width: number, height: number): void;
  90194. /**
  90195. * Set the WebGL's viewport
  90196. * @param viewport defines the viewport element to be used
  90197. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  90198. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  90199. */
  90200. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  90201. /**
  90202. * Directly set the WebGL Viewport
  90203. * @param x defines the x coordinate of the viewport (in screen space)
  90204. * @param y defines the y coordinate of the viewport (in screen space)
  90205. * @param width defines the width of the viewport (in screen space)
  90206. * @param height defines the height of the viewport (in screen space)
  90207. * @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
  90208. */
  90209. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  90210. /**
  90211. * Begin a new frame
  90212. */
  90213. beginFrame(): void;
  90214. /**
  90215. * Enf the current frame
  90216. */
  90217. endFrame(): void;
  90218. /**
  90219. * Resize the view according to the canvas' size
  90220. */
  90221. resize(): void;
  90222. /**
  90223. * Force a specific size of the canvas
  90224. * @param width defines the new canvas' width
  90225. * @param height defines the new canvas' height
  90226. */
  90227. setSize(width: number, height: number): void;
  90228. /**
  90229. * Binds the frame buffer to the specified texture.
  90230. * @param texture The texture to render to or null for the default canvas
  90231. * @param faceIndex The face of the texture to render to in case of cube texture
  90232. * @param requiredWidth The width of the target to render to
  90233. * @param requiredHeight The height of the target to render to
  90234. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  90235. * @param depthStencilTexture The depth stencil texture to use to render
  90236. * @param lodLevel defines le lod level to bind to the frame buffer
  90237. */
  90238. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  90239. /** @hidden */
  90240. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  90241. /**
  90242. * Unbind the current render target texture from the webGL context
  90243. * @param texture defines the render target texture to unbind
  90244. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  90245. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  90246. */
  90247. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  90248. /**
  90249. * Force the mipmap generation for the given render target texture
  90250. * @param texture defines the render target texture to use
  90251. */
  90252. generateMipMapsForCubemap(texture: InternalTexture): void;
  90253. /**
  90254. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  90255. */
  90256. flushFramebuffer(): void;
  90257. /**
  90258. * Unbind the current render target and bind the default framebuffer
  90259. */
  90260. restoreDefaultFramebuffer(): void;
  90261. /**
  90262. * Create an uniform buffer
  90263. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90264. * @param elements defines the content of the uniform buffer
  90265. * @returns the webGL uniform buffer
  90266. */
  90267. createUniformBuffer(elements: FloatArray): DataBuffer;
  90268. /**
  90269. * Create a dynamic uniform buffer
  90270. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90271. * @param elements defines the content of the uniform buffer
  90272. * @returns the webGL uniform buffer
  90273. */
  90274. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  90275. /**
  90276. * Update an existing uniform buffer
  90277. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  90278. * @param uniformBuffer defines the target uniform buffer
  90279. * @param elements defines the content to update
  90280. * @param offset defines the offset in the uniform buffer where update should start
  90281. * @param count defines the size of the data to update
  90282. */
  90283. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  90284. private _resetVertexBufferBinding;
  90285. /**
  90286. * Creates a vertex buffer
  90287. * @param data the data for the vertex buffer
  90288. * @returns the new WebGL static buffer
  90289. */
  90290. createVertexBuffer(data: DataArray): DataBuffer;
  90291. /**
  90292. * Creates a dynamic vertex buffer
  90293. * @param data the data for the dynamic vertex buffer
  90294. * @returns the new WebGL dynamic buffer
  90295. */
  90296. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  90297. /**
  90298. * Update a dynamic index buffer
  90299. * @param indexBuffer defines the target index buffer
  90300. * @param indices defines the data to update
  90301. * @param offset defines the offset in the target index buffer where update should start
  90302. */
  90303. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  90304. /**
  90305. * Updates a dynamic vertex buffer.
  90306. * @param vertexBuffer the vertex buffer to update
  90307. * @param data the data used to update the vertex buffer
  90308. * @param byteOffset the byte offset of the data
  90309. * @param byteLength the byte length of the data
  90310. */
  90311. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  90312. private _resetIndexBufferBinding;
  90313. /**
  90314. * Creates a new index buffer
  90315. * @param indices defines the content of the index buffer
  90316. * @param updatable defines if the index buffer must be updatable
  90317. * @returns a new webGL buffer
  90318. */
  90319. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  90320. /**
  90321. * Bind a webGL buffer to the webGL context
  90322. * @param buffer defines the buffer to bind
  90323. */
  90324. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  90325. /**
  90326. * Bind an uniform buffer to the current webGL context
  90327. * @param buffer defines the buffer to bind
  90328. */
  90329. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  90330. /**
  90331. * Bind a buffer to the current webGL context at a given location
  90332. * @param buffer defines the buffer to bind
  90333. * @param location defines the index where to bind the buffer
  90334. */
  90335. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  90336. /**
  90337. * Bind a specific block at a given index in a specific shader program
  90338. * @param pipelineContext defines the pipeline context to use
  90339. * @param blockName defines the block name
  90340. * @param index defines the index where to bind the block
  90341. */
  90342. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  90343. private bindIndexBuffer;
  90344. private bindBuffer;
  90345. /**
  90346. * update the bound buffer with the given data
  90347. * @param data defines the data to update
  90348. */
  90349. updateArrayBuffer(data: Float32Array): void;
  90350. private _vertexAttribPointer;
  90351. private _bindIndexBufferWithCache;
  90352. private _bindVertexBuffersAttributes;
  90353. /**
  90354. * Records a vertex array object
  90355. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90356. * @param vertexBuffers defines the list of vertex buffers to store
  90357. * @param indexBuffer defines the index buffer to store
  90358. * @param effect defines the effect to store
  90359. * @returns the new vertex array object
  90360. */
  90361. recordVertexArrayObject(vertexBuffers: {
  90362. [key: string]: VertexBuffer;
  90363. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  90364. /**
  90365. * Bind a specific vertex array object
  90366. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  90367. * @param vertexArrayObject defines the vertex array object to bind
  90368. * @param indexBuffer defines the index buffer to bind
  90369. */
  90370. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  90371. /**
  90372. * Bind webGl buffers directly to the webGL context
  90373. * @param vertexBuffer defines the vertex buffer to bind
  90374. * @param indexBuffer defines the index buffer to bind
  90375. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  90376. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  90377. * @param effect defines the effect associated with the vertex buffer
  90378. */
  90379. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  90380. private _unbindVertexArrayObject;
  90381. /**
  90382. * Bind a list of vertex buffers to the webGL context
  90383. * @param vertexBuffers defines the list of vertex buffers to bind
  90384. * @param indexBuffer defines the index buffer to bind
  90385. * @param effect defines the effect associated with the vertex buffers
  90386. */
  90387. bindBuffers(vertexBuffers: {
  90388. [key: string]: Nullable<VertexBuffer>;
  90389. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  90390. /**
  90391. * Unbind all instance attributes
  90392. */
  90393. unbindInstanceAttributes(): void;
  90394. /**
  90395. * Release and free the memory of a vertex array object
  90396. * @param vao defines the vertex array object to delete
  90397. */
  90398. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  90399. /** @hidden */
  90400. _releaseBuffer(buffer: DataBuffer): boolean;
  90401. /**
  90402. * Creates a webGL buffer to use with instanciation
  90403. * @param capacity defines the size of the buffer
  90404. * @returns the webGL buffer
  90405. */
  90406. createInstancesBuffer(capacity: number): DataBuffer;
  90407. /**
  90408. * Delete a webGL buffer used with instanciation
  90409. * @param buffer defines the webGL buffer to delete
  90410. */
  90411. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  90412. /**
  90413. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  90414. * @param instancesBuffer defines the webGL buffer to update and bind
  90415. * @param data defines the data to store in the buffer
  90416. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  90417. */
  90418. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  90419. /**
  90420. * Apply all cached states (depth, culling, stencil and alpha)
  90421. */
  90422. applyStates(): void;
  90423. /**
  90424. * Send a draw order
  90425. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90426. * @param indexStart defines the starting index
  90427. * @param indexCount defines the number of index to draw
  90428. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90429. */
  90430. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  90431. /**
  90432. * Draw a list of points
  90433. * @param verticesStart defines the index of first vertex to draw
  90434. * @param verticesCount defines the count of vertices to draw
  90435. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90436. */
  90437. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90438. /**
  90439. * Draw a list of unindexed primitives
  90440. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  90441. * @param verticesStart defines the index of first vertex to draw
  90442. * @param verticesCount defines the count of vertices to draw
  90443. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90444. */
  90445. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90446. /**
  90447. * Draw a list of indexed primitives
  90448. * @param fillMode defines the primitive to use
  90449. * @param indexStart defines the starting index
  90450. * @param indexCount defines the number of index to draw
  90451. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90452. */
  90453. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  90454. /**
  90455. * Draw a list of unindexed primitives
  90456. * @param fillMode defines the primitive to use
  90457. * @param verticesStart defines the index of first vertex to draw
  90458. * @param verticesCount defines the count of vertices to draw
  90459. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  90460. */
  90461. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  90462. private _drawMode;
  90463. /** @hidden */
  90464. _releaseEffect(effect: Effect): void;
  90465. /** @hidden */
  90466. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  90467. /**
  90468. * Create a new effect (used to store vertex/fragment shaders)
  90469. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  90470. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  90471. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  90472. * @param samplers defines an array of string used to represent textures
  90473. * @param defines defines the string containing the defines to use to compile the shaders
  90474. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  90475. * @param onCompiled defines a function to call when the effect creation is successful
  90476. * @param onError defines a function to call when the effect creation has failed
  90477. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  90478. * @returns the new Effect
  90479. */
  90480. 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;
  90481. private _compileShader;
  90482. private _compileRawShader;
  90483. /**
  90484. * Directly creates a webGL program
  90485. * @param pipelineContext defines the pipeline context to attach to
  90486. * @param vertexCode defines the vertex shader code to use
  90487. * @param fragmentCode defines the fragment shader code to use
  90488. * @param context defines the webGL context to use (if not set, the current one will be used)
  90489. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90490. * @returns the new webGL program
  90491. */
  90492. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90493. /**
  90494. * Creates a webGL program
  90495. * @param pipelineContext defines the pipeline context to attach to
  90496. * @param vertexCode defines the vertex shader code to use
  90497. * @param fragmentCode defines the fragment shader code to use
  90498. * @param defines defines the string containing the defines to use to compile the shaders
  90499. * @param context defines the webGL context to use (if not set, the current one will be used)
  90500. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  90501. * @returns the new webGL program
  90502. */
  90503. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  90504. /**
  90505. * Creates a new pipeline context
  90506. * @returns the new pipeline
  90507. */
  90508. createPipelineContext(): WebGLPipelineContext;
  90509. private _createShaderProgram;
  90510. private _finalizePipelineContext;
  90511. /** @hidden */
  90512. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  90513. /** @hidden */
  90514. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  90515. /** @hidden */
  90516. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  90517. /**
  90518. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  90519. * @param pipelineContext defines the pipeline context to use
  90520. * @param uniformsNames defines the list of uniform names
  90521. * @returns an array of webGL uniform locations
  90522. */
  90523. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  90524. /**
  90525. * Gets the lsit of active attributes for a given webGL program
  90526. * @param pipelineContext defines the pipeline context to use
  90527. * @param attributesNames defines the list of attribute names to get
  90528. * @returns an array of indices indicating the offset of each attribute
  90529. */
  90530. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  90531. /**
  90532. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  90533. * @param effect defines the effect to activate
  90534. */
  90535. enableEffect(effect: Nullable<Effect>): void;
  90536. /**
  90537. * Set the value of an uniform to an array of int32
  90538. * @param uniform defines the webGL uniform location where to store the value
  90539. * @param array defines the array of int32 to store
  90540. */
  90541. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90542. /**
  90543. * Set the value of an uniform to an array of int32 (stored as vec2)
  90544. * @param uniform defines the webGL uniform location where to store the value
  90545. * @param array defines the array of int32 to store
  90546. */
  90547. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90548. /**
  90549. * Set the value of an uniform to an array of int32 (stored as vec3)
  90550. * @param uniform defines the webGL uniform location where to store the value
  90551. * @param array defines the array of int32 to store
  90552. */
  90553. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90554. /**
  90555. * Set the value of an uniform to an array of int32 (stored as vec4)
  90556. * @param uniform defines the webGL uniform location where to store the value
  90557. * @param array defines the array of int32 to store
  90558. */
  90559. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  90560. /**
  90561. * Set the value of an uniform to an array of float32
  90562. * @param uniform defines the webGL uniform location where to store the value
  90563. * @param array defines the array of float32 to store
  90564. */
  90565. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90566. /**
  90567. * Set the value of an uniform to an array of float32 (stored as vec2)
  90568. * @param uniform defines the webGL uniform location where to store the value
  90569. * @param array defines the array of float32 to store
  90570. */
  90571. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90572. /**
  90573. * Set the value of an uniform to an array of float32 (stored as vec3)
  90574. * @param uniform defines the webGL uniform location where to store the value
  90575. * @param array defines the array of float32 to store
  90576. */
  90577. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90578. /**
  90579. * Set the value of an uniform to an array of float32 (stored as vec4)
  90580. * @param uniform defines the webGL uniform location where to store the value
  90581. * @param array defines the array of float32 to store
  90582. */
  90583. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  90584. /**
  90585. * Set the value of an uniform to an array of number
  90586. * @param uniform defines the webGL uniform location where to store the value
  90587. * @param array defines the array of number to store
  90588. */
  90589. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90590. /**
  90591. * Set the value of an uniform to an array of number (stored as vec2)
  90592. * @param uniform defines the webGL uniform location where to store the value
  90593. * @param array defines the array of number to store
  90594. */
  90595. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90596. /**
  90597. * Set the value of an uniform to an array of number (stored as vec3)
  90598. * @param uniform defines the webGL uniform location where to store the value
  90599. * @param array defines the array of number to store
  90600. */
  90601. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90602. /**
  90603. * Set the value of an uniform to an array of number (stored as vec4)
  90604. * @param uniform defines the webGL uniform location where to store the value
  90605. * @param array defines the array of number to store
  90606. */
  90607. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  90608. /**
  90609. * Set the value of an uniform to an array of float32 (stored as matrices)
  90610. * @param uniform defines the webGL uniform location where to store the value
  90611. * @param matrices defines the array of float32 to store
  90612. */
  90613. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  90614. /**
  90615. * Set the value of an uniform to a matrix
  90616. * @param uniform defines the webGL uniform location where to store the value
  90617. * @param matrix defines the matrix to store
  90618. */
  90619. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  90620. /**
  90621. * Set the value of an uniform to a matrix (3x3)
  90622. * @param uniform defines the webGL uniform location where to store the value
  90623. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  90624. */
  90625. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  90626. /**
  90627. * Set the value of an uniform to a matrix (2x2)
  90628. * @param uniform defines the webGL uniform location where to store the value
  90629. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  90630. */
  90631. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  90632. /**
  90633. * Set the value of an uniform to a number (int)
  90634. * @param uniform defines the webGL uniform location where to store the value
  90635. * @param value defines the int number to store
  90636. */
  90637. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  90638. /**
  90639. * Set the value of an uniform to a number (float)
  90640. * @param uniform defines the webGL uniform location where to store the value
  90641. * @param value defines the float number to store
  90642. */
  90643. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  90644. /**
  90645. * Set the value of an uniform to a vec2
  90646. * @param uniform defines the webGL uniform location where to store the value
  90647. * @param x defines the 1st component of the value
  90648. * @param y defines the 2nd component of the value
  90649. */
  90650. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  90651. /**
  90652. * Set the value of an uniform to a vec3
  90653. * @param uniform defines the webGL uniform location where to store the value
  90654. * @param x defines the 1st component of the value
  90655. * @param y defines the 2nd component of the value
  90656. * @param z defines the 3rd component of the value
  90657. */
  90658. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  90659. /**
  90660. * Set the value of an uniform to a boolean
  90661. * @param uniform defines the webGL uniform location where to store the value
  90662. * @param bool defines the boolean to store
  90663. */
  90664. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  90665. /**
  90666. * Set the value of an uniform to a vec4
  90667. * @param uniform defines the webGL uniform location where to store the value
  90668. * @param x defines the 1st component of the value
  90669. * @param y defines the 2nd component of the value
  90670. * @param z defines the 3rd component of the value
  90671. * @param w defines the 4th component of the value
  90672. */
  90673. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  90674. /**
  90675. * Set the value of an uniform to a Color3
  90676. * @param uniform defines the webGL uniform location where to store the value
  90677. * @param color3 defines the color to store
  90678. */
  90679. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  90680. /**
  90681. * Set the value of an uniform to a Color3 and an alpha value
  90682. * @param uniform defines the webGL uniform location where to store the value
  90683. * @param color3 defines the color to store
  90684. * @param alpha defines the alpha component to store
  90685. */
  90686. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  90687. /**
  90688. * Sets a Color4 on a uniform variable
  90689. * @param uniform defines the uniform location
  90690. * @param color4 defines the value to be set
  90691. */
  90692. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  90693. /**
  90694. * Set various states to the webGL context
  90695. * @param culling defines backface culling state
  90696. * @param zOffset defines the value to apply to zOffset (0 by default)
  90697. * @param force defines if states must be applied even if cache is up to date
  90698. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  90699. */
  90700. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  90701. /**
  90702. * Set the z offset to apply to current rendering
  90703. * @param value defines the offset to apply
  90704. */
  90705. setZOffset(value: number): void;
  90706. /**
  90707. * Gets the current value of the zOffset
  90708. * @returns the current zOffset state
  90709. */
  90710. getZOffset(): number;
  90711. /**
  90712. * Enable or disable depth buffering
  90713. * @param enable defines the state to set
  90714. */
  90715. setDepthBuffer(enable: boolean): void;
  90716. /**
  90717. * Gets a boolean indicating if depth writing is enabled
  90718. * @returns the current depth writing state
  90719. */
  90720. getDepthWrite(): boolean;
  90721. /**
  90722. * Enable or disable depth writing
  90723. * @param enable defines the state to set
  90724. */
  90725. setDepthWrite(enable: boolean): void;
  90726. /**
  90727. * Enable or disable color writing
  90728. * @param enable defines the state to set
  90729. */
  90730. setColorWrite(enable: boolean): void;
  90731. /**
  90732. * Gets a boolean indicating if color writing is enabled
  90733. * @returns the current color writing state
  90734. */
  90735. getColorWrite(): boolean;
  90736. /**
  90737. * Sets alpha constants used by some alpha blending modes
  90738. * @param r defines the red component
  90739. * @param g defines the green component
  90740. * @param b defines the blue component
  90741. * @param a defines the alpha component
  90742. */
  90743. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  90744. /**
  90745. * Sets the current alpha mode
  90746. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  90747. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  90748. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  90749. */
  90750. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  90751. /**
  90752. * Gets the current alpha mode
  90753. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  90754. * @returns the current alpha mode
  90755. */
  90756. getAlphaMode(): number;
  90757. /**
  90758. * Clears the list of texture accessible through engine.
  90759. * This can help preventing texture load conflict due to name collision.
  90760. */
  90761. clearInternalTexturesCache(): void;
  90762. /**
  90763. * Force the entire cache to be cleared
  90764. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  90765. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  90766. */
  90767. wipeCaches(bruteForce?: boolean): void;
  90768. /**
  90769. * Set the compressed texture format to use, based on the formats you have, and the formats
  90770. * supported by the hardware / browser.
  90771. *
  90772. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  90773. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  90774. * to API arguments needed to compressed textures. This puts the burden on the container
  90775. * generator to house the arcane code for determining these for current & future formats.
  90776. *
  90777. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  90778. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  90779. *
  90780. * Note: The result of this call is not taken into account when a texture is base64.
  90781. *
  90782. * @param formatsAvailable defines the list of those format families you have created
  90783. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  90784. *
  90785. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  90786. * @returns The extension selected.
  90787. */
  90788. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  90789. /** @hidden */
  90790. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  90791. min: number;
  90792. mag: number;
  90793. };
  90794. /** @hidden */
  90795. _createTexture(): WebGLTexture;
  90796. /**
  90797. * Usually called from Texture.ts.
  90798. * Passed information to create a WebGLTexture
  90799. * @param urlArg defines a value which contains one of the following:
  90800. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  90801. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  90802. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  90803. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  90804. * @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)
  90805. * @param scene needed for loading to the correct scene
  90806. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  90807. * @param onLoad optional callback to be called upon successful completion
  90808. * @param onError optional callback to be called upon failure
  90809. * @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
  90810. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  90811. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  90812. * @param forcedExtension defines the extension to use to pick the right loader
  90813. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  90814. * @returns a InternalTexture for assignment back into BABYLON.Texture
  90815. */
  90816. 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;
  90817. private _rescaleTexture;
  90818. private _unpackFlipYCached;
  90819. /**
  90820. * In case you are sharing the context with other applications, it might
  90821. * be interested to not cache the unpack flip y state to ensure a consistent
  90822. * value would be set.
  90823. */
  90824. enableUnpackFlipYCached: boolean;
  90825. /** @hidden */
  90826. _unpackFlipY(value: boolean): void;
  90827. /** @hidden */
  90828. _getUnpackAlignement(): number;
  90829. /**
  90830. * Creates a dynamic texture
  90831. * @param width defines the width of the texture
  90832. * @param height defines the height of the texture
  90833. * @param generateMipMaps defines if the engine should generate the mip levels
  90834. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  90835. * @returns the dynamic texture inside an InternalTexture
  90836. */
  90837. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  90838. /**
  90839. * Update the sampling mode of a given texture
  90840. * @param samplingMode defines the required sampling mode
  90841. * @param texture defines the texture to update
  90842. */
  90843. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  90844. /**
  90845. * Update the content of a dynamic texture
  90846. * @param texture defines the texture to update
  90847. * @param canvas defines the canvas containing the source
  90848. * @param invertY defines if data must be stored with Y axis inverted
  90849. * @param premulAlpha defines if alpha is stored as premultiplied
  90850. * @param format defines the format of the data
  90851. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  90852. */
  90853. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  90854. /**
  90855. * Update a video texture
  90856. * @param texture defines the texture to update
  90857. * @param video defines the video element to use
  90858. * @param invertY defines if data must be stored with Y axis inverted
  90859. */
  90860. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  90861. /**
  90862. * Updates a depth texture Comparison Mode and Function.
  90863. * If the comparison Function is equal to 0, the mode will be set to none.
  90864. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  90865. * @param texture The texture to set the comparison function for
  90866. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  90867. */
  90868. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  90869. /** @hidden */
  90870. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  90871. width: number;
  90872. height: number;
  90873. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  90874. /**
  90875. * Creates a depth stencil texture.
  90876. * This is only available in WebGL 2 or with the depth texture extension available.
  90877. * @param size The size of face edge in the texture.
  90878. * @param options The options defining the texture.
  90879. * @returns The texture
  90880. */
  90881. createDepthStencilTexture(size: number | {
  90882. width: number;
  90883. height: number;
  90884. }, options: DepthTextureCreationOptions): InternalTexture;
  90885. /**
  90886. * Creates a depth stencil texture.
  90887. * This is only available in WebGL 2 or with the depth texture extension available.
  90888. * @param size The size of face edge in the texture.
  90889. * @param options The options defining the texture.
  90890. * @returns The texture
  90891. */
  90892. private _createDepthStencilTexture;
  90893. /**
  90894. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  90895. * @param renderTarget The render target to set the frame buffer for
  90896. */
  90897. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  90898. /**
  90899. * Creates a new render target texture
  90900. * @param size defines the size of the texture
  90901. * @param options defines the options used to create the texture
  90902. * @returns a new render target texture stored in an InternalTexture
  90903. */
  90904. createRenderTargetTexture(size: number | {
  90905. width: number;
  90906. height: number;
  90907. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  90908. /** @hidden */
  90909. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  90910. /**
  90911. * Updates the sample count of a render target texture
  90912. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  90913. * @param texture defines the texture to update
  90914. * @param samples defines the sample count to set
  90915. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  90916. */
  90917. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  90918. /** @hidden */
  90919. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  90920. /** @hidden */
  90921. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  90922. /** @hidden */
  90923. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  90924. /** @hidden */
  90925. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  90926. /**
  90927. * @hidden
  90928. */
  90929. _setCubeMapTextureParams(loadMipmap: boolean): void;
  90930. private _prepareWebGLTextureContinuation;
  90931. private _prepareWebGLTexture;
  90932. /** @hidden */
  90933. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  90934. /** @hidden */
  90935. _releaseFramebufferObjects(texture: InternalTexture): void;
  90936. /** @hidden */
  90937. _releaseTexture(texture: InternalTexture): void;
  90938. private setProgram;
  90939. private _boundUniforms;
  90940. /**
  90941. * Binds an effect to the webGL context
  90942. * @param effect defines the effect to bind
  90943. */
  90944. bindSamplers(effect: Effect): void;
  90945. private _activateCurrentTexture;
  90946. /** @hidden */
  90947. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  90948. /** @hidden */
  90949. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  90950. /**
  90951. * Sets a texture to the webGL context from a postprocess
  90952. * @param channel defines the channel to use
  90953. * @param postProcess defines the source postprocess
  90954. */
  90955. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  90956. /**
  90957. * Binds the output of the passed in post process to the texture channel specified
  90958. * @param channel The channel the texture should be bound to
  90959. * @param postProcess The post process which's output should be bound
  90960. */
  90961. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  90962. /**
  90963. * Unbind all textures from the webGL context
  90964. */
  90965. unbindAllTextures(): void;
  90966. /**
  90967. * Sets a texture to the according uniform.
  90968. * @param channel The texture channel
  90969. * @param uniform The uniform to set
  90970. * @param texture The texture to apply
  90971. */
  90972. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  90973. /**
  90974. * Sets a depth stencil texture from a render target to the according uniform.
  90975. * @param channel The texture channel
  90976. * @param uniform The uniform to set
  90977. * @param texture The render target texture containing the depth stencil texture to apply
  90978. */
  90979. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  90980. private _bindSamplerUniformToChannel;
  90981. private _getTextureWrapMode;
  90982. private _setTexture;
  90983. /**
  90984. * Sets an array of texture to the webGL context
  90985. * @param channel defines the channel where the texture array must be set
  90986. * @param uniform defines the associated uniform location
  90987. * @param textures defines the array of textures to bind
  90988. */
  90989. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  90990. /** @hidden */
  90991. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  90992. private _setTextureParameterFloat;
  90993. private _setTextureParameterInteger;
  90994. /**
  90995. * Reads pixels from the current frame buffer. Please note that this function can be slow
  90996. * @param x defines the x coordinate of the rectangle where pixels must be read
  90997. * @param y defines the y coordinate of the rectangle where pixels must be read
  90998. * @param width defines the width of the rectangle where pixels must be read
  90999. * @param height defines the height of the rectangle where pixels must be read
  91000. * @returns a Uint8Array containing RGBA colors
  91001. */
  91002. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  91003. /**
  91004. * Add an externaly attached data from its key.
  91005. * This method call will fail and return false, if such key already exists.
  91006. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  91007. * @param key the unique key that identifies the data
  91008. * @param data the data object to associate to the key for this Engine instance
  91009. * @return true if no such key were already present and the data was added successfully, false otherwise
  91010. */
  91011. addExternalData<T>(key: string, data: T): boolean;
  91012. /**
  91013. * Get an externaly attached data from its key
  91014. * @param key the unique key that identifies the data
  91015. * @return the associated data, if present (can be null), or undefined if not present
  91016. */
  91017. getExternalData<T>(key: string): T;
  91018. /**
  91019. * Get an externaly attached data from its key, create it using a factory if it's not already present
  91020. * @param key the unique key that identifies the data
  91021. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  91022. * @return the associated data, can be null if the factory returned null.
  91023. */
  91024. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  91025. /**
  91026. * Remove an externaly attached data from the Engine instance
  91027. * @param key the unique key that identifies the data
  91028. * @return true if the data was successfully removed, false if it doesn't exist
  91029. */
  91030. removeExternalData(key: string): boolean;
  91031. /**
  91032. * Unbind all vertex attributes from the webGL context
  91033. */
  91034. unbindAllAttributes(): void;
  91035. /**
  91036. * 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
  91037. */
  91038. releaseEffects(): void;
  91039. /**
  91040. * Dispose and release all associated resources
  91041. */
  91042. dispose(): void;
  91043. /**
  91044. * Display the loading screen
  91045. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91046. */
  91047. displayLoadingUI(): void;
  91048. /**
  91049. * Hide the loading screen
  91050. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91051. */
  91052. hideLoadingUI(): void;
  91053. /**
  91054. * Gets the current loading screen object
  91055. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91056. */
  91057. /**
  91058. * Sets the current loading screen object
  91059. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91060. */
  91061. loadingScreen: ILoadingScreen;
  91062. /**
  91063. * Sets the current loading screen text
  91064. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91065. */
  91066. loadingUIText: string;
  91067. /**
  91068. * Sets the current loading screen background color
  91069. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  91070. */
  91071. loadingUIBackgroundColor: string;
  91072. /**
  91073. * Attach a new callback raised when context lost event is fired
  91074. * @param callback defines the callback to call
  91075. */
  91076. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91077. /**
  91078. * Attach a new callback raised when context restored event is fired
  91079. * @param callback defines the callback to call
  91080. */
  91081. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  91082. /**
  91083. * Gets the source code of the vertex shader associated with a specific webGL program
  91084. * @param program defines the program to use
  91085. * @returns a string containing the source code of the vertex shader associated with the program
  91086. */
  91087. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  91088. /**
  91089. * Gets the source code of the fragment shader associated with a specific webGL program
  91090. * @param program defines the program to use
  91091. * @returns a string containing the source code of the fragment shader associated with the program
  91092. */
  91093. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  91094. /**
  91095. * Get the current error code of the webGL context
  91096. * @returns the error code
  91097. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  91098. */
  91099. getError(): number;
  91100. /**
  91101. * Gets the current framerate
  91102. * @returns a number representing the framerate
  91103. */
  91104. getFps(): number;
  91105. /**
  91106. * Gets the time spent between current and previous frame
  91107. * @returns a number representing the delta time in ms
  91108. */
  91109. getDeltaTime(): number;
  91110. private _measureFps;
  91111. /** @hidden */
  91112. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  91113. private _canRenderToFloatFramebuffer;
  91114. private _canRenderToHalfFloatFramebuffer;
  91115. private _canRenderToFramebuffer;
  91116. /** @hidden */
  91117. _getWebGLTextureType(type: number): number;
  91118. /** @hidden */
  91119. _getInternalFormat(format: number): number;
  91120. /** @hidden */
  91121. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  91122. /** @hidden */
  91123. _getRGBAMultiSampleBufferFormat(type: number): number;
  91124. /** @hidden */
  91125. _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;
  91126. /** @hidden */
  91127. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  91128. /**
  91129. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  91130. * @returns true if the engine can be created
  91131. * @ignorenaming
  91132. */
  91133. static isSupported(): boolean;
  91134. }
  91135. }
  91136. declare module BABYLON {
  91137. /**
  91138. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  91139. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  91140. */
  91141. export class EffectFallbacks {
  91142. private _defines;
  91143. private _currentRank;
  91144. private _maxRank;
  91145. private _mesh;
  91146. /**
  91147. * Removes the fallback from the bound mesh.
  91148. */
  91149. unBindMesh(): void;
  91150. /**
  91151. * Adds a fallback on the specified property.
  91152. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91153. * @param define The name of the define in the shader
  91154. */
  91155. addFallback(rank: number, define: string): void;
  91156. /**
  91157. * Sets the mesh to use CPU skinning when needing to fallback.
  91158. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  91159. * @param mesh The mesh to use the fallbacks.
  91160. */
  91161. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  91162. /**
  91163. * Checks to see if more fallbacks are still availible.
  91164. */
  91165. readonly isMoreFallbacks: boolean;
  91166. /**
  91167. * Removes the defines that shoould be removed when falling back.
  91168. * @param currentDefines defines the current define statements for the shader.
  91169. * @param effect defines the current effect we try to compile
  91170. * @returns The resulting defines with defines of the current rank removed.
  91171. */
  91172. reduce(currentDefines: string, effect: Effect): string;
  91173. }
  91174. /**
  91175. * Options to be used when creating an effect.
  91176. */
  91177. export class EffectCreationOptions {
  91178. /**
  91179. * Atrributes that will be used in the shader.
  91180. */
  91181. attributes: string[];
  91182. /**
  91183. * Uniform varible names that will be set in the shader.
  91184. */
  91185. uniformsNames: string[];
  91186. /**
  91187. * Uniform buffer varible names that will be set in the shader.
  91188. */
  91189. uniformBuffersNames: string[];
  91190. /**
  91191. * Sampler texture variable names that will be set in the shader.
  91192. */
  91193. samplers: string[];
  91194. /**
  91195. * Define statements that will be set in the shader.
  91196. */
  91197. defines: any;
  91198. /**
  91199. * Possible fallbacks for this effect to improve performance when needed.
  91200. */
  91201. fallbacks: Nullable<EffectFallbacks>;
  91202. /**
  91203. * Callback that will be called when the shader is compiled.
  91204. */
  91205. onCompiled: Nullable<(effect: Effect) => void>;
  91206. /**
  91207. * Callback that will be called if an error occurs during shader compilation.
  91208. */
  91209. onError: Nullable<(effect: Effect, errors: string) => void>;
  91210. /**
  91211. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91212. */
  91213. indexParameters: any;
  91214. /**
  91215. * Max number of lights that can be used in the shader.
  91216. */
  91217. maxSimultaneousLights: number;
  91218. /**
  91219. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  91220. */
  91221. transformFeedbackVaryings: Nullable<string[]>;
  91222. }
  91223. /**
  91224. * Effect containing vertex and fragment shader that can be executed on an object.
  91225. */
  91226. export class Effect implements IDisposable {
  91227. /**
  91228. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  91229. */
  91230. static ShadersRepository: string;
  91231. /**
  91232. * Name of the effect.
  91233. */
  91234. name: any;
  91235. /**
  91236. * String container all the define statements that should be set on the shader.
  91237. */
  91238. defines: string;
  91239. /**
  91240. * Callback that will be called when the shader is compiled.
  91241. */
  91242. onCompiled: Nullable<(effect: Effect) => void>;
  91243. /**
  91244. * Callback that will be called if an error occurs during shader compilation.
  91245. */
  91246. onError: Nullable<(effect: Effect, errors: string) => void>;
  91247. /**
  91248. * Callback that will be called when effect is bound.
  91249. */
  91250. onBind: Nullable<(effect: Effect) => void>;
  91251. /**
  91252. * Unique ID of the effect.
  91253. */
  91254. uniqueId: number;
  91255. /**
  91256. * Observable that will be called when the shader is compiled.
  91257. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  91258. */
  91259. onCompileObservable: Observable<Effect>;
  91260. /**
  91261. * Observable that will be called if an error occurs during shader compilation.
  91262. */
  91263. onErrorObservable: Observable<Effect>;
  91264. /** @hidden */
  91265. _onBindObservable: Nullable<Observable<Effect>>;
  91266. /**
  91267. * Observable that will be called when effect is bound.
  91268. */
  91269. readonly onBindObservable: Observable<Effect>;
  91270. /** @hidden */
  91271. _bonesComputationForcedToCPU: boolean;
  91272. private static _uniqueIdSeed;
  91273. private _engine;
  91274. private _uniformBuffersNames;
  91275. private _uniformsNames;
  91276. private _samplerList;
  91277. private _samplers;
  91278. private _isReady;
  91279. private _compilationError;
  91280. private _attributesNames;
  91281. private _attributes;
  91282. private _uniforms;
  91283. /**
  91284. * Key for the effect.
  91285. * @hidden
  91286. */
  91287. _key: string;
  91288. private _indexParameters;
  91289. private _fallbacks;
  91290. private _vertexSourceCode;
  91291. private _fragmentSourceCode;
  91292. private _vertexSourceCodeOverride;
  91293. private _fragmentSourceCodeOverride;
  91294. private _transformFeedbackVaryings;
  91295. /**
  91296. * Compiled shader to webGL program.
  91297. * @hidden
  91298. */
  91299. _pipelineContext: Nullable<IPipelineContext>;
  91300. private _valueCache;
  91301. private static _baseCache;
  91302. /**
  91303. * Instantiates an effect.
  91304. * An effect can be used to create/manage/execute vertex and fragment shaders.
  91305. * @param baseName Name of the effect.
  91306. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  91307. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  91308. * @param samplers List of sampler variables that will be passed to the shader.
  91309. * @param engine Engine to be used to render the effect
  91310. * @param defines Define statements to be added to the shader.
  91311. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  91312. * @param onCompiled Callback that will be called when the shader is compiled.
  91313. * @param onError Callback that will be called if an error occurs during shader compilation.
  91314. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  91315. */
  91316. 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);
  91317. /**
  91318. * Unique key for this effect
  91319. */
  91320. readonly key: string;
  91321. /**
  91322. * If the effect has been compiled and prepared.
  91323. * @returns if the effect is compiled and prepared.
  91324. */
  91325. isReady(): boolean;
  91326. /**
  91327. * The engine the effect was initialized with.
  91328. * @returns the engine.
  91329. */
  91330. getEngine(): Engine;
  91331. /**
  91332. * The pipeline context for this effect
  91333. * @returns the associated pipeline context
  91334. */
  91335. getPipelineContext(): Nullable<IPipelineContext>;
  91336. /**
  91337. * The set of names of attribute variables for the shader.
  91338. * @returns An array of attribute names.
  91339. */
  91340. getAttributesNames(): string[];
  91341. /**
  91342. * Returns the attribute at the given index.
  91343. * @param index The index of the attribute.
  91344. * @returns The location of the attribute.
  91345. */
  91346. getAttributeLocation(index: number): number;
  91347. /**
  91348. * Returns the attribute based on the name of the variable.
  91349. * @param name of the attribute to look up.
  91350. * @returns the attribute location.
  91351. */
  91352. getAttributeLocationByName(name: string): number;
  91353. /**
  91354. * The number of attributes.
  91355. * @returns the numnber of attributes.
  91356. */
  91357. getAttributesCount(): number;
  91358. /**
  91359. * Gets the index of a uniform variable.
  91360. * @param uniformName of the uniform to look up.
  91361. * @returns the index.
  91362. */
  91363. getUniformIndex(uniformName: string): number;
  91364. /**
  91365. * Returns the attribute based on the name of the variable.
  91366. * @param uniformName of the uniform to look up.
  91367. * @returns the location of the uniform.
  91368. */
  91369. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  91370. /**
  91371. * Returns an array of sampler variable names
  91372. * @returns The array of sampler variable neames.
  91373. */
  91374. getSamplers(): string[];
  91375. /**
  91376. * The error from the last compilation.
  91377. * @returns the error string.
  91378. */
  91379. getCompilationError(): string;
  91380. /**
  91381. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  91382. * @param func The callback to be used.
  91383. */
  91384. executeWhenCompiled(func: (effect: Effect) => void): void;
  91385. private _checkIsReady;
  91386. /** @hidden */
  91387. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  91388. /** @hidden */
  91389. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  91390. /** @hidden */
  91391. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  91392. private _processShaderConversion;
  91393. private _processIncludes;
  91394. private _processPrecision;
  91395. /**
  91396. * Recompiles the webGL program
  91397. * @param vertexSourceCode The source code for the vertex shader.
  91398. * @param fragmentSourceCode The source code for the fragment shader.
  91399. * @param onCompiled Callback called when completed.
  91400. * @param onError Callback called on error.
  91401. * @hidden
  91402. */
  91403. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  91404. /**
  91405. * Prepares the effect
  91406. * @hidden
  91407. */
  91408. _prepareEffect(): void;
  91409. /**
  91410. * Checks if the effect is supported. (Must be called after compilation)
  91411. */
  91412. readonly isSupported: boolean;
  91413. /**
  91414. * Binds a texture to the engine to be used as output of the shader.
  91415. * @param channel Name of the output variable.
  91416. * @param texture Texture to bind.
  91417. * @hidden
  91418. */
  91419. _bindTexture(channel: string, texture: InternalTexture): void;
  91420. /**
  91421. * Sets a texture on the engine to be used in the shader.
  91422. * @param channel Name of the sampler variable.
  91423. * @param texture Texture to set.
  91424. */
  91425. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  91426. /**
  91427. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  91428. * @param channel Name of the sampler variable.
  91429. * @param texture Texture to set.
  91430. */
  91431. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  91432. /**
  91433. * Sets an array of textures on the engine to be used in the shader.
  91434. * @param channel Name of the variable.
  91435. * @param textures Textures to set.
  91436. */
  91437. setTextureArray(channel: string, textures: BaseTexture[]): void;
  91438. /**
  91439. * 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)
  91440. * @param channel Name of the sampler variable.
  91441. * @param postProcess Post process to get the input texture from.
  91442. */
  91443. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  91444. /**
  91445. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  91446. * 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)
  91447. * @param channel Name of the sampler variable.
  91448. * @param postProcess Post process to get the output texture from.
  91449. */
  91450. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  91451. /** @hidden */
  91452. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  91453. /** @hidden */
  91454. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  91455. /** @hidden */
  91456. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  91457. /** @hidden */
  91458. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  91459. /**
  91460. * Binds a buffer to a uniform.
  91461. * @param buffer Buffer to bind.
  91462. * @param name Name of the uniform variable to bind to.
  91463. */
  91464. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  91465. /**
  91466. * Binds block to a uniform.
  91467. * @param blockName Name of the block to bind.
  91468. * @param index Index to bind.
  91469. */
  91470. bindUniformBlock(blockName: string, index: number): void;
  91471. /**
  91472. * Sets an interger value on a uniform variable.
  91473. * @param uniformName Name of the variable.
  91474. * @param value Value to be set.
  91475. * @returns this effect.
  91476. */
  91477. setInt(uniformName: string, value: number): Effect;
  91478. /**
  91479. * Sets an int array on a uniform variable.
  91480. * @param uniformName Name of the variable.
  91481. * @param array array to be set.
  91482. * @returns this effect.
  91483. */
  91484. setIntArray(uniformName: string, array: Int32Array): Effect;
  91485. /**
  91486. * 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)
  91487. * @param uniformName Name of the variable.
  91488. * @param array array to be set.
  91489. * @returns this effect.
  91490. */
  91491. setIntArray2(uniformName: string, array: Int32Array): Effect;
  91492. /**
  91493. * 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)
  91494. * @param uniformName Name of the variable.
  91495. * @param array array to be set.
  91496. * @returns this effect.
  91497. */
  91498. setIntArray3(uniformName: string, array: Int32Array): Effect;
  91499. /**
  91500. * 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)
  91501. * @param uniformName Name of the variable.
  91502. * @param array array to be set.
  91503. * @returns this effect.
  91504. */
  91505. setIntArray4(uniformName: string, array: Int32Array): Effect;
  91506. /**
  91507. * Sets an float array on a uniform variable.
  91508. * @param uniformName Name of the variable.
  91509. * @param array array to be set.
  91510. * @returns this effect.
  91511. */
  91512. setFloatArray(uniformName: string, array: Float32Array): Effect;
  91513. /**
  91514. * 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)
  91515. * @param uniformName Name of the variable.
  91516. * @param array array to be set.
  91517. * @returns this effect.
  91518. */
  91519. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  91520. /**
  91521. * 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)
  91522. * @param uniformName Name of the variable.
  91523. * @param array array to be set.
  91524. * @returns this effect.
  91525. */
  91526. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  91527. /**
  91528. * 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)
  91529. * @param uniformName Name of the variable.
  91530. * @param array array to be set.
  91531. * @returns this effect.
  91532. */
  91533. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  91534. /**
  91535. * Sets an array on a uniform variable.
  91536. * @param uniformName Name of the variable.
  91537. * @param array array to be set.
  91538. * @returns this effect.
  91539. */
  91540. setArray(uniformName: string, array: number[]): Effect;
  91541. /**
  91542. * 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)
  91543. * @param uniformName Name of the variable.
  91544. * @param array array to be set.
  91545. * @returns this effect.
  91546. */
  91547. setArray2(uniformName: string, array: number[]): Effect;
  91548. /**
  91549. * 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)
  91550. * @param uniformName Name of the variable.
  91551. * @param array array to be set.
  91552. * @returns this effect.
  91553. */
  91554. setArray3(uniformName: string, array: number[]): Effect;
  91555. /**
  91556. * 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)
  91557. * @param uniformName Name of the variable.
  91558. * @param array array to be set.
  91559. * @returns this effect.
  91560. */
  91561. setArray4(uniformName: string, array: number[]): Effect;
  91562. /**
  91563. * Sets matrices on a uniform variable.
  91564. * @param uniformName Name of the variable.
  91565. * @param matrices matrices to be set.
  91566. * @returns this effect.
  91567. */
  91568. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  91569. /**
  91570. * Sets matrix on a uniform variable.
  91571. * @param uniformName Name of the variable.
  91572. * @param matrix matrix to be set.
  91573. * @returns this effect.
  91574. */
  91575. setMatrix(uniformName: string, matrix: Matrix): Effect;
  91576. /**
  91577. * 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)
  91578. * @param uniformName Name of the variable.
  91579. * @param matrix matrix to be set.
  91580. * @returns this effect.
  91581. */
  91582. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  91583. /**
  91584. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  91585. * @param uniformName Name of the variable.
  91586. * @param matrix matrix to be set.
  91587. * @returns this effect.
  91588. */
  91589. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  91590. /**
  91591. * Sets a float on a uniform variable.
  91592. * @param uniformName Name of the variable.
  91593. * @param value value to be set.
  91594. * @returns this effect.
  91595. */
  91596. setFloat(uniformName: string, value: number): Effect;
  91597. /**
  91598. * Sets a boolean on a uniform variable.
  91599. * @param uniformName Name of the variable.
  91600. * @param bool value to be set.
  91601. * @returns this effect.
  91602. */
  91603. setBool(uniformName: string, bool: boolean): Effect;
  91604. /**
  91605. * Sets a Vector2 on a uniform variable.
  91606. * @param uniformName Name of the variable.
  91607. * @param vector2 vector2 to be set.
  91608. * @returns this effect.
  91609. */
  91610. setVector2(uniformName: string, vector2: Vector2): Effect;
  91611. /**
  91612. * Sets a float2 on a uniform variable.
  91613. * @param uniformName Name of the variable.
  91614. * @param x First float in float2.
  91615. * @param y Second float in float2.
  91616. * @returns this effect.
  91617. */
  91618. setFloat2(uniformName: string, x: number, y: number): Effect;
  91619. /**
  91620. * Sets a Vector3 on a uniform variable.
  91621. * @param uniformName Name of the variable.
  91622. * @param vector3 Value to be set.
  91623. * @returns this effect.
  91624. */
  91625. setVector3(uniformName: string, vector3: Vector3): Effect;
  91626. /**
  91627. * Sets a float3 on a uniform variable.
  91628. * @param uniformName Name of the variable.
  91629. * @param x First float in float3.
  91630. * @param y Second float in float3.
  91631. * @param z Third float in float3.
  91632. * @returns this effect.
  91633. */
  91634. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  91635. /**
  91636. * Sets a Vector4 on a uniform variable.
  91637. * @param uniformName Name of the variable.
  91638. * @param vector4 Value to be set.
  91639. * @returns this effect.
  91640. */
  91641. setVector4(uniformName: string, vector4: Vector4): Effect;
  91642. /**
  91643. * Sets a float4 on a uniform variable.
  91644. * @param uniformName Name of the variable.
  91645. * @param x First float in float4.
  91646. * @param y Second float in float4.
  91647. * @param z Third float in float4.
  91648. * @param w Fourth float in float4.
  91649. * @returns this effect.
  91650. */
  91651. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  91652. /**
  91653. * Sets a Color3 on a uniform variable.
  91654. * @param uniformName Name of the variable.
  91655. * @param color3 Value to be set.
  91656. * @returns this effect.
  91657. */
  91658. setColor3(uniformName: string, color3: Color3): Effect;
  91659. /**
  91660. * Sets a Color4 on a uniform variable.
  91661. * @param uniformName Name of the variable.
  91662. * @param color3 Value to be set.
  91663. * @param alpha Alpha value to be set.
  91664. * @returns this effect.
  91665. */
  91666. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  91667. /**
  91668. * Sets a Color4 on a uniform variable
  91669. * @param uniformName defines the name of the variable
  91670. * @param color4 defines the value to be set
  91671. * @returns this effect.
  91672. */
  91673. setDirectColor4(uniformName: string, color4: Color4): Effect;
  91674. /** Release all associated resources */
  91675. dispose(): void;
  91676. /**
  91677. * This function will add a new shader to the shader store
  91678. * @param name the name of the shader
  91679. * @param pixelShader optional pixel shader content
  91680. * @param vertexShader optional vertex shader content
  91681. */
  91682. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  91683. /**
  91684. * Store of each shader (The can be looked up using effect.key)
  91685. */
  91686. static ShadersStore: {
  91687. [key: string]: string;
  91688. };
  91689. /**
  91690. * Store of each included file for a shader (The can be looked up using effect.key)
  91691. */
  91692. static IncludesShadersStore: {
  91693. [key: string]: string;
  91694. };
  91695. /**
  91696. * Resets the cache of effects.
  91697. */
  91698. static ResetCache(): void;
  91699. }
  91700. }
  91701. declare module BABYLON {
  91702. /**
  91703. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  91704. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  91705. * 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;
  91706. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  91707. */
  91708. export class ColorCurves {
  91709. private _dirty;
  91710. private _tempColor;
  91711. private _globalCurve;
  91712. private _highlightsCurve;
  91713. private _midtonesCurve;
  91714. private _shadowsCurve;
  91715. private _positiveCurve;
  91716. private _negativeCurve;
  91717. private _globalHue;
  91718. private _globalDensity;
  91719. private _globalSaturation;
  91720. private _globalExposure;
  91721. /**
  91722. * Gets the global Hue value.
  91723. * 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).
  91724. */
  91725. /**
  91726. * Sets the global Hue value.
  91727. * 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).
  91728. */
  91729. globalHue: number;
  91730. /**
  91731. * Gets the global Density value.
  91732. * 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.
  91733. * Values less than zero provide a filter of opposite hue.
  91734. */
  91735. /**
  91736. * Sets the global Density value.
  91737. * 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.
  91738. * Values less than zero provide a filter of opposite hue.
  91739. */
  91740. globalDensity: number;
  91741. /**
  91742. * Gets the global Saturation value.
  91743. * 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.
  91744. */
  91745. /**
  91746. * Sets the global Saturation value.
  91747. * 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.
  91748. */
  91749. globalSaturation: number;
  91750. /**
  91751. * Gets the global Exposure value.
  91752. * 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.
  91753. */
  91754. /**
  91755. * Sets the global Exposure value.
  91756. * 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.
  91757. */
  91758. globalExposure: number;
  91759. private _highlightsHue;
  91760. private _highlightsDensity;
  91761. private _highlightsSaturation;
  91762. private _highlightsExposure;
  91763. /**
  91764. * Gets the highlights Hue value.
  91765. * 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).
  91766. */
  91767. /**
  91768. * Sets the highlights Hue value.
  91769. * 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).
  91770. */
  91771. highlightsHue: number;
  91772. /**
  91773. * Gets the highlights Density value.
  91774. * 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.
  91775. * Values less than zero provide a filter of opposite hue.
  91776. */
  91777. /**
  91778. * Sets the highlights Density value.
  91779. * 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.
  91780. * Values less than zero provide a filter of opposite hue.
  91781. */
  91782. highlightsDensity: number;
  91783. /**
  91784. * Gets the highlights Saturation value.
  91785. * 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.
  91786. */
  91787. /**
  91788. * Sets the highlights Saturation value.
  91789. * 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.
  91790. */
  91791. highlightsSaturation: number;
  91792. /**
  91793. * Gets the highlights Exposure value.
  91794. * 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.
  91795. */
  91796. /**
  91797. * Sets the highlights Exposure value.
  91798. * 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.
  91799. */
  91800. highlightsExposure: number;
  91801. private _midtonesHue;
  91802. private _midtonesDensity;
  91803. private _midtonesSaturation;
  91804. private _midtonesExposure;
  91805. /**
  91806. * Gets the midtones Hue value.
  91807. * 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).
  91808. */
  91809. /**
  91810. * Sets the midtones Hue value.
  91811. * 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).
  91812. */
  91813. midtonesHue: number;
  91814. /**
  91815. * Gets the midtones Density value.
  91816. * 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.
  91817. * Values less than zero provide a filter of opposite hue.
  91818. */
  91819. /**
  91820. * Sets the midtones Density value.
  91821. * 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.
  91822. * Values less than zero provide a filter of opposite hue.
  91823. */
  91824. midtonesDensity: number;
  91825. /**
  91826. * Gets the midtones Saturation value.
  91827. * 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.
  91828. */
  91829. /**
  91830. * Sets the midtones Saturation value.
  91831. * 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.
  91832. */
  91833. midtonesSaturation: number;
  91834. /**
  91835. * Gets the midtones Exposure value.
  91836. * 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.
  91837. */
  91838. /**
  91839. * Sets the midtones Exposure value.
  91840. * 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.
  91841. */
  91842. midtonesExposure: number;
  91843. private _shadowsHue;
  91844. private _shadowsDensity;
  91845. private _shadowsSaturation;
  91846. private _shadowsExposure;
  91847. /**
  91848. * Gets the shadows Hue value.
  91849. * 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).
  91850. */
  91851. /**
  91852. * Sets the shadows Hue value.
  91853. * 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).
  91854. */
  91855. shadowsHue: number;
  91856. /**
  91857. * Gets the shadows Density value.
  91858. * 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.
  91859. * Values less than zero provide a filter of opposite hue.
  91860. */
  91861. /**
  91862. * Sets the shadows Density value.
  91863. * 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.
  91864. * Values less than zero provide a filter of opposite hue.
  91865. */
  91866. shadowsDensity: number;
  91867. /**
  91868. * Gets the shadows Saturation value.
  91869. * 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.
  91870. */
  91871. /**
  91872. * Sets the shadows Saturation value.
  91873. * 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.
  91874. */
  91875. shadowsSaturation: number;
  91876. /**
  91877. * Gets the shadows Exposure value.
  91878. * 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.
  91879. */
  91880. /**
  91881. * Sets the shadows Exposure value.
  91882. * 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.
  91883. */
  91884. shadowsExposure: number;
  91885. /**
  91886. * Returns the class name
  91887. * @returns The class name
  91888. */
  91889. getClassName(): string;
  91890. /**
  91891. * Binds the color curves to the shader.
  91892. * @param colorCurves The color curve to bind
  91893. * @param effect The effect to bind to
  91894. * @param positiveUniform The positive uniform shader parameter
  91895. * @param neutralUniform The neutral uniform shader parameter
  91896. * @param negativeUniform The negative uniform shader parameter
  91897. */
  91898. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  91899. /**
  91900. * Prepare the list of uniforms associated with the ColorCurves effects.
  91901. * @param uniformsList The list of uniforms used in the effect
  91902. */
  91903. static PrepareUniforms(uniformsList: string[]): void;
  91904. /**
  91905. * Returns color grading data based on a hue, density, saturation and exposure value.
  91906. * @param filterHue The hue of the color filter.
  91907. * @param filterDensity The density of the color filter.
  91908. * @param saturation The saturation.
  91909. * @param exposure The exposure.
  91910. * @param result The result data container.
  91911. */
  91912. private getColorGradingDataToRef;
  91913. /**
  91914. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  91915. * @param value The input slider value in range [-100,100].
  91916. * @returns Adjusted value.
  91917. */
  91918. private static applyColorGradingSliderNonlinear;
  91919. /**
  91920. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  91921. * @param hue The hue (H) input.
  91922. * @param saturation The saturation (S) input.
  91923. * @param brightness The brightness (B) input.
  91924. * @result An RGBA color represented as Vector4.
  91925. */
  91926. private static fromHSBToRef;
  91927. /**
  91928. * Returns a value clamped between min and max
  91929. * @param value The value to clamp
  91930. * @param min The minimum of value
  91931. * @param max The maximum of value
  91932. * @returns The clamped value.
  91933. */
  91934. private static clamp;
  91935. /**
  91936. * Clones the current color curve instance.
  91937. * @return The cloned curves
  91938. */
  91939. clone(): ColorCurves;
  91940. /**
  91941. * Serializes the current color curve instance to a json representation.
  91942. * @return a JSON representation
  91943. */
  91944. serialize(): any;
  91945. /**
  91946. * Parses the color curve from a json representation.
  91947. * @param source the JSON source to parse
  91948. * @return The parsed curves
  91949. */
  91950. static Parse(source: any): ColorCurves;
  91951. }
  91952. }
  91953. declare module BABYLON {
  91954. /**
  91955. * Interface to follow in your material defines to integrate easily the
  91956. * Image proccessing functions.
  91957. * @hidden
  91958. */
  91959. export interface IImageProcessingConfigurationDefines {
  91960. IMAGEPROCESSING: boolean;
  91961. VIGNETTE: boolean;
  91962. VIGNETTEBLENDMODEMULTIPLY: boolean;
  91963. VIGNETTEBLENDMODEOPAQUE: boolean;
  91964. TONEMAPPING: boolean;
  91965. TONEMAPPING_ACES: boolean;
  91966. CONTRAST: boolean;
  91967. EXPOSURE: boolean;
  91968. COLORCURVES: boolean;
  91969. COLORGRADING: boolean;
  91970. COLORGRADING3D: boolean;
  91971. SAMPLER3DGREENDEPTH: boolean;
  91972. SAMPLER3DBGRMAP: boolean;
  91973. IMAGEPROCESSINGPOSTPROCESS: boolean;
  91974. }
  91975. /**
  91976. * @hidden
  91977. */
  91978. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  91979. IMAGEPROCESSING: boolean;
  91980. VIGNETTE: boolean;
  91981. VIGNETTEBLENDMODEMULTIPLY: boolean;
  91982. VIGNETTEBLENDMODEOPAQUE: boolean;
  91983. TONEMAPPING: boolean;
  91984. TONEMAPPING_ACES: boolean;
  91985. CONTRAST: boolean;
  91986. COLORCURVES: boolean;
  91987. COLORGRADING: boolean;
  91988. COLORGRADING3D: boolean;
  91989. SAMPLER3DGREENDEPTH: boolean;
  91990. SAMPLER3DBGRMAP: boolean;
  91991. IMAGEPROCESSINGPOSTPROCESS: boolean;
  91992. EXPOSURE: boolean;
  91993. constructor();
  91994. }
  91995. /**
  91996. * This groups together the common properties used for image processing either in direct forward pass
  91997. * or through post processing effect depending on the use of the image processing pipeline in your scene
  91998. * or not.
  91999. */
  92000. export class ImageProcessingConfiguration {
  92001. /**
  92002. * Default tone mapping applied in BabylonJS.
  92003. */
  92004. static readonly TONEMAPPING_STANDARD: number;
  92005. /**
  92006. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  92007. * to other engines rendering to increase portability.
  92008. */
  92009. static readonly TONEMAPPING_ACES: number;
  92010. /**
  92011. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  92012. */
  92013. colorCurves: Nullable<ColorCurves>;
  92014. private _colorCurvesEnabled;
  92015. /**
  92016. * Gets wether the color curves effect is enabled.
  92017. */
  92018. /**
  92019. * Sets wether the color curves effect is enabled.
  92020. */
  92021. colorCurvesEnabled: boolean;
  92022. private _colorGradingTexture;
  92023. /**
  92024. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92025. */
  92026. /**
  92027. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  92028. */
  92029. colorGradingTexture: Nullable<BaseTexture>;
  92030. private _colorGradingEnabled;
  92031. /**
  92032. * Gets wether the color grading effect is enabled.
  92033. */
  92034. /**
  92035. * Sets wether the color grading effect is enabled.
  92036. */
  92037. colorGradingEnabled: boolean;
  92038. private _colorGradingWithGreenDepth;
  92039. /**
  92040. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  92041. */
  92042. /**
  92043. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  92044. */
  92045. colorGradingWithGreenDepth: boolean;
  92046. private _colorGradingBGR;
  92047. /**
  92048. * Gets wether the color grading texture contains BGR values.
  92049. */
  92050. /**
  92051. * Sets wether the color grading texture contains BGR values.
  92052. */
  92053. colorGradingBGR: boolean;
  92054. /** @hidden */
  92055. _exposure: number;
  92056. /**
  92057. * Gets the Exposure used in the effect.
  92058. */
  92059. /**
  92060. * Sets the Exposure used in the effect.
  92061. */
  92062. exposure: number;
  92063. private _toneMappingEnabled;
  92064. /**
  92065. * Gets wether the tone mapping effect is enabled.
  92066. */
  92067. /**
  92068. * Sets wether the tone mapping effect is enabled.
  92069. */
  92070. toneMappingEnabled: boolean;
  92071. private _toneMappingType;
  92072. /**
  92073. * Gets the type of tone mapping effect.
  92074. */
  92075. /**
  92076. * Sets the type of tone mapping effect used in BabylonJS.
  92077. */
  92078. toneMappingType: number;
  92079. protected _contrast: number;
  92080. /**
  92081. * Gets the contrast used in the effect.
  92082. */
  92083. /**
  92084. * Sets the contrast used in the effect.
  92085. */
  92086. contrast: number;
  92087. /**
  92088. * Vignette stretch size.
  92089. */
  92090. vignetteStretch: number;
  92091. /**
  92092. * Vignette centre X Offset.
  92093. */
  92094. vignetteCentreX: number;
  92095. /**
  92096. * Vignette centre Y Offset.
  92097. */
  92098. vignetteCentreY: number;
  92099. /**
  92100. * Vignette weight or intensity of the vignette effect.
  92101. */
  92102. vignetteWeight: number;
  92103. /**
  92104. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  92105. * if vignetteEnabled is set to true.
  92106. */
  92107. vignetteColor: Color4;
  92108. /**
  92109. * Camera field of view used by the Vignette effect.
  92110. */
  92111. vignetteCameraFov: number;
  92112. private _vignetteBlendMode;
  92113. /**
  92114. * Gets the vignette blend mode allowing different kind of effect.
  92115. */
  92116. /**
  92117. * Sets the vignette blend mode allowing different kind of effect.
  92118. */
  92119. vignetteBlendMode: number;
  92120. private _vignetteEnabled;
  92121. /**
  92122. * Gets wether the vignette effect is enabled.
  92123. */
  92124. /**
  92125. * Sets wether the vignette effect is enabled.
  92126. */
  92127. vignetteEnabled: boolean;
  92128. private _applyByPostProcess;
  92129. /**
  92130. * Gets wether the image processing is applied through a post process or not.
  92131. */
  92132. /**
  92133. * Sets wether the image processing is applied through a post process or not.
  92134. */
  92135. applyByPostProcess: boolean;
  92136. private _isEnabled;
  92137. /**
  92138. * Gets wether the image processing is enabled or not.
  92139. */
  92140. /**
  92141. * Sets wether the image processing is enabled or not.
  92142. */
  92143. isEnabled: boolean;
  92144. /**
  92145. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  92146. */
  92147. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  92148. /**
  92149. * Method called each time the image processing information changes requires to recompile the effect.
  92150. */
  92151. protected _updateParameters(): void;
  92152. /**
  92153. * Gets the current class name.
  92154. * @return "ImageProcessingConfiguration"
  92155. */
  92156. getClassName(): string;
  92157. /**
  92158. * Prepare the list of uniforms associated with the Image Processing effects.
  92159. * @param uniforms The list of uniforms used in the effect
  92160. * @param defines the list of defines currently in use
  92161. */
  92162. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  92163. /**
  92164. * Prepare the list of samplers associated with the Image Processing effects.
  92165. * @param samplersList The list of uniforms used in the effect
  92166. * @param defines the list of defines currently in use
  92167. */
  92168. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  92169. /**
  92170. * Prepare the list of defines associated to the shader.
  92171. * @param defines the list of defines to complete
  92172. * @param forPostProcess Define if we are currently in post process mode or not
  92173. */
  92174. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  92175. /**
  92176. * Returns true if all the image processing information are ready.
  92177. * @returns True if ready, otherwise, false
  92178. */
  92179. isReady(): boolean;
  92180. /**
  92181. * Binds the image processing to the shader.
  92182. * @param effect The effect to bind to
  92183. * @param aspectRatio Define the current aspect ratio of the effect
  92184. */
  92185. bind(effect: Effect, aspectRatio?: number): void;
  92186. /**
  92187. * Clones the current image processing instance.
  92188. * @return The cloned image processing
  92189. */
  92190. clone(): ImageProcessingConfiguration;
  92191. /**
  92192. * Serializes the current image processing instance to a json representation.
  92193. * @return a JSON representation
  92194. */
  92195. serialize(): any;
  92196. /**
  92197. * Parses the image processing from a json representation.
  92198. * @param source the JSON source to parse
  92199. * @return The parsed image processing
  92200. */
  92201. static Parse(source: any): ImageProcessingConfiguration;
  92202. private static _VIGNETTEMODE_MULTIPLY;
  92203. private static _VIGNETTEMODE_OPAQUE;
  92204. /**
  92205. * Used to apply the vignette as a mix with the pixel color.
  92206. */
  92207. static readonly VIGNETTEMODE_MULTIPLY: number;
  92208. /**
  92209. * Used to apply the vignette as a replacement of the pixel color.
  92210. */
  92211. static readonly VIGNETTEMODE_OPAQUE: number;
  92212. }
  92213. }
  92214. declare module BABYLON {
  92215. /**
  92216. * This represents all the required information to add a fresnel effect on a material:
  92217. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  92218. */
  92219. export class FresnelParameters {
  92220. private _isEnabled;
  92221. /**
  92222. * Define if the fresnel effect is enable or not.
  92223. */
  92224. isEnabled: boolean;
  92225. /**
  92226. * Define the color used on edges (grazing angle)
  92227. */
  92228. leftColor: Color3;
  92229. /**
  92230. * Define the color used on center
  92231. */
  92232. rightColor: Color3;
  92233. /**
  92234. * Define bias applied to computed fresnel term
  92235. */
  92236. bias: number;
  92237. /**
  92238. * Defined the power exponent applied to fresnel term
  92239. */
  92240. power: number;
  92241. /**
  92242. * Clones the current fresnel and its valuues
  92243. * @returns a clone fresnel configuration
  92244. */
  92245. clone(): FresnelParameters;
  92246. /**
  92247. * Serializes the current fresnel parameters to a JSON representation.
  92248. * @return the JSON serialization
  92249. */
  92250. serialize(): any;
  92251. /**
  92252. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  92253. * @param parsedFresnelParameters Define the JSON representation
  92254. * @returns the parsed parameters
  92255. */
  92256. static Parse(parsedFresnelParameters: any): FresnelParameters;
  92257. }
  92258. }
  92259. declare module BABYLON {
  92260. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  92261. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92262. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92263. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92264. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92265. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92266. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92267. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92268. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92269. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92270. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92271. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92272. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92273. /**
  92274. * Decorator used to define property that can be serialized as reference to a camera
  92275. * @param sourceName defines the name of the property to decorate
  92276. */
  92277. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  92278. /**
  92279. * Class used to help serialization objects
  92280. */
  92281. export class SerializationHelper {
  92282. /** hidden */
  92283. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  92284. /** hidden */
  92285. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  92286. /** hidden */
  92287. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  92288. /** hidden */
  92289. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  92290. /**
  92291. * Appends the serialized animations from the source animations
  92292. * @param source Source containing the animations
  92293. * @param destination Target to store the animations
  92294. */
  92295. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  92296. /**
  92297. * Static function used to serialized a specific entity
  92298. * @param entity defines the entity to serialize
  92299. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  92300. * @returns a JSON compatible object representing the serialization of the entity
  92301. */
  92302. static Serialize<T>(entity: T, serializationObject?: any): any;
  92303. /**
  92304. * Creates a new entity from a serialization data object
  92305. * @param creationFunction defines a function used to instanciated the new entity
  92306. * @param source defines the source serialization data
  92307. * @param scene defines the hosting scene
  92308. * @param rootUrl defines the root url for resources
  92309. * @returns a new entity
  92310. */
  92311. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  92312. /**
  92313. * Clones an object
  92314. * @param creationFunction defines the function used to instanciate the new object
  92315. * @param source defines the source object
  92316. * @returns the cloned object
  92317. */
  92318. static Clone<T>(creationFunction: () => T, source: T): T;
  92319. /**
  92320. * Instanciates a new object based on a source one (some data will be shared between both object)
  92321. * @param creationFunction defines the function used to instanciate the new object
  92322. * @param source defines the source object
  92323. * @returns the new object
  92324. */
  92325. static Instanciate<T>(creationFunction: () => T, source: T): T;
  92326. }
  92327. }
  92328. declare module BABYLON {
  92329. /**
  92330. * This is the base class of all the camera used in the application.
  92331. * @see http://doc.babylonjs.com/features/cameras
  92332. */
  92333. export class Camera extends Node {
  92334. /** @hidden */
  92335. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  92336. /**
  92337. * This is the default projection mode used by the cameras.
  92338. * It helps recreating a feeling of perspective and better appreciate depth.
  92339. * This is the best way to simulate real life cameras.
  92340. */
  92341. static readonly PERSPECTIVE_CAMERA: number;
  92342. /**
  92343. * This helps creating camera with an orthographic mode.
  92344. * 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.
  92345. */
  92346. static readonly ORTHOGRAPHIC_CAMERA: number;
  92347. /**
  92348. * This is the default FOV mode for perspective cameras.
  92349. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  92350. */
  92351. static readonly FOVMODE_VERTICAL_FIXED: number;
  92352. /**
  92353. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  92354. */
  92355. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  92356. /**
  92357. * This specifies ther is no need for a camera rig.
  92358. * Basically only one eye is rendered corresponding to the camera.
  92359. */
  92360. static readonly RIG_MODE_NONE: number;
  92361. /**
  92362. * Simulates a camera Rig with one blue eye and one red eye.
  92363. * This can be use with 3d blue and red glasses.
  92364. */
  92365. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  92366. /**
  92367. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  92368. */
  92369. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  92370. /**
  92371. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  92372. */
  92373. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  92374. /**
  92375. * Defines that both eyes of the camera will be rendered over under each other.
  92376. */
  92377. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  92378. /**
  92379. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  92380. */
  92381. static readonly RIG_MODE_VR: number;
  92382. /**
  92383. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  92384. */
  92385. static readonly RIG_MODE_WEBVR: number;
  92386. /**
  92387. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  92388. */
  92389. static readonly RIG_MODE_CUSTOM: number;
  92390. /**
  92391. * Defines if by default attaching controls should prevent the default javascript event to continue.
  92392. */
  92393. static ForceAttachControlToAlwaysPreventDefault: boolean;
  92394. /**
  92395. * Define the input manager associated with the camera.
  92396. */
  92397. inputs: CameraInputsManager<Camera>;
  92398. /** @hidden */
  92399. _position: Vector3;
  92400. /**
  92401. * Define the current local position of the camera in the scene
  92402. */
  92403. position: Vector3;
  92404. /**
  92405. * The vector the camera should consider as up.
  92406. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  92407. */
  92408. upVector: Vector3;
  92409. /**
  92410. * Define the current limit on the left side for an orthographic camera
  92411. * In scene unit
  92412. */
  92413. orthoLeft: Nullable<number>;
  92414. /**
  92415. * Define the current limit on the right side for an orthographic camera
  92416. * In scene unit
  92417. */
  92418. orthoRight: Nullable<number>;
  92419. /**
  92420. * Define the current limit on the bottom side for an orthographic camera
  92421. * In scene unit
  92422. */
  92423. orthoBottom: Nullable<number>;
  92424. /**
  92425. * Define the current limit on the top side for an orthographic camera
  92426. * In scene unit
  92427. */
  92428. orthoTop: Nullable<number>;
  92429. /**
  92430. * Field Of View is set in Radians. (default is 0.8)
  92431. */
  92432. fov: number;
  92433. /**
  92434. * Define the minimum distance the camera can see from.
  92435. * This is important to note that the depth buffer are not infinite and the closer it starts
  92436. * the more your scene might encounter depth fighting issue.
  92437. */
  92438. minZ: number;
  92439. /**
  92440. * Define the maximum distance the camera can see to.
  92441. * This is important to note that the depth buffer are not infinite and the further it end
  92442. * the more your scene might encounter depth fighting issue.
  92443. */
  92444. maxZ: number;
  92445. /**
  92446. * Define the default inertia of the camera.
  92447. * This helps giving a smooth feeling to the camera movement.
  92448. */
  92449. inertia: number;
  92450. /**
  92451. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  92452. */
  92453. mode: number;
  92454. /**
  92455. * Define wether the camera is intermediate.
  92456. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  92457. */
  92458. isIntermediate: boolean;
  92459. /**
  92460. * Define the viewport of the camera.
  92461. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  92462. */
  92463. viewport: Viewport;
  92464. /**
  92465. * Restricts the camera to viewing objects with the same layerMask.
  92466. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  92467. */
  92468. layerMask: number;
  92469. /**
  92470. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  92471. */
  92472. fovMode: number;
  92473. /**
  92474. * Rig mode of the camera.
  92475. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  92476. * This is normally controlled byt the camera themselves as internal use.
  92477. */
  92478. cameraRigMode: number;
  92479. /**
  92480. * Defines the distance between both "eyes" in case of a RIG
  92481. */
  92482. interaxialDistance: number;
  92483. /**
  92484. * Defines if stereoscopic rendering is done side by side or over under.
  92485. */
  92486. isStereoscopicSideBySide: boolean;
  92487. /**
  92488. * 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
  92489. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  92490. * else in the scene.
  92491. */
  92492. customRenderTargets: RenderTargetTexture[];
  92493. /**
  92494. * When set, the camera will render to this render target instead of the default canvas
  92495. */
  92496. outputRenderTarget: Nullable<RenderTargetTexture>;
  92497. /**
  92498. * Observable triggered when the camera view matrix has changed.
  92499. */
  92500. onViewMatrixChangedObservable: Observable<Camera>;
  92501. /**
  92502. * Observable triggered when the camera Projection matrix has changed.
  92503. */
  92504. onProjectionMatrixChangedObservable: Observable<Camera>;
  92505. /**
  92506. * Observable triggered when the inputs have been processed.
  92507. */
  92508. onAfterCheckInputsObservable: Observable<Camera>;
  92509. /**
  92510. * Observable triggered when reset has been called and applied to the camera.
  92511. */
  92512. onRestoreStateObservable: Observable<Camera>;
  92513. /** @hidden */
  92514. _cameraRigParams: any;
  92515. /** @hidden */
  92516. _rigCameras: Camera[];
  92517. /** @hidden */
  92518. _rigPostProcess: Nullable<PostProcess>;
  92519. protected _webvrViewMatrix: Matrix;
  92520. /** @hidden */
  92521. _skipRendering: boolean;
  92522. /** @hidden */
  92523. _projectionMatrix: Matrix;
  92524. /** @hidden */
  92525. _postProcesses: Nullable<PostProcess>[];
  92526. /** @hidden */
  92527. _activeMeshes: SmartArray<AbstractMesh>;
  92528. protected _globalPosition: Vector3;
  92529. /** hidden */
  92530. _computedViewMatrix: Matrix;
  92531. private _doNotComputeProjectionMatrix;
  92532. private _transformMatrix;
  92533. private _frustumPlanes;
  92534. private _refreshFrustumPlanes;
  92535. private _storedFov;
  92536. private _stateStored;
  92537. /**
  92538. * Instantiates a new camera object.
  92539. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  92540. * @see http://doc.babylonjs.com/features/cameras
  92541. * @param name Defines the name of the camera in the scene
  92542. * @param position Defines the position of the camera
  92543. * @param scene Defines the scene the camera belongs too
  92544. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  92545. */
  92546. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92547. /**
  92548. * Store current camera state (fov, position, etc..)
  92549. * @returns the camera
  92550. */
  92551. storeState(): Camera;
  92552. /**
  92553. * Restores the camera state values if it has been stored. You must call storeState() first
  92554. */
  92555. protected _restoreStateValues(): boolean;
  92556. /**
  92557. * Restored camera state. You must call storeState() first.
  92558. * @returns true if restored and false otherwise
  92559. */
  92560. restoreState(): boolean;
  92561. /**
  92562. * Gets the class name of the camera.
  92563. * @returns the class name
  92564. */
  92565. getClassName(): string;
  92566. /** @hidden */
  92567. readonly _isCamera: boolean;
  92568. /**
  92569. * Gets a string representation of the camera useful for debug purpose.
  92570. * @param fullDetails Defines that a more verboe level of logging is required
  92571. * @returns the string representation
  92572. */
  92573. toString(fullDetails?: boolean): string;
  92574. /**
  92575. * Gets the current world space position of the camera.
  92576. */
  92577. readonly globalPosition: Vector3;
  92578. /**
  92579. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  92580. * @returns the active meshe list
  92581. */
  92582. getActiveMeshes(): SmartArray<AbstractMesh>;
  92583. /**
  92584. * Check wether a mesh is part of the current active mesh list of the camera
  92585. * @param mesh Defines the mesh to check
  92586. * @returns true if active, false otherwise
  92587. */
  92588. isActiveMesh(mesh: Mesh): boolean;
  92589. /**
  92590. * Is this camera ready to be used/rendered
  92591. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  92592. * @return true if the camera is ready
  92593. */
  92594. isReady(completeCheck?: boolean): boolean;
  92595. /** @hidden */
  92596. _initCache(): void;
  92597. /** @hidden */
  92598. _updateCache(ignoreParentClass?: boolean): void;
  92599. /** @hidden */
  92600. _isSynchronized(): boolean;
  92601. /** @hidden */
  92602. _isSynchronizedViewMatrix(): boolean;
  92603. /** @hidden */
  92604. _isSynchronizedProjectionMatrix(): boolean;
  92605. /**
  92606. * Attach the input controls to a specific dom element to get the input from.
  92607. * @param element Defines the element the controls should be listened from
  92608. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92609. */
  92610. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92611. /**
  92612. * Detach the current controls from the specified dom element.
  92613. * @param element Defines the element to stop listening the inputs from
  92614. */
  92615. detachControl(element: HTMLElement): void;
  92616. /**
  92617. * Update the camera state according to the different inputs gathered during the frame.
  92618. */
  92619. update(): void;
  92620. /** @hidden */
  92621. _checkInputs(): void;
  92622. /** @hidden */
  92623. readonly rigCameras: Camera[];
  92624. /**
  92625. * Gets the post process used by the rig cameras
  92626. */
  92627. readonly rigPostProcess: Nullable<PostProcess>;
  92628. /**
  92629. * Internal, gets the first post proces.
  92630. * @returns the first post process to be run on this camera.
  92631. */
  92632. _getFirstPostProcess(): Nullable<PostProcess>;
  92633. private _cascadePostProcessesToRigCams;
  92634. /**
  92635. * Attach a post process to the camera.
  92636. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92637. * @param postProcess The post process to attach to the camera
  92638. * @param insertAt The position of the post process in case several of them are in use in the scene
  92639. * @returns the position the post process has been inserted at
  92640. */
  92641. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  92642. /**
  92643. * Detach a post process to the camera.
  92644. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  92645. * @param postProcess The post process to detach from the camera
  92646. */
  92647. detachPostProcess(postProcess: PostProcess): void;
  92648. /**
  92649. * Gets the current world matrix of the camera
  92650. */
  92651. getWorldMatrix(): Matrix;
  92652. /** @hidden */
  92653. _getViewMatrix(): Matrix;
  92654. /**
  92655. * Gets the current view matrix of the camera.
  92656. * @param force forces the camera to recompute the matrix without looking at the cached state
  92657. * @returns the view matrix
  92658. */
  92659. getViewMatrix(force?: boolean): Matrix;
  92660. /**
  92661. * Freeze the projection matrix.
  92662. * It will prevent the cache check of the camera projection compute and can speed up perf
  92663. * if no parameter of the camera are meant to change
  92664. * @param projection Defines manually a projection if necessary
  92665. */
  92666. freezeProjectionMatrix(projection?: Matrix): void;
  92667. /**
  92668. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  92669. */
  92670. unfreezeProjectionMatrix(): void;
  92671. /**
  92672. * Gets the current projection matrix of the camera.
  92673. * @param force forces the camera to recompute the matrix without looking at the cached state
  92674. * @returns the projection matrix
  92675. */
  92676. getProjectionMatrix(force?: boolean): Matrix;
  92677. /**
  92678. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  92679. * @returns a Matrix
  92680. */
  92681. getTransformationMatrix(): Matrix;
  92682. private _updateFrustumPlanes;
  92683. /**
  92684. * Checks if a cullable object (mesh...) is in the camera frustum
  92685. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  92686. * @param target The object to check
  92687. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  92688. * @returns true if the object is in frustum otherwise false
  92689. */
  92690. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  92691. /**
  92692. * Checks if a cullable object (mesh...) is in the camera frustum
  92693. * Unlike isInFrustum this cheks the full bounding box
  92694. * @param target The object to check
  92695. * @returns true if the object is in frustum otherwise false
  92696. */
  92697. isCompletelyInFrustum(target: ICullable): boolean;
  92698. /**
  92699. * Gets a ray in the forward direction from the camera.
  92700. * @param length Defines the length of the ray to create
  92701. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  92702. * @param origin Defines the start point of the ray which defaults to the camera position
  92703. * @returns the forward ray
  92704. */
  92705. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  92706. /**
  92707. * Releases resources associated with this node.
  92708. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  92709. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  92710. */
  92711. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  92712. /** @hidden */
  92713. _isLeftCamera: boolean;
  92714. /**
  92715. * Gets the left camera of a rig setup in case of Rigged Camera
  92716. */
  92717. readonly isLeftCamera: boolean;
  92718. /** @hidden */
  92719. _isRightCamera: boolean;
  92720. /**
  92721. * Gets the right camera of a rig setup in case of Rigged Camera
  92722. */
  92723. readonly isRightCamera: boolean;
  92724. /**
  92725. * Gets the left camera of a rig setup in case of Rigged Camera
  92726. */
  92727. readonly leftCamera: Nullable<FreeCamera>;
  92728. /**
  92729. * Gets the right camera of a rig setup in case of Rigged Camera
  92730. */
  92731. readonly rightCamera: Nullable<FreeCamera>;
  92732. /**
  92733. * Gets the left camera target of a rig setup in case of Rigged Camera
  92734. * @returns the target position
  92735. */
  92736. getLeftTarget(): Nullable<Vector3>;
  92737. /**
  92738. * Gets the right camera target of a rig setup in case of Rigged Camera
  92739. * @returns the target position
  92740. */
  92741. getRightTarget(): Nullable<Vector3>;
  92742. /**
  92743. * @hidden
  92744. */
  92745. setCameraRigMode(mode: number, rigParams: any): void;
  92746. /** @hidden */
  92747. static _setStereoscopicRigMode(camera: Camera): void;
  92748. /** @hidden */
  92749. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  92750. /** @hidden */
  92751. static _setVRRigMode(camera: Camera, rigParams: any): void;
  92752. /** @hidden */
  92753. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  92754. /** @hidden */
  92755. _getVRProjectionMatrix(): Matrix;
  92756. protected _updateCameraRotationMatrix(): void;
  92757. protected _updateWebVRCameraRotationMatrix(): void;
  92758. /**
  92759. * This function MUST be overwritten by the different WebVR cameras available.
  92760. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92761. * @hidden
  92762. */
  92763. _getWebVRProjectionMatrix(): Matrix;
  92764. /**
  92765. * This function MUST be overwritten by the different WebVR cameras available.
  92766. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  92767. * @hidden
  92768. */
  92769. _getWebVRViewMatrix(): Matrix;
  92770. /** @hidden */
  92771. setCameraRigParameter(name: string, value: any): void;
  92772. /**
  92773. * needs to be overridden by children so sub has required properties to be copied
  92774. * @hidden
  92775. */
  92776. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  92777. /**
  92778. * May need to be overridden by children
  92779. * @hidden
  92780. */
  92781. _updateRigCameras(): void;
  92782. /** @hidden */
  92783. _setupInputs(): void;
  92784. /**
  92785. * Serialiaze the camera setup to a json represention
  92786. * @returns the JSON representation
  92787. */
  92788. serialize(): any;
  92789. /**
  92790. * Clones the current camera.
  92791. * @param name The cloned camera name
  92792. * @returns the cloned camera
  92793. */
  92794. clone(name: string): Camera;
  92795. /**
  92796. * Gets the direction of the camera relative to a given local axis.
  92797. * @param localAxis Defines the reference axis to provide a relative direction.
  92798. * @return the direction
  92799. */
  92800. getDirection(localAxis: Vector3): Vector3;
  92801. /**
  92802. * Gets the direction of the camera relative to a given local axis into a passed vector.
  92803. * @param localAxis Defines the reference axis to provide a relative direction.
  92804. * @param result Defines the vector to store the result in
  92805. */
  92806. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  92807. /**
  92808. * Gets a camera constructor for a given camera type
  92809. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92810. * @param name The name of the camera the result will be able to instantiate
  92811. * @param scene The scene the result will construct the camera in
  92812. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92813. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92814. * @returns a factory method to construc the camera
  92815. */
  92816. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92817. /**
  92818. * Compute the world matrix of the camera.
  92819. * @returns the camera workd matrix
  92820. */
  92821. computeWorldMatrix(): Matrix;
  92822. /**
  92823. * Parse a JSON and creates the camera from the parsed information
  92824. * @param parsedCamera The JSON to parse
  92825. * @param scene The scene to instantiate the camera in
  92826. * @returns the newly constructed camera
  92827. */
  92828. static Parse(parsedCamera: any, scene: Scene): Camera;
  92829. }
  92830. }
  92831. declare module BABYLON {
  92832. /**
  92833. * Interface for any object that can request an animation frame
  92834. */
  92835. export interface ICustomAnimationFrameRequester {
  92836. /**
  92837. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  92838. */
  92839. renderFunction?: Function;
  92840. /**
  92841. * Called to request the next frame to render to
  92842. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  92843. */
  92844. requestAnimationFrame: Function;
  92845. /**
  92846. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  92847. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  92848. */
  92849. requestID?: number;
  92850. }
  92851. /**
  92852. * Interface containing an array of animations
  92853. */
  92854. export interface IAnimatable {
  92855. /**
  92856. * Array of animations
  92857. */
  92858. animations: Nullable<Array<Animation>>;
  92859. }
  92860. /** Interface used by value gradients (color, factor, ...) */
  92861. export interface IValueGradient {
  92862. /**
  92863. * Gets or sets the gradient value (between 0 and 1)
  92864. */
  92865. gradient: number;
  92866. }
  92867. /** Class used to store color4 gradient */
  92868. export class ColorGradient implements IValueGradient {
  92869. /**
  92870. * Gets or sets the gradient value (between 0 and 1)
  92871. */
  92872. gradient: number;
  92873. /**
  92874. * Gets or sets first associated color
  92875. */
  92876. color1: Color4;
  92877. /**
  92878. * Gets or sets second associated color
  92879. */
  92880. color2?: Color4;
  92881. /**
  92882. * Will get a color picked randomly between color1 and color2.
  92883. * If color2 is undefined then color1 will be used
  92884. * @param result defines the target Color4 to store the result in
  92885. */
  92886. getColorToRef(result: Color4): void;
  92887. }
  92888. /** Class used to store color 3 gradient */
  92889. export class Color3Gradient implements IValueGradient {
  92890. /**
  92891. * Gets or sets the gradient value (between 0 and 1)
  92892. */
  92893. gradient: number;
  92894. /**
  92895. * Gets or sets the associated color
  92896. */
  92897. color: Color3;
  92898. }
  92899. /** Class used to store factor gradient */
  92900. export class FactorGradient implements IValueGradient {
  92901. /**
  92902. * Gets or sets the gradient value (between 0 and 1)
  92903. */
  92904. gradient: number;
  92905. /**
  92906. * Gets or sets first associated factor
  92907. */
  92908. factor1: number;
  92909. /**
  92910. * Gets or sets second associated factor
  92911. */
  92912. factor2?: number;
  92913. /**
  92914. * Will get a number picked randomly between factor1 and factor2.
  92915. * If factor2 is undefined then factor1 will be used
  92916. * @returns the picked number
  92917. */
  92918. getFactor(): number;
  92919. }
  92920. /**
  92921. * @ignore
  92922. * Application error to support additional information when loading a file
  92923. */
  92924. export class LoadFileError extends Error {
  92925. /** defines the optional web request */
  92926. request?: WebRequest | undefined;
  92927. private static _setPrototypeOf;
  92928. /**
  92929. * Creates a new LoadFileError
  92930. * @param message defines the message of the error
  92931. * @param request defines the optional web request
  92932. */
  92933. constructor(message: string,
  92934. /** defines the optional web request */
  92935. request?: WebRequest | undefined);
  92936. }
  92937. /**
  92938. * Class used to define a retry strategy when error happens while loading assets
  92939. */
  92940. export class RetryStrategy {
  92941. /**
  92942. * Function used to defines an exponential back off strategy
  92943. * @param maxRetries defines the maximum number of retries (3 by default)
  92944. * @param baseInterval defines the interval between retries
  92945. * @returns the strategy function to use
  92946. */
  92947. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  92948. }
  92949. /**
  92950. * File request interface
  92951. */
  92952. export interface IFileRequest {
  92953. /**
  92954. * Raised when the request is complete (success or error).
  92955. */
  92956. onCompleteObservable: Observable<IFileRequest>;
  92957. /**
  92958. * Aborts the request for a file.
  92959. */
  92960. abort: () => void;
  92961. }
  92962. /**
  92963. * Class containing a set of static utilities functions
  92964. */
  92965. export class Tools {
  92966. /**
  92967. * Gets or sets the base URL to use to load assets
  92968. */
  92969. static BaseUrl: string;
  92970. /**
  92971. * Enable/Disable Custom HTTP Request Headers globally.
  92972. * default = false
  92973. * @see CustomRequestHeaders
  92974. */
  92975. static UseCustomRequestHeaders: boolean;
  92976. /**
  92977. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  92978. * i.e. when loading files, where the server/service expects an Authorization header
  92979. */
  92980. static CustomRequestHeaders: {
  92981. [key: string]: string;
  92982. };
  92983. /**
  92984. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  92985. */
  92986. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  92987. /**
  92988. * Default behaviour for cors in the application.
  92989. * It can be a string if the expected behavior is identical in the entire app.
  92990. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  92991. */
  92992. static CorsBehavior: string | ((url: string | string[]) => string);
  92993. /**
  92994. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  92995. * @ignorenaming
  92996. */
  92997. static UseFallbackTexture: boolean;
  92998. /**
  92999. * Use this object to register external classes like custom textures or material
  93000. * to allow the laoders to instantiate them
  93001. */
  93002. static RegisteredExternalClasses: {
  93003. [key: string]: Object;
  93004. };
  93005. /**
  93006. * Texture content used if a texture cannot loaded
  93007. * @ignorenaming
  93008. */
  93009. static fallbackTexture: string;
  93010. /**
  93011. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  93012. * @param u defines the coordinate on X axis
  93013. * @param v defines the coordinate on Y axis
  93014. * @param width defines the width of the source data
  93015. * @param height defines the height of the source data
  93016. * @param pixels defines the source byte array
  93017. * @param color defines the output color
  93018. */
  93019. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  93020. /**
  93021. * Interpolates between a and b via alpha
  93022. * @param a The lower value (returned when alpha = 0)
  93023. * @param b The upper value (returned when alpha = 1)
  93024. * @param alpha The interpolation-factor
  93025. * @return The mixed value
  93026. */
  93027. static Mix(a: number, b: number, alpha: number): number;
  93028. /**
  93029. * Tries to instantiate a new object from a given class name
  93030. * @param className defines the class name to instantiate
  93031. * @returns the new object or null if the system was not able to do the instantiation
  93032. */
  93033. static Instantiate(className: string): any;
  93034. /**
  93035. * Provides a slice function that will work even on IE
  93036. * @param data defines the array to slice
  93037. * @param start defines the start of the data (optional)
  93038. * @param end defines the end of the data (optional)
  93039. * @returns the new sliced array
  93040. */
  93041. static Slice<T>(data: T, start?: number, end?: number): T;
  93042. /**
  93043. * Polyfill for setImmediate
  93044. * @param action defines the action to execute after the current execution block
  93045. */
  93046. static SetImmediate(action: () => void): void;
  93047. /**
  93048. * Function indicating if a number is an exponent of 2
  93049. * @param value defines the value to test
  93050. * @returns true if the value is an exponent of 2
  93051. */
  93052. static IsExponentOfTwo(value: number): boolean;
  93053. private static _tmpFloatArray;
  93054. /**
  93055. * Returns the nearest 32-bit single precision float representation of a Number
  93056. * @param value A Number. If the parameter is of a different type, it will get converted
  93057. * to a number or to NaN if it cannot be converted
  93058. * @returns number
  93059. */
  93060. static FloatRound(value: number): number;
  93061. /**
  93062. * Find the next highest power of two.
  93063. * @param x Number to start search from.
  93064. * @return Next highest power of two.
  93065. */
  93066. static CeilingPOT(x: number): number;
  93067. /**
  93068. * Find the next lowest power of two.
  93069. * @param x Number to start search from.
  93070. * @return Next lowest power of two.
  93071. */
  93072. static FloorPOT(x: number): number;
  93073. /**
  93074. * Find the nearest power of two.
  93075. * @param x Number to start search from.
  93076. * @return Next nearest power of two.
  93077. */
  93078. static NearestPOT(x: number): number;
  93079. /**
  93080. * Get the closest exponent of two
  93081. * @param value defines the value to approximate
  93082. * @param max defines the maximum value to return
  93083. * @param mode defines how to define the closest value
  93084. * @returns closest exponent of two of the given value
  93085. */
  93086. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  93087. /**
  93088. * Extracts the filename from a path
  93089. * @param path defines the path to use
  93090. * @returns the filename
  93091. */
  93092. static GetFilename(path: string): string;
  93093. /**
  93094. * Extracts the "folder" part of a path (everything before the filename).
  93095. * @param uri The URI to extract the info from
  93096. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  93097. * @returns The "folder" part of the path
  93098. */
  93099. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  93100. /**
  93101. * Extracts text content from a DOM element hierarchy
  93102. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  93103. */
  93104. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  93105. /**
  93106. * Convert an angle in radians to degrees
  93107. * @param angle defines the angle to convert
  93108. * @returns the angle in degrees
  93109. */
  93110. static ToDegrees(angle: number): number;
  93111. /**
  93112. * Convert an angle in degrees to radians
  93113. * @param angle defines the angle to convert
  93114. * @returns the angle in radians
  93115. */
  93116. static ToRadians(angle: number): number;
  93117. /**
  93118. * Encode a buffer to a base64 string
  93119. * @param buffer defines the buffer to encode
  93120. * @returns the encoded string
  93121. */
  93122. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  93123. /**
  93124. * Extracts minimum and maximum values from a list of indexed positions
  93125. * @param positions defines the positions to use
  93126. * @param indices defines the indices to the positions
  93127. * @param indexStart defines the start index
  93128. * @param indexCount defines the end index
  93129. * @param bias defines bias value to add to the result
  93130. * @return minimum and maximum values
  93131. */
  93132. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  93133. minimum: Vector3;
  93134. maximum: Vector3;
  93135. };
  93136. /**
  93137. * Extracts minimum and maximum values from a list of positions
  93138. * @param positions defines the positions to use
  93139. * @param start defines the start index in the positions array
  93140. * @param count defines the number of positions to handle
  93141. * @param bias defines bias value to add to the result
  93142. * @param stride defines the stride size to use (distance between two positions in the positions array)
  93143. * @return minimum and maximum values
  93144. */
  93145. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  93146. minimum: Vector3;
  93147. maximum: Vector3;
  93148. };
  93149. /**
  93150. * Returns an array if obj is not an array
  93151. * @param obj defines the object to evaluate as an array
  93152. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  93153. * @returns either obj directly if obj is an array or a new array containing obj
  93154. */
  93155. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  93156. /**
  93157. * Gets the pointer prefix to use
  93158. * @returns "pointer" if touch is enabled. Else returns "mouse"
  93159. */
  93160. static GetPointerPrefix(): string;
  93161. /**
  93162. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  93163. * @param func - the function to be called
  93164. * @param requester - the object that will request the next frame. Falls back to window.
  93165. * @returns frame number
  93166. */
  93167. static QueueNewFrame(func: () => void, requester?: any): number;
  93168. /**
  93169. * Ask the browser to promote the current element to fullscreen rendering mode
  93170. * @param element defines the DOM element to promote
  93171. */
  93172. static RequestFullscreen(element: HTMLElement): void;
  93173. /**
  93174. * Asks the browser to exit fullscreen mode
  93175. */
  93176. static ExitFullscreen(): void;
  93177. /**
  93178. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  93179. * @param url define the url we are trying
  93180. * @param element define the dom element where to configure the cors policy
  93181. */
  93182. static SetCorsBehavior(url: string | string[], element: {
  93183. crossOrigin: string | null;
  93184. }): void;
  93185. /**
  93186. * Removes unwanted characters from an url
  93187. * @param url defines the url to clean
  93188. * @returns the cleaned url
  93189. */
  93190. static CleanUrl(url: string): string;
  93191. /**
  93192. * Gets or sets a function used to pre-process url before using them to load assets
  93193. */
  93194. static PreprocessUrl: (url: string) => string;
  93195. /**
  93196. * Loads an image as an HTMLImageElement.
  93197. * @param input url string, ArrayBuffer, or Blob to load
  93198. * @param onLoad callback called when the image successfully loads
  93199. * @param onError callback called when the image fails to load
  93200. * @param offlineProvider offline provider for caching
  93201. * @returns the HTMLImageElement of the loaded image
  93202. */
  93203. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  93204. /**
  93205. * Loads a file
  93206. * @param url url string, ArrayBuffer, or Blob to load
  93207. * @param onSuccess callback called when the file successfully loads
  93208. * @param onProgress callback called while file is loading (if the server supports this mode)
  93209. * @param offlineProvider defines the offline provider for caching
  93210. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  93211. * @param onError callback called when the file fails to load
  93212. * @returns a file request object
  93213. */
  93214. 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;
  93215. /**
  93216. * Load a script (identified by an url). When the url returns, the
  93217. * content of this file is added into a new script element, attached to the DOM (body element)
  93218. * @param scriptUrl defines the url of the script to laod
  93219. * @param onSuccess defines the callback called when the script is loaded
  93220. * @param onError defines the callback to call if an error occurs
  93221. * @param scriptId defines the id of the script element
  93222. */
  93223. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  93224. /**
  93225. * Load an asynchronous script (identified by an url). When the url returns, the
  93226. * content of this file is added into a new script element, attached to the DOM (body element)
  93227. * @param scriptUrl defines the url of the script to laod
  93228. * @param scriptId defines the id of the script element
  93229. * @returns a promise request object
  93230. */
  93231. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  93232. /**
  93233. * Loads a file from a blob
  93234. * @param fileToLoad defines the blob to use
  93235. * @param callback defines the callback to call when data is loaded
  93236. * @param progressCallback defines the callback to call during loading process
  93237. * @returns a file request object
  93238. */
  93239. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  93240. /**
  93241. * Loads a file
  93242. * @param fileToLoad defines the file to load
  93243. * @param callback defines the callback to call when data is loaded
  93244. * @param progressCallBack defines the callback to call during loading process
  93245. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  93246. * @returns a file request object
  93247. */
  93248. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  93249. /**
  93250. * Creates a data url from a given string content
  93251. * @param content defines the content to convert
  93252. * @returns the new data url link
  93253. */
  93254. static FileAsURL(content: string): string;
  93255. /**
  93256. * Format the given number to a specific decimal format
  93257. * @param value defines the number to format
  93258. * @param decimals defines the number of decimals to use
  93259. * @returns the formatted string
  93260. */
  93261. static Format(value: number, decimals?: number): string;
  93262. /**
  93263. * Checks if a given vector is inside a specific range
  93264. * @param v defines the vector to test
  93265. * @param min defines the minimum range
  93266. * @param max defines the maximum range
  93267. */
  93268. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  93269. /**
  93270. * Tries to copy an object by duplicating every property
  93271. * @param source defines the source object
  93272. * @param destination defines the target object
  93273. * @param doNotCopyList defines a list of properties to avoid
  93274. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  93275. */
  93276. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  93277. /**
  93278. * Gets a boolean indicating if the given object has no own property
  93279. * @param obj defines the object to test
  93280. * @returns true if object has no own property
  93281. */
  93282. static IsEmpty(obj: any): boolean;
  93283. /**
  93284. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  93285. * @param str Source string
  93286. * @param suffix Suffix to search for in the source string
  93287. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  93288. */
  93289. static EndsWith(str: string, suffix: string): boolean;
  93290. /**
  93291. * Function used to register events at window level
  93292. * @param events defines the events to register
  93293. */
  93294. static RegisterTopRootEvents(events: {
  93295. name: string;
  93296. handler: Nullable<(e: FocusEvent) => any>;
  93297. }[]): void;
  93298. /**
  93299. * Function used to unregister events from window level
  93300. * @param events defines the events to unregister
  93301. */
  93302. static UnregisterTopRootEvents(events: {
  93303. name: string;
  93304. handler: Nullable<(e: FocusEvent) => any>;
  93305. }[]): void;
  93306. /**
  93307. * @ignore
  93308. */
  93309. static _ScreenshotCanvas: HTMLCanvasElement;
  93310. /**
  93311. * Dumps the current bound framebuffer
  93312. * @param width defines the rendering width
  93313. * @param height defines the rendering height
  93314. * @param engine defines the hosting engine
  93315. * @param successCallback defines the callback triggered once the data are available
  93316. * @param mimeType defines the mime type of the result
  93317. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  93318. */
  93319. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93320. /**
  93321. * Converts the canvas data to blob.
  93322. * This acts as a polyfill for browsers not supporting the to blob function.
  93323. * @param canvas Defines the canvas to extract the data from
  93324. * @param successCallback Defines the callback triggered once the data are available
  93325. * @param mimeType Defines the mime type of the result
  93326. */
  93327. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  93328. /**
  93329. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  93330. * @param successCallback defines the callback triggered once the data are available
  93331. * @param mimeType defines the mime type of the result
  93332. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  93333. */
  93334. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  93335. /**
  93336. * Downloads a blob in the browser
  93337. * @param blob defines the blob to download
  93338. * @param fileName defines the name of the downloaded file
  93339. */
  93340. static Download(blob: Blob, fileName: string): void;
  93341. /**
  93342. * Captures a screenshot of the current rendering
  93343. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93344. * @param engine defines the rendering engine
  93345. * @param camera defines the source camera
  93346. * @param size This parameter can be set to a single number or to an object with the
  93347. * following (optional) properties: precision, width, height. If a single number is passed,
  93348. * it will be used for both width and height. If an object is passed, the screenshot size
  93349. * will be derived from the parameters. The precision property is a multiplier allowing
  93350. * rendering at a higher or lower resolution
  93351. * @param successCallback defines the callback receives a single parameter which contains the
  93352. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93353. * src parameter of an <img> to display it
  93354. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  93355. * Check your browser for supported MIME types
  93356. */
  93357. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  93358. /**
  93359. * Generates an image screenshot from the specified camera.
  93360. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  93361. * @param engine The engine to use for rendering
  93362. * @param camera The camera to use for rendering
  93363. * @param size This parameter can be set to a single number or to an object with the
  93364. * following (optional) properties: precision, width, height. If a single number is passed,
  93365. * it will be used for both width and height. If an object is passed, the screenshot size
  93366. * will be derived from the parameters. The precision property is a multiplier allowing
  93367. * rendering at a higher or lower resolution
  93368. * @param successCallback The callback receives a single parameter which contains the
  93369. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  93370. * src parameter of an <img> to display it
  93371. * @param mimeType The MIME type of the screenshot image (default: image/png).
  93372. * Check your browser for supported MIME types
  93373. * @param samples Texture samples (default: 1)
  93374. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  93375. * @param fileName A name for for the downloaded file.
  93376. */
  93377. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  93378. /**
  93379. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  93380. * Be aware Math.random() could cause collisions, but:
  93381. * "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"
  93382. * @returns a pseudo random id
  93383. */
  93384. static RandomId(): string;
  93385. /**
  93386. * Test if the given uri is a base64 string
  93387. * @param uri The uri to test
  93388. * @return True if the uri is a base64 string or false otherwise
  93389. */
  93390. static IsBase64(uri: string): boolean;
  93391. /**
  93392. * Decode the given base64 uri.
  93393. * @param uri The uri to decode
  93394. * @return The decoded base64 data.
  93395. */
  93396. static DecodeBase64(uri: string): ArrayBuffer;
  93397. /**
  93398. * Gets the absolute url.
  93399. * @param url the input url
  93400. * @return the absolute url
  93401. */
  93402. static GetAbsoluteUrl(url: string): string;
  93403. /**
  93404. * No log
  93405. */
  93406. static readonly NoneLogLevel: number;
  93407. /**
  93408. * Only message logs
  93409. */
  93410. static readonly MessageLogLevel: number;
  93411. /**
  93412. * Only warning logs
  93413. */
  93414. static readonly WarningLogLevel: number;
  93415. /**
  93416. * Only error logs
  93417. */
  93418. static readonly ErrorLogLevel: number;
  93419. /**
  93420. * All logs
  93421. */
  93422. static readonly AllLogLevel: number;
  93423. /**
  93424. * Gets a value indicating the number of loading errors
  93425. * @ignorenaming
  93426. */
  93427. static readonly errorsCount: number;
  93428. /**
  93429. * Callback called when a new log is added
  93430. */
  93431. static OnNewCacheEntry: (entry: string) => void;
  93432. /**
  93433. * Log a message to the console
  93434. * @param message defines the message to log
  93435. */
  93436. static Log(message: string): void;
  93437. /**
  93438. * Write a warning message to the console
  93439. * @param message defines the message to log
  93440. */
  93441. static Warn(message: string): void;
  93442. /**
  93443. * Write an error message to the console
  93444. * @param message defines the message to log
  93445. */
  93446. static Error(message: string): void;
  93447. /**
  93448. * Gets current log cache (list of logs)
  93449. */
  93450. static readonly LogCache: string;
  93451. /**
  93452. * Clears the log cache
  93453. */
  93454. static ClearLogCache(): void;
  93455. /**
  93456. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  93457. */
  93458. static LogLevels: number;
  93459. /**
  93460. * Checks if the loaded document was accessed via `file:`-Protocol.
  93461. * @returns boolean
  93462. */
  93463. static IsFileURL(): boolean;
  93464. /**
  93465. * Checks if the window object exists
  93466. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  93467. */
  93468. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  93469. /**
  93470. * No performance log
  93471. */
  93472. static readonly PerformanceNoneLogLevel: number;
  93473. /**
  93474. * Use user marks to log performance
  93475. */
  93476. static readonly PerformanceUserMarkLogLevel: number;
  93477. /**
  93478. * Log performance to the console
  93479. */
  93480. static readonly PerformanceConsoleLogLevel: number;
  93481. private static _performance;
  93482. /**
  93483. * Sets the current performance log level
  93484. */
  93485. static PerformanceLogLevel: number;
  93486. private static _StartPerformanceCounterDisabled;
  93487. private static _EndPerformanceCounterDisabled;
  93488. private static _StartUserMark;
  93489. private static _EndUserMark;
  93490. private static _StartPerformanceConsole;
  93491. private static _EndPerformanceConsole;
  93492. /**
  93493. * Starts a performance counter
  93494. */
  93495. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93496. /**
  93497. * Ends a specific performance coutner
  93498. */
  93499. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  93500. /**
  93501. * Gets either window.performance.now() if supported or Date.now() else
  93502. */
  93503. static readonly Now: number;
  93504. /**
  93505. * This method will return the name of the class used to create the instance of the given object.
  93506. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  93507. * @param object the object to get the class name from
  93508. * @param isType defines if the object is actually a type
  93509. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  93510. */
  93511. static GetClassName(object: any, isType?: boolean): string;
  93512. /**
  93513. * Gets the first element of an array satisfying a given predicate
  93514. * @param array defines the array to browse
  93515. * @param predicate defines the predicate to use
  93516. * @returns null if not found or the element
  93517. */
  93518. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  93519. /**
  93520. * This method will return the name of the full name of the class, including its owning module (if any).
  93521. * 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).
  93522. * @param object the object to get the class name from
  93523. * @param isType defines if the object is actually a type
  93524. * @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.
  93525. * @ignorenaming
  93526. */
  93527. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  93528. /**
  93529. * Returns a promise that resolves after the given amount of time.
  93530. * @param delay Number of milliseconds to delay
  93531. * @returns Promise that resolves after the given amount of time
  93532. */
  93533. static DelayAsync(delay: number): Promise<void>;
  93534. /**
  93535. * Gets the current gradient from an array of IValueGradient
  93536. * @param ratio defines the current ratio to get
  93537. * @param gradients defines the array of IValueGradient
  93538. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  93539. */
  93540. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  93541. }
  93542. /**
  93543. * This class is used to track a performance counter which is number based.
  93544. * The user has access to many properties which give statistics of different nature.
  93545. *
  93546. * The implementer can track two kinds of Performance Counter: time and count.
  93547. * 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.
  93548. * 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.
  93549. */
  93550. export class PerfCounter {
  93551. /**
  93552. * Gets or sets a global boolean to turn on and off all the counters
  93553. */
  93554. static Enabled: boolean;
  93555. /**
  93556. * Returns the smallest value ever
  93557. */
  93558. readonly min: number;
  93559. /**
  93560. * Returns the biggest value ever
  93561. */
  93562. readonly max: number;
  93563. /**
  93564. * Returns the average value since the performance counter is running
  93565. */
  93566. readonly average: number;
  93567. /**
  93568. * Returns the average value of the last second the counter was monitored
  93569. */
  93570. readonly lastSecAverage: number;
  93571. /**
  93572. * Returns the current value
  93573. */
  93574. readonly current: number;
  93575. /**
  93576. * Gets the accumulated total
  93577. */
  93578. readonly total: number;
  93579. /**
  93580. * Gets the total value count
  93581. */
  93582. readonly count: number;
  93583. /**
  93584. * Creates a new counter
  93585. */
  93586. constructor();
  93587. /**
  93588. * Call this method to start monitoring a new frame.
  93589. * 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.
  93590. */
  93591. fetchNewFrame(): void;
  93592. /**
  93593. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  93594. * @param newCount the count value to add to the monitored count
  93595. * @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.
  93596. */
  93597. addCount(newCount: number, fetchResult: boolean): void;
  93598. /**
  93599. * Start monitoring this performance counter
  93600. */
  93601. beginMonitoring(): void;
  93602. /**
  93603. * Compute the time lapsed since the previous beginMonitoring() call.
  93604. * @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
  93605. */
  93606. endMonitoring(newFrame?: boolean): void;
  93607. private _fetchResult;
  93608. private _startMonitoringTime;
  93609. private _min;
  93610. private _max;
  93611. private _average;
  93612. private _current;
  93613. private _totalValueCount;
  93614. private _totalAccumulated;
  93615. private _lastSecAverage;
  93616. private _lastSecAccumulated;
  93617. private _lastSecTime;
  93618. private _lastSecValueCount;
  93619. }
  93620. /**
  93621. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  93622. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  93623. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  93624. * @param name The name of the class, case should be preserved
  93625. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  93626. */
  93627. export function className(name: string, module?: string): (target: Object) => void;
  93628. /**
  93629. * An implementation of a loop for asynchronous functions.
  93630. */
  93631. export class AsyncLoop {
  93632. /**
  93633. * Defines the number of iterations for the loop
  93634. */
  93635. iterations: number;
  93636. /**
  93637. * Defines the current index of the loop.
  93638. */
  93639. index: number;
  93640. private _done;
  93641. private _fn;
  93642. private _successCallback;
  93643. /**
  93644. * Constructor.
  93645. * @param iterations the number of iterations.
  93646. * @param func the function to run each iteration
  93647. * @param successCallback the callback that will be called upon succesful execution
  93648. * @param offset starting offset.
  93649. */
  93650. constructor(
  93651. /**
  93652. * Defines the number of iterations for the loop
  93653. */
  93654. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  93655. /**
  93656. * Execute the next iteration. Must be called after the last iteration was finished.
  93657. */
  93658. executeNext(): void;
  93659. /**
  93660. * Break the loop and run the success callback.
  93661. */
  93662. breakLoop(): void;
  93663. /**
  93664. * Create and run an async loop.
  93665. * @param iterations the number of iterations.
  93666. * @param fn the function to run each iteration
  93667. * @param successCallback the callback that will be called upon succesful execution
  93668. * @param offset starting offset.
  93669. * @returns the created async loop object
  93670. */
  93671. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  93672. /**
  93673. * A for-loop that will run a given number of iterations synchronous and the rest async.
  93674. * @param iterations total number of iterations
  93675. * @param syncedIterations number of synchronous iterations in each async iteration.
  93676. * @param fn the function to call each iteration.
  93677. * @param callback a success call back that will be called when iterating stops.
  93678. * @param breakFunction a break condition (optional)
  93679. * @param timeout timeout settings for the setTimeout function. default - 0.
  93680. * @returns the created async loop object
  93681. */
  93682. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  93683. }
  93684. }
  93685. declare module BABYLON {
  93686. /** @hidden */
  93687. export interface ICollisionCoordinator {
  93688. createCollider(): Collider;
  93689. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  93690. init(scene: Scene): void;
  93691. }
  93692. /** @hidden */
  93693. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  93694. private _scene;
  93695. private _scaledPosition;
  93696. private _scaledVelocity;
  93697. private _finalPosition;
  93698. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  93699. createCollider(): Collider;
  93700. init(scene: Scene): void;
  93701. private _collideWithWorld;
  93702. }
  93703. }
  93704. declare module BABYLON {
  93705. /**
  93706. * Class used to manage all inputs for the scene.
  93707. */
  93708. export class InputManager {
  93709. /** The distance in pixel that you have to move to prevent some events */
  93710. static DragMovementThreshold: number;
  93711. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  93712. static LongPressDelay: number;
  93713. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  93714. static DoubleClickDelay: number;
  93715. /** If you need to check double click without raising a single click at first click, enable this flag */
  93716. static ExclusiveDoubleClickMode: boolean;
  93717. private _wheelEventName;
  93718. private _onPointerMove;
  93719. private _onPointerDown;
  93720. private _onPointerUp;
  93721. private _initClickEvent;
  93722. private _initActionManager;
  93723. private _delayedSimpleClick;
  93724. private _delayedSimpleClickTimeout;
  93725. private _previousDelayedSimpleClickTimeout;
  93726. private _meshPickProceed;
  93727. private _previousButtonPressed;
  93728. private _currentPickResult;
  93729. private _previousPickResult;
  93730. private _totalPointersPressed;
  93731. private _doubleClickOccured;
  93732. private _pointerOverMesh;
  93733. private _pickedDownMesh;
  93734. private _pickedUpMesh;
  93735. private _pointerX;
  93736. private _pointerY;
  93737. private _unTranslatedPointerX;
  93738. private _unTranslatedPointerY;
  93739. private _startingPointerPosition;
  93740. private _previousStartingPointerPosition;
  93741. private _startingPointerTime;
  93742. private _previousStartingPointerTime;
  93743. private _pointerCaptures;
  93744. private _onKeyDown;
  93745. private _onKeyUp;
  93746. private _onCanvasFocusObserver;
  93747. private _onCanvasBlurObserver;
  93748. private _scene;
  93749. /**
  93750. * Creates a new InputManager
  93751. * @param scene defines the hosting scene
  93752. */
  93753. constructor(scene: Scene);
  93754. /**
  93755. * Gets the mesh that is currently under the pointer
  93756. */
  93757. readonly meshUnderPointer: Nullable<AbstractMesh>;
  93758. /**
  93759. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  93760. */
  93761. readonly unTranslatedPointer: Vector2;
  93762. /**
  93763. * Gets or sets the current on-screen X position of the pointer
  93764. */
  93765. pointerX: number;
  93766. /**
  93767. * Gets or sets the current on-screen Y position of the pointer
  93768. */
  93769. pointerY: number;
  93770. private _updatePointerPosition;
  93771. private _processPointerMove;
  93772. private _setRayOnPointerInfo;
  93773. private _checkPrePointerObservable;
  93774. /**
  93775. * Use this method to simulate a pointer move on a mesh
  93776. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  93777. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  93778. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  93779. */
  93780. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  93781. /**
  93782. * Use this method to simulate a pointer down on a mesh
  93783. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  93784. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  93785. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  93786. */
  93787. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  93788. private _processPointerDown;
  93789. /** @hidden */
  93790. _isPointerSwiping(): boolean;
  93791. /**
  93792. * Use this method to simulate a pointer up on a mesh
  93793. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  93794. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  93795. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  93796. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  93797. */
  93798. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  93799. private _processPointerUp;
  93800. /**
  93801. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  93802. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  93803. * @returns true if the pointer was captured
  93804. */
  93805. isPointerCaptured(pointerId?: number): boolean;
  93806. /**
  93807. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  93808. * @param attachUp defines if you want to attach events to pointerup
  93809. * @param attachDown defines if you want to attach events to pointerdown
  93810. * @param attachMove defines if you want to attach events to pointermove
  93811. */
  93812. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  93813. /**
  93814. * Detaches all event handlers
  93815. */
  93816. detachControl(): void;
  93817. /**
  93818. * Force the value of meshUnderPointer
  93819. * @param mesh defines the mesh to use
  93820. */
  93821. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93822. /**
  93823. * Gets the mesh under the pointer
  93824. * @returns a Mesh or null if no mesh is under the pointer
  93825. */
  93826. getPointerOverMesh(): Nullable<AbstractMesh>;
  93827. }
  93828. }
  93829. declare module BABYLON {
  93830. /**
  93831. * This class defines the direct association between an animation and a target
  93832. */
  93833. export class TargetedAnimation {
  93834. /**
  93835. * Animation to perform
  93836. */
  93837. animation: Animation;
  93838. /**
  93839. * Target to animate
  93840. */
  93841. target: any;
  93842. /**
  93843. * Serialize the object
  93844. * @returns the JSON object representing the current entity
  93845. */
  93846. serialize(): any;
  93847. }
  93848. /**
  93849. * Use this class to create coordinated animations on multiple targets
  93850. */
  93851. export class AnimationGroup implements IDisposable {
  93852. /** The name of the animation group */
  93853. name: string;
  93854. private _scene;
  93855. private _targetedAnimations;
  93856. private _animatables;
  93857. private _from;
  93858. private _to;
  93859. private _isStarted;
  93860. private _isPaused;
  93861. private _speedRatio;
  93862. private _loopAnimation;
  93863. /**
  93864. * Gets or sets the unique id of the node
  93865. */
  93866. uniqueId: number;
  93867. /**
  93868. * This observable will notify when one animation have ended
  93869. */
  93870. onAnimationEndObservable: Observable<TargetedAnimation>;
  93871. /**
  93872. * Observer raised when one animation loops
  93873. */
  93874. onAnimationLoopObservable: Observable<TargetedAnimation>;
  93875. /**
  93876. * This observable will notify when all animations have ended.
  93877. */
  93878. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  93879. /**
  93880. * This observable will notify when all animations have paused.
  93881. */
  93882. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  93883. /**
  93884. * This observable will notify when all animations are playing.
  93885. */
  93886. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  93887. /**
  93888. * Gets the first frame
  93889. */
  93890. readonly from: number;
  93891. /**
  93892. * Gets the last frame
  93893. */
  93894. readonly to: number;
  93895. /**
  93896. * Define if the animations are started
  93897. */
  93898. readonly isStarted: boolean;
  93899. /**
  93900. * Gets a value indicating that the current group is playing
  93901. */
  93902. readonly isPlaying: boolean;
  93903. /**
  93904. * Gets or sets the speed ratio to use for all animations
  93905. */
  93906. /**
  93907. * Gets or sets the speed ratio to use for all animations
  93908. */
  93909. speedRatio: number;
  93910. /**
  93911. * Gets or sets if all animations should loop or not
  93912. */
  93913. loopAnimation: boolean;
  93914. /**
  93915. * Gets the targeted animations for this animation group
  93916. */
  93917. readonly targetedAnimations: Array<TargetedAnimation>;
  93918. /**
  93919. * returning the list of animatables controlled by this animation group.
  93920. */
  93921. readonly animatables: Array<Animatable>;
  93922. /**
  93923. * Instantiates a new Animation Group.
  93924. * This helps managing several animations at once.
  93925. * @see http://doc.babylonjs.com/how_to/group
  93926. * @param name Defines the name of the group
  93927. * @param scene Defines the scene the group belongs to
  93928. */
  93929. constructor(
  93930. /** The name of the animation group */
  93931. name: string, scene?: Nullable<Scene>);
  93932. /**
  93933. * Add an animation (with its target) in the group
  93934. * @param animation defines the animation we want to add
  93935. * @param target defines the target of the animation
  93936. * @returns the TargetedAnimation object
  93937. */
  93938. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  93939. /**
  93940. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  93941. * It can add constant keys at begin or end
  93942. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  93943. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  93944. * @returns the animation group
  93945. */
  93946. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  93947. /**
  93948. * Start all animations on given targets
  93949. * @param loop defines if animations must loop
  93950. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  93951. * @param from defines the from key (optional)
  93952. * @param to defines the to key (optional)
  93953. * @returns the current animation group
  93954. */
  93955. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  93956. /**
  93957. * Pause all animations
  93958. * @returns the animation group
  93959. */
  93960. pause(): AnimationGroup;
  93961. /**
  93962. * Play all animations to initial state
  93963. * This function will start() the animations if they were not started or will restart() them if they were paused
  93964. * @param loop defines if animations must loop
  93965. * @returns the animation group
  93966. */
  93967. play(loop?: boolean): AnimationGroup;
  93968. /**
  93969. * Reset all animations to initial state
  93970. * @returns the animation group
  93971. */
  93972. reset(): AnimationGroup;
  93973. /**
  93974. * Restart animations from key 0
  93975. * @returns the animation group
  93976. */
  93977. restart(): AnimationGroup;
  93978. /**
  93979. * Stop all animations
  93980. * @returns the animation group
  93981. */
  93982. stop(): AnimationGroup;
  93983. /**
  93984. * Set animation weight for all animatables
  93985. * @param weight defines the weight to use
  93986. * @return the animationGroup
  93987. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  93988. */
  93989. setWeightForAllAnimatables(weight: number): AnimationGroup;
  93990. /**
  93991. * Synchronize and normalize all animatables with a source animatable
  93992. * @param root defines the root animatable to synchronize with
  93993. * @return the animationGroup
  93994. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  93995. */
  93996. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  93997. /**
  93998. * Goes to a specific frame in this animation group
  93999. * @param frame the frame number to go to
  94000. * @return the animationGroup
  94001. */
  94002. goToFrame(frame: number): AnimationGroup;
  94003. /**
  94004. * Dispose all associated resources
  94005. */
  94006. dispose(): void;
  94007. private _checkAnimationGroupEnded;
  94008. /**
  94009. * Clone the current animation group and returns a copy
  94010. * @param newName defines the name of the new group
  94011. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  94012. * @returns the new aniamtion group
  94013. */
  94014. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  94015. /**
  94016. * Serializes the animationGroup to an object
  94017. * @returns Serialized object
  94018. */
  94019. serialize(): any;
  94020. /**
  94021. * Returns a new AnimationGroup object parsed from the source provided.
  94022. * @param parsedAnimationGroup defines the source
  94023. * @param scene defines the scene that will receive the animationGroup
  94024. * @returns a new AnimationGroup
  94025. */
  94026. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  94027. /**
  94028. * Returns the string "AnimationGroup"
  94029. * @returns "AnimationGroup"
  94030. */
  94031. getClassName(): string;
  94032. /**
  94033. * Creates a detailled string about the object
  94034. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  94035. * @returns a string representing the object
  94036. */
  94037. toString(fullDetails?: boolean): string;
  94038. }
  94039. }
  94040. declare module BABYLON {
  94041. /**
  94042. * Define an interface for all classes that will hold resources
  94043. */
  94044. export interface IDisposable {
  94045. /**
  94046. * Releases all held resources
  94047. */
  94048. dispose(): void;
  94049. }
  94050. /** Interface defining initialization parameters for Scene class */
  94051. export interface SceneOptions {
  94052. /**
  94053. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  94054. * It will improve performance when the number of geometries becomes important.
  94055. */
  94056. useGeometryUniqueIdsMap?: boolean;
  94057. /**
  94058. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  94059. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94060. */
  94061. useMaterialMeshMap?: boolean;
  94062. /**
  94063. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  94064. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  94065. */
  94066. useClonedMeshhMap?: boolean;
  94067. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  94068. virtual?: boolean;
  94069. }
  94070. /**
  94071. * Represents a scene to be rendered by the engine.
  94072. * @see http://doc.babylonjs.com/features/scene
  94073. */
  94074. export class Scene extends AbstractScene implements IAnimatable {
  94075. private static _uniqueIdCounter;
  94076. /** The fog is deactivated */
  94077. static readonly FOGMODE_NONE: number;
  94078. /** The fog density is following an exponential function */
  94079. static readonly FOGMODE_EXP: number;
  94080. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  94081. static readonly FOGMODE_EXP2: number;
  94082. /** The fog density is following a linear function. */
  94083. static readonly FOGMODE_LINEAR: number;
  94084. /**
  94085. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  94086. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94087. */
  94088. static MinDeltaTime: number;
  94089. /**
  94090. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  94091. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94092. */
  94093. static MaxDeltaTime: number;
  94094. /**
  94095. * Factory used to create the default material.
  94096. * @param name The name of the material to create
  94097. * @param scene The scene to create the material for
  94098. * @returns The default material
  94099. */
  94100. static DefaultMaterialFactory(scene: Scene): Material;
  94101. /**
  94102. * Factory used to create the a collision coordinator.
  94103. * @returns The collision coordinator
  94104. */
  94105. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  94106. /** @hidden */
  94107. _inputManager: InputManager;
  94108. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  94109. cameraToUseForPointers: Nullable<Camera>;
  94110. /** @hidden */
  94111. readonly _isScene: boolean;
  94112. /**
  94113. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  94114. */
  94115. autoClear: boolean;
  94116. /**
  94117. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  94118. */
  94119. autoClearDepthAndStencil: boolean;
  94120. /**
  94121. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  94122. */
  94123. clearColor: Color4;
  94124. /**
  94125. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  94126. */
  94127. ambientColor: Color3;
  94128. /**
  94129. * This is use to store the default BRDF lookup for PBR materials in your scene.
  94130. * It should only be one of the following (if not the default embedded one):
  94131. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  94132. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  94133. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  94134. * The material properties need to be setup according to the type of texture in use.
  94135. */
  94136. environmentBRDFTexture: BaseTexture;
  94137. /** @hidden */
  94138. protected _environmentTexture: Nullable<BaseTexture>;
  94139. /**
  94140. * Texture used in all pbr material as the reflection texture.
  94141. * As in the majority of the scene they are the same (exception for multi room and so on),
  94142. * this is easier to reference from here than from all the materials.
  94143. */
  94144. /**
  94145. * Texture used in all pbr material as the reflection texture.
  94146. * As in the majority of the scene they are the same (exception for multi room and so on),
  94147. * this is easier to set here than in all the materials.
  94148. */
  94149. environmentTexture: Nullable<BaseTexture>;
  94150. /** @hidden */
  94151. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  94152. /**
  94153. * Default image processing configuration used either in the rendering
  94154. * Forward main pass or through the imageProcessingPostProcess if present.
  94155. * As in the majority of the scene they are the same (exception for multi camera),
  94156. * this is easier to reference from here than from all the materials and post process.
  94157. *
  94158. * No setter as we it is a shared configuration, you can set the values instead.
  94159. */
  94160. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  94161. private _forceWireframe;
  94162. /**
  94163. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  94164. */
  94165. forceWireframe: boolean;
  94166. private _forcePointsCloud;
  94167. /**
  94168. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  94169. */
  94170. forcePointsCloud: boolean;
  94171. /**
  94172. * Gets or sets the active clipplane 1
  94173. */
  94174. clipPlane: Nullable<Plane>;
  94175. /**
  94176. * Gets or sets the active clipplane 2
  94177. */
  94178. clipPlane2: Nullable<Plane>;
  94179. /**
  94180. * Gets or sets the active clipplane 3
  94181. */
  94182. clipPlane3: Nullable<Plane>;
  94183. /**
  94184. * Gets or sets the active clipplane 4
  94185. */
  94186. clipPlane4: Nullable<Plane>;
  94187. /**
  94188. * Gets or sets a boolean indicating if animations are enabled
  94189. */
  94190. animationsEnabled: boolean;
  94191. private _animationPropertiesOverride;
  94192. /**
  94193. * Gets or sets the animation properties override
  94194. */
  94195. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  94196. /**
  94197. * Gets or sets a boolean indicating if a constant deltatime has to be used
  94198. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  94199. */
  94200. useConstantAnimationDeltaTime: boolean;
  94201. /**
  94202. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  94203. * Please note that it requires to run a ray cast through the scene on every frame
  94204. */
  94205. constantlyUpdateMeshUnderPointer: boolean;
  94206. /**
  94207. * Defines the HTML cursor to use when hovering over interactive elements
  94208. */
  94209. hoverCursor: string;
  94210. /**
  94211. * Defines the HTML default cursor to use (empty by default)
  94212. */
  94213. defaultCursor: string;
  94214. /**
  94215. * This is used to call preventDefault() on pointer down
  94216. * in order to block unwanted artifacts like system double clicks
  94217. */
  94218. preventDefaultOnPointerDown: boolean;
  94219. /**
  94220. * This is used to call preventDefault() on pointer up
  94221. * in order to block unwanted artifacts like system double clicks
  94222. */
  94223. preventDefaultOnPointerUp: boolean;
  94224. /**
  94225. * Gets or sets user defined metadata
  94226. */
  94227. metadata: any;
  94228. /**
  94229. * For internal use only. Please do not use.
  94230. */
  94231. reservedDataStore: any;
  94232. /**
  94233. * Gets the name of the plugin used to load this scene (null by default)
  94234. */
  94235. loadingPluginName: string;
  94236. /**
  94237. * Use this array to add regular expressions used to disable offline support for specific urls
  94238. */
  94239. disableOfflineSupportExceptionRules: RegExp[];
  94240. /**
  94241. * An event triggered when the scene is disposed.
  94242. */
  94243. onDisposeObservable: Observable<Scene>;
  94244. private _onDisposeObserver;
  94245. /** Sets a function to be executed when this scene is disposed. */
  94246. onDispose: () => void;
  94247. /**
  94248. * An event triggered before rendering the scene (right after animations and physics)
  94249. */
  94250. onBeforeRenderObservable: Observable<Scene>;
  94251. private _onBeforeRenderObserver;
  94252. /** Sets a function to be executed before rendering this scene */
  94253. beforeRender: Nullable<() => void>;
  94254. /**
  94255. * An event triggered after rendering the scene
  94256. */
  94257. onAfterRenderObservable: Observable<Scene>;
  94258. private _onAfterRenderObserver;
  94259. /** Sets a function to be executed after rendering this scene */
  94260. afterRender: Nullable<() => void>;
  94261. /**
  94262. * An event triggered before animating the scene
  94263. */
  94264. onBeforeAnimationsObservable: Observable<Scene>;
  94265. /**
  94266. * An event triggered after animations processing
  94267. */
  94268. onAfterAnimationsObservable: Observable<Scene>;
  94269. /**
  94270. * An event triggered before draw calls are ready to be sent
  94271. */
  94272. onBeforeDrawPhaseObservable: Observable<Scene>;
  94273. /**
  94274. * An event triggered after draw calls have been sent
  94275. */
  94276. onAfterDrawPhaseObservable: Observable<Scene>;
  94277. /**
  94278. * An event triggered when the scene is ready
  94279. */
  94280. onReadyObservable: Observable<Scene>;
  94281. /**
  94282. * An event triggered before rendering a camera
  94283. */
  94284. onBeforeCameraRenderObservable: Observable<Camera>;
  94285. private _onBeforeCameraRenderObserver;
  94286. /** Sets a function to be executed before rendering a camera*/
  94287. beforeCameraRender: () => void;
  94288. /**
  94289. * An event triggered after rendering a camera
  94290. */
  94291. onAfterCameraRenderObservable: Observable<Camera>;
  94292. private _onAfterCameraRenderObserver;
  94293. /** Sets a function to be executed after rendering a camera*/
  94294. afterCameraRender: () => void;
  94295. /**
  94296. * An event triggered when active meshes evaluation is about to start
  94297. */
  94298. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  94299. /**
  94300. * An event triggered when active meshes evaluation is done
  94301. */
  94302. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  94303. /**
  94304. * An event triggered when particles rendering is about to start
  94305. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94306. */
  94307. onBeforeParticlesRenderingObservable: Observable<Scene>;
  94308. /**
  94309. * An event triggered when particles rendering is done
  94310. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  94311. */
  94312. onAfterParticlesRenderingObservable: Observable<Scene>;
  94313. /**
  94314. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  94315. */
  94316. onDataLoadedObservable: Observable<Scene>;
  94317. /**
  94318. * An event triggered when a camera is created
  94319. */
  94320. onNewCameraAddedObservable: Observable<Camera>;
  94321. /**
  94322. * An event triggered when a camera is removed
  94323. */
  94324. onCameraRemovedObservable: Observable<Camera>;
  94325. /**
  94326. * An event triggered when a light is created
  94327. */
  94328. onNewLightAddedObservable: Observable<Light>;
  94329. /**
  94330. * An event triggered when a light is removed
  94331. */
  94332. onLightRemovedObservable: Observable<Light>;
  94333. /**
  94334. * An event triggered when a geometry is created
  94335. */
  94336. onNewGeometryAddedObservable: Observable<Geometry>;
  94337. /**
  94338. * An event triggered when a geometry is removed
  94339. */
  94340. onGeometryRemovedObservable: Observable<Geometry>;
  94341. /**
  94342. * An event triggered when a transform node is created
  94343. */
  94344. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  94345. /**
  94346. * An event triggered when a transform node is removed
  94347. */
  94348. onTransformNodeRemovedObservable: Observable<TransformNode>;
  94349. /**
  94350. * An event triggered when a mesh is created
  94351. */
  94352. onNewMeshAddedObservable: Observable<AbstractMesh>;
  94353. /**
  94354. * An event triggered when a mesh is removed
  94355. */
  94356. onMeshRemovedObservable: Observable<AbstractMesh>;
  94357. /**
  94358. * An event triggered when a skeleton is created
  94359. */
  94360. onNewSkeletonAddedObservable: Observable<Skeleton>;
  94361. /**
  94362. * An event triggered when a skeleton is removed
  94363. */
  94364. onSkeletonRemovedObservable: Observable<Skeleton>;
  94365. /**
  94366. * An event triggered when a material is created
  94367. */
  94368. onNewMaterialAddedObservable: Observable<Material>;
  94369. /**
  94370. * An event triggered when a material is removed
  94371. */
  94372. onMaterialRemovedObservable: Observable<Material>;
  94373. /**
  94374. * An event triggered when a texture is created
  94375. */
  94376. onNewTextureAddedObservable: Observable<BaseTexture>;
  94377. /**
  94378. * An event triggered when a texture is removed
  94379. */
  94380. onTextureRemovedObservable: Observable<BaseTexture>;
  94381. /**
  94382. * An event triggered when render targets are about to be rendered
  94383. * Can happen multiple times per frame.
  94384. */
  94385. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  94386. /**
  94387. * An event triggered when render targets were rendered.
  94388. * Can happen multiple times per frame.
  94389. */
  94390. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  94391. /**
  94392. * An event triggered before calculating deterministic simulation step
  94393. */
  94394. onBeforeStepObservable: Observable<Scene>;
  94395. /**
  94396. * An event triggered after calculating deterministic simulation step
  94397. */
  94398. onAfterStepObservable: Observable<Scene>;
  94399. /**
  94400. * An event triggered when the activeCamera property is updated
  94401. */
  94402. onActiveCameraChanged: Observable<Scene>;
  94403. /**
  94404. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  94405. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94406. * 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)
  94407. */
  94408. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94409. /**
  94410. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  94411. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  94412. * 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)
  94413. */
  94414. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  94415. /**
  94416. * This Observable will when a mesh has been imported into the scene.
  94417. */
  94418. onMeshImportedObservable: Observable<AbstractMesh>;
  94419. /**
  94420. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  94421. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  94422. */
  94423. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  94424. /** @hidden */
  94425. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  94426. /**
  94427. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  94428. */
  94429. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  94430. /**
  94431. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  94432. */
  94433. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  94434. /**
  94435. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  94436. */
  94437. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  94438. /** Callback called when a pointer move is detected */
  94439. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94440. /** Callback called when a pointer down is detected */
  94441. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  94442. /** Callback called when a pointer up is detected */
  94443. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  94444. /** Callback called when a pointer pick is detected */
  94445. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  94446. /**
  94447. * 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).
  94448. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  94449. */
  94450. onPrePointerObservable: Observable<PointerInfoPre>;
  94451. /**
  94452. * Observable event triggered each time an input event is received from the rendering canvas
  94453. */
  94454. onPointerObservable: Observable<PointerInfo>;
  94455. /**
  94456. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  94457. */
  94458. readonly unTranslatedPointer: Vector2;
  94459. /**
  94460. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  94461. */
  94462. static DragMovementThreshold: number;
  94463. /**
  94464. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  94465. */
  94466. static LongPressDelay: number;
  94467. /**
  94468. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  94469. */
  94470. static DoubleClickDelay: number;
  94471. /** If you need to check double click without raising a single click at first click, enable this flag */
  94472. static ExclusiveDoubleClickMode: boolean;
  94473. /** @hidden */
  94474. _mirroredCameraPosition: Nullable<Vector3>;
  94475. /**
  94476. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  94477. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  94478. */
  94479. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  94480. /**
  94481. * Observable event triggered each time an keyboard event is received from the hosting window
  94482. */
  94483. onKeyboardObservable: Observable<KeyboardInfo>;
  94484. private _useRightHandedSystem;
  94485. /**
  94486. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  94487. */
  94488. useRightHandedSystem: boolean;
  94489. private _timeAccumulator;
  94490. private _currentStepId;
  94491. private _currentInternalStep;
  94492. /**
  94493. * Sets the step Id used by deterministic lock step
  94494. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94495. * @param newStepId defines the step Id
  94496. */
  94497. setStepId(newStepId: number): void;
  94498. /**
  94499. * Gets the step Id used by deterministic lock step
  94500. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94501. * @returns the step Id
  94502. */
  94503. getStepId(): number;
  94504. /**
  94505. * Gets the internal step used by deterministic lock step
  94506. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  94507. * @returns the internal step
  94508. */
  94509. getInternalStep(): number;
  94510. private _fogEnabled;
  94511. /**
  94512. * Gets or sets a boolean indicating if fog is enabled on this scene
  94513. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94514. * (Default is true)
  94515. */
  94516. fogEnabled: boolean;
  94517. private _fogMode;
  94518. /**
  94519. * Gets or sets the fog mode to use
  94520. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94521. * | mode | value |
  94522. * | --- | --- |
  94523. * | FOGMODE_NONE | 0 |
  94524. * | FOGMODE_EXP | 1 |
  94525. * | FOGMODE_EXP2 | 2 |
  94526. * | FOGMODE_LINEAR | 3 |
  94527. */
  94528. fogMode: number;
  94529. /**
  94530. * Gets or sets the fog color to use
  94531. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94532. * (Default is Color3(0.2, 0.2, 0.3))
  94533. */
  94534. fogColor: Color3;
  94535. /**
  94536. * Gets or sets the fog density to use
  94537. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94538. * (Default is 0.1)
  94539. */
  94540. fogDensity: number;
  94541. /**
  94542. * Gets or sets the fog start distance to use
  94543. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94544. * (Default is 0)
  94545. */
  94546. fogStart: number;
  94547. /**
  94548. * Gets or sets the fog end distance to use
  94549. * @see http://doc.babylonjs.com/babylon101/environment#fog
  94550. * (Default is 1000)
  94551. */
  94552. fogEnd: number;
  94553. private _shadowsEnabled;
  94554. /**
  94555. * Gets or sets a boolean indicating if shadows are enabled on this scene
  94556. */
  94557. shadowsEnabled: boolean;
  94558. private _lightsEnabled;
  94559. /**
  94560. * Gets or sets a boolean indicating if lights are enabled on this scene
  94561. */
  94562. lightsEnabled: boolean;
  94563. /** All of the active cameras added to this scene. */
  94564. activeCameras: Camera[];
  94565. /** @hidden */
  94566. _activeCamera: Nullable<Camera>;
  94567. /** Gets or sets the current active camera */
  94568. activeCamera: Nullable<Camera>;
  94569. private _defaultMaterial;
  94570. /** The default material used on meshes when no material is affected */
  94571. /** The default material used on meshes when no material is affected */
  94572. defaultMaterial: Material;
  94573. private _texturesEnabled;
  94574. /**
  94575. * Gets or sets a boolean indicating if textures are enabled on this scene
  94576. */
  94577. texturesEnabled: boolean;
  94578. /**
  94579. * Gets or sets a boolean indicating if particles are enabled on this scene
  94580. */
  94581. particlesEnabled: boolean;
  94582. /**
  94583. * Gets or sets a boolean indicating if sprites are enabled on this scene
  94584. */
  94585. spritesEnabled: boolean;
  94586. private _skeletonsEnabled;
  94587. /**
  94588. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  94589. */
  94590. skeletonsEnabled: boolean;
  94591. /**
  94592. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  94593. */
  94594. lensFlaresEnabled: boolean;
  94595. /**
  94596. * Gets or sets a boolean indicating if collisions are enabled on this scene
  94597. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94598. */
  94599. collisionsEnabled: boolean;
  94600. private _collisionCoordinator;
  94601. /** @hidden */
  94602. readonly collisionCoordinator: ICollisionCoordinator;
  94603. /**
  94604. * Defines the gravity applied to this scene (used only for collisions)
  94605. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  94606. */
  94607. gravity: Vector3;
  94608. /**
  94609. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  94610. */
  94611. postProcessesEnabled: boolean;
  94612. /**
  94613. * The list of postprocesses added to the scene
  94614. */
  94615. postProcesses: PostProcess[];
  94616. /**
  94617. * Gets the current postprocess manager
  94618. */
  94619. postProcessManager: PostProcessManager;
  94620. /**
  94621. * Gets or sets a boolean indicating if render targets are enabled on this scene
  94622. */
  94623. renderTargetsEnabled: boolean;
  94624. /**
  94625. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  94626. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  94627. */
  94628. dumpNextRenderTargets: boolean;
  94629. /**
  94630. * The list of user defined render targets added to the scene
  94631. */
  94632. customRenderTargets: RenderTargetTexture[];
  94633. /**
  94634. * Defines if texture loading must be delayed
  94635. * If true, textures will only be loaded when they need to be rendered
  94636. */
  94637. useDelayedTextureLoading: boolean;
  94638. /**
  94639. * Gets the list of meshes imported to the scene through SceneLoader
  94640. */
  94641. importedMeshesFiles: String[];
  94642. /**
  94643. * Gets or sets a boolean indicating if probes are enabled on this scene
  94644. */
  94645. probesEnabled: boolean;
  94646. /**
  94647. * Gets or sets the current offline provider to use to store scene data
  94648. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  94649. */
  94650. offlineProvider: IOfflineProvider;
  94651. /**
  94652. * Gets or sets the action manager associated with the scene
  94653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  94654. */
  94655. actionManager: AbstractActionManager;
  94656. private _meshesForIntersections;
  94657. /**
  94658. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  94659. */
  94660. proceduralTexturesEnabled: boolean;
  94661. private _engine;
  94662. private _totalVertices;
  94663. /** @hidden */
  94664. _activeIndices: PerfCounter;
  94665. /** @hidden */
  94666. _activeParticles: PerfCounter;
  94667. /** @hidden */
  94668. _activeBones: PerfCounter;
  94669. private _animationRatio;
  94670. /** @hidden */
  94671. _animationTimeLast: number;
  94672. /** @hidden */
  94673. _animationTime: number;
  94674. /**
  94675. * Gets or sets a general scale for animation speed
  94676. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  94677. */
  94678. animationTimeScale: number;
  94679. /** @hidden */
  94680. _cachedMaterial: Nullable<Material>;
  94681. /** @hidden */
  94682. _cachedEffect: Nullable<Effect>;
  94683. /** @hidden */
  94684. _cachedVisibility: Nullable<number>;
  94685. private _renderId;
  94686. private _frameId;
  94687. private _executeWhenReadyTimeoutId;
  94688. private _intermediateRendering;
  94689. private _viewUpdateFlag;
  94690. private _projectionUpdateFlag;
  94691. /** @hidden */
  94692. _toBeDisposed: Nullable<IDisposable>[];
  94693. private _activeRequests;
  94694. /** @hidden */
  94695. _pendingData: any[];
  94696. private _isDisposed;
  94697. /**
  94698. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  94699. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  94700. */
  94701. dispatchAllSubMeshesOfActiveMeshes: boolean;
  94702. private _activeMeshes;
  94703. private _processedMaterials;
  94704. private _renderTargets;
  94705. /** @hidden */
  94706. _activeParticleSystems: SmartArray<IParticleSystem>;
  94707. private _activeSkeletons;
  94708. private _softwareSkinnedMeshes;
  94709. private _renderingManager;
  94710. /** @hidden */
  94711. _activeAnimatables: Animatable[];
  94712. private _transformMatrix;
  94713. private _sceneUbo;
  94714. /** @hidden */
  94715. _viewMatrix: Matrix;
  94716. private _projectionMatrix;
  94717. /** @hidden */
  94718. _forcedViewPosition: Nullable<Vector3>;
  94719. /** @hidden */
  94720. _frustumPlanes: Plane[];
  94721. /**
  94722. * Gets the list of frustum planes (built from the active camera)
  94723. */
  94724. readonly frustumPlanes: Plane[];
  94725. /**
  94726. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  94727. * This is useful if there are more lights that the maximum simulteanous authorized
  94728. */
  94729. requireLightSorting: boolean;
  94730. /** @hidden */
  94731. readonly useMaterialMeshMap: boolean;
  94732. /** @hidden */
  94733. readonly useClonedMeshhMap: boolean;
  94734. private _externalData;
  94735. private _uid;
  94736. /**
  94737. * @hidden
  94738. * Backing store of defined scene components.
  94739. */
  94740. _components: ISceneComponent[];
  94741. /**
  94742. * @hidden
  94743. * Backing store of defined scene components.
  94744. */
  94745. _serializableComponents: ISceneSerializableComponent[];
  94746. /**
  94747. * List of components to register on the next registration step.
  94748. */
  94749. private _transientComponents;
  94750. /**
  94751. * Registers the transient components if needed.
  94752. */
  94753. private _registerTransientComponents;
  94754. /**
  94755. * @hidden
  94756. * Add a component to the scene.
  94757. * Note that the ccomponent could be registered on th next frame if this is called after
  94758. * the register component stage.
  94759. * @param component Defines the component to add to the scene
  94760. */
  94761. _addComponent(component: ISceneComponent): void;
  94762. /**
  94763. * @hidden
  94764. * Gets a component from the scene.
  94765. * @param name defines the name of the component to retrieve
  94766. * @returns the component or null if not present
  94767. */
  94768. _getComponent(name: string): Nullable<ISceneComponent>;
  94769. /**
  94770. * @hidden
  94771. * Defines the actions happening before camera updates.
  94772. */
  94773. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  94774. /**
  94775. * @hidden
  94776. * Defines the actions happening before clear the canvas.
  94777. */
  94778. _beforeClearStage: Stage<SimpleStageAction>;
  94779. /**
  94780. * @hidden
  94781. * Defines the actions when collecting render targets for the frame.
  94782. */
  94783. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  94784. /**
  94785. * @hidden
  94786. * Defines the actions happening for one camera in the frame.
  94787. */
  94788. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  94789. /**
  94790. * @hidden
  94791. * Defines the actions happening during the per mesh ready checks.
  94792. */
  94793. _isReadyForMeshStage: Stage<MeshStageAction>;
  94794. /**
  94795. * @hidden
  94796. * Defines the actions happening before evaluate active mesh checks.
  94797. */
  94798. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  94799. /**
  94800. * @hidden
  94801. * Defines the actions happening during the evaluate sub mesh checks.
  94802. */
  94803. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  94804. /**
  94805. * @hidden
  94806. * Defines the actions happening during the active mesh stage.
  94807. */
  94808. _activeMeshStage: Stage<ActiveMeshStageAction>;
  94809. /**
  94810. * @hidden
  94811. * Defines the actions happening during the per camera render target step.
  94812. */
  94813. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  94814. /**
  94815. * @hidden
  94816. * Defines the actions happening just before the active camera is drawing.
  94817. */
  94818. _beforeCameraDrawStage: Stage<CameraStageAction>;
  94819. /**
  94820. * @hidden
  94821. * Defines the actions happening just before a render target is drawing.
  94822. */
  94823. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  94824. /**
  94825. * @hidden
  94826. * Defines the actions happening just before a rendering group is drawing.
  94827. */
  94828. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  94829. /**
  94830. * @hidden
  94831. * Defines the actions happening just before a mesh is drawing.
  94832. */
  94833. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  94834. /**
  94835. * @hidden
  94836. * Defines the actions happening just after a mesh has been drawn.
  94837. */
  94838. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  94839. /**
  94840. * @hidden
  94841. * Defines the actions happening just after a rendering group has been drawn.
  94842. */
  94843. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  94844. /**
  94845. * @hidden
  94846. * Defines the actions happening just after the active camera has been drawn.
  94847. */
  94848. _afterCameraDrawStage: Stage<CameraStageAction>;
  94849. /**
  94850. * @hidden
  94851. * Defines the actions happening just after a render target has been drawn.
  94852. */
  94853. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  94854. /**
  94855. * @hidden
  94856. * Defines the actions happening just after rendering all cameras and computing intersections.
  94857. */
  94858. _afterRenderStage: Stage<SimpleStageAction>;
  94859. /**
  94860. * @hidden
  94861. * Defines the actions happening when a pointer move event happens.
  94862. */
  94863. _pointerMoveStage: Stage<PointerMoveStageAction>;
  94864. /**
  94865. * @hidden
  94866. * Defines the actions happening when a pointer down event happens.
  94867. */
  94868. _pointerDownStage: Stage<PointerUpDownStageAction>;
  94869. /**
  94870. * @hidden
  94871. * Defines the actions happening when a pointer up event happens.
  94872. */
  94873. _pointerUpStage: Stage<PointerUpDownStageAction>;
  94874. /**
  94875. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  94876. */
  94877. private geometriesByUniqueId;
  94878. /**
  94879. * Creates a new Scene
  94880. * @param engine defines the engine to use to render this scene
  94881. * @param options defines the scene options
  94882. */
  94883. constructor(engine: Engine, options?: SceneOptions);
  94884. /**
  94885. * Gets a string idenfifying the name of the class
  94886. * @returns "Scene" string
  94887. */
  94888. getClassName(): string;
  94889. private _defaultMeshCandidates;
  94890. /**
  94891. * @hidden
  94892. */
  94893. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  94894. private _defaultSubMeshCandidates;
  94895. /**
  94896. * @hidden
  94897. */
  94898. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  94899. /**
  94900. * Sets the default candidate providers for the scene.
  94901. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  94902. * and getCollidingSubMeshCandidates to their default function
  94903. */
  94904. setDefaultCandidateProviders(): void;
  94905. /**
  94906. * Gets the mesh that is currently under the pointer
  94907. */
  94908. readonly meshUnderPointer: Nullable<AbstractMesh>;
  94909. /**
  94910. * Gets or sets the current on-screen X position of the pointer
  94911. */
  94912. pointerX: number;
  94913. /**
  94914. * Gets or sets the current on-screen Y position of the pointer
  94915. */
  94916. pointerY: number;
  94917. /**
  94918. * Gets the cached material (ie. the latest rendered one)
  94919. * @returns the cached material
  94920. */
  94921. getCachedMaterial(): Nullable<Material>;
  94922. /**
  94923. * Gets the cached effect (ie. the latest rendered one)
  94924. * @returns the cached effect
  94925. */
  94926. getCachedEffect(): Nullable<Effect>;
  94927. /**
  94928. * Gets the cached visibility state (ie. the latest rendered one)
  94929. * @returns the cached visibility state
  94930. */
  94931. getCachedVisibility(): Nullable<number>;
  94932. /**
  94933. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  94934. * @param material defines the current material
  94935. * @param effect defines the current effect
  94936. * @param visibility defines the current visibility state
  94937. * @returns true if one parameter is not cached
  94938. */
  94939. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  94940. /**
  94941. * Gets the engine associated with the scene
  94942. * @returns an Engine
  94943. */
  94944. getEngine(): Engine;
  94945. /**
  94946. * Gets the total number of vertices rendered per frame
  94947. * @returns the total number of vertices rendered per frame
  94948. */
  94949. getTotalVertices(): number;
  94950. /**
  94951. * Gets the performance counter for total vertices
  94952. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  94953. */
  94954. readonly totalVerticesPerfCounter: PerfCounter;
  94955. /**
  94956. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  94957. * @returns the total number of active indices rendered per frame
  94958. */
  94959. getActiveIndices(): number;
  94960. /**
  94961. * Gets the performance counter for active indices
  94962. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  94963. */
  94964. readonly totalActiveIndicesPerfCounter: PerfCounter;
  94965. /**
  94966. * Gets the total number of active particles rendered per frame
  94967. * @returns the total number of active particles rendered per frame
  94968. */
  94969. getActiveParticles(): number;
  94970. /**
  94971. * Gets the performance counter for active particles
  94972. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  94973. */
  94974. readonly activeParticlesPerfCounter: PerfCounter;
  94975. /**
  94976. * Gets the total number of active bones rendered per frame
  94977. * @returns the total number of active bones rendered per frame
  94978. */
  94979. getActiveBones(): number;
  94980. /**
  94981. * Gets the performance counter for active bones
  94982. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  94983. */
  94984. readonly activeBonesPerfCounter: PerfCounter;
  94985. /**
  94986. * Gets the array of active meshes
  94987. * @returns an array of AbstractMesh
  94988. */
  94989. getActiveMeshes(): SmartArray<AbstractMesh>;
  94990. /**
  94991. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  94992. * @returns a number
  94993. */
  94994. getAnimationRatio(): number;
  94995. /**
  94996. * Gets an unique Id for the current render phase
  94997. * @returns a number
  94998. */
  94999. getRenderId(): number;
  95000. /**
  95001. * Gets an unique Id for the current frame
  95002. * @returns a number
  95003. */
  95004. getFrameId(): number;
  95005. /** Call this function if you want to manually increment the render Id*/
  95006. incrementRenderId(): void;
  95007. private _createUbo;
  95008. /**
  95009. * Use this method to simulate a pointer move on a mesh
  95010. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95011. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95012. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95013. * @returns the current scene
  95014. */
  95015. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95016. /**
  95017. * Use this method to simulate a pointer down on a mesh
  95018. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95019. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95020. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95021. * @returns the current scene
  95022. */
  95023. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  95024. /**
  95025. * Use this method to simulate a pointer up on a mesh
  95026. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  95027. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  95028. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  95029. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  95030. * @returns the current scene
  95031. */
  95032. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  95033. /**
  95034. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  95035. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  95036. * @returns true if the pointer was captured
  95037. */
  95038. isPointerCaptured(pointerId?: number): boolean;
  95039. /**
  95040. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  95041. * @param attachUp defines if you want to attach events to pointerup
  95042. * @param attachDown defines if you want to attach events to pointerdown
  95043. * @param attachMove defines if you want to attach events to pointermove
  95044. */
  95045. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  95046. /** Detaches all event handlers*/
  95047. detachControl(): void;
  95048. /**
  95049. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  95050. * Delay loaded resources are not taking in account
  95051. * @return true if all required resources are ready
  95052. */
  95053. isReady(): boolean;
  95054. /** Resets all cached information relative to material (including effect and visibility) */
  95055. resetCachedMaterial(): void;
  95056. /**
  95057. * Registers a function to be called before every frame render
  95058. * @param func defines the function to register
  95059. */
  95060. registerBeforeRender(func: () => void): void;
  95061. /**
  95062. * Unregisters a function called before every frame render
  95063. * @param func defines the function to unregister
  95064. */
  95065. unregisterBeforeRender(func: () => void): void;
  95066. /**
  95067. * Registers a function to be called after every frame render
  95068. * @param func defines the function to register
  95069. */
  95070. registerAfterRender(func: () => void): void;
  95071. /**
  95072. * Unregisters a function called after every frame render
  95073. * @param func defines the function to unregister
  95074. */
  95075. unregisterAfterRender(func: () => void): void;
  95076. private _executeOnceBeforeRender;
  95077. /**
  95078. * The provided function will run before render once and will be disposed afterwards.
  95079. * A timeout delay can be provided so that the function will be executed in N ms.
  95080. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  95081. * @param func The function to be executed.
  95082. * @param timeout optional delay in ms
  95083. */
  95084. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  95085. /** @hidden */
  95086. _addPendingData(data: any): void;
  95087. /** @hidden */
  95088. _removePendingData(data: any): void;
  95089. /**
  95090. * Returns the number of items waiting to be loaded
  95091. * @returns the number of items waiting to be loaded
  95092. */
  95093. getWaitingItemsCount(): number;
  95094. /**
  95095. * Returns a boolean indicating if the scene is still loading data
  95096. */
  95097. readonly isLoading: boolean;
  95098. /**
  95099. * Registers a function to be executed when the scene is ready
  95100. * @param {Function} func - the function to be executed
  95101. */
  95102. executeWhenReady(func: () => void): void;
  95103. /**
  95104. * Returns a promise that resolves when the scene is ready
  95105. * @returns A promise that resolves when the scene is ready
  95106. */
  95107. whenReadyAsync(): Promise<void>;
  95108. /** @hidden */
  95109. _checkIsReady(): void;
  95110. /**
  95111. * Gets all animatable attached to the scene
  95112. */
  95113. readonly animatables: Animatable[];
  95114. /**
  95115. * Resets the last animation time frame.
  95116. * Useful to override when animations start running when loading a scene for the first time.
  95117. */
  95118. resetLastAnimationTimeFrame(): void;
  95119. /**
  95120. * Gets the current view matrix
  95121. * @returns a Matrix
  95122. */
  95123. getViewMatrix(): Matrix;
  95124. /**
  95125. * Gets the current projection matrix
  95126. * @returns a Matrix
  95127. */
  95128. getProjectionMatrix(): Matrix;
  95129. /**
  95130. * Gets the current transform matrix
  95131. * @returns a Matrix made of View * Projection
  95132. */
  95133. getTransformMatrix(): Matrix;
  95134. /**
  95135. * Sets the current transform matrix
  95136. * @param viewL defines the View matrix to use
  95137. * @param projectionL defines the Projection matrix to use
  95138. * @param viewR defines the right View matrix to use (if provided)
  95139. * @param projectionR defines the right Projection matrix to use (if provided)
  95140. */
  95141. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  95142. /**
  95143. * Gets the uniform buffer used to store scene data
  95144. * @returns a UniformBuffer
  95145. */
  95146. getSceneUniformBuffer(): UniformBuffer;
  95147. /**
  95148. * Gets an unique (relatively to the current scene) Id
  95149. * @returns an unique number for the scene
  95150. */
  95151. getUniqueId(): number;
  95152. /**
  95153. * Add a mesh to the list of scene's meshes
  95154. * @param newMesh defines the mesh to add
  95155. * @param recursive if all child meshes should also be added to the scene
  95156. */
  95157. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  95158. /**
  95159. * Remove a mesh for the list of scene's meshes
  95160. * @param toRemove defines the mesh to remove
  95161. * @param recursive if all child meshes should also be removed from the scene
  95162. * @returns the index where the mesh was in the mesh list
  95163. */
  95164. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  95165. /**
  95166. * Add a transform node to the list of scene's transform nodes
  95167. * @param newTransformNode defines the transform node to add
  95168. */
  95169. addTransformNode(newTransformNode: TransformNode): void;
  95170. /**
  95171. * Remove a transform node for the list of scene's transform nodes
  95172. * @param toRemove defines the transform node to remove
  95173. * @returns the index where the transform node was in the transform node list
  95174. */
  95175. removeTransformNode(toRemove: TransformNode): number;
  95176. /**
  95177. * Remove a skeleton for the list of scene's skeletons
  95178. * @param toRemove defines the skeleton to remove
  95179. * @returns the index where the skeleton was in the skeleton list
  95180. */
  95181. removeSkeleton(toRemove: Skeleton): number;
  95182. /**
  95183. * Remove a morph target for the list of scene's morph targets
  95184. * @param toRemove defines the morph target to remove
  95185. * @returns the index where the morph target was in the morph target list
  95186. */
  95187. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  95188. /**
  95189. * Remove a light for the list of scene's lights
  95190. * @param toRemove defines the light to remove
  95191. * @returns the index where the light was in the light list
  95192. */
  95193. removeLight(toRemove: Light): number;
  95194. /**
  95195. * Remove a camera for the list of scene's cameras
  95196. * @param toRemove defines the camera to remove
  95197. * @returns the index where the camera was in the camera list
  95198. */
  95199. removeCamera(toRemove: Camera): number;
  95200. /**
  95201. * Remove a particle system for the list of scene's particle systems
  95202. * @param toRemove defines the particle system to remove
  95203. * @returns the index where the particle system was in the particle system list
  95204. */
  95205. removeParticleSystem(toRemove: IParticleSystem): number;
  95206. /**
  95207. * Remove a animation for the list of scene's animations
  95208. * @param toRemove defines the animation to remove
  95209. * @returns the index where the animation was in the animation list
  95210. */
  95211. removeAnimation(toRemove: Animation): number;
  95212. /**
  95213. * Will stop the animation of the given target
  95214. * @param target - the target
  95215. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  95216. * @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)
  95217. */
  95218. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  95219. /**
  95220. * Removes the given animation group from this scene.
  95221. * @param toRemove The animation group to remove
  95222. * @returns The index of the removed animation group
  95223. */
  95224. removeAnimationGroup(toRemove: AnimationGroup): number;
  95225. /**
  95226. * Removes the given multi-material from this scene.
  95227. * @param toRemove The multi-material to remove
  95228. * @returns The index of the removed multi-material
  95229. */
  95230. removeMultiMaterial(toRemove: MultiMaterial): number;
  95231. /**
  95232. * Removes the given material from this scene.
  95233. * @param toRemove The material to remove
  95234. * @returns The index of the removed material
  95235. */
  95236. removeMaterial(toRemove: Material): number;
  95237. /**
  95238. * Removes the given action manager from this scene.
  95239. * @param toRemove The action manager to remove
  95240. * @returns The index of the removed action manager
  95241. */
  95242. removeActionManager(toRemove: AbstractActionManager): number;
  95243. /**
  95244. * Removes the given texture from this scene.
  95245. * @param toRemove The texture to remove
  95246. * @returns The index of the removed texture
  95247. */
  95248. removeTexture(toRemove: BaseTexture): number;
  95249. /**
  95250. * Adds the given light to this scene
  95251. * @param newLight The light to add
  95252. */
  95253. addLight(newLight: Light): void;
  95254. /**
  95255. * Sorts the list list based on light priorities
  95256. */
  95257. sortLightsByPriority(): void;
  95258. /**
  95259. * Adds the given camera to this scene
  95260. * @param newCamera The camera to add
  95261. */
  95262. addCamera(newCamera: Camera): void;
  95263. /**
  95264. * Adds the given skeleton to this scene
  95265. * @param newSkeleton The skeleton to add
  95266. */
  95267. addSkeleton(newSkeleton: Skeleton): void;
  95268. /**
  95269. * Adds the given particle system to this scene
  95270. * @param newParticleSystem The particle system to add
  95271. */
  95272. addParticleSystem(newParticleSystem: IParticleSystem): void;
  95273. /**
  95274. * Adds the given animation to this scene
  95275. * @param newAnimation The animation to add
  95276. */
  95277. addAnimation(newAnimation: Animation): void;
  95278. /**
  95279. * Adds the given animation group to this scene.
  95280. * @param newAnimationGroup The animation group to add
  95281. */
  95282. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  95283. /**
  95284. * Adds the given multi-material to this scene
  95285. * @param newMultiMaterial The multi-material to add
  95286. */
  95287. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  95288. /**
  95289. * Adds the given material to this scene
  95290. * @param newMaterial The material to add
  95291. */
  95292. addMaterial(newMaterial: Material): void;
  95293. /**
  95294. * Adds the given morph target to this scene
  95295. * @param newMorphTargetManager The morph target to add
  95296. */
  95297. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  95298. /**
  95299. * Adds the given geometry to this scene
  95300. * @param newGeometry The geometry to add
  95301. */
  95302. addGeometry(newGeometry: Geometry): void;
  95303. /**
  95304. * Adds the given action manager to this scene
  95305. * @param newActionManager The action manager to add
  95306. */
  95307. addActionManager(newActionManager: AbstractActionManager): void;
  95308. /**
  95309. * Adds the given texture to this scene.
  95310. * @param newTexture The texture to add
  95311. */
  95312. addTexture(newTexture: BaseTexture): void;
  95313. /**
  95314. * Switch active camera
  95315. * @param newCamera defines the new active camera
  95316. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  95317. */
  95318. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  95319. /**
  95320. * sets the active camera of the scene using its ID
  95321. * @param id defines the camera's ID
  95322. * @return the new active camera or null if none found.
  95323. */
  95324. setActiveCameraByID(id: string): Nullable<Camera>;
  95325. /**
  95326. * sets the active camera of the scene using its name
  95327. * @param name defines the camera's name
  95328. * @returns the new active camera or null if none found.
  95329. */
  95330. setActiveCameraByName(name: string): Nullable<Camera>;
  95331. /**
  95332. * get an animation group using its name
  95333. * @param name defines the material's name
  95334. * @return the animation group or null if none found.
  95335. */
  95336. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  95337. /**
  95338. * Get a material using its unique id
  95339. * @param uniqueId defines the material's unique id
  95340. * @return the material or null if none found.
  95341. */
  95342. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  95343. /**
  95344. * get a material using its id
  95345. * @param id defines the material's ID
  95346. * @return the material or null if none found.
  95347. */
  95348. getMaterialByID(id: string): Nullable<Material>;
  95349. /**
  95350. * Gets a material using its name
  95351. * @param name defines the material's name
  95352. * @return the material or null if none found.
  95353. */
  95354. getMaterialByName(name: string): Nullable<Material>;
  95355. /**
  95356. * Gets a camera using its id
  95357. * @param id defines the id to look for
  95358. * @returns the camera or null if not found
  95359. */
  95360. getCameraByID(id: string): Nullable<Camera>;
  95361. /**
  95362. * Gets a camera using its unique id
  95363. * @param uniqueId defines the unique id to look for
  95364. * @returns the camera or null if not found
  95365. */
  95366. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  95367. /**
  95368. * Gets a camera using its name
  95369. * @param name defines the camera's name
  95370. * @return the camera or null if none found.
  95371. */
  95372. getCameraByName(name: string): Nullable<Camera>;
  95373. /**
  95374. * Gets a bone using its id
  95375. * @param id defines the bone's id
  95376. * @return the bone or null if not found
  95377. */
  95378. getBoneByID(id: string): Nullable<Bone>;
  95379. /**
  95380. * Gets a bone using its id
  95381. * @param name defines the bone's name
  95382. * @return the bone or null if not found
  95383. */
  95384. getBoneByName(name: string): Nullable<Bone>;
  95385. /**
  95386. * Gets a light node using its name
  95387. * @param name defines the the light's name
  95388. * @return the light or null if none found.
  95389. */
  95390. getLightByName(name: string): Nullable<Light>;
  95391. /**
  95392. * Gets a light node using its id
  95393. * @param id defines the light's id
  95394. * @return the light or null if none found.
  95395. */
  95396. getLightByID(id: string): Nullable<Light>;
  95397. /**
  95398. * Gets a light node using its scene-generated unique ID
  95399. * @param uniqueId defines the light's unique id
  95400. * @return the light or null if none found.
  95401. */
  95402. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  95403. /**
  95404. * Gets a particle system by id
  95405. * @param id defines the particle system id
  95406. * @return the corresponding system or null if none found
  95407. */
  95408. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  95409. /**
  95410. * Gets a geometry using its ID
  95411. * @param id defines the geometry's id
  95412. * @return the geometry or null if none found.
  95413. */
  95414. getGeometryByID(id: string): Nullable<Geometry>;
  95415. private _getGeometryByUniqueID;
  95416. /**
  95417. * Add a new geometry to this scene
  95418. * @param geometry defines the geometry to be added to the scene.
  95419. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  95420. * @return a boolean defining if the geometry was added or not
  95421. */
  95422. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  95423. /**
  95424. * Removes an existing geometry
  95425. * @param geometry defines the geometry to be removed from the scene
  95426. * @return a boolean defining if the geometry was removed or not
  95427. */
  95428. removeGeometry(geometry: Geometry): boolean;
  95429. /**
  95430. * Gets the list of geometries attached to the scene
  95431. * @returns an array of Geometry
  95432. */
  95433. getGeometries(): Geometry[];
  95434. /**
  95435. * Gets the first added mesh found of a given ID
  95436. * @param id defines the id to search for
  95437. * @return the mesh found or null if not found at all
  95438. */
  95439. getMeshByID(id: string): Nullable<AbstractMesh>;
  95440. /**
  95441. * Gets a list of meshes using their id
  95442. * @param id defines the id to search for
  95443. * @returns a list of meshes
  95444. */
  95445. getMeshesByID(id: string): Array<AbstractMesh>;
  95446. /**
  95447. * Gets the first added transform node found of a given ID
  95448. * @param id defines the id to search for
  95449. * @return the found transform node or null if not found at all.
  95450. */
  95451. getTransformNodeByID(id: string): Nullable<TransformNode>;
  95452. /**
  95453. * Gets a transform node with its auto-generated unique id
  95454. * @param uniqueId efines the unique id to search for
  95455. * @return the found transform node or null if not found at all.
  95456. */
  95457. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  95458. /**
  95459. * Gets a list of transform nodes using their id
  95460. * @param id defines the id to search for
  95461. * @returns a list of transform nodes
  95462. */
  95463. getTransformNodesByID(id: string): Array<TransformNode>;
  95464. /**
  95465. * Gets a mesh with its auto-generated unique id
  95466. * @param uniqueId defines the unique id to search for
  95467. * @return the found mesh or null if not found at all.
  95468. */
  95469. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  95470. /**
  95471. * Gets a the last added mesh using a given id
  95472. * @param id defines the id to search for
  95473. * @return the found mesh or null if not found at all.
  95474. */
  95475. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  95476. /**
  95477. * Gets a the last added node (Mesh, Camera, Light) using a given id
  95478. * @param id defines the id to search for
  95479. * @return the found node or null if not found at all
  95480. */
  95481. getLastEntryByID(id: string): Nullable<Node>;
  95482. /**
  95483. * Gets a node (Mesh, Camera, Light) using a given id
  95484. * @param id defines the id to search for
  95485. * @return the found node or null if not found at all
  95486. */
  95487. getNodeByID(id: string): Nullable<Node>;
  95488. /**
  95489. * Gets a node (Mesh, Camera, Light) using a given name
  95490. * @param name defines the name to search for
  95491. * @return the found node or null if not found at all.
  95492. */
  95493. getNodeByName(name: string): Nullable<Node>;
  95494. /**
  95495. * Gets a mesh using a given name
  95496. * @param name defines the name to search for
  95497. * @return the found mesh or null if not found at all.
  95498. */
  95499. getMeshByName(name: string): Nullable<AbstractMesh>;
  95500. /**
  95501. * Gets a transform node using a given name
  95502. * @param name defines the name to search for
  95503. * @return the found transform node or null if not found at all.
  95504. */
  95505. getTransformNodeByName(name: string): Nullable<TransformNode>;
  95506. /**
  95507. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  95508. * @param id defines the id to search for
  95509. * @return the found skeleton or null if not found at all.
  95510. */
  95511. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  95512. /**
  95513. * Gets a skeleton using a given auto generated unique id
  95514. * @param uniqueId defines the unique id to search for
  95515. * @return the found skeleton or null if not found at all.
  95516. */
  95517. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  95518. /**
  95519. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  95520. * @param id defines the id to search for
  95521. * @return the found skeleton or null if not found at all.
  95522. */
  95523. getSkeletonById(id: string): Nullable<Skeleton>;
  95524. /**
  95525. * Gets a skeleton using a given name
  95526. * @param name defines the name to search for
  95527. * @return the found skeleton or null if not found at all.
  95528. */
  95529. getSkeletonByName(name: string): Nullable<Skeleton>;
  95530. /**
  95531. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  95532. * @param id defines the id to search for
  95533. * @return the found morph target manager or null if not found at all.
  95534. */
  95535. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  95536. /**
  95537. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  95538. * @param id defines the id to search for
  95539. * @return the found morph target or null if not found at all.
  95540. */
  95541. getMorphTargetById(id: string): Nullable<MorphTarget>;
  95542. /**
  95543. * Gets a boolean indicating if the given mesh is active
  95544. * @param mesh defines the mesh to look for
  95545. * @returns true if the mesh is in the active list
  95546. */
  95547. isActiveMesh(mesh: AbstractMesh): boolean;
  95548. /**
  95549. * Return a unique id as a string which can serve as an identifier for the scene
  95550. */
  95551. readonly uid: string;
  95552. /**
  95553. * Add an externaly attached data from its key.
  95554. * This method call will fail and return false, if such key already exists.
  95555. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  95556. * @param key the unique key that identifies the data
  95557. * @param data the data object to associate to the key for this Engine instance
  95558. * @return true if no such key were already present and the data was added successfully, false otherwise
  95559. */
  95560. addExternalData<T>(key: string, data: T): boolean;
  95561. /**
  95562. * Get an externaly attached data from its key
  95563. * @param key the unique key that identifies the data
  95564. * @return the associated data, if present (can be null), or undefined if not present
  95565. */
  95566. getExternalData<T>(key: string): Nullable<T>;
  95567. /**
  95568. * Get an externaly attached data from its key, create it using a factory if it's not already present
  95569. * @param key the unique key that identifies the data
  95570. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  95571. * @return the associated data, can be null if the factory returned null.
  95572. */
  95573. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  95574. /**
  95575. * Remove an externaly attached data from the Engine instance
  95576. * @param key the unique key that identifies the data
  95577. * @return true if the data was successfully removed, false if it doesn't exist
  95578. */
  95579. removeExternalData(key: string): boolean;
  95580. private _evaluateSubMesh;
  95581. /**
  95582. * Clear the processed materials smart array preventing retention point in material dispose.
  95583. */
  95584. freeProcessedMaterials(): void;
  95585. private _preventFreeActiveMeshesAndRenderingGroups;
  95586. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  95587. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  95588. * when disposing several meshes in a row or a hierarchy of meshes.
  95589. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  95590. */
  95591. blockfreeActiveMeshesAndRenderingGroups: boolean;
  95592. /**
  95593. * Clear the active meshes smart array preventing retention point in mesh dispose.
  95594. */
  95595. freeActiveMeshes(): void;
  95596. /**
  95597. * Clear the info related to rendering groups preventing retention points during dispose.
  95598. */
  95599. freeRenderingGroups(): void;
  95600. /** @hidden */
  95601. _isInIntermediateRendering(): boolean;
  95602. /**
  95603. * Lambda returning the list of potentially active meshes.
  95604. */
  95605. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  95606. /**
  95607. * Lambda returning the list of potentially active sub meshes.
  95608. */
  95609. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  95610. /**
  95611. * Lambda returning the list of potentially intersecting sub meshes.
  95612. */
  95613. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  95614. /**
  95615. * Lambda returning the list of potentially colliding sub meshes.
  95616. */
  95617. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  95618. private _activeMeshesFrozen;
  95619. /**
  95620. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  95621. * @returns the current scene
  95622. */
  95623. freezeActiveMeshes(): Scene;
  95624. /**
  95625. * Use this function to restart evaluating active meshes on every frame
  95626. * @returns the current scene
  95627. */
  95628. unfreezeActiveMeshes(): Scene;
  95629. private _evaluateActiveMeshes;
  95630. private _activeMesh;
  95631. /**
  95632. * Update the transform matrix to update from the current active camera
  95633. * @param force defines a boolean used to force the update even if cache is up to date
  95634. */
  95635. updateTransformMatrix(force?: boolean): void;
  95636. private _bindFrameBuffer;
  95637. /** @hidden */
  95638. _allowPostProcessClearColor: boolean;
  95639. /** @hidden */
  95640. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  95641. private _processSubCameras;
  95642. private _checkIntersections;
  95643. /** @hidden */
  95644. _advancePhysicsEngineStep(step: number): void;
  95645. /**
  95646. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  95647. */
  95648. getDeterministicFrameTime: () => number;
  95649. /** @hidden */
  95650. _animate(): void;
  95651. /** Execute all animations (for a frame) */
  95652. animate(): void;
  95653. /**
  95654. * Render the scene
  95655. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  95656. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  95657. */
  95658. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  95659. /**
  95660. * Freeze all materials
  95661. * A frozen material will not be updatable but should be faster to render
  95662. */
  95663. freezeMaterials(): void;
  95664. /**
  95665. * Unfreeze all materials
  95666. * A frozen material will not be updatable but should be faster to render
  95667. */
  95668. unfreezeMaterials(): void;
  95669. /**
  95670. * Releases all held ressources
  95671. */
  95672. dispose(): void;
  95673. /**
  95674. * Gets if the scene is already disposed
  95675. */
  95676. readonly isDisposed: boolean;
  95677. /**
  95678. * Call this function to reduce memory footprint of the scene.
  95679. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  95680. */
  95681. clearCachedVertexData(): void;
  95682. /**
  95683. * This function will remove the local cached buffer data from texture.
  95684. * It will save memory but will prevent the texture from being rebuilt
  95685. */
  95686. cleanCachedTextureBuffer(): void;
  95687. /**
  95688. * Get the world extend vectors with an optional filter
  95689. *
  95690. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  95691. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  95692. */
  95693. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  95694. min: Vector3;
  95695. max: Vector3;
  95696. };
  95697. /**
  95698. * Creates a ray that can be used to pick in the scene
  95699. * @param x defines the x coordinate of the origin (on-screen)
  95700. * @param y defines the y coordinate of the origin (on-screen)
  95701. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  95702. * @param camera defines the camera to use for the picking
  95703. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  95704. * @returns a Ray
  95705. */
  95706. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  95707. /**
  95708. * Creates a ray that can be used to pick in the scene
  95709. * @param x defines the x coordinate of the origin (on-screen)
  95710. * @param y defines the y coordinate of the origin (on-screen)
  95711. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  95712. * @param result defines the ray where to store the picking ray
  95713. * @param camera defines the camera to use for the picking
  95714. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  95715. * @returns the current scene
  95716. */
  95717. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  95718. /**
  95719. * Creates a ray that can be used to pick in the scene
  95720. * @param x defines the x coordinate of the origin (on-screen)
  95721. * @param y defines the y coordinate of the origin (on-screen)
  95722. * @param camera defines the camera to use for the picking
  95723. * @returns a Ray
  95724. */
  95725. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  95726. /**
  95727. * Creates a ray that can be used to pick in the scene
  95728. * @param x defines the x coordinate of the origin (on-screen)
  95729. * @param y defines the y coordinate of the origin (on-screen)
  95730. * @param result defines the ray where to store the picking ray
  95731. * @param camera defines the camera to use for the picking
  95732. * @returns the current scene
  95733. */
  95734. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  95735. /** Launch a ray to try to pick a mesh in the scene
  95736. * @param x position on screen
  95737. * @param y position on screen
  95738. * @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
  95739. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  95740. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  95741. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95742. * @returns a PickingInfo
  95743. */
  95744. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  95745. /** Use the given ray to pick a mesh in the scene
  95746. * @param ray The ray to use to pick meshes
  95747. * @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
  95748. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  95749. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95750. * @returns a PickingInfo
  95751. */
  95752. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  95753. /**
  95754. * Launch a ray to try to pick a mesh in the scene
  95755. * @param x X position on screen
  95756. * @param y Y position on screen
  95757. * @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
  95758. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  95759. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95760. * @returns an array of PickingInfo
  95761. */
  95762. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  95763. /**
  95764. * Launch a ray to try to pick a mesh in the scene
  95765. * @param ray Ray to use
  95766. * @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
  95767. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  95768. * @returns an array of PickingInfo
  95769. */
  95770. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  95771. /**
  95772. * Force the value of meshUnderPointer
  95773. * @param mesh defines the mesh to use
  95774. */
  95775. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  95776. /**
  95777. * Gets the mesh under the pointer
  95778. * @returns a Mesh or null if no mesh is under the pointer
  95779. */
  95780. getPointerOverMesh(): Nullable<AbstractMesh>;
  95781. /** @hidden */
  95782. _rebuildGeometries(): void;
  95783. /** @hidden */
  95784. _rebuildTextures(): void;
  95785. private _getByTags;
  95786. /**
  95787. * Get a list of meshes by tags
  95788. * @param tagsQuery defines the tags query to use
  95789. * @param forEach defines a predicate used to filter results
  95790. * @returns an array of Mesh
  95791. */
  95792. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  95793. /**
  95794. * Get a list of cameras by tags
  95795. * @param tagsQuery defines the tags query to use
  95796. * @param forEach defines a predicate used to filter results
  95797. * @returns an array of Camera
  95798. */
  95799. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  95800. /**
  95801. * Get a list of lights by tags
  95802. * @param tagsQuery defines the tags query to use
  95803. * @param forEach defines a predicate used to filter results
  95804. * @returns an array of Light
  95805. */
  95806. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  95807. /**
  95808. * Get a list of materials by tags
  95809. * @param tagsQuery defines the tags query to use
  95810. * @param forEach defines a predicate used to filter results
  95811. * @returns an array of Material
  95812. */
  95813. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  95814. /**
  95815. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95816. * This allowed control for front to back rendering or reversly depending of the special needs.
  95817. *
  95818. * @param renderingGroupId The rendering group id corresponding to its index
  95819. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95820. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95821. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95822. */
  95823. 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;
  95824. /**
  95825. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95826. *
  95827. * @param renderingGroupId The rendering group id corresponding to its index
  95828. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95829. * @param depth Automatically clears depth between groups if true and autoClear is true.
  95830. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  95831. */
  95832. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  95833. /**
  95834. * Gets the current auto clear configuration for one rendering group of the rendering
  95835. * manager.
  95836. * @param index the rendering group index to get the information for
  95837. * @returns The auto clear setup for the requested rendering group
  95838. */
  95839. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  95840. private _blockMaterialDirtyMechanism;
  95841. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  95842. blockMaterialDirtyMechanism: boolean;
  95843. /**
  95844. * Will flag all materials as dirty to trigger new shader compilation
  95845. * @param flag defines the flag used to specify which material part must be marked as dirty
  95846. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  95847. */
  95848. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  95849. /** @hidden */
  95850. _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;
  95851. /** @hidden */
  95852. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  95853. }
  95854. }
  95855. declare module BABYLON {
  95856. /**
  95857. * Set of assets to keep when moving a scene into an asset container.
  95858. */
  95859. export class KeepAssets extends AbstractScene {
  95860. }
  95861. /**
  95862. * Container with a set of assets that can be added or removed from a scene.
  95863. */
  95864. export class AssetContainer extends AbstractScene {
  95865. /**
  95866. * The scene the AssetContainer belongs to.
  95867. */
  95868. scene: Scene;
  95869. /**
  95870. * Instantiates an AssetContainer.
  95871. * @param scene The scene the AssetContainer belongs to.
  95872. */
  95873. constructor(scene: Scene);
  95874. /**
  95875. * Adds all the assets from the container to the scene.
  95876. */
  95877. addAllToScene(): void;
  95878. /**
  95879. * Removes all the assets in the container from the scene
  95880. */
  95881. removeAllFromScene(): void;
  95882. /**
  95883. * Disposes all the assets in the container
  95884. */
  95885. dispose(): void;
  95886. private _moveAssets;
  95887. /**
  95888. * Removes all the assets contained in the scene and adds them to the container.
  95889. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  95890. */
  95891. moveAllFromScene(keepAssets?: KeepAssets): void;
  95892. /**
  95893. * 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.
  95894. * @returns the root mesh
  95895. */
  95896. createRootMesh(): Mesh;
  95897. }
  95898. }
  95899. declare module BABYLON {
  95900. /**
  95901. * Defines how the parser contract is defined.
  95902. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  95903. */
  95904. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  95905. /**
  95906. * Defines how the individual parser contract is defined.
  95907. * These parser can parse an individual asset
  95908. */
  95909. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  95910. /**
  95911. * Base class of the scene acting as a container for the different elements composing a scene.
  95912. * This class is dynamically extended by the different components of the scene increasing
  95913. * flexibility and reducing coupling
  95914. */
  95915. export abstract class AbstractScene {
  95916. /**
  95917. * Stores the list of available parsers in the application.
  95918. */
  95919. private static _BabylonFileParsers;
  95920. /**
  95921. * Stores the list of available individual parsers in the application.
  95922. */
  95923. private static _IndividualBabylonFileParsers;
  95924. /**
  95925. * Adds a parser in the list of available ones
  95926. * @param name Defines the name of the parser
  95927. * @param parser Defines the parser to add
  95928. */
  95929. static AddParser(name: string, parser: BabylonFileParser): void;
  95930. /**
  95931. * Gets a general parser from the list of avaialble ones
  95932. * @param name Defines the name of the parser
  95933. * @returns the requested parser or null
  95934. */
  95935. static GetParser(name: string): Nullable<BabylonFileParser>;
  95936. /**
  95937. * Adds n individual parser in the list of available ones
  95938. * @param name Defines the name of the parser
  95939. * @param parser Defines the parser to add
  95940. */
  95941. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  95942. /**
  95943. * Gets an individual parser from the list of avaialble ones
  95944. * @param name Defines the name of the parser
  95945. * @returns the requested parser or null
  95946. */
  95947. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  95948. /**
  95949. * Parser json data and populate both a scene and its associated container object
  95950. * @param jsonData Defines the data to parse
  95951. * @param scene Defines the scene to parse the data for
  95952. * @param container Defines the container attached to the parsing sequence
  95953. * @param rootUrl Defines the root url of the data
  95954. */
  95955. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  95956. /**
  95957. * Gets the list of root nodes (ie. nodes with no parent)
  95958. */
  95959. rootNodes: Node[];
  95960. /** All of the cameras added to this scene
  95961. * @see http://doc.babylonjs.com/babylon101/cameras
  95962. */
  95963. cameras: Camera[];
  95964. /**
  95965. * All of the lights added to this scene
  95966. * @see http://doc.babylonjs.com/babylon101/lights
  95967. */
  95968. lights: Light[];
  95969. /**
  95970. * All of the (abstract) meshes added to this scene
  95971. */
  95972. meshes: AbstractMesh[];
  95973. /**
  95974. * The list of skeletons added to the scene
  95975. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95976. */
  95977. skeletons: Skeleton[];
  95978. /**
  95979. * All of the particle systems added to this scene
  95980. * @see http://doc.babylonjs.com/babylon101/particles
  95981. */
  95982. particleSystems: IParticleSystem[];
  95983. /**
  95984. * Gets a list of Animations associated with the scene
  95985. */
  95986. animations: Animation[];
  95987. /**
  95988. * All of the animation groups added to this scene
  95989. * @see http://doc.babylonjs.com/how_to/group
  95990. */
  95991. animationGroups: AnimationGroup[];
  95992. /**
  95993. * All of the multi-materials added to this scene
  95994. * @see http://doc.babylonjs.com/how_to/multi_materials
  95995. */
  95996. multiMaterials: MultiMaterial[];
  95997. /**
  95998. * All of the materials added to this scene
  95999. * In the context of a Scene, it is not supposed to be modified manually.
  96000. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  96001. * Note also that the order of the Material wihin the array is not significant and might change.
  96002. * @see http://doc.babylonjs.com/babylon101/materials
  96003. */
  96004. materials: Material[];
  96005. /**
  96006. * The list of morph target managers added to the scene
  96007. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  96008. */
  96009. morphTargetManagers: MorphTargetManager[];
  96010. /**
  96011. * The list of geometries used in the scene.
  96012. */
  96013. geometries: Geometry[];
  96014. /**
  96015. * All of the tranform nodes added to this scene
  96016. * In the context of a Scene, it is not supposed to be modified manually.
  96017. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  96018. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  96019. * @see http://doc.babylonjs.com/how_to/transformnode
  96020. */
  96021. transformNodes: TransformNode[];
  96022. /**
  96023. * ActionManagers available on the scene.
  96024. */
  96025. actionManagers: AbstractActionManager[];
  96026. /**
  96027. * Textures to keep.
  96028. */
  96029. textures: BaseTexture[];
  96030. /**
  96031. * Environment texture for the scene
  96032. */
  96033. environmentTexture: Nullable<BaseTexture>;
  96034. }
  96035. }
  96036. declare module BABYLON {
  96037. /**
  96038. * Defines a sound that can be played in the application.
  96039. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  96040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96041. */
  96042. export class Sound {
  96043. /**
  96044. * The name of the sound in the scene.
  96045. */
  96046. name: string;
  96047. /**
  96048. * Does the sound autoplay once loaded.
  96049. */
  96050. autoplay: boolean;
  96051. /**
  96052. * Does the sound loop after it finishes playing once.
  96053. */
  96054. loop: boolean;
  96055. /**
  96056. * Does the sound use a custom attenuation curve to simulate the falloff
  96057. * happening when the source gets further away from the camera.
  96058. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96059. */
  96060. useCustomAttenuation: boolean;
  96061. /**
  96062. * The sound track id this sound belongs to.
  96063. */
  96064. soundTrackId: number;
  96065. /**
  96066. * Is this sound currently played.
  96067. */
  96068. isPlaying: boolean;
  96069. /**
  96070. * Is this sound currently paused.
  96071. */
  96072. isPaused: boolean;
  96073. /**
  96074. * Does this sound enables spatial sound.
  96075. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96076. */
  96077. spatialSound: boolean;
  96078. /**
  96079. * Define the reference distance the sound should be heard perfectly.
  96080. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96081. */
  96082. refDistance: number;
  96083. /**
  96084. * Define the roll off factor of spatial sounds.
  96085. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96086. */
  96087. rolloffFactor: number;
  96088. /**
  96089. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  96090. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96091. */
  96092. maxDistance: number;
  96093. /**
  96094. * Define the distance attenuation model the sound will follow.
  96095. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96096. */
  96097. distanceModel: string;
  96098. /**
  96099. * @hidden
  96100. * Back Compat
  96101. **/
  96102. onended: () => any;
  96103. /**
  96104. * Observable event when the current playing sound finishes.
  96105. */
  96106. onEndedObservable: Observable<Sound>;
  96107. private _panningModel;
  96108. private _playbackRate;
  96109. private _streaming;
  96110. private _startTime;
  96111. private _startOffset;
  96112. private _position;
  96113. /** @hidden */
  96114. _positionInEmitterSpace: boolean;
  96115. private _localDirection;
  96116. private _volume;
  96117. private _isReadyToPlay;
  96118. private _isDirectional;
  96119. private _readyToPlayCallback;
  96120. private _audioBuffer;
  96121. private _soundSource;
  96122. private _streamingSource;
  96123. private _soundPanner;
  96124. private _soundGain;
  96125. private _inputAudioNode;
  96126. private _outputAudioNode;
  96127. private _coneInnerAngle;
  96128. private _coneOuterAngle;
  96129. private _coneOuterGain;
  96130. private _scene;
  96131. private _connectedTransformNode;
  96132. private _customAttenuationFunction;
  96133. private _registerFunc;
  96134. private _isOutputConnected;
  96135. private _htmlAudioElement;
  96136. private _urlType;
  96137. /** @hidden */
  96138. static _SceneComponentInitialization: (scene: Scene) => void;
  96139. /**
  96140. * Create a sound and attach it to a scene
  96141. * @param name Name of your sound
  96142. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  96143. * @param scene defines the scene the sound belongs to
  96144. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  96145. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  96146. */
  96147. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  96148. /**
  96149. * Release the sound and its associated resources
  96150. */
  96151. dispose(): void;
  96152. /**
  96153. * Gets if the sounds is ready to be played or not.
  96154. * @returns true if ready, otherwise false
  96155. */
  96156. isReady(): boolean;
  96157. private _soundLoaded;
  96158. /**
  96159. * Sets the data of the sound from an audiobuffer
  96160. * @param audioBuffer The audioBuffer containing the data
  96161. */
  96162. setAudioBuffer(audioBuffer: AudioBuffer): void;
  96163. /**
  96164. * Updates the current sounds options such as maxdistance, loop...
  96165. * @param options A JSON object containing values named as the object properties
  96166. */
  96167. updateOptions(options: any): void;
  96168. private _createSpatialParameters;
  96169. private _updateSpatialParameters;
  96170. /**
  96171. * Switch the panning model to HRTF:
  96172. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96173. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96174. */
  96175. switchPanningModelToHRTF(): void;
  96176. /**
  96177. * Switch the panning model to Equal Power:
  96178. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96179. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96180. */
  96181. switchPanningModelToEqualPower(): void;
  96182. private _switchPanningModel;
  96183. /**
  96184. * Connect this sound to a sound track audio node like gain...
  96185. * @param soundTrackAudioNode the sound track audio node to connect to
  96186. */
  96187. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  96188. /**
  96189. * Transform this sound into a directional source
  96190. * @param coneInnerAngle Size of the inner cone in degree
  96191. * @param coneOuterAngle Size of the outer cone in degree
  96192. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  96193. */
  96194. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  96195. /**
  96196. * Gets or sets the inner angle for the directional cone.
  96197. */
  96198. /**
  96199. * Gets or sets the inner angle for the directional cone.
  96200. */
  96201. directionalConeInnerAngle: number;
  96202. /**
  96203. * Gets or sets the outer angle for the directional cone.
  96204. */
  96205. /**
  96206. * Gets or sets the outer angle for the directional cone.
  96207. */
  96208. directionalConeOuterAngle: number;
  96209. /**
  96210. * Sets the position of the emitter if spatial sound is enabled
  96211. * @param newPosition Defines the new posisiton
  96212. */
  96213. setPosition(newPosition: Vector3): void;
  96214. /**
  96215. * Sets the local direction of the emitter if spatial sound is enabled
  96216. * @param newLocalDirection Defines the new local direction
  96217. */
  96218. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  96219. private _updateDirection;
  96220. /** @hidden */
  96221. updateDistanceFromListener(): void;
  96222. /**
  96223. * Sets a new custom attenuation function for the sound.
  96224. * @param callback Defines the function used for the attenuation
  96225. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  96226. */
  96227. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  96228. /**
  96229. * Play the sound
  96230. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  96231. * @param offset (optional) Start the sound setting it at a specific time
  96232. */
  96233. play(time?: number, offset?: number): void;
  96234. private _onended;
  96235. /**
  96236. * Stop the sound
  96237. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  96238. */
  96239. stop(time?: number): void;
  96240. /**
  96241. * Put the sound in pause
  96242. */
  96243. pause(): void;
  96244. /**
  96245. * Sets a dedicated volume for this sounds
  96246. * @param newVolume Define the new volume of the sound
  96247. * @param time Define in how long the sound should be at this value
  96248. */
  96249. setVolume(newVolume: number, time?: number): void;
  96250. /**
  96251. * Set the sound play back rate
  96252. * @param newPlaybackRate Define the playback rate the sound should be played at
  96253. */
  96254. setPlaybackRate(newPlaybackRate: number): void;
  96255. /**
  96256. * Gets the volume of the sound.
  96257. * @returns the volume of the sound
  96258. */
  96259. getVolume(): number;
  96260. /**
  96261. * Attach the sound to a dedicated mesh
  96262. * @param transformNode The transform node to connect the sound with
  96263. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96264. */
  96265. attachToMesh(transformNode: TransformNode): void;
  96266. /**
  96267. * Detach the sound from the previously attached mesh
  96268. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  96269. */
  96270. detachFromMesh(): void;
  96271. private _onRegisterAfterWorldMatrixUpdate;
  96272. /**
  96273. * Clone the current sound in the scene.
  96274. * @returns the new sound clone
  96275. */
  96276. clone(): Nullable<Sound>;
  96277. /**
  96278. * Gets the current underlying audio buffer containing the data
  96279. * @returns the audio buffer
  96280. */
  96281. getAudioBuffer(): Nullable<AudioBuffer>;
  96282. /**
  96283. * Serializes the Sound in a JSON representation
  96284. * @returns the JSON representation of the sound
  96285. */
  96286. serialize(): any;
  96287. /**
  96288. * Parse a JSON representation of a sound to innstantiate in a given scene
  96289. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  96290. * @param scene Define the scene the new parsed sound should be created in
  96291. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  96292. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  96293. * @returns the newly parsed sound
  96294. */
  96295. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  96296. }
  96297. }
  96298. declare module BABYLON {
  96299. /**
  96300. * This defines an action helpful to play a defined sound on a triggered action.
  96301. */
  96302. export class PlaySoundAction extends Action {
  96303. private _sound;
  96304. /**
  96305. * Instantiate the action
  96306. * @param triggerOptions defines the trigger options
  96307. * @param sound defines the sound to play
  96308. * @param condition defines the trigger related conditions
  96309. */
  96310. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96311. /** @hidden */
  96312. _prepare(): void;
  96313. /**
  96314. * Execute the action and play the sound.
  96315. */
  96316. execute(): void;
  96317. /**
  96318. * Serializes the actions and its related information.
  96319. * @param parent defines the object to serialize in
  96320. * @returns the serialized object
  96321. */
  96322. serialize(parent: any): any;
  96323. }
  96324. /**
  96325. * This defines an action helpful to stop a defined sound on a triggered action.
  96326. */
  96327. export class StopSoundAction extends Action {
  96328. private _sound;
  96329. /**
  96330. * Instantiate the action
  96331. * @param triggerOptions defines the trigger options
  96332. * @param sound defines the sound to stop
  96333. * @param condition defines the trigger related conditions
  96334. */
  96335. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  96336. /** @hidden */
  96337. _prepare(): void;
  96338. /**
  96339. * Execute the action and stop the sound.
  96340. */
  96341. execute(): void;
  96342. /**
  96343. * Serializes the actions and its related information.
  96344. * @param parent defines the object to serialize in
  96345. * @returns the serialized object
  96346. */
  96347. serialize(parent: any): any;
  96348. }
  96349. }
  96350. declare module BABYLON {
  96351. /**
  96352. * This defines an action responsible to change the value of a property
  96353. * by interpolating between its current value and the newly set one once triggered.
  96354. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  96355. */
  96356. export class InterpolateValueAction extends Action {
  96357. /**
  96358. * Defines the path of the property where the value should be interpolated
  96359. */
  96360. propertyPath: string;
  96361. /**
  96362. * Defines the target value at the end of the interpolation.
  96363. */
  96364. value: any;
  96365. /**
  96366. * Defines the time it will take for the property to interpolate to the value.
  96367. */
  96368. duration: number;
  96369. /**
  96370. * Defines if the other scene animations should be stopped when the action has been triggered
  96371. */
  96372. stopOtherAnimations?: boolean;
  96373. /**
  96374. * Defines a callback raised once the interpolation animation has been done.
  96375. */
  96376. onInterpolationDone?: () => void;
  96377. /**
  96378. * Observable triggered once the interpolation animation has been done.
  96379. */
  96380. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  96381. private _target;
  96382. private _effectiveTarget;
  96383. private _property;
  96384. /**
  96385. * Instantiate the action
  96386. * @param triggerOptions defines the trigger options
  96387. * @param target defines the object containing the value to interpolate
  96388. * @param propertyPath defines the path to the property in the target object
  96389. * @param value defines the target value at the end of the interpolation
  96390. * @param duration deines the time it will take for the property to interpolate to the value.
  96391. * @param condition defines the trigger related conditions
  96392. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  96393. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  96394. */
  96395. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  96396. /** @hidden */
  96397. _prepare(): void;
  96398. /**
  96399. * Execute the action starts the value interpolation.
  96400. */
  96401. execute(): void;
  96402. /**
  96403. * Serializes the actions and its related information.
  96404. * @param parent defines the object to serialize in
  96405. * @returns the serialized object
  96406. */
  96407. serialize(parent: any): any;
  96408. }
  96409. }
  96410. declare module BABYLON {
  96411. /**
  96412. * Options allowed during the creation of a sound track.
  96413. */
  96414. export interface ISoundTrackOptions {
  96415. /**
  96416. * The volume the sound track should take during creation
  96417. */
  96418. volume?: number;
  96419. /**
  96420. * Define if the sound track is the main sound track of the scene
  96421. */
  96422. mainTrack?: boolean;
  96423. }
  96424. /**
  96425. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  96426. * It will be also used in a future release to apply effects on a specific track.
  96427. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96428. */
  96429. export class SoundTrack {
  96430. /**
  96431. * The unique identifier of the sound track in the scene.
  96432. */
  96433. id: number;
  96434. /**
  96435. * The list of sounds included in the sound track.
  96436. */
  96437. soundCollection: Array<Sound>;
  96438. private _outputAudioNode;
  96439. private _scene;
  96440. private _isMainTrack;
  96441. private _connectedAnalyser;
  96442. private _options;
  96443. private _isInitialized;
  96444. /**
  96445. * Creates a new sound track.
  96446. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  96447. * @param scene Define the scene the sound track belongs to
  96448. * @param options
  96449. */
  96450. constructor(scene: Scene, options?: ISoundTrackOptions);
  96451. private _initializeSoundTrackAudioGraph;
  96452. /**
  96453. * Release the sound track and its associated resources
  96454. */
  96455. dispose(): void;
  96456. /**
  96457. * Adds a sound to this sound track
  96458. * @param sound define the cound to add
  96459. * @ignoreNaming
  96460. */
  96461. AddSound(sound: Sound): void;
  96462. /**
  96463. * Removes a sound to this sound track
  96464. * @param sound define the cound to remove
  96465. * @ignoreNaming
  96466. */
  96467. RemoveSound(sound: Sound): void;
  96468. /**
  96469. * Set a global volume for the full sound track.
  96470. * @param newVolume Define the new volume of the sound track
  96471. */
  96472. setVolume(newVolume: number): void;
  96473. /**
  96474. * Switch the panning model to HRTF:
  96475. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  96476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96477. */
  96478. switchPanningModelToHRTF(): void;
  96479. /**
  96480. * Switch the panning model to Equal Power:
  96481. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  96482. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  96483. */
  96484. switchPanningModelToEqualPower(): void;
  96485. /**
  96486. * Connect the sound track to an audio analyser allowing some amazing
  96487. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  96488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  96489. * @param analyser The analyser to connect to the engine
  96490. */
  96491. connectToAnalyser(analyser: Analyser): void;
  96492. }
  96493. }
  96494. declare module BABYLON {
  96495. interface AbstractScene {
  96496. /**
  96497. * The list of sounds used in the scene.
  96498. */
  96499. sounds: Nullable<Array<Sound>>;
  96500. }
  96501. interface Scene {
  96502. /**
  96503. * @hidden
  96504. * Backing field
  96505. */
  96506. _mainSoundTrack: SoundTrack;
  96507. /**
  96508. * The main sound track played by the scene.
  96509. * It cotains your primary collection of sounds.
  96510. */
  96511. mainSoundTrack: SoundTrack;
  96512. /**
  96513. * The list of sound tracks added to the scene
  96514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96515. */
  96516. soundTracks: Nullable<Array<SoundTrack>>;
  96517. /**
  96518. * Gets a sound using a given name
  96519. * @param name defines the name to search for
  96520. * @return the found sound or null if not found at all.
  96521. */
  96522. getSoundByName(name: string): Nullable<Sound>;
  96523. /**
  96524. * Gets or sets if audio support is enabled
  96525. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96526. */
  96527. audioEnabled: boolean;
  96528. /**
  96529. * Gets or sets if audio will be output to headphones
  96530. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  96531. */
  96532. headphone: boolean;
  96533. }
  96534. /**
  96535. * Defines the sound scene component responsible to manage any sounds
  96536. * in a given scene.
  96537. */
  96538. export class AudioSceneComponent implements ISceneSerializableComponent {
  96539. /**
  96540. * The component name helpfull to identify the component in the list of scene components.
  96541. */
  96542. readonly name: string;
  96543. /**
  96544. * The scene the component belongs to.
  96545. */
  96546. scene: Scene;
  96547. private _audioEnabled;
  96548. /**
  96549. * Gets whether audio is enabled or not.
  96550. * Please use related enable/disable method to switch state.
  96551. */
  96552. readonly audioEnabled: boolean;
  96553. private _headphone;
  96554. /**
  96555. * Gets whether audio is outputing to headphone or not.
  96556. * Please use the according Switch methods to change output.
  96557. */
  96558. readonly headphone: boolean;
  96559. /**
  96560. * Creates a new instance of the component for the given scene
  96561. * @param scene Defines the scene to register the component in
  96562. */
  96563. constructor(scene: Scene);
  96564. /**
  96565. * Registers the component in a given scene
  96566. */
  96567. register(): void;
  96568. /**
  96569. * Rebuilds the elements related to this component in case of
  96570. * context lost for instance.
  96571. */
  96572. rebuild(): void;
  96573. /**
  96574. * Serializes the component data to the specified json object
  96575. * @param serializationObject The object to serialize to
  96576. */
  96577. serialize(serializationObject: any): void;
  96578. /**
  96579. * Adds all the elements from the container to the scene
  96580. * @param container the container holding the elements
  96581. */
  96582. addFromContainer(container: AbstractScene): void;
  96583. /**
  96584. * Removes all the elements in the container from the scene
  96585. * @param container contains the elements to remove
  96586. * @param dispose if the removed element should be disposed (default: false)
  96587. */
  96588. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  96589. /**
  96590. * Disposes the component and the associated ressources.
  96591. */
  96592. dispose(): void;
  96593. /**
  96594. * Disables audio in the associated scene.
  96595. */
  96596. disableAudio(): void;
  96597. /**
  96598. * Enables audio in the associated scene.
  96599. */
  96600. enableAudio(): void;
  96601. /**
  96602. * Switch audio to headphone output.
  96603. */
  96604. switchAudioModeForHeadphones(): void;
  96605. /**
  96606. * Switch audio to normal speakers.
  96607. */
  96608. switchAudioModeForNormalSpeakers(): void;
  96609. private _afterRender;
  96610. }
  96611. }
  96612. declare module BABYLON {
  96613. /**
  96614. * Wraps one or more Sound objects and selects one with random weight for playback.
  96615. */
  96616. export class WeightedSound {
  96617. /** When true a Sound will be selected and played when the current playing Sound completes. */
  96618. loop: boolean;
  96619. private _coneInnerAngle;
  96620. private _coneOuterAngle;
  96621. private _volume;
  96622. /** A Sound is currently playing. */
  96623. isPlaying: boolean;
  96624. /** A Sound is currently paused. */
  96625. isPaused: boolean;
  96626. private _sounds;
  96627. private _weights;
  96628. private _currentIndex?;
  96629. /**
  96630. * Creates a new WeightedSound from the list of sounds given.
  96631. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  96632. * @param sounds Array of Sounds that will be selected from.
  96633. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  96634. */
  96635. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  96636. /**
  96637. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  96638. */
  96639. /**
  96640. * The size of cone in degress for a directional sound in which there will be no attenuation.
  96641. */
  96642. directionalConeInnerAngle: number;
  96643. /**
  96644. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  96645. * Listener angles between innerAngle and outerAngle will falloff linearly.
  96646. */
  96647. /**
  96648. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  96649. * Listener angles between innerAngle and outerAngle will falloff linearly.
  96650. */
  96651. directionalConeOuterAngle: number;
  96652. /**
  96653. * Playback volume.
  96654. */
  96655. /**
  96656. * Playback volume.
  96657. */
  96658. volume: number;
  96659. private _onended;
  96660. /**
  96661. * Suspend playback
  96662. */
  96663. pause(): void;
  96664. /**
  96665. * Stop playback
  96666. */
  96667. stop(): void;
  96668. /**
  96669. * Start playback.
  96670. * @param startOffset Position the clip head at a specific time in seconds.
  96671. */
  96672. play(startOffset?: number): void;
  96673. }
  96674. }
  96675. declare module BABYLON {
  96676. /**
  96677. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  96678. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  96679. */
  96680. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  96681. /**
  96682. * Gets the name of the behavior.
  96683. */
  96684. readonly name: string;
  96685. /**
  96686. * The easing function used by animations
  96687. */
  96688. static EasingFunction: BackEase;
  96689. /**
  96690. * The easing mode used by animations
  96691. */
  96692. static EasingMode: number;
  96693. /**
  96694. * The duration of the animation, in milliseconds
  96695. */
  96696. transitionDuration: number;
  96697. /**
  96698. * Length of the distance animated by the transition when lower radius is reached
  96699. */
  96700. lowerRadiusTransitionRange: number;
  96701. /**
  96702. * Length of the distance animated by the transition when upper radius is reached
  96703. */
  96704. upperRadiusTransitionRange: number;
  96705. private _autoTransitionRange;
  96706. /**
  96707. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  96708. */
  96709. /**
  96710. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  96711. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  96712. */
  96713. autoTransitionRange: boolean;
  96714. private _attachedCamera;
  96715. private _onAfterCheckInputsObserver;
  96716. private _onMeshTargetChangedObserver;
  96717. /**
  96718. * Initializes the behavior.
  96719. */
  96720. init(): void;
  96721. /**
  96722. * Attaches the behavior to its arc rotate camera.
  96723. * @param camera Defines the camera to attach the behavior to
  96724. */
  96725. attach(camera: ArcRotateCamera): void;
  96726. /**
  96727. * Detaches the behavior from its current arc rotate camera.
  96728. */
  96729. detach(): void;
  96730. private _radiusIsAnimating;
  96731. private _radiusBounceTransition;
  96732. private _animatables;
  96733. private _cachedWheelPrecision;
  96734. /**
  96735. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  96736. * @param radiusLimit The limit to check against.
  96737. * @return Bool to indicate if at limit.
  96738. */
  96739. private _isRadiusAtLimit;
  96740. /**
  96741. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  96742. * @param radiusDelta The delta by which to animate to. Can be negative.
  96743. */
  96744. private _applyBoundRadiusAnimation;
  96745. /**
  96746. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  96747. */
  96748. protected _clearAnimationLocks(): void;
  96749. /**
  96750. * Stops and removes all animations that have been applied to the camera
  96751. */
  96752. stopAllAnimations(): void;
  96753. }
  96754. }
  96755. declare module BABYLON {
  96756. /**
  96757. * 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.
  96758. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  96759. */
  96760. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  96761. /**
  96762. * Gets the name of the behavior.
  96763. */
  96764. readonly name: string;
  96765. private _mode;
  96766. private _radiusScale;
  96767. private _positionScale;
  96768. private _defaultElevation;
  96769. private _elevationReturnTime;
  96770. private _elevationReturnWaitTime;
  96771. private _zoomStopsAnimation;
  96772. private _framingTime;
  96773. /**
  96774. * The easing function used by animations
  96775. */
  96776. static EasingFunction: ExponentialEase;
  96777. /**
  96778. * The easing mode used by animations
  96779. */
  96780. static EasingMode: number;
  96781. /**
  96782. * Sets the current mode used by the behavior
  96783. */
  96784. /**
  96785. * Gets current mode used by the behavior.
  96786. */
  96787. mode: number;
  96788. /**
  96789. * Sets the scale applied to the radius (1 by default)
  96790. */
  96791. /**
  96792. * Gets the scale applied to the radius
  96793. */
  96794. radiusScale: number;
  96795. /**
  96796. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  96797. */
  96798. /**
  96799. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  96800. */
  96801. positionScale: number;
  96802. /**
  96803. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  96804. * behaviour is triggered, in radians.
  96805. */
  96806. /**
  96807. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  96808. * behaviour is triggered, in radians.
  96809. */
  96810. defaultElevation: number;
  96811. /**
  96812. * Sets the time (in milliseconds) taken to return to the default beta position.
  96813. * Negative value indicates camera should not return to default.
  96814. */
  96815. /**
  96816. * Gets the time (in milliseconds) taken to return to the default beta position.
  96817. * Negative value indicates camera should not return to default.
  96818. */
  96819. elevationReturnTime: number;
  96820. /**
  96821. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  96822. */
  96823. /**
  96824. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  96825. */
  96826. elevationReturnWaitTime: number;
  96827. /**
  96828. * Sets the flag that indicates if user zooming should stop animation.
  96829. */
  96830. /**
  96831. * Gets the flag that indicates if user zooming should stop animation.
  96832. */
  96833. zoomStopsAnimation: boolean;
  96834. /**
  96835. * Sets the transition time when framing the mesh, in milliseconds
  96836. */
  96837. /**
  96838. * Gets the transition time when framing the mesh, in milliseconds
  96839. */
  96840. framingTime: number;
  96841. /**
  96842. * Define if the behavior should automatically change the configured
  96843. * camera limits and sensibilities.
  96844. */
  96845. autoCorrectCameraLimitsAndSensibility: boolean;
  96846. private _onPrePointerObservableObserver;
  96847. private _onAfterCheckInputsObserver;
  96848. private _onMeshTargetChangedObserver;
  96849. private _attachedCamera;
  96850. private _isPointerDown;
  96851. private _lastInteractionTime;
  96852. /**
  96853. * Initializes the behavior.
  96854. */
  96855. init(): void;
  96856. /**
  96857. * Attaches the behavior to its arc rotate camera.
  96858. * @param camera Defines the camera to attach the behavior to
  96859. */
  96860. attach(camera: ArcRotateCamera): void;
  96861. /**
  96862. * Detaches the behavior from its current arc rotate camera.
  96863. */
  96864. detach(): void;
  96865. private _animatables;
  96866. private _betaIsAnimating;
  96867. private _betaTransition;
  96868. private _radiusTransition;
  96869. private _vectorTransition;
  96870. /**
  96871. * Targets the given mesh and updates zoom level accordingly.
  96872. * @param mesh The mesh to target.
  96873. * @param radius Optional. If a cached radius position already exists, overrides default.
  96874. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  96875. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  96876. * @param onAnimationEnd Callback triggered at the end of the framing animation
  96877. */
  96878. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  96879. /**
  96880. * Targets the given mesh with its children and updates zoom level accordingly.
  96881. * @param mesh The mesh to target.
  96882. * @param radius Optional. If a cached radius position already exists, overrides default.
  96883. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  96884. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  96885. * @param onAnimationEnd Callback triggered at the end of the framing animation
  96886. */
  96887. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  96888. /**
  96889. * Targets the given meshes with their children and updates zoom level accordingly.
  96890. * @param meshes The mesh to target.
  96891. * @param radius Optional. If a cached radius position already exists, overrides default.
  96892. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  96893. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  96894. * @param onAnimationEnd Callback triggered at the end of the framing animation
  96895. */
  96896. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  96897. /**
  96898. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  96899. * @param minimumWorld Determines the smaller position of the bounding box extend
  96900. * @param maximumWorld Determines the bigger position of the bounding box extend
  96901. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  96902. * @param onAnimationEnd Callback triggered at the end of the framing animation
  96903. */
  96904. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  96905. /**
  96906. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  96907. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  96908. * frustum width.
  96909. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  96910. * to fully enclose the mesh in the viewing frustum.
  96911. */
  96912. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  96913. /**
  96914. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  96915. * is automatically returned to its default position (expected to be above ground plane).
  96916. */
  96917. private _maintainCameraAboveGround;
  96918. /**
  96919. * Returns the frustum slope based on the canvas ratio and camera FOV
  96920. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  96921. */
  96922. private _getFrustumSlope;
  96923. /**
  96924. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  96925. */
  96926. private _clearAnimationLocks;
  96927. /**
  96928. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  96929. */
  96930. private _applyUserInteraction;
  96931. /**
  96932. * Stops and removes all animations that have been applied to the camera
  96933. */
  96934. stopAllAnimations(): void;
  96935. /**
  96936. * Gets a value indicating if the user is moving the camera
  96937. */
  96938. readonly isUserIsMoving: boolean;
  96939. /**
  96940. * The camera can move all the way towards the mesh.
  96941. */
  96942. static IgnoreBoundsSizeMode: number;
  96943. /**
  96944. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  96945. */
  96946. static FitFrustumSidesMode: number;
  96947. }
  96948. }
  96949. declare module BABYLON {
  96950. /**
  96951. * Base class for Camera Pointer Inputs.
  96952. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  96953. * for example usage.
  96954. */
  96955. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  96956. /**
  96957. * Defines the camera the input is attached to.
  96958. */
  96959. abstract camera: Camera;
  96960. /**
  96961. * Whether keyboard modifier keys are pressed at time of last mouse event.
  96962. */
  96963. protected _altKey: boolean;
  96964. protected _ctrlKey: boolean;
  96965. protected _metaKey: boolean;
  96966. protected _shiftKey: boolean;
  96967. /**
  96968. * Which mouse buttons were pressed at time of last mouse event.
  96969. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  96970. */
  96971. protected _buttonsPressed: number;
  96972. /**
  96973. * Defines the buttons associated with the input to handle camera move.
  96974. */
  96975. buttons: number[];
  96976. /**
  96977. * Attach the input controls to a specific dom element to get the input from.
  96978. * @param element Defines the element the controls should be listened from
  96979. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96980. */
  96981. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96982. /**
  96983. * Detach the current controls from the specified dom element.
  96984. * @param element Defines the element to stop listening the inputs from
  96985. */
  96986. detachControl(element: Nullable<HTMLElement>): void;
  96987. /**
  96988. * Gets the class name of the current input.
  96989. * @returns the class name
  96990. */
  96991. getClassName(): string;
  96992. /**
  96993. * Get the friendly name associated with the input class.
  96994. * @returns the input friendly name
  96995. */
  96996. getSimpleName(): string;
  96997. /**
  96998. * Called on pointer POINTERDOUBLETAP event.
  96999. * Override this method to provide functionality on POINTERDOUBLETAP event.
  97000. */
  97001. protected onDoubleTap(type: string): void;
  97002. /**
  97003. * Called on pointer POINTERMOVE event if only a single touch is active.
  97004. * Override this method to provide functionality.
  97005. */
  97006. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97007. /**
  97008. * Called on pointer POINTERMOVE event if multiple touches are active.
  97009. * Override this method to provide functionality.
  97010. */
  97011. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97012. /**
  97013. * Called on JS contextmenu event.
  97014. * Override this method to provide functionality.
  97015. */
  97016. protected onContextMenu(evt: PointerEvent): void;
  97017. /**
  97018. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97019. * press.
  97020. * Override this method to provide functionality.
  97021. */
  97022. protected onButtonDown(evt: PointerEvent): void;
  97023. /**
  97024. * Called each time a new POINTERUP event occurs. Ie, for each button
  97025. * release.
  97026. * Override this method to provide functionality.
  97027. */
  97028. protected onButtonUp(evt: PointerEvent): void;
  97029. /**
  97030. * Called when window becomes inactive.
  97031. * Override this method to provide functionality.
  97032. */
  97033. protected onLostFocus(): void;
  97034. private _pointerInput;
  97035. private _observer;
  97036. private _onLostFocus;
  97037. private pointA;
  97038. private pointB;
  97039. }
  97040. }
  97041. declare module BABYLON {
  97042. /**
  97043. * Manage the pointers inputs to control an arc rotate camera.
  97044. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97045. */
  97046. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  97047. /**
  97048. * Defines the camera the input is attached to.
  97049. */
  97050. camera: ArcRotateCamera;
  97051. /**
  97052. * Gets the class name of the current input.
  97053. * @returns the class name
  97054. */
  97055. getClassName(): string;
  97056. /**
  97057. * Defines the buttons associated with the input to handle camera move.
  97058. */
  97059. buttons: number[];
  97060. /**
  97061. * Defines the pointer angular sensibility along the X axis or how fast is
  97062. * the camera rotating.
  97063. */
  97064. angularSensibilityX: number;
  97065. /**
  97066. * Defines the pointer angular sensibility along the Y axis or how fast is
  97067. * the camera rotating.
  97068. */
  97069. angularSensibilityY: number;
  97070. /**
  97071. * Defines the pointer pinch precision or how fast is the camera zooming.
  97072. */
  97073. pinchPrecision: number;
  97074. /**
  97075. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  97076. * from 0.
  97077. * It defines the percentage of current camera.radius to use as delta when
  97078. * pinch zoom is used.
  97079. */
  97080. pinchDeltaPercentage: number;
  97081. /**
  97082. * Defines the pointer panning sensibility or how fast is the camera moving.
  97083. */
  97084. panningSensibility: number;
  97085. /**
  97086. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  97087. */
  97088. multiTouchPanning: boolean;
  97089. /**
  97090. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  97091. * zoom (pinch) through multitouch.
  97092. */
  97093. multiTouchPanAndZoom: boolean;
  97094. /**
  97095. * Revers pinch action direction.
  97096. */
  97097. pinchInwards: boolean;
  97098. private _isPanClick;
  97099. private _twoFingerActivityCount;
  97100. private _isPinching;
  97101. /**
  97102. * Called on pointer POINTERMOVE event if only a single touch is active.
  97103. */
  97104. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  97105. /**
  97106. * Called on pointer POINTERDOUBLETAP event.
  97107. */
  97108. protected onDoubleTap(type: string): void;
  97109. /**
  97110. * Called on pointer POINTERMOVE event if multiple touches are active.
  97111. */
  97112. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  97113. /**
  97114. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  97115. * press.
  97116. */
  97117. protected onButtonDown(evt: PointerEvent): void;
  97118. /**
  97119. * Called each time a new POINTERUP event occurs. Ie, for each button
  97120. * release.
  97121. */
  97122. protected onButtonUp(evt: PointerEvent): void;
  97123. /**
  97124. * Called when window becomes inactive.
  97125. */
  97126. protected onLostFocus(): void;
  97127. }
  97128. }
  97129. declare module BABYLON {
  97130. /**
  97131. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  97132. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97133. */
  97134. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  97135. /**
  97136. * Defines the camera the input is attached to.
  97137. */
  97138. camera: ArcRotateCamera;
  97139. /**
  97140. * Defines the list of key codes associated with the up action (increase alpha)
  97141. */
  97142. keysUp: number[];
  97143. /**
  97144. * Defines the list of key codes associated with the down action (decrease alpha)
  97145. */
  97146. keysDown: number[];
  97147. /**
  97148. * Defines the list of key codes associated with the left action (increase beta)
  97149. */
  97150. keysLeft: number[];
  97151. /**
  97152. * Defines the list of key codes associated with the right action (decrease beta)
  97153. */
  97154. keysRight: number[];
  97155. /**
  97156. * Defines the list of key codes associated with the reset action.
  97157. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  97158. */
  97159. keysReset: number[];
  97160. /**
  97161. * Defines the panning sensibility of the inputs.
  97162. * (How fast is the camera paning)
  97163. */
  97164. panningSensibility: number;
  97165. /**
  97166. * Defines the zooming sensibility of the inputs.
  97167. * (How fast is the camera zooming)
  97168. */
  97169. zoomingSensibility: number;
  97170. /**
  97171. * Defines wether maintaining the alt key down switch the movement mode from
  97172. * orientation to zoom.
  97173. */
  97174. useAltToZoom: boolean;
  97175. /**
  97176. * Rotation speed of the camera
  97177. */
  97178. angularSpeed: number;
  97179. private _keys;
  97180. private _ctrlPressed;
  97181. private _altPressed;
  97182. private _onCanvasBlurObserver;
  97183. private _onKeyboardObserver;
  97184. private _engine;
  97185. private _scene;
  97186. /**
  97187. * Attach the input controls to a specific dom element to get the input from.
  97188. * @param element Defines the element the controls should be listened from
  97189. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97190. */
  97191. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97192. /**
  97193. * Detach the current controls from the specified dom element.
  97194. * @param element Defines the element to stop listening the inputs from
  97195. */
  97196. detachControl(element: Nullable<HTMLElement>): void;
  97197. /**
  97198. * Update the current camera state depending on the inputs that have been used this frame.
  97199. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  97200. */
  97201. checkInputs(): void;
  97202. /**
  97203. * Gets the class name of the current intput.
  97204. * @returns the class name
  97205. */
  97206. getClassName(): string;
  97207. /**
  97208. * Get the friendly name associated with the input class.
  97209. * @returns the input friendly name
  97210. */
  97211. getSimpleName(): string;
  97212. }
  97213. }
  97214. declare module BABYLON {
  97215. /**
  97216. * Manage the mouse wheel inputs to control an arc rotate camera.
  97217. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97218. */
  97219. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  97220. /**
  97221. * Defines the camera the input is attached to.
  97222. */
  97223. camera: ArcRotateCamera;
  97224. /**
  97225. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97226. */
  97227. wheelPrecision: number;
  97228. /**
  97229. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  97230. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  97231. */
  97232. wheelDeltaPercentage: number;
  97233. private _wheel;
  97234. private _observer;
  97235. private computeDeltaFromMouseWheelLegacyEvent;
  97236. /**
  97237. * Attach the input controls to a specific dom element to get the input from.
  97238. * @param element Defines the element the controls should be listened from
  97239. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97240. */
  97241. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  97242. /**
  97243. * Detach the current controls from the specified dom element.
  97244. * @param element Defines the element to stop listening the inputs from
  97245. */
  97246. detachControl(element: Nullable<HTMLElement>): void;
  97247. /**
  97248. * Gets the class name of the current intput.
  97249. * @returns the class name
  97250. */
  97251. getClassName(): string;
  97252. /**
  97253. * Get the friendly name associated with the input class.
  97254. * @returns the input friendly name
  97255. */
  97256. getSimpleName(): string;
  97257. }
  97258. }
  97259. declare module BABYLON {
  97260. /**
  97261. * Default Inputs manager for the ArcRotateCamera.
  97262. * It groups all the default supported inputs for ease of use.
  97263. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  97264. */
  97265. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  97266. /**
  97267. * Instantiates a new ArcRotateCameraInputsManager.
  97268. * @param camera Defines the camera the inputs belong to
  97269. */
  97270. constructor(camera: ArcRotateCamera);
  97271. /**
  97272. * Add mouse wheel input support to the input manager.
  97273. * @returns the current input manager
  97274. */
  97275. addMouseWheel(): ArcRotateCameraInputsManager;
  97276. /**
  97277. * Add pointers input support to the input manager.
  97278. * @returns the current input manager
  97279. */
  97280. addPointers(): ArcRotateCameraInputsManager;
  97281. /**
  97282. * Add keyboard input support to the input manager.
  97283. * @returns the current input manager
  97284. */
  97285. addKeyboard(): ArcRotateCameraInputsManager;
  97286. }
  97287. }
  97288. declare module BABYLON {
  97289. /**
  97290. * This represents an orbital type of camera.
  97291. *
  97292. * 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.
  97293. * 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.
  97294. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  97295. */
  97296. export class ArcRotateCamera extends TargetCamera {
  97297. /**
  97298. * Defines the rotation angle of the camera along the longitudinal axis.
  97299. */
  97300. alpha: number;
  97301. /**
  97302. * Defines the rotation angle of the camera along the latitudinal axis.
  97303. */
  97304. beta: number;
  97305. /**
  97306. * Defines the radius of the camera from it s target point.
  97307. */
  97308. radius: number;
  97309. protected _target: Vector3;
  97310. protected _targetHost: Nullable<AbstractMesh>;
  97311. /**
  97312. * Defines the target point of the camera.
  97313. * The camera looks towards it form the radius distance.
  97314. */
  97315. target: Vector3;
  97316. /**
  97317. * Define the current local position of the camera in the scene
  97318. */
  97319. position: Vector3;
  97320. protected _upVector: Vector3;
  97321. protected _upToYMatrix: Matrix;
  97322. protected _YToUpMatrix: Matrix;
  97323. /**
  97324. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  97325. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  97326. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  97327. */
  97328. upVector: Vector3;
  97329. /**
  97330. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  97331. */
  97332. setMatUp(): void;
  97333. /**
  97334. * Current inertia value on the longitudinal axis.
  97335. * The bigger this number the longer it will take for the camera to stop.
  97336. */
  97337. inertialAlphaOffset: number;
  97338. /**
  97339. * Current inertia value on the latitudinal axis.
  97340. * The bigger this number the longer it will take for the camera to stop.
  97341. */
  97342. inertialBetaOffset: number;
  97343. /**
  97344. * Current inertia value on the radius axis.
  97345. * The bigger this number the longer it will take for the camera to stop.
  97346. */
  97347. inertialRadiusOffset: number;
  97348. /**
  97349. * Minimum allowed angle on the longitudinal axis.
  97350. * This can help limiting how the Camera is able to move in the scene.
  97351. */
  97352. lowerAlphaLimit: Nullable<number>;
  97353. /**
  97354. * Maximum allowed angle on the longitudinal axis.
  97355. * This can help limiting how the Camera is able to move in the scene.
  97356. */
  97357. upperAlphaLimit: Nullable<number>;
  97358. /**
  97359. * Minimum allowed angle on the latitudinal axis.
  97360. * This can help limiting how the Camera is able to move in the scene.
  97361. */
  97362. lowerBetaLimit: number;
  97363. /**
  97364. * Maximum allowed angle on the latitudinal axis.
  97365. * This can help limiting how the Camera is able to move in the scene.
  97366. */
  97367. upperBetaLimit: number;
  97368. /**
  97369. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  97370. * This can help limiting how the Camera is able to move in the scene.
  97371. */
  97372. lowerRadiusLimit: Nullable<number>;
  97373. /**
  97374. * Maximum allowed distance of the camera to the target (The camera can not get further).
  97375. * This can help limiting how the Camera is able to move in the scene.
  97376. */
  97377. upperRadiusLimit: Nullable<number>;
  97378. /**
  97379. * Defines the current inertia value used during panning of the camera along the X axis.
  97380. */
  97381. inertialPanningX: number;
  97382. /**
  97383. * Defines the current inertia value used during panning of the camera along the Y axis.
  97384. */
  97385. inertialPanningY: number;
  97386. /**
  97387. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  97388. * Basically if your fingers moves away from more than this distance you will be considered
  97389. * in pinch mode.
  97390. */
  97391. pinchToPanMaxDistance: number;
  97392. /**
  97393. * Defines the maximum distance the camera can pan.
  97394. * This could help keeping the cammera always in your scene.
  97395. */
  97396. panningDistanceLimit: Nullable<number>;
  97397. /**
  97398. * Defines the target of the camera before paning.
  97399. */
  97400. panningOriginTarget: Vector3;
  97401. /**
  97402. * Defines the value of the inertia used during panning.
  97403. * 0 would mean stop inertia and one would mean no decelleration at all.
  97404. */
  97405. panningInertia: number;
  97406. /**
  97407. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  97408. */
  97409. angularSensibilityX: number;
  97410. /**
  97411. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  97412. */
  97413. angularSensibilityY: number;
  97414. /**
  97415. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  97416. */
  97417. pinchPrecision: number;
  97418. /**
  97419. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  97420. * It will be used instead of pinchDeltaPrecision if different from 0.
  97421. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97422. */
  97423. pinchDeltaPercentage: number;
  97424. /**
  97425. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  97426. */
  97427. panningSensibility: number;
  97428. /**
  97429. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  97430. */
  97431. keysUp: number[];
  97432. /**
  97433. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  97434. */
  97435. keysDown: number[];
  97436. /**
  97437. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  97438. */
  97439. keysLeft: number[];
  97440. /**
  97441. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  97442. */
  97443. keysRight: number[];
  97444. /**
  97445. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  97446. */
  97447. wheelPrecision: number;
  97448. /**
  97449. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  97450. * It will be used instead of pinchDeltaPrecision if different from 0.
  97451. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  97452. */
  97453. wheelDeltaPercentage: number;
  97454. /**
  97455. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  97456. */
  97457. zoomOnFactor: number;
  97458. /**
  97459. * Defines a screen offset for the camera position.
  97460. */
  97461. targetScreenOffset: Vector2;
  97462. /**
  97463. * Allows the camera to be completely reversed.
  97464. * If false the camera can not arrive upside down.
  97465. */
  97466. allowUpsideDown: boolean;
  97467. /**
  97468. * Define if double tap/click is used to restore the previously saved state of the camera.
  97469. */
  97470. useInputToRestoreState: boolean;
  97471. /** @hidden */
  97472. _viewMatrix: Matrix;
  97473. /** @hidden */
  97474. _useCtrlForPanning: boolean;
  97475. /** @hidden */
  97476. _panningMouseButton: number;
  97477. /**
  97478. * Defines the input associated to the camera.
  97479. */
  97480. inputs: ArcRotateCameraInputsManager;
  97481. /** @hidden */
  97482. _reset: () => void;
  97483. /**
  97484. * Defines the allowed panning axis.
  97485. */
  97486. panningAxis: Vector3;
  97487. protected _localDirection: Vector3;
  97488. protected _transformedDirection: Vector3;
  97489. private _bouncingBehavior;
  97490. /**
  97491. * Gets the bouncing behavior of the camera if it has been enabled.
  97492. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97493. */
  97494. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  97495. /**
  97496. * Defines if the bouncing behavior of the camera is enabled on the camera.
  97497. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  97498. */
  97499. useBouncingBehavior: boolean;
  97500. private _framingBehavior;
  97501. /**
  97502. * Gets the framing behavior of the camera if it has been enabled.
  97503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97504. */
  97505. readonly framingBehavior: Nullable<FramingBehavior>;
  97506. /**
  97507. * Defines if the framing behavior of the camera is enabled on the camera.
  97508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  97509. */
  97510. useFramingBehavior: boolean;
  97511. private _autoRotationBehavior;
  97512. /**
  97513. * Gets the auto rotation behavior of the camera if it has been enabled.
  97514. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97515. */
  97516. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  97517. /**
  97518. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  97519. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97520. */
  97521. useAutoRotationBehavior: boolean;
  97522. /**
  97523. * Observable triggered when the mesh target has been changed on the camera.
  97524. */
  97525. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  97526. /**
  97527. * Event raised when the camera is colliding with a mesh.
  97528. */
  97529. onCollide: (collidedMesh: AbstractMesh) => void;
  97530. /**
  97531. * Defines whether the camera should check collision with the objects oh the scene.
  97532. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  97533. */
  97534. checkCollisions: boolean;
  97535. /**
  97536. * Defines the collision radius of the camera.
  97537. * This simulates a sphere around the camera.
  97538. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  97539. */
  97540. collisionRadius: Vector3;
  97541. protected _collider: Collider;
  97542. protected _previousPosition: Vector3;
  97543. protected _collisionVelocity: Vector3;
  97544. protected _newPosition: Vector3;
  97545. protected _previousAlpha: number;
  97546. protected _previousBeta: number;
  97547. protected _previousRadius: number;
  97548. protected _collisionTriggered: boolean;
  97549. protected _targetBoundingCenter: Nullable<Vector3>;
  97550. private _computationVector;
  97551. /**
  97552. * Instantiates a new ArcRotateCamera in a given scene
  97553. * @param name Defines the name of the camera
  97554. * @param alpha Defines the camera rotation along the logitudinal axis
  97555. * @param beta Defines the camera rotation along the latitudinal axis
  97556. * @param radius Defines the camera distance from its target
  97557. * @param target Defines the camera target
  97558. * @param scene Defines the scene the camera belongs to
  97559. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  97560. */
  97561. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  97562. /** @hidden */
  97563. _initCache(): void;
  97564. /** @hidden */
  97565. _updateCache(ignoreParentClass?: boolean): void;
  97566. protected _getTargetPosition(): Vector3;
  97567. private _storedAlpha;
  97568. private _storedBeta;
  97569. private _storedRadius;
  97570. private _storedTarget;
  97571. /**
  97572. * Stores the current state of the camera (alpha, beta, radius and target)
  97573. * @returns the camera itself
  97574. */
  97575. storeState(): Camera;
  97576. /**
  97577. * @hidden
  97578. * Restored camera state. You must call storeState() first
  97579. */
  97580. _restoreStateValues(): boolean;
  97581. /** @hidden */
  97582. _isSynchronizedViewMatrix(): boolean;
  97583. /**
  97584. * Attached controls to the current camera.
  97585. * @param element Defines the element the controls should be listened from
  97586. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  97587. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  97588. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  97589. */
  97590. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  97591. /**
  97592. * Detach the current controls from the camera.
  97593. * The camera will stop reacting to inputs.
  97594. * @param element Defines the element to stop listening the inputs from
  97595. */
  97596. detachControl(element: HTMLElement): void;
  97597. /** @hidden */
  97598. _checkInputs(): void;
  97599. protected _checkLimits(): void;
  97600. /**
  97601. * Rebuilds angles (alpha, beta) and radius from the give position and target
  97602. */
  97603. rebuildAnglesAndRadius(): void;
  97604. /**
  97605. * Use a position to define the current camera related information like aplha, beta and radius
  97606. * @param position Defines the position to set the camera at
  97607. */
  97608. setPosition(position: Vector3): void;
  97609. /**
  97610. * Defines the target the camera should look at.
  97611. * This will automatically adapt alpha beta and radius to fit within the new target.
  97612. * @param target Defines the new target as a Vector or a mesh
  97613. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  97614. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  97615. */
  97616. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  97617. /** @hidden */
  97618. _getViewMatrix(): Matrix;
  97619. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  97620. /**
  97621. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  97622. * @param meshes Defines the mesh to zoom on
  97623. * @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)
  97624. */
  97625. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  97626. /**
  97627. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  97628. * The target will be changed but the radius
  97629. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  97630. * @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)
  97631. */
  97632. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  97633. min: Vector3;
  97634. max: Vector3;
  97635. distance: number;
  97636. }, doNotUpdateMaxZ?: boolean): void;
  97637. /**
  97638. * @override
  97639. * Override Camera.createRigCamera
  97640. */
  97641. createRigCamera(name: string, cameraIndex: number): Camera;
  97642. /**
  97643. * @hidden
  97644. * @override
  97645. * Override Camera._updateRigCameras
  97646. */
  97647. _updateRigCameras(): void;
  97648. /**
  97649. * Destroy the camera and release the current resources hold by it.
  97650. */
  97651. dispose(): void;
  97652. /**
  97653. * Gets the current object class name.
  97654. * @return the class name
  97655. */
  97656. getClassName(): string;
  97657. }
  97658. }
  97659. declare module BABYLON {
  97660. /**
  97661. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  97662. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  97663. */
  97664. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  97665. /**
  97666. * Gets the name of the behavior.
  97667. */
  97668. readonly name: string;
  97669. private _zoomStopsAnimation;
  97670. private _idleRotationSpeed;
  97671. private _idleRotationWaitTime;
  97672. private _idleRotationSpinupTime;
  97673. /**
  97674. * Sets the flag that indicates if user zooming should stop animation.
  97675. */
  97676. /**
  97677. * Gets the flag that indicates if user zooming should stop animation.
  97678. */
  97679. zoomStopsAnimation: boolean;
  97680. /**
  97681. * Sets the default speed at which the camera rotates around the model.
  97682. */
  97683. /**
  97684. * Gets the default speed at which the camera rotates around the model.
  97685. */
  97686. idleRotationSpeed: number;
  97687. /**
  97688. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  97689. */
  97690. /**
  97691. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  97692. */
  97693. idleRotationWaitTime: number;
  97694. /**
  97695. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  97696. */
  97697. /**
  97698. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  97699. */
  97700. idleRotationSpinupTime: number;
  97701. /**
  97702. * Gets a value indicating if the camera is currently rotating because of this behavior
  97703. */
  97704. readonly rotationInProgress: boolean;
  97705. private _onPrePointerObservableObserver;
  97706. private _onAfterCheckInputsObserver;
  97707. private _attachedCamera;
  97708. private _isPointerDown;
  97709. private _lastFrameTime;
  97710. private _lastInteractionTime;
  97711. private _cameraRotationSpeed;
  97712. /**
  97713. * Initializes the behavior.
  97714. */
  97715. init(): void;
  97716. /**
  97717. * Attaches the behavior to its arc rotate camera.
  97718. * @param camera Defines the camera to attach the behavior to
  97719. */
  97720. attach(camera: ArcRotateCamera): void;
  97721. /**
  97722. * Detaches the behavior from its current arc rotate camera.
  97723. */
  97724. detach(): void;
  97725. /**
  97726. * Returns true if user is scrolling.
  97727. * @return true if user is scrolling.
  97728. */
  97729. private _userIsZooming;
  97730. private _lastFrameRadius;
  97731. private _shouldAnimationStopForInteraction;
  97732. /**
  97733. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  97734. */
  97735. private _applyUserInteraction;
  97736. private _userIsMoving;
  97737. }
  97738. }
  97739. declare module BABYLON {
  97740. /**
  97741. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  97742. */
  97743. export class AttachToBoxBehavior implements Behavior<Mesh> {
  97744. private ui;
  97745. /**
  97746. * The name of the behavior
  97747. */
  97748. name: string;
  97749. /**
  97750. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  97751. */
  97752. distanceAwayFromFace: number;
  97753. /**
  97754. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  97755. */
  97756. distanceAwayFromBottomOfFace: number;
  97757. private _faceVectors;
  97758. private _target;
  97759. private _scene;
  97760. private _onRenderObserver;
  97761. private _tmpMatrix;
  97762. private _tmpVector;
  97763. /**
  97764. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  97765. * @param ui The transform node that should be attched to the mesh
  97766. */
  97767. constructor(ui: TransformNode);
  97768. /**
  97769. * Initializes the behavior
  97770. */
  97771. init(): void;
  97772. private _closestFace;
  97773. private _zeroVector;
  97774. private _lookAtTmpMatrix;
  97775. private _lookAtToRef;
  97776. /**
  97777. * Attaches the AttachToBoxBehavior to the passed in mesh
  97778. * @param target The mesh that the specified node will be attached to
  97779. */
  97780. attach(target: Mesh): void;
  97781. /**
  97782. * Detaches the behavior from the mesh
  97783. */
  97784. detach(): void;
  97785. }
  97786. }
  97787. declare module BABYLON {
  97788. /**
  97789. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  97790. */
  97791. export class FadeInOutBehavior implements Behavior<Mesh> {
  97792. /**
  97793. * Time in milliseconds to delay before fading in (Default: 0)
  97794. */
  97795. delay: number;
  97796. /**
  97797. * Time in milliseconds for the mesh to fade in (Default: 300)
  97798. */
  97799. fadeInTime: number;
  97800. private _millisecondsPerFrame;
  97801. private _hovered;
  97802. private _hoverValue;
  97803. private _ownerNode;
  97804. /**
  97805. * Instatiates the FadeInOutBehavior
  97806. */
  97807. constructor();
  97808. /**
  97809. * The name of the behavior
  97810. */
  97811. readonly name: string;
  97812. /**
  97813. * Initializes the behavior
  97814. */
  97815. init(): void;
  97816. /**
  97817. * Attaches the fade behavior on the passed in mesh
  97818. * @param ownerNode The mesh that will be faded in/out once attached
  97819. */
  97820. attach(ownerNode: Mesh): void;
  97821. /**
  97822. * Detaches the behavior from the mesh
  97823. */
  97824. detach(): void;
  97825. /**
  97826. * Triggers the mesh to begin fading in or out
  97827. * @param value if the object should fade in or out (true to fade in)
  97828. */
  97829. fadeIn(value: boolean): void;
  97830. private _update;
  97831. private _setAllVisibility;
  97832. }
  97833. }
  97834. declare module BABYLON {
  97835. /**
  97836. * Class containing a set of static utilities functions for managing Pivots
  97837. * @hidden
  97838. */
  97839. export class PivotTools {
  97840. private static _PivotCached;
  97841. private static _OldPivotPoint;
  97842. private static _PivotTranslation;
  97843. private static _PivotTmpVector;
  97844. /** @hidden */
  97845. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  97846. /** @hidden */
  97847. static _RestorePivotPoint(mesh: AbstractMesh): void;
  97848. }
  97849. }
  97850. declare module BABYLON {
  97851. /**
  97852. * Class containing static functions to help procedurally build meshes
  97853. */
  97854. export class PlaneBuilder {
  97855. /**
  97856. * Creates a plane mesh
  97857. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  97858. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  97859. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  97860. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  97861. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  97862. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  97863. * @param name defines the name of the mesh
  97864. * @param options defines the options used to create the mesh
  97865. * @param scene defines the hosting scene
  97866. * @returns the plane mesh
  97867. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  97868. */
  97869. static CreatePlane(name: string, options: {
  97870. size?: number;
  97871. width?: number;
  97872. height?: number;
  97873. sideOrientation?: number;
  97874. frontUVs?: Vector4;
  97875. backUVs?: Vector4;
  97876. updatable?: boolean;
  97877. sourcePlane?: Plane;
  97878. }, scene?: Nullable<Scene>): Mesh;
  97879. }
  97880. }
  97881. declare module BABYLON {
  97882. /**
  97883. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  97884. */
  97885. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  97886. private static _AnyMouseID;
  97887. /**
  97888. * Abstract mesh the behavior is set on
  97889. */
  97890. attachedNode: AbstractMesh;
  97891. private _dragPlane;
  97892. private _scene;
  97893. private _pointerObserver;
  97894. private _beforeRenderObserver;
  97895. private static _planeScene;
  97896. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  97897. /**
  97898. * 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)
  97899. */
  97900. maxDragAngle: number;
  97901. /**
  97902. * @hidden
  97903. */
  97904. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  97905. /**
  97906. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  97907. */
  97908. currentDraggingPointerID: number;
  97909. /**
  97910. * The last position where the pointer hit the drag plane in world space
  97911. */
  97912. lastDragPosition: Vector3;
  97913. /**
  97914. * If the behavior is currently in a dragging state
  97915. */
  97916. dragging: boolean;
  97917. /**
  97918. * 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)
  97919. */
  97920. dragDeltaRatio: number;
  97921. /**
  97922. * If the drag plane orientation should be updated during the dragging (Default: true)
  97923. */
  97924. updateDragPlane: boolean;
  97925. private _debugMode;
  97926. private _moving;
  97927. /**
  97928. * Fires each time the attached mesh is dragged with the pointer
  97929. * * delta between last drag position and current drag position in world space
  97930. * * dragDistance along the drag axis
  97931. * * dragPlaneNormal normal of the current drag plane used during the drag
  97932. * * dragPlanePoint in world space where the drag intersects the drag plane
  97933. */
  97934. onDragObservable: Observable<{
  97935. delta: Vector3;
  97936. dragPlanePoint: Vector3;
  97937. dragPlaneNormal: Vector3;
  97938. dragDistance: number;
  97939. pointerId: number;
  97940. }>;
  97941. /**
  97942. * Fires each time a drag begins (eg. mouse down on mesh)
  97943. */
  97944. onDragStartObservable: Observable<{
  97945. dragPlanePoint: Vector3;
  97946. pointerId: number;
  97947. }>;
  97948. /**
  97949. * Fires each time a drag ends (eg. mouse release after drag)
  97950. */
  97951. onDragEndObservable: Observable<{
  97952. dragPlanePoint: Vector3;
  97953. pointerId: number;
  97954. }>;
  97955. /**
  97956. * If the attached mesh should be moved when dragged
  97957. */
  97958. moveAttached: boolean;
  97959. /**
  97960. * If the drag behavior will react to drag events (Default: true)
  97961. */
  97962. enabled: boolean;
  97963. /**
  97964. * If camera controls should be detached during the drag
  97965. */
  97966. detachCameraControls: boolean;
  97967. /**
  97968. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  97969. */
  97970. useObjectOrienationForDragging: boolean;
  97971. private _options;
  97972. /**
  97973. * Creates a pointer drag behavior that can be attached to a mesh
  97974. * @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)
  97975. */
  97976. constructor(options?: {
  97977. dragAxis?: Vector3;
  97978. dragPlaneNormal?: Vector3;
  97979. });
  97980. /**
  97981. * Predicate to determine if it is valid to move the object to a new position when it is moved
  97982. */
  97983. validateDrag: (targetPosition: Vector3) => boolean;
  97984. /**
  97985. * The name of the behavior
  97986. */
  97987. readonly name: string;
  97988. /**
  97989. * Initializes the behavior
  97990. */
  97991. init(): void;
  97992. private _tmpVector;
  97993. private _alternatePickedPoint;
  97994. private _worldDragAxis;
  97995. private _targetPosition;
  97996. private _attachedElement;
  97997. /**
  97998. * Attaches the drag behavior the passed in mesh
  97999. * @param ownerNode The mesh that will be dragged around once attached
  98000. */
  98001. attach(ownerNode: AbstractMesh): void;
  98002. /**
  98003. * Force relase the drag action by code.
  98004. */
  98005. releaseDrag(): void;
  98006. private _startDragRay;
  98007. private _lastPointerRay;
  98008. /**
  98009. * Simulates the start of a pointer drag event on the behavior
  98010. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  98011. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  98012. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  98013. */
  98014. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  98015. private _startDrag;
  98016. private _dragDelta;
  98017. private _moveDrag;
  98018. private _pickWithRayOnDragPlane;
  98019. private _pointA;
  98020. private _pointB;
  98021. private _pointC;
  98022. private _lineA;
  98023. private _lineB;
  98024. private _localAxis;
  98025. private _lookAt;
  98026. private _updateDragPlanePosition;
  98027. /**
  98028. * Detaches the behavior from the mesh
  98029. */
  98030. detach(): void;
  98031. }
  98032. }
  98033. declare module BABYLON {
  98034. /**
  98035. * A behavior that when attached to a mesh will allow the mesh to be scaled
  98036. */
  98037. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  98038. private _dragBehaviorA;
  98039. private _dragBehaviorB;
  98040. private _startDistance;
  98041. private _initialScale;
  98042. private _targetScale;
  98043. private _ownerNode;
  98044. private _sceneRenderObserver;
  98045. /**
  98046. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  98047. */
  98048. constructor();
  98049. /**
  98050. * The name of the behavior
  98051. */
  98052. readonly name: string;
  98053. /**
  98054. * Initializes the behavior
  98055. */
  98056. init(): void;
  98057. private _getCurrentDistance;
  98058. /**
  98059. * Attaches the scale behavior the passed in mesh
  98060. * @param ownerNode The mesh that will be scaled around once attached
  98061. */
  98062. attach(ownerNode: Mesh): void;
  98063. /**
  98064. * Detaches the behavior from the mesh
  98065. */
  98066. detach(): void;
  98067. }
  98068. }
  98069. declare module BABYLON {
  98070. /**
  98071. * 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
  98072. */
  98073. export class SixDofDragBehavior implements Behavior<Mesh> {
  98074. private static _virtualScene;
  98075. private _ownerNode;
  98076. private _sceneRenderObserver;
  98077. private _scene;
  98078. private _targetPosition;
  98079. private _virtualOriginMesh;
  98080. private _virtualDragMesh;
  98081. private _pointerObserver;
  98082. private _moving;
  98083. private _startingOrientation;
  98084. /**
  98085. * 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)
  98086. */
  98087. private zDragFactor;
  98088. /**
  98089. * If the object should rotate to face the drag origin
  98090. */
  98091. rotateDraggedObject: boolean;
  98092. /**
  98093. * If the behavior is currently in a dragging state
  98094. */
  98095. dragging: boolean;
  98096. /**
  98097. * 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)
  98098. */
  98099. dragDeltaRatio: number;
  98100. /**
  98101. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  98102. */
  98103. currentDraggingPointerID: number;
  98104. /**
  98105. * If camera controls should be detached during the drag
  98106. */
  98107. detachCameraControls: boolean;
  98108. /**
  98109. * Fires each time a drag starts
  98110. */
  98111. onDragStartObservable: Observable<{}>;
  98112. /**
  98113. * Fires each time a drag ends (eg. mouse release after drag)
  98114. */
  98115. onDragEndObservable: Observable<{}>;
  98116. /**
  98117. * 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
  98118. */
  98119. constructor();
  98120. /**
  98121. * The name of the behavior
  98122. */
  98123. readonly name: string;
  98124. /**
  98125. * Initializes the behavior
  98126. */
  98127. init(): void;
  98128. /**
  98129. * Attaches the scale behavior the passed in mesh
  98130. * @param ownerNode The mesh that will be scaled around once attached
  98131. */
  98132. attach(ownerNode: Mesh): void;
  98133. /**
  98134. * Detaches the behavior from the mesh
  98135. */
  98136. detach(): void;
  98137. }
  98138. }
  98139. declare module BABYLON {
  98140. /**
  98141. * Class used to apply inverse kinematics to bones
  98142. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  98143. */
  98144. export class BoneIKController {
  98145. private static _tmpVecs;
  98146. private static _tmpQuat;
  98147. private static _tmpMats;
  98148. /**
  98149. * Gets or sets the target mesh
  98150. */
  98151. targetMesh: AbstractMesh;
  98152. /** Gets or sets the mesh used as pole */
  98153. poleTargetMesh: AbstractMesh;
  98154. /**
  98155. * Gets or sets the bone used as pole
  98156. */
  98157. poleTargetBone: Nullable<Bone>;
  98158. /**
  98159. * Gets or sets the target position
  98160. */
  98161. targetPosition: Vector3;
  98162. /**
  98163. * Gets or sets the pole target position
  98164. */
  98165. poleTargetPosition: Vector3;
  98166. /**
  98167. * Gets or sets the pole target local offset
  98168. */
  98169. poleTargetLocalOffset: Vector3;
  98170. /**
  98171. * Gets or sets the pole angle
  98172. */
  98173. poleAngle: number;
  98174. /**
  98175. * Gets or sets the mesh associated with the controller
  98176. */
  98177. mesh: AbstractMesh;
  98178. /**
  98179. * 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)
  98180. */
  98181. slerpAmount: number;
  98182. private _bone1Quat;
  98183. private _bone1Mat;
  98184. private _bone2Ang;
  98185. private _bone1;
  98186. private _bone2;
  98187. private _bone1Length;
  98188. private _bone2Length;
  98189. private _maxAngle;
  98190. private _maxReach;
  98191. private _rightHandedSystem;
  98192. private _bendAxis;
  98193. private _slerping;
  98194. private _adjustRoll;
  98195. /**
  98196. * Gets or sets maximum allowed angle
  98197. */
  98198. maxAngle: number;
  98199. /**
  98200. * Creates a new BoneIKController
  98201. * @param mesh defines the mesh to control
  98202. * @param bone defines the bone to control
  98203. * @param options defines options to set up the controller
  98204. */
  98205. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  98206. targetMesh?: AbstractMesh;
  98207. poleTargetMesh?: AbstractMesh;
  98208. poleTargetBone?: Bone;
  98209. poleTargetLocalOffset?: Vector3;
  98210. poleAngle?: number;
  98211. bendAxis?: Vector3;
  98212. maxAngle?: number;
  98213. slerpAmount?: number;
  98214. });
  98215. private _setMaxAngle;
  98216. /**
  98217. * Force the controller to update the bones
  98218. */
  98219. update(): void;
  98220. }
  98221. }
  98222. declare module BABYLON {
  98223. /**
  98224. * Class used to make a bone look toward a point in space
  98225. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  98226. */
  98227. export class BoneLookController {
  98228. private static _tmpVecs;
  98229. private static _tmpQuat;
  98230. private static _tmpMats;
  98231. /**
  98232. * The target Vector3 that the bone will look at
  98233. */
  98234. target: Vector3;
  98235. /**
  98236. * The mesh that the bone is attached to
  98237. */
  98238. mesh: AbstractMesh;
  98239. /**
  98240. * The bone that will be looking to the target
  98241. */
  98242. bone: Bone;
  98243. /**
  98244. * The up axis of the coordinate system that is used when the bone is rotated
  98245. */
  98246. upAxis: Vector3;
  98247. /**
  98248. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  98249. */
  98250. upAxisSpace: Space;
  98251. /**
  98252. * Used to make an adjustment to the yaw of the bone
  98253. */
  98254. adjustYaw: number;
  98255. /**
  98256. * Used to make an adjustment to the pitch of the bone
  98257. */
  98258. adjustPitch: number;
  98259. /**
  98260. * Used to make an adjustment to the roll of the bone
  98261. */
  98262. adjustRoll: number;
  98263. /**
  98264. * 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)
  98265. */
  98266. slerpAmount: number;
  98267. private _minYaw;
  98268. private _maxYaw;
  98269. private _minPitch;
  98270. private _maxPitch;
  98271. private _minYawSin;
  98272. private _minYawCos;
  98273. private _maxYawSin;
  98274. private _maxYawCos;
  98275. private _midYawConstraint;
  98276. private _minPitchTan;
  98277. private _maxPitchTan;
  98278. private _boneQuat;
  98279. private _slerping;
  98280. private _transformYawPitch;
  98281. private _transformYawPitchInv;
  98282. private _firstFrameSkipped;
  98283. private _yawRange;
  98284. private _fowardAxis;
  98285. /**
  98286. * Gets or sets the minimum yaw angle that the bone can look to
  98287. */
  98288. minYaw: number;
  98289. /**
  98290. * Gets or sets the maximum yaw angle that the bone can look to
  98291. */
  98292. maxYaw: number;
  98293. /**
  98294. * Gets or sets the minimum pitch angle that the bone can look to
  98295. */
  98296. minPitch: number;
  98297. /**
  98298. * Gets or sets the maximum pitch angle that the bone can look to
  98299. */
  98300. maxPitch: number;
  98301. /**
  98302. * Create a BoneLookController
  98303. * @param mesh the mesh that the bone belongs to
  98304. * @param bone the bone that will be looking to the target
  98305. * @param target the target Vector3 to look at
  98306. * @param options optional settings:
  98307. * * maxYaw: the maximum angle the bone will yaw to
  98308. * * minYaw: the minimum angle the bone will yaw to
  98309. * * maxPitch: the maximum angle the bone will pitch to
  98310. * * minPitch: the minimum angle the bone will yaw to
  98311. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  98312. * * upAxis: the up axis of the coordinate system
  98313. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  98314. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  98315. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  98316. * * adjustYaw: used to make an adjustment to the yaw of the bone
  98317. * * adjustPitch: used to make an adjustment to the pitch of the bone
  98318. * * adjustRoll: used to make an adjustment to the roll of the bone
  98319. **/
  98320. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  98321. maxYaw?: number;
  98322. minYaw?: number;
  98323. maxPitch?: number;
  98324. minPitch?: number;
  98325. slerpAmount?: number;
  98326. upAxis?: Vector3;
  98327. upAxisSpace?: Space;
  98328. yawAxis?: Vector3;
  98329. pitchAxis?: Vector3;
  98330. adjustYaw?: number;
  98331. adjustPitch?: number;
  98332. adjustRoll?: number;
  98333. });
  98334. /**
  98335. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  98336. */
  98337. update(): void;
  98338. private _getAngleDiff;
  98339. private _getAngleBetween;
  98340. private _isAngleBetween;
  98341. }
  98342. }
  98343. declare module BABYLON {
  98344. /**
  98345. * Manage the gamepad inputs to control an arc rotate camera.
  98346. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98347. */
  98348. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  98349. /**
  98350. * Defines the camera the input is attached to.
  98351. */
  98352. camera: ArcRotateCamera;
  98353. /**
  98354. * Defines the gamepad the input is gathering event from.
  98355. */
  98356. gamepad: Nullable<Gamepad>;
  98357. /**
  98358. * Defines the gamepad rotation sensiblity.
  98359. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  98360. */
  98361. gamepadRotationSensibility: number;
  98362. /**
  98363. * Defines the gamepad move sensiblity.
  98364. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  98365. */
  98366. gamepadMoveSensibility: number;
  98367. private _onGamepadConnectedObserver;
  98368. private _onGamepadDisconnectedObserver;
  98369. /**
  98370. * Attach the input controls to a specific dom element to get the input from.
  98371. * @param element Defines the element the controls should be listened from
  98372. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98373. */
  98374. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98375. /**
  98376. * Detach the current controls from the specified dom element.
  98377. * @param element Defines the element to stop listening the inputs from
  98378. */
  98379. detachControl(element: Nullable<HTMLElement>): void;
  98380. /**
  98381. * Update the current camera state depending on the inputs that have been used this frame.
  98382. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98383. */
  98384. checkInputs(): void;
  98385. /**
  98386. * Gets the class name of the current intput.
  98387. * @returns the class name
  98388. */
  98389. getClassName(): string;
  98390. /**
  98391. * Get the friendly name associated with the input class.
  98392. * @returns the input friendly name
  98393. */
  98394. getSimpleName(): string;
  98395. }
  98396. }
  98397. declare module BABYLON {
  98398. interface ArcRotateCameraInputsManager {
  98399. /**
  98400. * Add orientation input support to the input manager.
  98401. * @returns the current input manager
  98402. */
  98403. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  98404. }
  98405. /**
  98406. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  98407. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98408. */
  98409. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  98410. /**
  98411. * Defines the camera the input is attached to.
  98412. */
  98413. camera: ArcRotateCamera;
  98414. /**
  98415. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  98416. */
  98417. alphaCorrection: number;
  98418. /**
  98419. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  98420. */
  98421. gammaCorrection: number;
  98422. private _alpha;
  98423. private _gamma;
  98424. private _dirty;
  98425. private _deviceOrientationHandler;
  98426. /**
  98427. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  98428. */
  98429. constructor();
  98430. /**
  98431. * Attach the input controls to a specific dom element to get the input from.
  98432. * @param element Defines the element the controls should be listened from
  98433. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98434. */
  98435. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98436. /** @hidden */
  98437. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  98438. /**
  98439. * Update the current camera state depending on the inputs that have been used this frame.
  98440. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98441. */
  98442. checkInputs(): void;
  98443. /**
  98444. * Detach the current controls from the specified dom element.
  98445. * @param element Defines the element to stop listening the inputs from
  98446. */
  98447. detachControl(element: Nullable<HTMLElement>): void;
  98448. /**
  98449. * Gets the class name of the current intput.
  98450. * @returns the class name
  98451. */
  98452. getClassName(): string;
  98453. /**
  98454. * Get the friendly name associated with the input class.
  98455. * @returns the input friendly name
  98456. */
  98457. getSimpleName(): string;
  98458. }
  98459. }
  98460. declare module BABYLON {
  98461. /**
  98462. * Listen to mouse events to control the camera.
  98463. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98464. */
  98465. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  98466. /**
  98467. * Defines the camera the input is attached to.
  98468. */
  98469. camera: FlyCamera;
  98470. /**
  98471. * Defines if touch is enabled. (Default is true.)
  98472. */
  98473. touchEnabled: boolean;
  98474. /**
  98475. * Defines the buttons associated with the input to handle camera rotation.
  98476. */
  98477. buttons: number[];
  98478. /**
  98479. * Assign buttons for Yaw control.
  98480. */
  98481. buttonsYaw: number[];
  98482. /**
  98483. * Assign buttons for Pitch control.
  98484. */
  98485. buttonsPitch: number[];
  98486. /**
  98487. * Assign buttons for Roll control.
  98488. */
  98489. buttonsRoll: number[];
  98490. /**
  98491. * Detect if any button is being pressed while mouse is moved.
  98492. * -1 = Mouse locked.
  98493. * 0 = Left button.
  98494. * 1 = Middle Button.
  98495. * 2 = Right Button.
  98496. */
  98497. activeButton: number;
  98498. /**
  98499. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  98500. * Higher values reduce its sensitivity.
  98501. */
  98502. angularSensibility: number;
  98503. private _mousemoveCallback;
  98504. private _observer;
  98505. private _rollObserver;
  98506. private previousPosition;
  98507. private noPreventDefault;
  98508. private element;
  98509. /**
  98510. * Listen to mouse events to control the camera.
  98511. * @param touchEnabled Define if touch is enabled. (Default is true.)
  98512. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98513. */
  98514. constructor(touchEnabled?: boolean);
  98515. /**
  98516. * Attach the mouse control to the HTML DOM element.
  98517. * @param element Defines the element that listens to the input events.
  98518. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  98519. */
  98520. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98521. /**
  98522. * Detach the current controls from the specified dom element.
  98523. * @param element Defines the element to stop listening the inputs from
  98524. */
  98525. detachControl(element: Nullable<HTMLElement>): void;
  98526. /**
  98527. * Gets the class name of the current input.
  98528. * @returns the class name.
  98529. */
  98530. getClassName(): string;
  98531. /**
  98532. * Get the friendly name associated with the input class.
  98533. * @returns the input's friendly name.
  98534. */
  98535. getSimpleName(): string;
  98536. private _pointerInput;
  98537. private _onMouseMove;
  98538. /**
  98539. * Rotate camera by mouse offset.
  98540. */
  98541. private rotateCamera;
  98542. }
  98543. }
  98544. declare module BABYLON {
  98545. /**
  98546. * Default Inputs manager for the FlyCamera.
  98547. * It groups all the default supported inputs for ease of use.
  98548. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98549. */
  98550. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  98551. /**
  98552. * Instantiates a new FlyCameraInputsManager.
  98553. * @param camera Defines the camera the inputs belong to.
  98554. */
  98555. constructor(camera: FlyCamera);
  98556. /**
  98557. * Add keyboard input support to the input manager.
  98558. * @returns the new FlyCameraKeyboardMoveInput().
  98559. */
  98560. addKeyboard(): FlyCameraInputsManager;
  98561. /**
  98562. * Add mouse input support to the input manager.
  98563. * @param touchEnabled Enable touch screen support.
  98564. * @returns the new FlyCameraMouseInput().
  98565. */
  98566. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  98567. }
  98568. }
  98569. declare module BABYLON {
  98570. /**
  98571. * This is a flying camera, designed for 3D movement and rotation in all directions,
  98572. * such as in a 3D Space Shooter or a Flight Simulator.
  98573. */
  98574. export class FlyCamera extends TargetCamera {
  98575. /**
  98576. * Define the collision ellipsoid of the camera.
  98577. * This is helpful for simulating a camera body, like a player's body.
  98578. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  98579. */
  98580. ellipsoid: Vector3;
  98581. /**
  98582. * Define an offset for the position of the ellipsoid around the camera.
  98583. * This can be helpful if the camera is attached away from the player's body center,
  98584. * such as at its head.
  98585. */
  98586. ellipsoidOffset: Vector3;
  98587. /**
  98588. * Enable or disable collisions of the camera with the rest of the scene objects.
  98589. */
  98590. checkCollisions: boolean;
  98591. /**
  98592. * Enable or disable gravity on the camera.
  98593. */
  98594. applyGravity: boolean;
  98595. /**
  98596. * Define the current direction the camera is moving to.
  98597. */
  98598. cameraDirection: Vector3;
  98599. /**
  98600. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  98601. * This overrides and empties cameraRotation.
  98602. */
  98603. rotationQuaternion: Quaternion;
  98604. /**
  98605. * Track Roll to maintain the wanted Rolling when looking around.
  98606. */
  98607. _trackRoll: number;
  98608. /**
  98609. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  98610. */
  98611. rollCorrect: number;
  98612. /**
  98613. * Mimic a banked turn, Rolling the camera when Yawing.
  98614. * It's recommended to use rollCorrect = 10 for faster banking correction.
  98615. */
  98616. bankedTurn: boolean;
  98617. /**
  98618. * Limit in radians for how much Roll banking will add. (Default: 90°)
  98619. */
  98620. bankedTurnLimit: number;
  98621. /**
  98622. * Value of 0 disables the banked Roll.
  98623. * Value of 1 is equal to the Yaw angle in radians.
  98624. */
  98625. bankedTurnMultiplier: number;
  98626. /**
  98627. * The inputs manager loads all the input sources, such as keyboard and mouse.
  98628. */
  98629. inputs: FlyCameraInputsManager;
  98630. /**
  98631. * Gets the input sensibility for mouse input.
  98632. * Higher values reduce sensitivity.
  98633. */
  98634. /**
  98635. * Sets the input sensibility for a mouse input.
  98636. * Higher values reduce sensitivity.
  98637. */
  98638. angularSensibility: number;
  98639. /**
  98640. * Get the keys for camera movement forward.
  98641. */
  98642. /**
  98643. * Set the keys for camera movement forward.
  98644. */
  98645. keysForward: number[];
  98646. /**
  98647. * Get the keys for camera movement backward.
  98648. */
  98649. keysBackward: number[];
  98650. /**
  98651. * Get the keys for camera movement up.
  98652. */
  98653. /**
  98654. * Set the keys for camera movement up.
  98655. */
  98656. keysUp: number[];
  98657. /**
  98658. * Get the keys for camera movement down.
  98659. */
  98660. /**
  98661. * Set the keys for camera movement down.
  98662. */
  98663. keysDown: number[];
  98664. /**
  98665. * Get the keys for camera movement left.
  98666. */
  98667. /**
  98668. * Set the keys for camera movement left.
  98669. */
  98670. keysLeft: number[];
  98671. /**
  98672. * Set the keys for camera movement right.
  98673. */
  98674. /**
  98675. * Set the keys for camera movement right.
  98676. */
  98677. keysRight: number[];
  98678. /**
  98679. * Event raised when the camera collides with a mesh in the scene.
  98680. */
  98681. onCollide: (collidedMesh: AbstractMesh) => void;
  98682. private _collider;
  98683. private _needMoveForGravity;
  98684. private _oldPosition;
  98685. private _diffPosition;
  98686. private _newPosition;
  98687. /** @hidden */
  98688. _localDirection: Vector3;
  98689. /** @hidden */
  98690. _transformedDirection: Vector3;
  98691. /**
  98692. * Instantiates a FlyCamera.
  98693. * This is a flying camera, designed for 3D movement and rotation in all directions,
  98694. * such as in a 3D Space Shooter or a Flight Simulator.
  98695. * @param name Define the name of the camera in the scene.
  98696. * @param position Define the starting position of the camera in the scene.
  98697. * @param scene Define the scene the camera belongs to.
  98698. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  98699. */
  98700. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  98701. /**
  98702. * Attach a control to the HTML DOM element.
  98703. * @param element Defines the element that listens to the input events.
  98704. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  98705. */
  98706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98707. /**
  98708. * Detach a control from the HTML DOM element.
  98709. * The camera will stop reacting to that input.
  98710. * @param element Defines the element that listens to the input events.
  98711. */
  98712. detachControl(element: HTMLElement): void;
  98713. private _collisionMask;
  98714. /**
  98715. * Get the mask that the camera ignores in collision events.
  98716. */
  98717. /**
  98718. * Set the mask that the camera ignores in collision events.
  98719. */
  98720. collisionMask: number;
  98721. /** @hidden */
  98722. _collideWithWorld(displacement: Vector3): void;
  98723. /** @hidden */
  98724. private _onCollisionPositionChange;
  98725. /** @hidden */
  98726. _checkInputs(): void;
  98727. /** @hidden */
  98728. _decideIfNeedsToMove(): boolean;
  98729. /** @hidden */
  98730. _updatePosition(): void;
  98731. /**
  98732. * Restore the Roll to its target value at the rate specified.
  98733. * @param rate - Higher means slower restoring.
  98734. * @hidden
  98735. */
  98736. restoreRoll(rate: number): void;
  98737. /**
  98738. * Destroy the camera and release the current resources held by it.
  98739. */
  98740. dispose(): void;
  98741. /**
  98742. * Get the current object class name.
  98743. * @returns the class name.
  98744. */
  98745. getClassName(): string;
  98746. }
  98747. }
  98748. declare module BABYLON {
  98749. /**
  98750. * Listen to keyboard events to control the camera.
  98751. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98752. */
  98753. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  98754. /**
  98755. * Defines the camera the input is attached to.
  98756. */
  98757. camera: FlyCamera;
  98758. /**
  98759. * The list of keyboard keys used to control the forward move of the camera.
  98760. */
  98761. keysForward: number[];
  98762. /**
  98763. * The list of keyboard keys used to control the backward move of the camera.
  98764. */
  98765. keysBackward: number[];
  98766. /**
  98767. * The list of keyboard keys used to control the forward move of the camera.
  98768. */
  98769. keysUp: number[];
  98770. /**
  98771. * The list of keyboard keys used to control the backward move of the camera.
  98772. */
  98773. keysDown: number[];
  98774. /**
  98775. * The list of keyboard keys used to control the right strafe move of the camera.
  98776. */
  98777. keysRight: number[];
  98778. /**
  98779. * The list of keyboard keys used to control the left strafe move of the camera.
  98780. */
  98781. keysLeft: number[];
  98782. private _keys;
  98783. private _onCanvasBlurObserver;
  98784. private _onKeyboardObserver;
  98785. private _engine;
  98786. private _scene;
  98787. /**
  98788. * Attach the input controls to a specific dom element to get the input from.
  98789. * @param element Defines the element the controls should be listened from
  98790. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98791. */
  98792. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98793. /**
  98794. * Detach the current controls from the specified dom element.
  98795. * @param element Defines the element to stop listening the inputs from
  98796. */
  98797. detachControl(element: Nullable<HTMLElement>): void;
  98798. /**
  98799. * Gets the class name of the current intput.
  98800. * @returns the class name
  98801. */
  98802. getClassName(): string;
  98803. /** @hidden */
  98804. _onLostFocus(e: FocusEvent): void;
  98805. /**
  98806. * Get the friendly name associated with the input class.
  98807. * @returns the input friendly name
  98808. */
  98809. getSimpleName(): string;
  98810. /**
  98811. * Update the current camera state depending on the inputs that have been used this frame.
  98812. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  98813. */
  98814. checkInputs(): void;
  98815. }
  98816. }
  98817. declare module BABYLON {
  98818. /**
  98819. * Manage the mouse wheel inputs to control a follow camera.
  98820. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98821. */
  98822. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  98823. /**
  98824. * Defines the camera the input is attached to.
  98825. */
  98826. camera: FollowCamera;
  98827. /**
  98828. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  98829. */
  98830. axisControlRadius: boolean;
  98831. /**
  98832. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  98833. */
  98834. axisControlHeight: boolean;
  98835. /**
  98836. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  98837. */
  98838. axisControlRotation: boolean;
  98839. /**
  98840. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  98841. * relation to mouseWheel events.
  98842. */
  98843. wheelPrecision: number;
  98844. /**
  98845. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  98846. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  98847. */
  98848. wheelDeltaPercentage: number;
  98849. private _wheel;
  98850. private _observer;
  98851. /**
  98852. * Attach the input controls to a specific dom element to get the input from.
  98853. * @param element Defines the element the controls should be listened from
  98854. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  98855. */
  98856. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  98857. /**
  98858. * Detach the current controls from the specified dom element.
  98859. * @param element Defines the element to stop listening the inputs from
  98860. */
  98861. detachControl(element: Nullable<HTMLElement>): void;
  98862. /**
  98863. * Gets the class name of the current intput.
  98864. * @returns the class name
  98865. */
  98866. getClassName(): string;
  98867. /**
  98868. * Get the friendly name associated with the input class.
  98869. * @returns the input friendly name
  98870. */
  98871. getSimpleName(): string;
  98872. }
  98873. }
  98874. declare module BABYLON {
  98875. /**
  98876. * Manage the pointers inputs to control an follow camera.
  98877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98878. */
  98879. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  98880. /**
  98881. * Defines the camera the input is attached to.
  98882. */
  98883. camera: FollowCamera;
  98884. /**
  98885. * Gets the class name of the current input.
  98886. * @returns the class name
  98887. */
  98888. getClassName(): string;
  98889. /**
  98890. * Defines the pointer angular sensibility along the X axis or how fast is
  98891. * the camera rotating.
  98892. * A negative number will reverse the axis direction.
  98893. */
  98894. angularSensibilityX: number;
  98895. /**
  98896. * Defines the pointer angular sensibility along the Y axis or how fast is
  98897. * the camera rotating.
  98898. * A negative number will reverse the axis direction.
  98899. */
  98900. angularSensibilityY: number;
  98901. /**
  98902. * Defines the pointer pinch precision or how fast is the camera zooming.
  98903. * A negative number will reverse the axis direction.
  98904. */
  98905. pinchPrecision: number;
  98906. /**
  98907. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  98908. * from 0.
  98909. * It defines the percentage of current camera.radius to use as delta when
  98910. * pinch zoom is used.
  98911. */
  98912. pinchDeltaPercentage: number;
  98913. /**
  98914. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  98915. */
  98916. axisXControlRadius: boolean;
  98917. /**
  98918. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  98919. */
  98920. axisXControlHeight: boolean;
  98921. /**
  98922. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  98923. */
  98924. axisXControlRotation: boolean;
  98925. /**
  98926. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  98927. */
  98928. axisYControlRadius: boolean;
  98929. /**
  98930. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  98931. */
  98932. axisYControlHeight: boolean;
  98933. /**
  98934. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  98935. */
  98936. axisYControlRotation: boolean;
  98937. /**
  98938. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  98939. */
  98940. axisPinchControlRadius: boolean;
  98941. /**
  98942. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  98943. */
  98944. axisPinchControlHeight: boolean;
  98945. /**
  98946. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  98947. */
  98948. axisPinchControlRotation: boolean;
  98949. /**
  98950. * Log error messages if basic misconfiguration has occurred.
  98951. */
  98952. warningEnable: boolean;
  98953. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  98954. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  98955. private _warningCounter;
  98956. private _warning;
  98957. }
  98958. }
  98959. declare module BABYLON {
  98960. /**
  98961. * Default Inputs manager for the FollowCamera.
  98962. * It groups all the default supported inputs for ease of use.
  98963. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  98964. */
  98965. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  98966. /**
  98967. * Instantiates a new FollowCameraInputsManager.
  98968. * @param camera Defines the camera the inputs belong to
  98969. */
  98970. constructor(camera: FollowCamera);
  98971. /**
  98972. * Add keyboard input support to the input manager.
  98973. * @returns the current input manager
  98974. */
  98975. addKeyboard(): FollowCameraInputsManager;
  98976. /**
  98977. * Add mouse wheel input support to the input manager.
  98978. * @returns the current input manager
  98979. */
  98980. addMouseWheel(): FollowCameraInputsManager;
  98981. /**
  98982. * Add pointers input support to the input manager.
  98983. * @returns the current input manager
  98984. */
  98985. addPointers(): FollowCameraInputsManager;
  98986. /**
  98987. * Add orientation input support to the input manager.
  98988. * @returns the current input manager
  98989. */
  98990. addVRDeviceOrientation(): FollowCameraInputsManager;
  98991. }
  98992. }
  98993. declare module BABYLON {
  98994. /**
  98995. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  98996. * an arc rotate version arcFollowCamera are available.
  98997. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  98998. */
  98999. export class FollowCamera extends TargetCamera {
  99000. /**
  99001. * Distance the follow camera should follow an object at
  99002. */
  99003. radius: number;
  99004. /**
  99005. * Minimum allowed distance of the camera to the axis of rotation
  99006. * (The camera can not get closer).
  99007. * This can help limiting how the Camera is able to move in the scene.
  99008. */
  99009. lowerRadiusLimit: Nullable<number>;
  99010. /**
  99011. * Maximum allowed distance of the camera to the axis of rotation
  99012. * (The camera can not get further).
  99013. * This can help limiting how the Camera is able to move in the scene.
  99014. */
  99015. upperRadiusLimit: Nullable<number>;
  99016. /**
  99017. * Define a rotation offset between the camera and the object it follows
  99018. */
  99019. rotationOffset: number;
  99020. /**
  99021. * Minimum allowed angle to camera position relative to target object.
  99022. * This can help limiting how the Camera is able to move in the scene.
  99023. */
  99024. lowerRotationOffsetLimit: Nullable<number>;
  99025. /**
  99026. * Maximum allowed angle to camera position relative to target object.
  99027. * This can help limiting how the Camera is able to move in the scene.
  99028. */
  99029. upperRotationOffsetLimit: Nullable<number>;
  99030. /**
  99031. * Define a height offset between the camera and the object it follows.
  99032. * It can help following an object from the top (like a car chaing a plane)
  99033. */
  99034. heightOffset: number;
  99035. /**
  99036. * Minimum allowed height of camera position relative to target object.
  99037. * This can help limiting how the Camera is able to move in the scene.
  99038. */
  99039. lowerHeightOffsetLimit: Nullable<number>;
  99040. /**
  99041. * Maximum allowed height of camera position relative to target object.
  99042. * This can help limiting how the Camera is able to move in the scene.
  99043. */
  99044. upperHeightOffsetLimit: Nullable<number>;
  99045. /**
  99046. * Define how fast the camera can accelerate to follow it s target.
  99047. */
  99048. cameraAcceleration: number;
  99049. /**
  99050. * Define the speed limit of the camera following an object.
  99051. */
  99052. maxCameraSpeed: number;
  99053. /**
  99054. * Define the target of the camera.
  99055. */
  99056. lockedTarget: Nullable<AbstractMesh>;
  99057. /**
  99058. * Defines the input associated with the camera.
  99059. */
  99060. inputs: FollowCameraInputsManager;
  99061. /**
  99062. * Instantiates the follow camera.
  99063. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99064. * @param name Define the name of the camera in the scene
  99065. * @param position Define the position of the camera
  99066. * @param scene Define the scene the camera belong to
  99067. * @param lockedTarget Define the target of the camera
  99068. */
  99069. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  99070. private _follow;
  99071. /**
  99072. * Attached controls to the current camera.
  99073. * @param element Defines the element the controls should be listened from
  99074. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99075. */
  99076. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99077. /**
  99078. * Detach the current controls from the camera.
  99079. * The camera will stop reacting to inputs.
  99080. * @param element Defines the element to stop listening the inputs from
  99081. */
  99082. detachControl(element: HTMLElement): void;
  99083. /** @hidden */
  99084. _checkInputs(): void;
  99085. private _checkLimits;
  99086. /**
  99087. * Gets the camera class name.
  99088. * @returns the class name
  99089. */
  99090. getClassName(): string;
  99091. }
  99092. /**
  99093. * Arc Rotate version of the follow camera.
  99094. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  99095. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99096. */
  99097. export class ArcFollowCamera extends TargetCamera {
  99098. /** The longitudinal angle of the camera */
  99099. alpha: number;
  99100. /** The latitudinal angle of the camera */
  99101. beta: number;
  99102. /** The radius of the camera from its target */
  99103. radius: number;
  99104. /** Define the camera target (the messh it should follow) */
  99105. target: Nullable<AbstractMesh>;
  99106. private _cartesianCoordinates;
  99107. /**
  99108. * Instantiates a new ArcFollowCamera
  99109. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  99110. * @param name Define the name of the camera
  99111. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  99112. * @param beta Define the rotation angle of the camera around the elevation axis
  99113. * @param radius Define the radius of the camera from its target point
  99114. * @param target Define the target of the camera
  99115. * @param scene Define the scene the camera belongs to
  99116. */
  99117. constructor(name: string,
  99118. /** The longitudinal angle of the camera */
  99119. alpha: number,
  99120. /** The latitudinal angle of the camera */
  99121. beta: number,
  99122. /** The radius of the camera from its target */
  99123. radius: number,
  99124. /** Define the camera target (the messh it should follow) */
  99125. target: Nullable<AbstractMesh>, scene: Scene);
  99126. private _follow;
  99127. /** @hidden */
  99128. _checkInputs(): void;
  99129. /**
  99130. * Returns the class name of the object.
  99131. * It is mostly used internally for serialization purposes.
  99132. */
  99133. getClassName(): string;
  99134. }
  99135. }
  99136. declare module BABYLON {
  99137. /**
  99138. * Manage the keyboard inputs to control the movement of a follow camera.
  99139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99140. */
  99141. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  99142. /**
  99143. * Defines the camera the input is attached to.
  99144. */
  99145. camera: FollowCamera;
  99146. /**
  99147. * Defines the list of key codes associated with the up action (increase heightOffset)
  99148. */
  99149. keysHeightOffsetIncr: number[];
  99150. /**
  99151. * Defines the list of key codes associated with the down action (decrease heightOffset)
  99152. */
  99153. keysHeightOffsetDecr: number[];
  99154. /**
  99155. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  99156. */
  99157. keysHeightOffsetModifierAlt: boolean;
  99158. /**
  99159. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  99160. */
  99161. keysHeightOffsetModifierCtrl: boolean;
  99162. /**
  99163. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  99164. */
  99165. keysHeightOffsetModifierShift: boolean;
  99166. /**
  99167. * Defines the list of key codes associated with the left action (increase rotationOffset)
  99168. */
  99169. keysRotationOffsetIncr: number[];
  99170. /**
  99171. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  99172. */
  99173. keysRotationOffsetDecr: number[];
  99174. /**
  99175. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  99176. */
  99177. keysRotationOffsetModifierAlt: boolean;
  99178. /**
  99179. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  99180. */
  99181. keysRotationOffsetModifierCtrl: boolean;
  99182. /**
  99183. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  99184. */
  99185. keysRotationOffsetModifierShift: boolean;
  99186. /**
  99187. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  99188. */
  99189. keysRadiusIncr: number[];
  99190. /**
  99191. * Defines the list of key codes associated with the zoom-out action (increase radius)
  99192. */
  99193. keysRadiusDecr: number[];
  99194. /**
  99195. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  99196. */
  99197. keysRadiusModifierAlt: boolean;
  99198. /**
  99199. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  99200. */
  99201. keysRadiusModifierCtrl: boolean;
  99202. /**
  99203. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  99204. */
  99205. keysRadiusModifierShift: boolean;
  99206. /**
  99207. * Defines the rate of change of heightOffset.
  99208. */
  99209. heightSensibility: number;
  99210. /**
  99211. * Defines the rate of change of rotationOffset.
  99212. */
  99213. rotationSensibility: number;
  99214. /**
  99215. * Defines the rate of change of radius.
  99216. */
  99217. radiusSensibility: number;
  99218. private _keys;
  99219. private _ctrlPressed;
  99220. private _altPressed;
  99221. private _shiftPressed;
  99222. private _onCanvasBlurObserver;
  99223. private _onKeyboardObserver;
  99224. private _engine;
  99225. private _scene;
  99226. /**
  99227. * Attach the input controls to a specific dom element to get the input from.
  99228. * @param element Defines the element the controls should be listened from
  99229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99230. */
  99231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99232. /**
  99233. * Detach the current controls from the specified dom element.
  99234. * @param element Defines the element to stop listening the inputs from
  99235. */
  99236. detachControl(element: Nullable<HTMLElement>): void;
  99237. /**
  99238. * Update the current camera state depending on the inputs that have been used this frame.
  99239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99240. */
  99241. checkInputs(): void;
  99242. /**
  99243. * Gets the class name of the current input.
  99244. * @returns the class name
  99245. */
  99246. getClassName(): string;
  99247. /**
  99248. * Get the friendly name associated with the input class.
  99249. * @returns the input friendly name
  99250. */
  99251. getSimpleName(): string;
  99252. /**
  99253. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99254. * allow modification of the heightOffset value.
  99255. */
  99256. private _modifierHeightOffset;
  99257. /**
  99258. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99259. * allow modification of the rotationOffset value.
  99260. */
  99261. private _modifierRotationOffset;
  99262. /**
  99263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  99264. * allow modification of the radius value.
  99265. */
  99266. private _modifierRadius;
  99267. }
  99268. }
  99269. declare module BABYLON {
  99270. interface FreeCameraInputsManager {
  99271. /**
  99272. * @hidden
  99273. */
  99274. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  99275. /**
  99276. * Add orientation input support to the input manager.
  99277. * @returns the current input manager
  99278. */
  99279. addDeviceOrientation(): FreeCameraInputsManager;
  99280. }
  99281. /**
  99282. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  99283. * Screen rotation is taken into account.
  99284. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99285. */
  99286. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  99287. private _camera;
  99288. private _screenOrientationAngle;
  99289. private _constantTranform;
  99290. private _screenQuaternion;
  99291. private _alpha;
  99292. private _beta;
  99293. private _gamma;
  99294. /**
  99295. * @hidden
  99296. */
  99297. _onDeviceOrientationChangedObservable: Observable<void>;
  99298. /**
  99299. * Instantiates a new input
  99300. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99301. */
  99302. constructor();
  99303. /**
  99304. * Define the camera controlled by the input.
  99305. */
  99306. camera: FreeCamera;
  99307. /**
  99308. * Attach the input controls to a specific dom element to get the input from.
  99309. * @param element Defines the element the controls should be listened from
  99310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99311. */
  99312. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99313. private _orientationChanged;
  99314. private _deviceOrientation;
  99315. /**
  99316. * Detach the current controls from the specified dom element.
  99317. * @param element Defines the element to stop listening the inputs from
  99318. */
  99319. detachControl(element: Nullable<HTMLElement>): void;
  99320. /**
  99321. * Update the current camera state depending on the inputs that have been used this frame.
  99322. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99323. */
  99324. checkInputs(): void;
  99325. /**
  99326. * Gets the class name of the current intput.
  99327. * @returns the class name
  99328. */
  99329. getClassName(): string;
  99330. /**
  99331. * Get the friendly name associated with the input class.
  99332. * @returns the input friendly name
  99333. */
  99334. getSimpleName(): string;
  99335. }
  99336. }
  99337. declare module BABYLON {
  99338. /**
  99339. * Manage the gamepad inputs to control a free camera.
  99340. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99341. */
  99342. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  99343. /**
  99344. * Define the camera the input is attached to.
  99345. */
  99346. camera: FreeCamera;
  99347. /**
  99348. * Define the Gamepad controlling the input
  99349. */
  99350. gamepad: Nullable<Gamepad>;
  99351. /**
  99352. * Defines the gamepad rotation sensiblity.
  99353. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99354. */
  99355. gamepadAngularSensibility: number;
  99356. /**
  99357. * Defines the gamepad move sensiblity.
  99358. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99359. */
  99360. gamepadMoveSensibility: number;
  99361. private _onGamepadConnectedObserver;
  99362. private _onGamepadDisconnectedObserver;
  99363. private _cameraTransform;
  99364. private _deltaTransform;
  99365. private _vector3;
  99366. private _vector2;
  99367. /**
  99368. * Attach the input controls to a specific dom element to get the input from.
  99369. * @param element Defines the element the controls should be listened from
  99370. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99371. */
  99372. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99373. /**
  99374. * Detach the current controls from the specified dom element.
  99375. * @param element Defines the element to stop listening the inputs from
  99376. */
  99377. detachControl(element: Nullable<HTMLElement>): void;
  99378. /**
  99379. * Update the current camera state depending on the inputs that have been used this frame.
  99380. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99381. */
  99382. checkInputs(): void;
  99383. /**
  99384. * Gets the class name of the current intput.
  99385. * @returns the class name
  99386. */
  99387. getClassName(): string;
  99388. /**
  99389. * Get the friendly name associated with the input class.
  99390. * @returns the input friendly name
  99391. */
  99392. getSimpleName(): string;
  99393. }
  99394. }
  99395. declare module BABYLON {
  99396. /**
  99397. * Defines the potential axis of a Joystick
  99398. */
  99399. export enum JoystickAxis {
  99400. /** X axis */
  99401. X = 0,
  99402. /** Y axis */
  99403. Y = 1,
  99404. /** Z axis */
  99405. Z = 2
  99406. }
  99407. /**
  99408. * Class used to define virtual joystick (used in touch mode)
  99409. */
  99410. export class VirtualJoystick {
  99411. /**
  99412. * Gets or sets a boolean indicating that left and right values must be inverted
  99413. */
  99414. reverseLeftRight: boolean;
  99415. /**
  99416. * Gets or sets a boolean indicating that up and down values must be inverted
  99417. */
  99418. reverseUpDown: boolean;
  99419. /**
  99420. * Gets the offset value for the position (ie. the change of the position value)
  99421. */
  99422. deltaPosition: Vector3;
  99423. /**
  99424. * Gets a boolean indicating if the virtual joystick was pressed
  99425. */
  99426. pressed: boolean;
  99427. /**
  99428. * Canvas the virtual joystick will render onto, default z-index of this is 5
  99429. */
  99430. static Canvas: Nullable<HTMLCanvasElement>;
  99431. private static _globalJoystickIndex;
  99432. private static vjCanvasContext;
  99433. private static vjCanvasWidth;
  99434. private static vjCanvasHeight;
  99435. private static halfWidth;
  99436. private _action;
  99437. private _axisTargetedByLeftAndRight;
  99438. private _axisTargetedByUpAndDown;
  99439. private _joystickSensibility;
  99440. private _inversedSensibility;
  99441. private _joystickPointerID;
  99442. private _joystickColor;
  99443. private _joystickPointerPos;
  99444. private _joystickPreviousPointerPos;
  99445. private _joystickPointerStartPos;
  99446. private _deltaJoystickVector;
  99447. private _leftJoystick;
  99448. private _touches;
  99449. private _onPointerDownHandlerRef;
  99450. private _onPointerMoveHandlerRef;
  99451. private _onPointerUpHandlerRef;
  99452. private _onResize;
  99453. /**
  99454. * Creates a new virtual joystick
  99455. * @param leftJoystick defines that the joystick is for left hand (false by default)
  99456. */
  99457. constructor(leftJoystick?: boolean);
  99458. /**
  99459. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  99460. * @param newJoystickSensibility defines the new sensibility
  99461. */
  99462. setJoystickSensibility(newJoystickSensibility: number): void;
  99463. private _onPointerDown;
  99464. private _onPointerMove;
  99465. private _onPointerUp;
  99466. /**
  99467. * Change the color of the virtual joystick
  99468. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  99469. */
  99470. setJoystickColor(newColor: string): void;
  99471. /**
  99472. * Defines a callback to call when the joystick is touched
  99473. * @param action defines the callback
  99474. */
  99475. setActionOnTouch(action: () => any): void;
  99476. /**
  99477. * Defines which axis you'd like to control for left & right
  99478. * @param axis defines the axis to use
  99479. */
  99480. setAxisForLeftRight(axis: JoystickAxis): void;
  99481. /**
  99482. * Defines which axis you'd like to control for up & down
  99483. * @param axis defines the axis to use
  99484. */
  99485. setAxisForUpDown(axis: JoystickAxis): void;
  99486. private _drawVirtualJoystick;
  99487. /**
  99488. * Release internal HTML canvas
  99489. */
  99490. releaseCanvas(): void;
  99491. }
  99492. }
  99493. declare module BABYLON {
  99494. interface FreeCameraInputsManager {
  99495. /**
  99496. * Add virtual joystick input support to the input manager.
  99497. * @returns the current input manager
  99498. */
  99499. addVirtualJoystick(): FreeCameraInputsManager;
  99500. }
  99501. /**
  99502. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  99503. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  99504. */
  99505. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  99506. /**
  99507. * Defines the camera the input is attached to.
  99508. */
  99509. camera: FreeCamera;
  99510. private _leftjoystick;
  99511. private _rightjoystick;
  99512. /**
  99513. * Gets the left stick of the virtual joystick.
  99514. * @returns The virtual Joystick
  99515. */
  99516. getLeftJoystick(): VirtualJoystick;
  99517. /**
  99518. * Gets the right stick of the virtual joystick.
  99519. * @returns The virtual Joystick
  99520. */
  99521. getRightJoystick(): VirtualJoystick;
  99522. /**
  99523. * Update the current camera state depending on the inputs that have been used this frame.
  99524. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99525. */
  99526. checkInputs(): void;
  99527. /**
  99528. * Attach the input controls to a specific dom element to get the input from.
  99529. * @param element Defines the element the controls should be listened from
  99530. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99531. */
  99532. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99533. /**
  99534. * Detach the current controls from the specified dom element.
  99535. * @param element Defines the element to stop listening the inputs from
  99536. */
  99537. detachControl(element: Nullable<HTMLElement>): void;
  99538. /**
  99539. * Gets the class name of the current intput.
  99540. * @returns the class name
  99541. */
  99542. getClassName(): string;
  99543. /**
  99544. * Get the friendly name associated with the input class.
  99545. * @returns the input friendly name
  99546. */
  99547. getSimpleName(): string;
  99548. }
  99549. }
  99550. declare module BABYLON {
  99551. /**
  99552. * This represents a FPS type of camera controlled by touch.
  99553. * This is like a universal camera minus the Gamepad controls.
  99554. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99555. */
  99556. export class TouchCamera extends FreeCamera {
  99557. /**
  99558. * Defines the touch sensibility for rotation.
  99559. * The higher the faster.
  99560. */
  99561. touchAngularSensibility: number;
  99562. /**
  99563. * Defines the touch sensibility for move.
  99564. * The higher the faster.
  99565. */
  99566. touchMoveSensibility: number;
  99567. /**
  99568. * Instantiates a new touch camera.
  99569. * This represents a FPS type of camera controlled by touch.
  99570. * This is like a universal camera minus the Gamepad controls.
  99571. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99572. * @param name Define the name of the camera in the scene
  99573. * @param position Define the start position of the camera in the scene
  99574. * @param scene Define the scene the camera belongs to
  99575. */
  99576. constructor(name: string, position: Vector3, scene: Scene);
  99577. /**
  99578. * Gets the current object class name.
  99579. * @return the class name
  99580. */
  99581. getClassName(): string;
  99582. /** @hidden */
  99583. _setupInputs(): void;
  99584. }
  99585. }
  99586. declare module BABYLON {
  99587. /**
  99588. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  99589. * being tilted forward or back and left or right.
  99590. */
  99591. export class DeviceOrientationCamera extends FreeCamera {
  99592. private _initialQuaternion;
  99593. private _quaternionCache;
  99594. private _tmpDragQuaternion;
  99595. /**
  99596. * Creates a new device orientation camera
  99597. * @param name The name of the camera
  99598. * @param position The start position camera
  99599. * @param scene The scene the camera belongs to
  99600. */
  99601. constructor(name: string, position: Vector3, scene: Scene);
  99602. /**
  99603. * @hidden
  99604. * Disabled pointer input on first orientation sensor update (Default: true)
  99605. */
  99606. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  99607. private _dragFactor;
  99608. /**
  99609. * Enabled turning on the y axis when the orientation sensor is active
  99610. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  99611. */
  99612. enableHorizontalDragging(dragFactor?: number): void;
  99613. /**
  99614. * Gets the current instance class name ("DeviceOrientationCamera").
  99615. * This helps avoiding instanceof at run time.
  99616. * @returns the class name
  99617. */
  99618. getClassName(): string;
  99619. /**
  99620. * @hidden
  99621. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  99622. */
  99623. _checkInputs(): void;
  99624. /**
  99625. * Reset the camera to its default orientation on the specified axis only.
  99626. * @param axis The axis to reset
  99627. */
  99628. resetToCurrentRotation(axis?: Axis): void;
  99629. }
  99630. }
  99631. declare module BABYLON {
  99632. /**
  99633. * Defines supported buttons for XBox360 compatible gamepads
  99634. */
  99635. export enum Xbox360Button {
  99636. /** A */
  99637. A = 0,
  99638. /** B */
  99639. B = 1,
  99640. /** X */
  99641. X = 2,
  99642. /** Y */
  99643. Y = 3,
  99644. /** Start */
  99645. Start = 4,
  99646. /** Back */
  99647. Back = 5,
  99648. /** Left button */
  99649. LB = 6,
  99650. /** Right button */
  99651. RB = 7,
  99652. /** Left stick */
  99653. LeftStick = 8,
  99654. /** Right stick */
  99655. RightStick = 9
  99656. }
  99657. /** Defines values for XBox360 DPad */
  99658. export enum Xbox360Dpad {
  99659. /** Up */
  99660. Up = 0,
  99661. /** Down */
  99662. Down = 1,
  99663. /** Left */
  99664. Left = 2,
  99665. /** Right */
  99666. Right = 3
  99667. }
  99668. /**
  99669. * Defines a XBox360 gamepad
  99670. */
  99671. export class Xbox360Pad extends Gamepad {
  99672. private _leftTrigger;
  99673. private _rightTrigger;
  99674. private _onlefttriggerchanged;
  99675. private _onrighttriggerchanged;
  99676. private _onbuttondown;
  99677. private _onbuttonup;
  99678. private _ondpaddown;
  99679. private _ondpadup;
  99680. /** Observable raised when a button is pressed */
  99681. onButtonDownObservable: Observable<Xbox360Button>;
  99682. /** Observable raised when a button is released */
  99683. onButtonUpObservable: Observable<Xbox360Button>;
  99684. /** Observable raised when a pad is pressed */
  99685. onPadDownObservable: Observable<Xbox360Dpad>;
  99686. /** Observable raised when a pad is released */
  99687. onPadUpObservable: Observable<Xbox360Dpad>;
  99688. private _buttonA;
  99689. private _buttonB;
  99690. private _buttonX;
  99691. private _buttonY;
  99692. private _buttonBack;
  99693. private _buttonStart;
  99694. private _buttonLB;
  99695. private _buttonRB;
  99696. private _buttonLeftStick;
  99697. private _buttonRightStick;
  99698. private _dPadUp;
  99699. private _dPadDown;
  99700. private _dPadLeft;
  99701. private _dPadRight;
  99702. private _isXboxOnePad;
  99703. /**
  99704. * Creates a new XBox360 gamepad object
  99705. * @param id defines the id of this gamepad
  99706. * @param index defines its index
  99707. * @param gamepad defines the internal HTML gamepad object
  99708. * @param xboxOne defines if it is a XBox One gamepad
  99709. */
  99710. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  99711. /**
  99712. * Defines the callback to call when left trigger is pressed
  99713. * @param callback defines the callback to use
  99714. */
  99715. onlefttriggerchanged(callback: (value: number) => void): void;
  99716. /**
  99717. * Defines the callback to call when right trigger is pressed
  99718. * @param callback defines the callback to use
  99719. */
  99720. onrighttriggerchanged(callback: (value: number) => void): void;
  99721. /**
  99722. * Gets the left trigger value
  99723. */
  99724. /**
  99725. * Sets the left trigger value
  99726. */
  99727. leftTrigger: number;
  99728. /**
  99729. * Gets the right trigger value
  99730. */
  99731. /**
  99732. * Sets the right trigger value
  99733. */
  99734. rightTrigger: number;
  99735. /**
  99736. * Defines the callback to call when a button is pressed
  99737. * @param callback defines the callback to use
  99738. */
  99739. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  99740. /**
  99741. * Defines the callback to call when a button is released
  99742. * @param callback defines the callback to use
  99743. */
  99744. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  99745. /**
  99746. * Defines the callback to call when a pad is pressed
  99747. * @param callback defines the callback to use
  99748. */
  99749. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  99750. /**
  99751. * Defines the callback to call when a pad is released
  99752. * @param callback defines the callback to use
  99753. */
  99754. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  99755. private _setButtonValue;
  99756. private _setDPadValue;
  99757. /**
  99758. * Gets the value of the `A` button
  99759. */
  99760. /**
  99761. * Sets the value of the `A` button
  99762. */
  99763. buttonA: number;
  99764. /**
  99765. * Gets the value of the `B` button
  99766. */
  99767. /**
  99768. * Sets the value of the `B` button
  99769. */
  99770. buttonB: number;
  99771. /**
  99772. * Gets the value of the `X` button
  99773. */
  99774. /**
  99775. * Sets the value of the `X` button
  99776. */
  99777. buttonX: number;
  99778. /**
  99779. * Gets the value of the `Y` button
  99780. */
  99781. /**
  99782. * Sets the value of the `Y` button
  99783. */
  99784. buttonY: number;
  99785. /**
  99786. * Gets the value of the `Start` button
  99787. */
  99788. /**
  99789. * Sets the value of the `Start` button
  99790. */
  99791. buttonStart: number;
  99792. /**
  99793. * Gets the value of the `Back` button
  99794. */
  99795. /**
  99796. * Sets the value of the `Back` button
  99797. */
  99798. buttonBack: number;
  99799. /**
  99800. * Gets the value of the `Left` button
  99801. */
  99802. /**
  99803. * Sets the value of the `Left` button
  99804. */
  99805. buttonLB: number;
  99806. /**
  99807. * Gets the value of the `Right` button
  99808. */
  99809. /**
  99810. * Sets the value of the `Right` button
  99811. */
  99812. buttonRB: number;
  99813. /**
  99814. * Gets the value of the Left joystick
  99815. */
  99816. /**
  99817. * Sets the value of the Left joystick
  99818. */
  99819. buttonLeftStick: number;
  99820. /**
  99821. * Gets the value of the Right joystick
  99822. */
  99823. /**
  99824. * Sets the value of the Right joystick
  99825. */
  99826. buttonRightStick: number;
  99827. /**
  99828. * Gets the value of D-pad up
  99829. */
  99830. /**
  99831. * Sets the value of D-pad up
  99832. */
  99833. dPadUp: number;
  99834. /**
  99835. * Gets the value of D-pad down
  99836. */
  99837. /**
  99838. * Sets the value of D-pad down
  99839. */
  99840. dPadDown: number;
  99841. /**
  99842. * Gets the value of D-pad left
  99843. */
  99844. /**
  99845. * Sets the value of D-pad left
  99846. */
  99847. dPadLeft: number;
  99848. /**
  99849. * Gets the value of D-pad right
  99850. */
  99851. /**
  99852. * Sets the value of D-pad right
  99853. */
  99854. dPadRight: number;
  99855. /**
  99856. * Force the gamepad to synchronize with device values
  99857. */
  99858. update(): void;
  99859. /**
  99860. * Disposes the gamepad
  99861. */
  99862. dispose(): void;
  99863. }
  99864. }
  99865. declare module BABYLON {
  99866. /**
  99867. * Manager for handling gamepads
  99868. */
  99869. export class GamepadManager {
  99870. private _scene?;
  99871. private _babylonGamepads;
  99872. private _oneGamepadConnected;
  99873. /** @hidden */
  99874. _isMonitoring: boolean;
  99875. private _gamepadEventSupported;
  99876. private _gamepadSupport;
  99877. /**
  99878. * observable to be triggered when the gamepad controller has been connected
  99879. */
  99880. onGamepadConnectedObservable: Observable<Gamepad>;
  99881. /**
  99882. * observable to be triggered when the gamepad controller has been disconnected
  99883. */
  99884. onGamepadDisconnectedObservable: Observable<Gamepad>;
  99885. private _onGamepadConnectedEvent;
  99886. private _onGamepadDisconnectedEvent;
  99887. /**
  99888. * Initializes the gamepad manager
  99889. * @param _scene BabylonJS scene
  99890. */
  99891. constructor(_scene?: Scene | undefined);
  99892. /**
  99893. * The gamepads in the game pad manager
  99894. */
  99895. readonly gamepads: Gamepad[];
  99896. /**
  99897. * Get the gamepad controllers based on type
  99898. * @param type The type of gamepad controller
  99899. * @returns Nullable gamepad
  99900. */
  99901. getGamepadByType(type?: number): Nullable<Gamepad>;
  99902. /**
  99903. * Disposes the gamepad manager
  99904. */
  99905. dispose(): void;
  99906. private _addNewGamepad;
  99907. private _startMonitoringGamepads;
  99908. private _stopMonitoringGamepads;
  99909. /** @hidden */
  99910. _checkGamepadsStatus(): void;
  99911. private _updateGamepadObjects;
  99912. }
  99913. }
  99914. declare module BABYLON {
  99915. interface Scene {
  99916. /** @hidden */
  99917. _gamepadManager: Nullable<GamepadManager>;
  99918. /**
  99919. * Gets the gamepad manager associated with the scene
  99920. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  99921. */
  99922. gamepadManager: GamepadManager;
  99923. }
  99924. /**
  99925. * Interface representing a free camera inputs manager
  99926. */
  99927. interface FreeCameraInputsManager {
  99928. /**
  99929. * Adds gamepad input support to the FreeCameraInputsManager.
  99930. * @returns the FreeCameraInputsManager
  99931. */
  99932. addGamepad(): FreeCameraInputsManager;
  99933. }
  99934. /**
  99935. * Interface representing an arc rotate camera inputs manager
  99936. */
  99937. interface ArcRotateCameraInputsManager {
  99938. /**
  99939. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99940. * @returns the camera inputs manager
  99941. */
  99942. addGamepad(): ArcRotateCameraInputsManager;
  99943. }
  99944. /**
  99945. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99946. */
  99947. export class GamepadSystemSceneComponent implements ISceneComponent {
  99948. /**
  99949. * The component name helpfull to identify the component in the list of scene components.
  99950. */
  99951. readonly name: string;
  99952. /**
  99953. * The scene the component belongs to.
  99954. */
  99955. scene: Scene;
  99956. /**
  99957. * Creates a new instance of the component for the given scene
  99958. * @param scene Defines the scene to register the component in
  99959. */
  99960. constructor(scene: Scene);
  99961. /**
  99962. * Registers the component in a given scene
  99963. */
  99964. register(): void;
  99965. /**
  99966. * Rebuilds the elements related to this component in case of
  99967. * context lost for instance.
  99968. */
  99969. rebuild(): void;
  99970. /**
  99971. * Disposes the component and the associated ressources
  99972. */
  99973. dispose(): void;
  99974. private _beforeCameraUpdate;
  99975. }
  99976. }
  99977. declare module BABYLON {
  99978. /**
  99979. * 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,
  99980. * which still works and will still be found in many Playgrounds.
  99981. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99982. */
  99983. export class UniversalCamera extends TouchCamera {
  99984. /**
  99985. * Defines the gamepad rotation sensiblity.
  99986. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  99987. */
  99988. gamepadAngularSensibility: number;
  99989. /**
  99990. * Defines the gamepad move sensiblity.
  99991. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  99992. */
  99993. gamepadMoveSensibility: number;
  99994. /**
  99995. * 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,
  99996. * which still works and will still be found in many Playgrounds.
  99997. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  99998. * @param name Define the name of the camera in the scene
  99999. * @param position Define the start position of the camera in the scene
  100000. * @param scene Define the scene the camera belongs to
  100001. */
  100002. constructor(name: string, position: Vector3, scene: Scene);
  100003. /**
  100004. * Gets the current object class name.
  100005. * @return the class name
  100006. */
  100007. getClassName(): string;
  100008. }
  100009. }
  100010. declare module BABYLON {
  100011. /**
  100012. * This represents a FPS type of camera. This is only here for back compat purpose.
  100013. * Please use the UniversalCamera instead as both are identical.
  100014. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100015. */
  100016. export class GamepadCamera extends UniversalCamera {
  100017. /**
  100018. * Instantiates a new Gamepad Camera
  100019. * This represents a FPS type of camera. This is only here for back compat purpose.
  100020. * Please use the UniversalCamera instead as both are identical.
  100021. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  100022. * @param name Define the name of the camera in the scene
  100023. * @param position Define the start position of the camera in the scene
  100024. * @param scene Define the scene the camera belongs to
  100025. */
  100026. constructor(name: string, position: Vector3, scene: Scene);
  100027. /**
  100028. * Gets the current object class name.
  100029. * @return the class name
  100030. */
  100031. getClassName(): string;
  100032. }
  100033. }
  100034. declare module BABYLON {
  100035. /** @hidden */
  100036. export var passPixelShader: {
  100037. name: string;
  100038. shader: string;
  100039. };
  100040. }
  100041. declare module BABYLON {
  100042. /** @hidden */
  100043. export var passCubePixelShader: {
  100044. name: string;
  100045. shader: string;
  100046. };
  100047. }
  100048. declare module BABYLON {
  100049. /**
  100050. * PassPostProcess which produces an output the same as it's input
  100051. */
  100052. export class PassPostProcess extends PostProcess {
  100053. /**
  100054. * Creates the PassPostProcess
  100055. * @param name The name of the effect.
  100056. * @param options The required width/height ratio to downsize to before computing the render pass.
  100057. * @param camera The camera to apply the render pass to.
  100058. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100059. * @param engine The engine which the post process will be applied. (default: current engine)
  100060. * @param reusable If the post process can be reused on the same frame. (default: false)
  100061. * @param textureType The type of texture to be used when performing the post processing.
  100062. * @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)
  100063. */
  100064. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100065. }
  100066. /**
  100067. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  100068. */
  100069. export class PassCubePostProcess extends PostProcess {
  100070. private _face;
  100071. /**
  100072. * Gets or sets the cube face to display.
  100073. * * 0 is +X
  100074. * * 1 is -X
  100075. * * 2 is +Y
  100076. * * 3 is -Y
  100077. * * 4 is +Z
  100078. * * 5 is -Z
  100079. */
  100080. face: number;
  100081. /**
  100082. * Creates the PassCubePostProcess
  100083. * @param name The name of the effect.
  100084. * @param options The required width/height ratio to downsize to before computing the render pass.
  100085. * @param camera The camera to apply the render pass to.
  100086. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100087. * @param engine The engine which the post process will be applied. (default: current engine)
  100088. * @param reusable If the post process can be reused on the same frame. (default: false)
  100089. * @param textureType The type of texture to be used when performing the post processing.
  100090. * @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)
  100091. */
  100092. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  100093. }
  100094. }
  100095. declare module BABYLON {
  100096. /** @hidden */
  100097. export var anaglyphPixelShader: {
  100098. name: string;
  100099. shader: string;
  100100. };
  100101. }
  100102. declare module BABYLON {
  100103. /**
  100104. * Postprocess used to generate anaglyphic rendering
  100105. */
  100106. export class AnaglyphPostProcess extends PostProcess {
  100107. private _passedProcess;
  100108. /**
  100109. * Creates a new AnaglyphPostProcess
  100110. * @param name defines postprocess name
  100111. * @param options defines creation options or target ratio scale
  100112. * @param rigCameras defines cameras using this postprocess
  100113. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  100114. * @param engine defines hosting engine
  100115. * @param reusable defines if the postprocess will be reused multiple times per frame
  100116. */
  100117. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  100118. }
  100119. }
  100120. declare module BABYLON {
  100121. /**
  100122. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  100123. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100124. */
  100125. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  100126. /**
  100127. * Creates a new AnaglyphArcRotateCamera
  100128. * @param name defines camera name
  100129. * @param alpha defines alpha angle (in radians)
  100130. * @param beta defines beta angle (in radians)
  100131. * @param radius defines radius
  100132. * @param target defines camera target
  100133. * @param interaxialDistance defines distance between each color axis
  100134. * @param scene defines the hosting scene
  100135. */
  100136. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  100137. /**
  100138. * Gets camera class name
  100139. * @returns AnaglyphArcRotateCamera
  100140. */
  100141. getClassName(): string;
  100142. }
  100143. }
  100144. declare module BABYLON {
  100145. /**
  100146. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  100147. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100148. */
  100149. export class AnaglyphFreeCamera extends FreeCamera {
  100150. /**
  100151. * Creates a new AnaglyphFreeCamera
  100152. * @param name defines camera name
  100153. * @param position defines initial position
  100154. * @param interaxialDistance defines distance between each color axis
  100155. * @param scene defines the hosting scene
  100156. */
  100157. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100158. /**
  100159. * Gets camera class name
  100160. * @returns AnaglyphFreeCamera
  100161. */
  100162. getClassName(): string;
  100163. }
  100164. }
  100165. declare module BABYLON {
  100166. /**
  100167. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  100168. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100169. */
  100170. export class AnaglyphGamepadCamera extends GamepadCamera {
  100171. /**
  100172. * Creates a new AnaglyphGamepadCamera
  100173. * @param name defines camera name
  100174. * @param position defines initial position
  100175. * @param interaxialDistance defines distance between each color axis
  100176. * @param scene defines the hosting scene
  100177. */
  100178. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100179. /**
  100180. * Gets camera class name
  100181. * @returns AnaglyphGamepadCamera
  100182. */
  100183. getClassName(): string;
  100184. }
  100185. }
  100186. declare module BABYLON {
  100187. /**
  100188. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  100189. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  100190. */
  100191. export class AnaglyphUniversalCamera extends UniversalCamera {
  100192. /**
  100193. * Creates a new AnaglyphUniversalCamera
  100194. * @param name defines camera name
  100195. * @param position defines initial position
  100196. * @param interaxialDistance defines distance between each color axis
  100197. * @param scene defines the hosting scene
  100198. */
  100199. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  100200. /**
  100201. * Gets camera class name
  100202. * @returns AnaglyphUniversalCamera
  100203. */
  100204. getClassName(): string;
  100205. }
  100206. }
  100207. declare module BABYLON {
  100208. /** @hidden */
  100209. export var stereoscopicInterlacePixelShader: {
  100210. name: string;
  100211. shader: string;
  100212. };
  100213. }
  100214. declare module BABYLON {
  100215. /**
  100216. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  100217. */
  100218. export class StereoscopicInterlacePostProcess extends PostProcess {
  100219. private _stepSize;
  100220. private _passedProcess;
  100221. /**
  100222. * Initializes a StereoscopicInterlacePostProcess
  100223. * @param name The name of the effect.
  100224. * @param rigCameras The rig cameras to be appled to the post process
  100225. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  100226. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  100227. * @param engine The engine which the post process will be applied. (default: current engine)
  100228. * @param reusable If the post process can be reused on the same frame. (default: false)
  100229. */
  100230. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  100231. }
  100232. }
  100233. declare module BABYLON {
  100234. /**
  100235. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  100236. * @see http://doc.babylonjs.com/features/cameras
  100237. */
  100238. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  100239. /**
  100240. * Creates a new StereoscopicArcRotateCamera
  100241. * @param name defines camera name
  100242. * @param alpha defines alpha angle (in radians)
  100243. * @param beta defines beta angle (in radians)
  100244. * @param radius defines radius
  100245. * @param target defines camera target
  100246. * @param interaxialDistance defines distance between each color axis
  100247. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100248. * @param scene defines the hosting scene
  100249. */
  100250. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100251. /**
  100252. * Gets camera class name
  100253. * @returns StereoscopicArcRotateCamera
  100254. */
  100255. getClassName(): string;
  100256. }
  100257. }
  100258. declare module BABYLON {
  100259. /**
  100260. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  100261. * @see http://doc.babylonjs.com/features/cameras
  100262. */
  100263. export class StereoscopicFreeCamera extends FreeCamera {
  100264. /**
  100265. * Creates a new StereoscopicFreeCamera
  100266. * @param name defines camera name
  100267. * @param position defines initial position
  100268. * @param interaxialDistance defines distance between each color axis
  100269. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100270. * @param scene defines the hosting scene
  100271. */
  100272. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100273. /**
  100274. * Gets camera class name
  100275. * @returns StereoscopicFreeCamera
  100276. */
  100277. getClassName(): string;
  100278. }
  100279. }
  100280. declare module BABYLON {
  100281. /**
  100282. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  100283. * @see http://doc.babylonjs.com/features/cameras
  100284. */
  100285. export class StereoscopicGamepadCamera extends GamepadCamera {
  100286. /**
  100287. * Creates a new StereoscopicGamepadCamera
  100288. * @param name defines camera name
  100289. * @param position defines initial position
  100290. * @param interaxialDistance defines distance between each color axis
  100291. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100292. * @param scene defines the hosting scene
  100293. */
  100294. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100295. /**
  100296. * Gets camera class name
  100297. * @returns StereoscopicGamepadCamera
  100298. */
  100299. getClassName(): string;
  100300. }
  100301. }
  100302. declare module BABYLON {
  100303. /**
  100304. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  100305. * @see http://doc.babylonjs.com/features/cameras
  100306. */
  100307. export class StereoscopicUniversalCamera extends UniversalCamera {
  100308. /**
  100309. * Creates a new StereoscopicUniversalCamera
  100310. * @param name defines camera name
  100311. * @param position defines initial position
  100312. * @param interaxialDistance defines distance between each color axis
  100313. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  100314. * @param scene defines the hosting scene
  100315. */
  100316. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  100317. /**
  100318. * Gets camera class name
  100319. * @returns StereoscopicUniversalCamera
  100320. */
  100321. getClassName(): string;
  100322. }
  100323. }
  100324. declare module BABYLON {
  100325. /**
  100326. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  100327. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100328. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100329. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100330. */
  100331. export class VirtualJoysticksCamera extends FreeCamera {
  100332. /**
  100333. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  100334. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  100335. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  100336. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  100337. * @param name Define the name of the camera in the scene
  100338. * @param position Define the start position of the camera in the scene
  100339. * @param scene Define the scene the camera belongs to
  100340. */
  100341. constructor(name: string, position: Vector3, scene: Scene);
  100342. /**
  100343. * Gets the current object class name.
  100344. * @return the class name
  100345. */
  100346. getClassName(): string;
  100347. }
  100348. }
  100349. declare module BABYLON {
  100350. /**
  100351. * This represents all the required metrics to create a VR camera.
  100352. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  100353. */
  100354. export class VRCameraMetrics {
  100355. /**
  100356. * Define the horizontal resolution off the screen.
  100357. */
  100358. hResolution: number;
  100359. /**
  100360. * Define the vertical resolution off the screen.
  100361. */
  100362. vResolution: number;
  100363. /**
  100364. * Define the horizontal screen size.
  100365. */
  100366. hScreenSize: number;
  100367. /**
  100368. * Define the vertical screen size.
  100369. */
  100370. vScreenSize: number;
  100371. /**
  100372. * Define the vertical screen center position.
  100373. */
  100374. vScreenCenter: number;
  100375. /**
  100376. * Define the distance of the eyes to the screen.
  100377. */
  100378. eyeToScreenDistance: number;
  100379. /**
  100380. * Define the distance between both lenses
  100381. */
  100382. lensSeparationDistance: number;
  100383. /**
  100384. * Define the distance between both viewer's eyes.
  100385. */
  100386. interpupillaryDistance: number;
  100387. /**
  100388. * Define the distortion factor of the VR postprocess.
  100389. * Please, touch with care.
  100390. */
  100391. distortionK: number[];
  100392. /**
  100393. * Define the chromatic aberration correction factors for the VR post process.
  100394. */
  100395. chromaAbCorrection: number[];
  100396. /**
  100397. * Define the scale factor of the post process.
  100398. * The smaller the better but the slower.
  100399. */
  100400. postProcessScaleFactor: number;
  100401. /**
  100402. * Define an offset for the lens center.
  100403. */
  100404. lensCenterOffset: number;
  100405. /**
  100406. * Define if the current vr camera should compensate the distortion of the lense or not.
  100407. */
  100408. compensateDistortion: boolean;
  100409. /**
  100410. * Defines if multiview should be enabled when rendering (Default: false)
  100411. */
  100412. multiviewEnabled: boolean;
  100413. /**
  100414. * Gets the rendering aspect ratio based on the provided resolutions.
  100415. */
  100416. readonly aspectRatio: number;
  100417. /**
  100418. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  100419. */
  100420. readonly aspectRatioFov: number;
  100421. /**
  100422. * @hidden
  100423. */
  100424. readonly leftHMatrix: Matrix;
  100425. /**
  100426. * @hidden
  100427. */
  100428. readonly rightHMatrix: Matrix;
  100429. /**
  100430. * @hidden
  100431. */
  100432. readonly leftPreViewMatrix: Matrix;
  100433. /**
  100434. * @hidden
  100435. */
  100436. readonly rightPreViewMatrix: Matrix;
  100437. /**
  100438. * Get the default VRMetrics based on the most generic setup.
  100439. * @returns the default vr metrics
  100440. */
  100441. static GetDefault(): VRCameraMetrics;
  100442. }
  100443. }
  100444. declare module BABYLON {
  100445. /** @hidden */
  100446. export var vrDistortionCorrectionPixelShader: {
  100447. name: string;
  100448. shader: string;
  100449. };
  100450. }
  100451. declare module BABYLON {
  100452. /**
  100453. * VRDistortionCorrectionPostProcess used for mobile VR
  100454. */
  100455. export class VRDistortionCorrectionPostProcess extends PostProcess {
  100456. private _isRightEye;
  100457. private _distortionFactors;
  100458. private _postProcessScaleFactor;
  100459. private _lensCenterOffset;
  100460. private _scaleIn;
  100461. private _scaleFactor;
  100462. private _lensCenter;
  100463. /**
  100464. * Initializes the VRDistortionCorrectionPostProcess
  100465. * @param name The name of the effect.
  100466. * @param camera The camera to apply the render pass to.
  100467. * @param isRightEye If this is for the right eye distortion
  100468. * @param vrMetrics All the required metrics for the VR camera
  100469. */
  100470. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  100471. }
  100472. }
  100473. declare module BABYLON {
  100474. /**
  100475. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  100476. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100477. */
  100478. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  100479. /**
  100480. * Creates a new VRDeviceOrientationArcRotateCamera
  100481. * @param name defines camera name
  100482. * @param alpha defines the camera rotation along the logitudinal axis
  100483. * @param beta defines the camera rotation along the latitudinal axis
  100484. * @param radius defines the camera distance from its target
  100485. * @param target defines the camera target
  100486. * @param scene defines the scene the camera belongs to
  100487. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100488. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100489. */
  100490. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100491. /**
  100492. * Gets camera class name
  100493. * @returns VRDeviceOrientationArcRotateCamera
  100494. */
  100495. getClassName(): string;
  100496. }
  100497. }
  100498. declare module BABYLON {
  100499. /**
  100500. * Camera used to simulate VR rendering (based on FreeCamera)
  100501. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100502. */
  100503. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  100504. /**
  100505. * Creates a new VRDeviceOrientationFreeCamera
  100506. * @param name defines camera name
  100507. * @param position defines the start position of the camera
  100508. * @param scene defines the scene the camera belongs to
  100509. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100510. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100511. */
  100512. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100513. /**
  100514. * Gets camera class name
  100515. * @returns VRDeviceOrientationFreeCamera
  100516. */
  100517. getClassName(): string;
  100518. }
  100519. }
  100520. declare module BABYLON {
  100521. /**
  100522. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  100523. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  100524. */
  100525. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  100526. /**
  100527. * Creates a new VRDeviceOrientationGamepadCamera
  100528. * @param name defines camera name
  100529. * @param position defines the start position of the camera
  100530. * @param scene defines the scene the camera belongs to
  100531. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  100532. * @param vrCameraMetrics defines the vr metrics associated to the camera
  100533. */
  100534. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  100535. /**
  100536. * Gets camera class name
  100537. * @returns VRDeviceOrientationGamepadCamera
  100538. */
  100539. getClassName(): string;
  100540. }
  100541. }
  100542. declare module BABYLON {
  100543. /**
  100544. * Base class of materials working in push mode in babylon JS
  100545. * @hidden
  100546. */
  100547. export class PushMaterial extends Material {
  100548. protected _activeEffect: Effect;
  100549. protected _normalMatrix: Matrix;
  100550. /**
  100551. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100552. * This means that the material can keep using a previous shader while a new one is being compiled.
  100553. * This is mostly used when shader parallel compilation is supported (true by default)
  100554. */
  100555. allowShaderHotSwapping: boolean;
  100556. constructor(name: string, scene: Scene);
  100557. getEffect(): Effect;
  100558. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100559. /**
  100560. * Binds the given world matrix to the active effect
  100561. *
  100562. * @param world the matrix to bind
  100563. */
  100564. bindOnlyWorldMatrix(world: Matrix): void;
  100565. /**
  100566. * Binds the given normal matrix to the active effect
  100567. *
  100568. * @param normalMatrix the matrix to bind
  100569. */
  100570. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100571. bind(world: Matrix, mesh?: Mesh): void;
  100572. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100573. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100574. }
  100575. }
  100576. declare module BABYLON {
  100577. /**
  100578. * This groups all the flags used to control the materials channel.
  100579. */
  100580. export class MaterialFlags {
  100581. private static _DiffuseTextureEnabled;
  100582. /**
  100583. * Are diffuse textures enabled in the application.
  100584. */
  100585. static DiffuseTextureEnabled: boolean;
  100586. private static _AmbientTextureEnabled;
  100587. /**
  100588. * Are ambient textures enabled in the application.
  100589. */
  100590. static AmbientTextureEnabled: boolean;
  100591. private static _OpacityTextureEnabled;
  100592. /**
  100593. * Are opacity textures enabled in the application.
  100594. */
  100595. static OpacityTextureEnabled: boolean;
  100596. private static _ReflectionTextureEnabled;
  100597. /**
  100598. * Are reflection textures enabled in the application.
  100599. */
  100600. static ReflectionTextureEnabled: boolean;
  100601. private static _EmissiveTextureEnabled;
  100602. /**
  100603. * Are emissive textures enabled in the application.
  100604. */
  100605. static EmissiveTextureEnabled: boolean;
  100606. private static _SpecularTextureEnabled;
  100607. /**
  100608. * Are specular textures enabled in the application.
  100609. */
  100610. static SpecularTextureEnabled: boolean;
  100611. private static _BumpTextureEnabled;
  100612. /**
  100613. * Are bump textures enabled in the application.
  100614. */
  100615. static BumpTextureEnabled: boolean;
  100616. private static _LightmapTextureEnabled;
  100617. /**
  100618. * Are lightmap textures enabled in the application.
  100619. */
  100620. static LightmapTextureEnabled: boolean;
  100621. private static _RefractionTextureEnabled;
  100622. /**
  100623. * Are refraction textures enabled in the application.
  100624. */
  100625. static RefractionTextureEnabled: boolean;
  100626. private static _ColorGradingTextureEnabled;
  100627. /**
  100628. * Are color grading textures enabled in the application.
  100629. */
  100630. static ColorGradingTextureEnabled: boolean;
  100631. private static _FresnelEnabled;
  100632. /**
  100633. * Are fresnels enabled in the application.
  100634. */
  100635. static FresnelEnabled: boolean;
  100636. private static _ClearCoatTextureEnabled;
  100637. /**
  100638. * Are clear coat textures enabled in the application.
  100639. */
  100640. static ClearCoatTextureEnabled: boolean;
  100641. private static _ClearCoatBumpTextureEnabled;
  100642. /**
  100643. * Are clear coat bump textures enabled in the application.
  100644. */
  100645. static ClearCoatBumpTextureEnabled: boolean;
  100646. private static _ClearCoatTintTextureEnabled;
  100647. /**
  100648. * Are clear coat tint textures enabled in the application.
  100649. */
  100650. static ClearCoatTintTextureEnabled: boolean;
  100651. private static _SheenTextureEnabled;
  100652. /**
  100653. * Are sheen textures enabled in the application.
  100654. */
  100655. static SheenTextureEnabled: boolean;
  100656. private static _AnisotropicTextureEnabled;
  100657. /**
  100658. * Are anisotropic textures enabled in the application.
  100659. */
  100660. static AnisotropicTextureEnabled: boolean;
  100661. private static _ThicknessTextureEnabled;
  100662. /**
  100663. * Are thickness textures enabled in the application.
  100664. */
  100665. static ThicknessTextureEnabled: boolean;
  100666. }
  100667. }
  100668. declare module BABYLON {
  100669. /** @hidden */
  100670. export var defaultFragmentDeclaration: {
  100671. name: string;
  100672. shader: string;
  100673. };
  100674. }
  100675. declare module BABYLON {
  100676. /** @hidden */
  100677. export var defaultUboDeclaration: {
  100678. name: string;
  100679. shader: string;
  100680. };
  100681. }
  100682. declare module BABYLON {
  100683. /** @hidden */
  100684. export var lightFragmentDeclaration: {
  100685. name: string;
  100686. shader: string;
  100687. };
  100688. }
  100689. declare module BABYLON {
  100690. /** @hidden */
  100691. export var lightUboDeclaration: {
  100692. name: string;
  100693. shader: string;
  100694. };
  100695. }
  100696. declare module BABYLON {
  100697. /** @hidden */
  100698. export var lightsFragmentFunctions: {
  100699. name: string;
  100700. shader: string;
  100701. };
  100702. }
  100703. declare module BABYLON {
  100704. /** @hidden */
  100705. export var shadowsFragmentFunctions: {
  100706. name: string;
  100707. shader: string;
  100708. };
  100709. }
  100710. declare module BABYLON {
  100711. /** @hidden */
  100712. export var fresnelFunction: {
  100713. name: string;
  100714. shader: string;
  100715. };
  100716. }
  100717. declare module BABYLON {
  100718. /** @hidden */
  100719. export var reflectionFunction: {
  100720. name: string;
  100721. shader: string;
  100722. };
  100723. }
  100724. declare module BABYLON {
  100725. /** @hidden */
  100726. export var bumpFragmentFunctions: {
  100727. name: string;
  100728. shader: string;
  100729. };
  100730. }
  100731. declare module BABYLON {
  100732. /** @hidden */
  100733. export var logDepthDeclaration: {
  100734. name: string;
  100735. shader: string;
  100736. };
  100737. }
  100738. declare module BABYLON {
  100739. /** @hidden */
  100740. export var bumpFragment: {
  100741. name: string;
  100742. shader: string;
  100743. };
  100744. }
  100745. declare module BABYLON {
  100746. /** @hidden */
  100747. export var depthPrePass: {
  100748. name: string;
  100749. shader: string;
  100750. };
  100751. }
  100752. declare module BABYLON {
  100753. /** @hidden */
  100754. export var lightFragment: {
  100755. name: string;
  100756. shader: string;
  100757. };
  100758. }
  100759. declare module BABYLON {
  100760. /** @hidden */
  100761. export var logDepthFragment: {
  100762. name: string;
  100763. shader: string;
  100764. };
  100765. }
  100766. declare module BABYLON {
  100767. /** @hidden */
  100768. export var defaultPixelShader: {
  100769. name: string;
  100770. shader: string;
  100771. };
  100772. }
  100773. declare module BABYLON {
  100774. /** @hidden */
  100775. export var defaultVertexDeclaration: {
  100776. name: string;
  100777. shader: string;
  100778. };
  100779. }
  100780. declare module BABYLON {
  100781. /** @hidden */
  100782. export var bumpVertexDeclaration: {
  100783. name: string;
  100784. shader: string;
  100785. };
  100786. }
  100787. declare module BABYLON {
  100788. /** @hidden */
  100789. export var bumpVertex: {
  100790. name: string;
  100791. shader: string;
  100792. };
  100793. }
  100794. declare module BABYLON {
  100795. /** @hidden */
  100796. export var fogVertex: {
  100797. name: string;
  100798. shader: string;
  100799. };
  100800. }
  100801. declare module BABYLON {
  100802. /** @hidden */
  100803. export var shadowsVertex: {
  100804. name: string;
  100805. shader: string;
  100806. };
  100807. }
  100808. declare module BABYLON {
  100809. /** @hidden */
  100810. export var pointCloudVertex: {
  100811. name: string;
  100812. shader: string;
  100813. };
  100814. }
  100815. declare module BABYLON {
  100816. /** @hidden */
  100817. export var logDepthVertex: {
  100818. name: string;
  100819. shader: string;
  100820. };
  100821. }
  100822. declare module BABYLON {
  100823. /** @hidden */
  100824. export var defaultVertexShader: {
  100825. name: string;
  100826. shader: string;
  100827. };
  100828. }
  100829. declare module BABYLON {
  100830. /** @hidden */
  100831. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100832. MAINUV1: boolean;
  100833. MAINUV2: boolean;
  100834. DIFFUSE: boolean;
  100835. DIFFUSEDIRECTUV: number;
  100836. AMBIENT: boolean;
  100837. AMBIENTDIRECTUV: number;
  100838. OPACITY: boolean;
  100839. OPACITYDIRECTUV: number;
  100840. OPACITYRGB: boolean;
  100841. REFLECTION: boolean;
  100842. EMISSIVE: boolean;
  100843. EMISSIVEDIRECTUV: number;
  100844. SPECULAR: boolean;
  100845. SPECULARDIRECTUV: number;
  100846. BUMP: boolean;
  100847. BUMPDIRECTUV: number;
  100848. PARALLAX: boolean;
  100849. PARALLAXOCCLUSION: boolean;
  100850. SPECULAROVERALPHA: boolean;
  100851. CLIPPLANE: boolean;
  100852. CLIPPLANE2: boolean;
  100853. CLIPPLANE3: boolean;
  100854. CLIPPLANE4: boolean;
  100855. ALPHATEST: boolean;
  100856. DEPTHPREPASS: boolean;
  100857. ALPHAFROMDIFFUSE: boolean;
  100858. POINTSIZE: boolean;
  100859. FOG: boolean;
  100860. SPECULARTERM: boolean;
  100861. DIFFUSEFRESNEL: boolean;
  100862. OPACITYFRESNEL: boolean;
  100863. REFLECTIONFRESNEL: boolean;
  100864. REFRACTIONFRESNEL: boolean;
  100865. EMISSIVEFRESNEL: boolean;
  100866. FRESNEL: boolean;
  100867. NORMAL: boolean;
  100868. UV1: boolean;
  100869. UV2: boolean;
  100870. VERTEXCOLOR: boolean;
  100871. VERTEXALPHA: boolean;
  100872. NUM_BONE_INFLUENCERS: number;
  100873. BonesPerMesh: number;
  100874. BONETEXTURE: boolean;
  100875. INSTANCES: boolean;
  100876. GLOSSINESS: boolean;
  100877. ROUGHNESS: boolean;
  100878. EMISSIVEASILLUMINATION: boolean;
  100879. LINKEMISSIVEWITHDIFFUSE: boolean;
  100880. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100881. LIGHTMAP: boolean;
  100882. LIGHTMAPDIRECTUV: number;
  100883. OBJECTSPACE_NORMALMAP: boolean;
  100884. USELIGHTMAPASSHADOWMAP: boolean;
  100885. REFLECTIONMAP_3D: boolean;
  100886. REFLECTIONMAP_SPHERICAL: boolean;
  100887. REFLECTIONMAP_PLANAR: boolean;
  100888. REFLECTIONMAP_CUBIC: boolean;
  100889. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100890. REFLECTIONMAP_PROJECTION: boolean;
  100891. REFLECTIONMAP_SKYBOX: boolean;
  100892. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  100893. REFLECTIONMAP_EXPLICIT: boolean;
  100894. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100895. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100896. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100897. INVERTCUBICMAP: boolean;
  100898. LOGARITHMICDEPTH: boolean;
  100899. REFRACTION: boolean;
  100900. REFRACTIONMAP_3D: boolean;
  100901. REFLECTIONOVERALPHA: boolean;
  100902. TWOSIDEDLIGHTING: boolean;
  100903. SHADOWFLOAT: boolean;
  100904. MORPHTARGETS: boolean;
  100905. MORPHTARGETS_NORMAL: boolean;
  100906. MORPHTARGETS_TANGENT: boolean;
  100907. NUM_MORPH_INFLUENCERS: number;
  100908. NONUNIFORMSCALING: boolean;
  100909. PREMULTIPLYALPHA: boolean;
  100910. IMAGEPROCESSING: boolean;
  100911. VIGNETTE: boolean;
  100912. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100913. VIGNETTEBLENDMODEOPAQUE: boolean;
  100914. TONEMAPPING: boolean;
  100915. TONEMAPPING_ACES: boolean;
  100916. CONTRAST: boolean;
  100917. COLORCURVES: boolean;
  100918. COLORGRADING: boolean;
  100919. COLORGRADING3D: boolean;
  100920. SAMPLER3DGREENDEPTH: boolean;
  100921. SAMPLER3DBGRMAP: boolean;
  100922. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100923. MULTIVIEW: boolean;
  100924. /**
  100925. * If the reflection texture on this material is in linear color space
  100926. * @hidden
  100927. */
  100928. IS_REFLECTION_LINEAR: boolean;
  100929. /**
  100930. * If the refraction texture on this material is in linear color space
  100931. * @hidden
  100932. */
  100933. IS_REFRACTION_LINEAR: boolean;
  100934. EXPOSURE: boolean;
  100935. constructor();
  100936. setReflectionMode(modeToEnable: string): void;
  100937. }
  100938. /**
  100939. * This is the default material used in Babylon. It is the best trade off between quality
  100940. * and performances.
  100941. * @see http://doc.babylonjs.com/babylon101/materials
  100942. */
  100943. export class StandardMaterial extends PushMaterial {
  100944. private _diffuseTexture;
  100945. /**
  100946. * The basic texture of the material as viewed under a light.
  100947. */
  100948. diffuseTexture: Nullable<BaseTexture>;
  100949. private _ambientTexture;
  100950. /**
  100951. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  100952. */
  100953. ambientTexture: Nullable<BaseTexture>;
  100954. private _opacityTexture;
  100955. /**
  100956. * Define the transparency of the material from a texture.
  100957. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  100958. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  100959. */
  100960. opacityTexture: Nullable<BaseTexture>;
  100961. private _reflectionTexture;
  100962. /**
  100963. * Define the texture used to display the reflection.
  100964. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100965. */
  100966. reflectionTexture: Nullable<BaseTexture>;
  100967. private _emissiveTexture;
  100968. /**
  100969. * Define texture of the material as if self lit.
  100970. * This will be mixed in the final result even in the absence of light.
  100971. */
  100972. emissiveTexture: Nullable<BaseTexture>;
  100973. private _specularTexture;
  100974. /**
  100975. * Define how the color and intensity of the highlight given by the light in the material.
  100976. */
  100977. specularTexture: Nullable<BaseTexture>;
  100978. private _bumpTexture;
  100979. /**
  100980. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  100981. * 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.
  100982. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  100983. */
  100984. bumpTexture: Nullable<BaseTexture>;
  100985. private _lightmapTexture;
  100986. /**
  100987. * Complex lighting can be computationally expensive to compute at runtime.
  100988. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  100989. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  100990. */
  100991. lightmapTexture: Nullable<BaseTexture>;
  100992. private _refractionTexture;
  100993. /**
  100994. * Define the texture used to display the refraction.
  100995. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  100996. */
  100997. refractionTexture: Nullable<BaseTexture>;
  100998. /**
  100999. * The color of the material lit by the environmental background lighting.
  101000. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101001. */
  101002. ambientColor: Color3;
  101003. /**
  101004. * The basic color of the material as viewed under a light.
  101005. */
  101006. diffuseColor: Color3;
  101007. /**
  101008. * Define how the color and intensity of the highlight given by the light in the material.
  101009. */
  101010. specularColor: Color3;
  101011. /**
  101012. * Define the color of the material as if self lit.
  101013. * This will be mixed in the final result even in the absence of light.
  101014. */
  101015. emissiveColor: Color3;
  101016. /**
  101017. * Defines how sharp are the highlights in the material.
  101018. * The bigger the value the sharper giving a more glossy feeling to the result.
  101019. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101020. */
  101021. specularPower: number;
  101022. private _useAlphaFromDiffuseTexture;
  101023. /**
  101024. * Does the transparency come from the diffuse texture alpha channel.
  101025. */
  101026. useAlphaFromDiffuseTexture: boolean;
  101027. private _useEmissiveAsIllumination;
  101028. /**
  101029. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101030. */
  101031. useEmissiveAsIllumination: boolean;
  101032. private _linkEmissiveWithDiffuse;
  101033. /**
  101034. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101035. * the emissive level when the final color is close to one.
  101036. */
  101037. linkEmissiveWithDiffuse: boolean;
  101038. private _useSpecularOverAlpha;
  101039. /**
  101040. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101041. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101042. */
  101043. useSpecularOverAlpha: boolean;
  101044. private _useReflectionOverAlpha;
  101045. /**
  101046. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101047. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101048. */
  101049. useReflectionOverAlpha: boolean;
  101050. private _disableLighting;
  101051. /**
  101052. * Does lights from the scene impacts this material.
  101053. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101054. */
  101055. disableLighting: boolean;
  101056. private _useObjectSpaceNormalMap;
  101057. /**
  101058. * Allows using an object space normal map (instead of tangent space).
  101059. */
  101060. useObjectSpaceNormalMap: boolean;
  101061. private _useParallax;
  101062. /**
  101063. * Is parallax enabled or not.
  101064. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101065. */
  101066. useParallax: boolean;
  101067. private _useParallaxOcclusion;
  101068. /**
  101069. * Is parallax occlusion enabled or not.
  101070. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101071. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101072. */
  101073. useParallaxOcclusion: boolean;
  101074. /**
  101075. * 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.
  101076. */
  101077. parallaxScaleBias: number;
  101078. private _roughness;
  101079. /**
  101080. * Helps to define how blurry the reflections should appears in the material.
  101081. */
  101082. roughness: number;
  101083. /**
  101084. * In case of refraction, define the value of the indice of refraction.
  101085. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101086. */
  101087. indexOfRefraction: number;
  101088. /**
  101089. * Invert the refraction texture alongside the y axis.
  101090. * It can be useful with procedural textures or probe for instance.
  101091. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101092. */
  101093. invertRefractionY: boolean;
  101094. /**
  101095. * Defines the alpha limits in alpha test mode.
  101096. */
  101097. alphaCutOff: number;
  101098. private _useLightmapAsShadowmap;
  101099. /**
  101100. * In case of light mapping, define whether the map contains light or shadow informations.
  101101. */
  101102. useLightmapAsShadowmap: boolean;
  101103. private _diffuseFresnelParameters;
  101104. /**
  101105. * Define the diffuse fresnel parameters of the material.
  101106. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101107. */
  101108. diffuseFresnelParameters: FresnelParameters;
  101109. private _opacityFresnelParameters;
  101110. /**
  101111. * Define the opacity fresnel parameters of the material.
  101112. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101113. */
  101114. opacityFresnelParameters: FresnelParameters;
  101115. private _reflectionFresnelParameters;
  101116. /**
  101117. * Define the reflection fresnel parameters of the material.
  101118. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101119. */
  101120. reflectionFresnelParameters: FresnelParameters;
  101121. private _refractionFresnelParameters;
  101122. /**
  101123. * Define the refraction fresnel parameters of the material.
  101124. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101125. */
  101126. refractionFresnelParameters: FresnelParameters;
  101127. private _emissiveFresnelParameters;
  101128. /**
  101129. * Define the emissive fresnel parameters of the material.
  101130. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101131. */
  101132. emissiveFresnelParameters: FresnelParameters;
  101133. private _useReflectionFresnelFromSpecular;
  101134. /**
  101135. * If true automatically deducts the fresnels values from the material specularity.
  101136. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101137. */
  101138. useReflectionFresnelFromSpecular: boolean;
  101139. private _useGlossinessFromSpecularMapAlpha;
  101140. /**
  101141. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101142. */
  101143. useGlossinessFromSpecularMapAlpha: boolean;
  101144. private _maxSimultaneousLights;
  101145. /**
  101146. * Defines the maximum number of lights that can be used in the material
  101147. */
  101148. maxSimultaneousLights: number;
  101149. private _invertNormalMapX;
  101150. /**
  101151. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101152. */
  101153. invertNormalMapX: boolean;
  101154. private _invertNormalMapY;
  101155. /**
  101156. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101157. */
  101158. invertNormalMapY: boolean;
  101159. private _twoSidedLighting;
  101160. /**
  101161. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101162. */
  101163. twoSidedLighting: boolean;
  101164. /**
  101165. * Default configuration related to image processing available in the standard Material.
  101166. */
  101167. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101168. /**
  101169. * Gets the image processing configuration used either in this material.
  101170. */
  101171. /**
  101172. * Sets the Default image processing configuration used either in the this material.
  101173. *
  101174. * If sets to null, the scene one is in use.
  101175. */
  101176. imageProcessingConfiguration: ImageProcessingConfiguration;
  101177. /**
  101178. * Keep track of the image processing observer to allow dispose and replace.
  101179. */
  101180. private _imageProcessingObserver;
  101181. /**
  101182. * Attaches a new image processing configuration to the Standard Material.
  101183. * @param configuration
  101184. */
  101185. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101186. /**
  101187. * Gets wether the color curves effect is enabled.
  101188. */
  101189. /**
  101190. * Sets wether the color curves effect is enabled.
  101191. */
  101192. cameraColorCurvesEnabled: boolean;
  101193. /**
  101194. * Gets wether the color grading effect is enabled.
  101195. */
  101196. /**
  101197. * Gets wether the color grading effect is enabled.
  101198. */
  101199. cameraColorGradingEnabled: boolean;
  101200. /**
  101201. * Gets wether tonemapping is enabled or not.
  101202. */
  101203. /**
  101204. * Sets wether tonemapping is enabled or not
  101205. */
  101206. cameraToneMappingEnabled: boolean;
  101207. /**
  101208. * The camera exposure used on this material.
  101209. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101210. * This corresponds to a photographic exposure.
  101211. */
  101212. /**
  101213. * The camera exposure used on this material.
  101214. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101215. * This corresponds to a photographic exposure.
  101216. */
  101217. cameraExposure: number;
  101218. /**
  101219. * Gets The camera contrast used on this material.
  101220. */
  101221. /**
  101222. * Sets The camera contrast used on this material.
  101223. */
  101224. cameraContrast: number;
  101225. /**
  101226. * Gets the Color Grading 2D Lookup Texture.
  101227. */
  101228. /**
  101229. * Sets the Color Grading 2D Lookup Texture.
  101230. */
  101231. cameraColorGradingTexture: Nullable<BaseTexture>;
  101232. /**
  101233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101235. * 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;
  101236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101237. */
  101238. /**
  101239. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101240. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101241. * 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;
  101242. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101243. */
  101244. cameraColorCurves: Nullable<ColorCurves>;
  101245. /**
  101246. * Custom callback helping to override the default shader used in the material.
  101247. */
  101248. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  101249. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101250. protected _worldViewProjectionMatrix: Matrix;
  101251. protected _globalAmbientColor: Color3;
  101252. protected _useLogarithmicDepth: boolean;
  101253. /**
  101254. * Instantiates a new standard material.
  101255. * This is the default material used in Babylon. It is the best trade off between quality
  101256. * and performances.
  101257. * @see http://doc.babylonjs.com/babylon101/materials
  101258. * @param name Define the name of the material in the scene
  101259. * @param scene Define the scene the material belong to
  101260. */
  101261. constructor(name: string, scene: Scene);
  101262. /**
  101263. * Gets a boolean indicating that current material needs to register RTT
  101264. */
  101265. readonly hasRenderTargetTextures: boolean;
  101266. /**
  101267. * Gets the current class name of the material e.g. "StandardMaterial"
  101268. * Mainly use in serialization.
  101269. * @returns the class name
  101270. */
  101271. getClassName(): string;
  101272. /**
  101273. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101274. * You can try switching to logarithmic depth.
  101275. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101276. */
  101277. useLogarithmicDepth: boolean;
  101278. /**
  101279. * Specifies if the material will require alpha blending
  101280. * @returns a boolean specifying if alpha blending is needed
  101281. */
  101282. needAlphaBlending(): boolean;
  101283. /**
  101284. * Specifies if this material should be rendered in alpha test mode
  101285. * @returns a boolean specifying if an alpha test is needed.
  101286. */
  101287. needAlphaTesting(): boolean;
  101288. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101289. /**
  101290. * Get the texture used for alpha test purpose.
  101291. * @returns the diffuse texture in case of the standard material.
  101292. */
  101293. getAlphaTestTexture(): Nullable<BaseTexture>;
  101294. /**
  101295. * Get if the submesh is ready to be used and all its information available.
  101296. * Child classes can use it to update shaders
  101297. * @param mesh defines the mesh to check
  101298. * @param subMesh defines which submesh to check
  101299. * @param useInstances specifies that instances should be used
  101300. * @returns a boolean indicating that the submesh is ready or not
  101301. */
  101302. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101303. /**
  101304. * Builds the material UBO layouts.
  101305. * Used internally during the effect preparation.
  101306. */
  101307. buildUniformLayout(): void;
  101308. /**
  101309. * Unbinds the material from the mesh
  101310. */
  101311. unbind(): void;
  101312. /**
  101313. * Binds the submesh to this material by preparing the effect and shader to draw
  101314. * @param world defines the world transformation matrix
  101315. * @param mesh defines the mesh containing the submesh
  101316. * @param subMesh defines the submesh to bind the material to
  101317. */
  101318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101319. /**
  101320. * Get the list of animatables in the material.
  101321. * @returns the list of animatables object used in the material
  101322. */
  101323. getAnimatables(): IAnimatable[];
  101324. /**
  101325. * Gets the active textures from the material
  101326. * @returns an array of textures
  101327. */
  101328. getActiveTextures(): BaseTexture[];
  101329. /**
  101330. * Specifies if the material uses a texture
  101331. * @param texture defines the texture to check against the material
  101332. * @returns a boolean specifying if the material uses the texture
  101333. */
  101334. hasTexture(texture: BaseTexture): boolean;
  101335. /**
  101336. * Disposes the material
  101337. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101338. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101339. */
  101340. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101341. /**
  101342. * Makes a duplicate of the material, and gives it a new name
  101343. * @param name defines the new name for the duplicated material
  101344. * @returns the cloned material
  101345. */
  101346. clone(name: string): StandardMaterial;
  101347. /**
  101348. * Serializes this material in a JSON representation
  101349. * @returns the serialized material object
  101350. */
  101351. serialize(): any;
  101352. /**
  101353. * Creates a standard material from parsed material data
  101354. * @param source defines the JSON representation of the material
  101355. * @param scene defines the hosting scene
  101356. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101357. * @returns a new standard material
  101358. */
  101359. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101360. /**
  101361. * Are diffuse textures enabled in the application.
  101362. */
  101363. static DiffuseTextureEnabled: boolean;
  101364. /**
  101365. * Are ambient textures enabled in the application.
  101366. */
  101367. static AmbientTextureEnabled: boolean;
  101368. /**
  101369. * Are opacity textures enabled in the application.
  101370. */
  101371. static OpacityTextureEnabled: boolean;
  101372. /**
  101373. * Are reflection textures enabled in the application.
  101374. */
  101375. static ReflectionTextureEnabled: boolean;
  101376. /**
  101377. * Are emissive textures enabled in the application.
  101378. */
  101379. static EmissiveTextureEnabled: boolean;
  101380. /**
  101381. * Are specular textures enabled in the application.
  101382. */
  101383. static SpecularTextureEnabled: boolean;
  101384. /**
  101385. * Are bump textures enabled in the application.
  101386. */
  101387. static BumpTextureEnabled: boolean;
  101388. /**
  101389. * Are lightmap textures enabled in the application.
  101390. */
  101391. static LightmapTextureEnabled: boolean;
  101392. /**
  101393. * Are refraction textures enabled in the application.
  101394. */
  101395. static RefractionTextureEnabled: boolean;
  101396. /**
  101397. * Are color grading textures enabled in the application.
  101398. */
  101399. static ColorGradingTextureEnabled: boolean;
  101400. /**
  101401. * Are fresnels enabled in the application.
  101402. */
  101403. static FresnelEnabled: boolean;
  101404. }
  101405. }
  101406. declare module BABYLON {
  101407. /**
  101408. * A class extending Texture allowing drawing on a texture
  101409. * @see http://doc.babylonjs.com/how_to/dynamictexture
  101410. */
  101411. export class DynamicTexture extends Texture {
  101412. private _generateMipMaps;
  101413. private _canvas;
  101414. private _context;
  101415. private _engine;
  101416. /**
  101417. * Creates a DynamicTexture
  101418. * @param name defines the name of the texture
  101419. * @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
  101420. * @param scene defines the scene where you want the texture
  101421. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  101422. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  101423. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  101424. */
  101425. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  101426. /**
  101427. * Get the current class name of the texture useful for serialization or dynamic coding.
  101428. * @returns "DynamicTexture"
  101429. */
  101430. getClassName(): string;
  101431. /**
  101432. * Gets the current state of canRescale
  101433. */
  101434. readonly canRescale: boolean;
  101435. private _recreate;
  101436. /**
  101437. * Scales the texture
  101438. * @param ratio the scale factor to apply to both width and height
  101439. */
  101440. scale(ratio: number): void;
  101441. /**
  101442. * Resizes the texture
  101443. * @param width the new width
  101444. * @param height the new height
  101445. */
  101446. scaleTo(width: number, height: number): void;
  101447. /**
  101448. * Gets the context of the canvas used by the texture
  101449. * @returns the canvas context of the dynamic texture
  101450. */
  101451. getContext(): CanvasRenderingContext2D;
  101452. /**
  101453. * Clears the texture
  101454. */
  101455. clear(): void;
  101456. /**
  101457. * Updates the texture
  101458. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101459. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  101460. */
  101461. update(invertY?: boolean, premulAlpha?: boolean): void;
  101462. /**
  101463. * Draws text onto the texture
  101464. * @param text defines the text to be drawn
  101465. * @param x defines the placement of the text from the left
  101466. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  101467. * @param font defines the font to be used with font-style, font-size, font-name
  101468. * @param color defines the color used for the text
  101469. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  101470. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  101471. * @param update defines whether texture is immediately update (default is true)
  101472. */
  101473. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  101474. /**
  101475. * Clones the texture
  101476. * @returns the clone of the texture.
  101477. */
  101478. clone(): DynamicTexture;
  101479. /**
  101480. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  101481. * @returns a serialized dynamic texture object
  101482. */
  101483. serialize(): any;
  101484. /** @hidden */
  101485. _rebuild(): void;
  101486. }
  101487. }
  101488. declare module BABYLON {
  101489. /** @hidden */
  101490. export var imageProcessingPixelShader: {
  101491. name: string;
  101492. shader: string;
  101493. };
  101494. }
  101495. declare module BABYLON {
  101496. /**
  101497. * ImageProcessingPostProcess
  101498. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  101499. */
  101500. export class ImageProcessingPostProcess extends PostProcess {
  101501. /**
  101502. * Default configuration related to image processing available in the PBR Material.
  101503. */
  101504. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101505. /**
  101506. * Gets the image processing configuration used either in this material.
  101507. */
  101508. /**
  101509. * Sets the Default image processing configuration used either in the this material.
  101510. *
  101511. * If sets to null, the scene one is in use.
  101512. */
  101513. imageProcessingConfiguration: ImageProcessingConfiguration;
  101514. /**
  101515. * Keep track of the image processing observer to allow dispose and replace.
  101516. */
  101517. private _imageProcessingObserver;
  101518. /**
  101519. * Attaches a new image processing configuration to the PBR Material.
  101520. * @param configuration
  101521. */
  101522. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  101523. /**
  101524. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  101525. */
  101526. /**
  101527. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  101528. */
  101529. colorCurves: Nullable<ColorCurves>;
  101530. /**
  101531. * Gets wether the color curves effect is enabled.
  101532. */
  101533. /**
  101534. * Sets wether the color curves effect is enabled.
  101535. */
  101536. colorCurvesEnabled: boolean;
  101537. /**
  101538. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  101539. */
  101540. /**
  101541. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  101542. */
  101543. colorGradingTexture: Nullable<BaseTexture>;
  101544. /**
  101545. * Gets wether the color grading effect is enabled.
  101546. */
  101547. /**
  101548. * Gets wether the color grading effect is enabled.
  101549. */
  101550. colorGradingEnabled: boolean;
  101551. /**
  101552. * Gets exposure used in the effect.
  101553. */
  101554. /**
  101555. * Sets exposure used in the effect.
  101556. */
  101557. exposure: number;
  101558. /**
  101559. * Gets wether tonemapping is enabled or not.
  101560. */
  101561. /**
  101562. * Sets wether tonemapping is enabled or not
  101563. */
  101564. toneMappingEnabled: boolean;
  101565. /**
  101566. * Gets the type of tone mapping effect.
  101567. */
  101568. /**
  101569. * Sets the type of tone mapping effect.
  101570. */
  101571. toneMappingType: number;
  101572. /**
  101573. * Gets contrast used in the effect.
  101574. */
  101575. /**
  101576. * Sets contrast used in the effect.
  101577. */
  101578. contrast: number;
  101579. /**
  101580. * Gets Vignette stretch size.
  101581. */
  101582. /**
  101583. * Sets Vignette stretch size.
  101584. */
  101585. vignetteStretch: number;
  101586. /**
  101587. * Gets Vignette centre X Offset.
  101588. */
  101589. /**
  101590. * Sets Vignette centre X Offset.
  101591. */
  101592. vignetteCentreX: number;
  101593. /**
  101594. * Gets Vignette centre Y Offset.
  101595. */
  101596. /**
  101597. * Sets Vignette centre Y Offset.
  101598. */
  101599. vignetteCentreY: number;
  101600. /**
  101601. * Gets Vignette weight or intensity of the vignette effect.
  101602. */
  101603. /**
  101604. * Sets Vignette weight or intensity of the vignette effect.
  101605. */
  101606. vignetteWeight: number;
  101607. /**
  101608. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  101609. * if vignetteEnabled is set to true.
  101610. */
  101611. /**
  101612. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  101613. * if vignetteEnabled is set to true.
  101614. */
  101615. vignetteColor: Color4;
  101616. /**
  101617. * Gets Camera field of view used by the Vignette effect.
  101618. */
  101619. /**
  101620. * Sets Camera field of view used by the Vignette effect.
  101621. */
  101622. vignetteCameraFov: number;
  101623. /**
  101624. * Gets the vignette blend mode allowing different kind of effect.
  101625. */
  101626. /**
  101627. * Sets the vignette blend mode allowing different kind of effect.
  101628. */
  101629. vignetteBlendMode: number;
  101630. /**
  101631. * Gets wether the vignette effect is enabled.
  101632. */
  101633. /**
  101634. * Sets wether the vignette effect is enabled.
  101635. */
  101636. vignetteEnabled: boolean;
  101637. private _fromLinearSpace;
  101638. /**
  101639. * Gets wether the input of the processing is in Gamma or Linear Space.
  101640. */
  101641. /**
  101642. * Sets wether the input of the processing is in Gamma or Linear Space.
  101643. */
  101644. fromLinearSpace: boolean;
  101645. /**
  101646. * Defines cache preventing GC.
  101647. */
  101648. private _defines;
  101649. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  101650. /**
  101651. * "ImageProcessingPostProcess"
  101652. * @returns "ImageProcessingPostProcess"
  101653. */
  101654. getClassName(): string;
  101655. protected _updateParameters(): void;
  101656. dispose(camera?: Camera): void;
  101657. }
  101658. }
  101659. declare module BABYLON {
  101660. /**
  101661. * Class containing static functions to help procedurally build meshes
  101662. */
  101663. export class GroundBuilder {
  101664. /**
  101665. * Creates a ground mesh
  101666. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  101667. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  101668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  101669. * @param name defines the name of the mesh
  101670. * @param options defines the options used to create the mesh
  101671. * @param scene defines the hosting scene
  101672. * @returns the ground mesh
  101673. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  101674. */
  101675. static CreateGround(name: string, options: {
  101676. width?: number;
  101677. height?: number;
  101678. subdivisions?: number;
  101679. subdivisionsX?: number;
  101680. subdivisionsY?: number;
  101681. updatable?: boolean;
  101682. }, scene: any): Mesh;
  101683. /**
  101684. * Creates a tiled ground mesh
  101685. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  101686. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  101687. * * 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
  101688. * * 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
  101689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101690. * @param name defines the name of the mesh
  101691. * @param options defines the options used to create the mesh
  101692. * @param scene defines the hosting scene
  101693. * @returns the tiled ground mesh
  101694. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  101695. */
  101696. static CreateTiledGround(name: string, options: {
  101697. xmin: number;
  101698. zmin: number;
  101699. xmax: number;
  101700. zmax: number;
  101701. subdivisions?: {
  101702. w: number;
  101703. h: number;
  101704. };
  101705. precision?: {
  101706. w: number;
  101707. h: number;
  101708. };
  101709. updatable?: boolean;
  101710. }, scene?: Nullable<Scene>): Mesh;
  101711. /**
  101712. * Creates a ground mesh from a height map
  101713. * * The parameter `url` sets the URL of the height map image resource.
  101714. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  101715. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  101716. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  101717. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  101718. * * 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.
  101719. * * 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).
  101720. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  101721. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101722. * @param name defines the name of the mesh
  101723. * @param url defines the url to the height map
  101724. * @param options defines the options used to create the mesh
  101725. * @param scene defines the hosting scene
  101726. * @returns the ground mesh
  101727. * @see https://doc.babylonjs.com/babylon101/height_map
  101728. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  101729. */
  101730. static CreateGroundFromHeightMap(name: string, url: string, options: {
  101731. width?: number;
  101732. height?: number;
  101733. subdivisions?: number;
  101734. minHeight?: number;
  101735. maxHeight?: number;
  101736. colorFilter?: Color3;
  101737. alphaFilter?: number;
  101738. updatable?: boolean;
  101739. onReady?: (mesh: GroundMesh) => void;
  101740. }, scene?: Nullable<Scene>): GroundMesh;
  101741. }
  101742. }
  101743. declare module BABYLON {
  101744. /**
  101745. * Class containing static functions to help procedurally build meshes
  101746. */
  101747. export class TorusBuilder {
  101748. /**
  101749. * Creates a torus mesh
  101750. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  101751. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  101752. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  101753. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101754. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101755. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101756. * @param name defines the name of the mesh
  101757. * @param options defines the options used to create the mesh
  101758. * @param scene defines the hosting scene
  101759. * @returns the torus mesh
  101760. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  101761. */
  101762. static CreateTorus(name: string, options: {
  101763. diameter?: number;
  101764. thickness?: number;
  101765. tessellation?: number;
  101766. updatable?: boolean;
  101767. sideOrientation?: number;
  101768. frontUVs?: Vector4;
  101769. backUVs?: Vector4;
  101770. }, scene: any): Mesh;
  101771. }
  101772. }
  101773. declare module BABYLON {
  101774. /**
  101775. * Class containing static functions to help procedurally build meshes
  101776. */
  101777. export class CylinderBuilder {
  101778. /**
  101779. * Creates a cylinder or a cone mesh
  101780. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  101781. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  101782. * * 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.
  101783. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  101784. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  101785. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  101786. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  101787. * * 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).
  101788. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  101789. * * 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).
  101790. * * 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
  101791. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  101792. * * 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
  101793. * * 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.
  101794. * * If `enclose` is false, a ring surface is one element.
  101795. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  101796. * * 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
  101797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  101798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  101799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  101800. * @param name defines the name of the mesh
  101801. * @param options defines the options used to create the mesh
  101802. * @param scene defines the hosting scene
  101803. * @returns the cylinder mesh
  101804. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  101805. */
  101806. static CreateCylinder(name: string, options: {
  101807. height?: number;
  101808. diameterTop?: number;
  101809. diameterBottom?: number;
  101810. diameter?: number;
  101811. tessellation?: number;
  101812. subdivisions?: number;
  101813. arc?: number;
  101814. faceColors?: Color4[];
  101815. faceUV?: Vector4[];
  101816. updatable?: boolean;
  101817. hasRings?: boolean;
  101818. enclose?: boolean;
  101819. cap?: number;
  101820. sideOrientation?: number;
  101821. frontUVs?: Vector4;
  101822. backUVs?: Vector4;
  101823. }, scene: any): Mesh;
  101824. }
  101825. }
  101826. declare module BABYLON {
  101827. /**
  101828. * Options to modify the vr teleportation behavior.
  101829. */
  101830. export interface VRTeleportationOptions {
  101831. /**
  101832. * The name of the mesh which should be used as the teleportation floor. (default: null)
  101833. */
  101834. floorMeshName?: string;
  101835. /**
  101836. * A list of meshes to be used as the teleportation floor. (default: empty)
  101837. */
  101838. floorMeshes?: Mesh[];
  101839. }
  101840. /**
  101841. * Options to modify the vr experience helper's behavior.
  101842. */
  101843. export interface VRExperienceHelperOptions extends WebVROptions {
  101844. /**
  101845. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  101846. */
  101847. createDeviceOrientationCamera?: boolean;
  101848. /**
  101849. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  101850. */
  101851. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  101852. /**
  101853. * Uses the main button on the controller to toggle the laser casted. (default: true)
  101854. */
  101855. laserToggle?: boolean;
  101856. /**
  101857. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  101858. */
  101859. floorMeshes?: Mesh[];
  101860. /**
  101861. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  101862. */
  101863. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  101864. }
  101865. /**
  101866. * Event containing information after VR has been entered
  101867. */
  101868. export class OnAfterEnteringVRObservableEvent {
  101869. /**
  101870. * If entering vr was successful
  101871. */
  101872. success: boolean;
  101873. }
  101874. /**
  101875. * Helps to quickly add VR support to an existing scene.
  101876. * See http://doc.babylonjs.com/how_to/webvr_helper
  101877. */
  101878. export class VRExperienceHelper {
  101879. /** Options to modify the vr experience helper's behavior. */
  101880. webVROptions: VRExperienceHelperOptions;
  101881. private _scene;
  101882. private _position;
  101883. private _btnVR;
  101884. private _btnVRDisplayed;
  101885. private _webVRsupported;
  101886. private _webVRready;
  101887. private _webVRrequesting;
  101888. private _webVRpresenting;
  101889. private _hasEnteredVR;
  101890. private _fullscreenVRpresenting;
  101891. private _canvas;
  101892. private _webVRCamera;
  101893. private _vrDeviceOrientationCamera;
  101894. private _deviceOrientationCamera;
  101895. private _existingCamera;
  101896. private _onKeyDown;
  101897. private _onVrDisplayPresentChange;
  101898. private _onVRDisplayChanged;
  101899. private _onVRRequestPresentStart;
  101900. private _onVRRequestPresentComplete;
  101901. /**
  101902. * Observable raised right before entering VR.
  101903. */
  101904. onEnteringVRObservable: Observable<VRExperienceHelper>;
  101905. /**
  101906. * Observable raised when entering VR has completed.
  101907. */
  101908. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  101909. /**
  101910. * Observable raised when exiting VR.
  101911. */
  101912. onExitingVRObservable: Observable<VRExperienceHelper>;
  101913. /**
  101914. * Observable raised when controller mesh is loaded.
  101915. */
  101916. onControllerMeshLoadedObservable: Observable<WebVRController>;
  101917. /** Return this.onEnteringVRObservable
  101918. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  101919. */
  101920. readonly onEnteringVR: Observable<VRExperienceHelper>;
  101921. /** Return this.onExitingVRObservable
  101922. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  101923. */
  101924. readonly onExitingVR: Observable<VRExperienceHelper>;
  101925. /** Return this.onControllerMeshLoadedObservable
  101926. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  101927. */
  101928. readonly onControllerMeshLoaded: Observable<WebVRController>;
  101929. private _rayLength;
  101930. private _useCustomVRButton;
  101931. private _teleportationRequested;
  101932. private _teleportActive;
  101933. private _floorMeshName;
  101934. private _floorMeshesCollection;
  101935. private _rotationAllowed;
  101936. private _teleportBackwardsVector;
  101937. private _teleportationTarget;
  101938. private _isDefaultTeleportationTarget;
  101939. private _postProcessMove;
  101940. private _teleportationFillColor;
  101941. private _teleportationBorderColor;
  101942. private _rotationAngle;
  101943. private _haloCenter;
  101944. private _cameraGazer;
  101945. private _padSensibilityUp;
  101946. private _padSensibilityDown;
  101947. private _leftController;
  101948. private _rightController;
  101949. /**
  101950. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  101951. */
  101952. onNewMeshSelected: Observable<AbstractMesh>;
  101953. /**
  101954. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  101955. */
  101956. onNewMeshPicked: Observable<PickingInfo>;
  101957. private _circleEase;
  101958. /**
  101959. * Observable raised before camera teleportation
  101960. */
  101961. onBeforeCameraTeleport: Observable<Vector3>;
  101962. /**
  101963. * Observable raised after camera teleportation
  101964. */
  101965. onAfterCameraTeleport: Observable<Vector3>;
  101966. /**
  101967. * Observable raised when current selected mesh gets unselected
  101968. */
  101969. onSelectedMeshUnselected: Observable<AbstractMesh>;
  101970. private _raySelectionPredicate;
  101971. /**
  101972. * To be optionaly changed by user to define custom ray selection
  101973. */
  101974. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  101975. /**
  101976. * To be optionaly changed by user to define custom selection logic (after ray selection)
  101977. */
  101978. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  101979. /**
  101980. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  101981. */
  101982. teleportationEnabled: boolean;
  101983. private _defaultHeight;
  101984. private _teleportationInitialized;
  101985. private _interactionsEnabled;
  101986. private _interactionsRequested;
  101987. private _displayGaze;
  101988. private _displayLaserPointer;
  101989. /**
  101990. * The mesh used to display where the user is going to teleport.
  101991. */
  101992. /**
  101993. * Sets the mesh to be used to display where the user is going to teleport.
  101994. */
  101995. teleportationTarget: Mesh;
  101996. /**
  101997. * 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
  101998. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  101999. * See http://doc.babylonjs.com/resources/baking_transformations
  102000. */
  102001. gazeTrackerMesh: Mesh;
  102002. /**
  102003. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  102004. */
  102005. updateGazeTrackerScale: boolean;
  102006. /**
  102007. * If the gaze trackers color should be updated when selecting meshes
  102008. */
  102009. updateGazeTrackerColor: boolean;
  102010. /**
  102011. * The gaze tracking mesh corresponding to the left controller
  102012. */
  102013. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  102014. /**
  102015. * The gaze tracking mesh corresponding to the right controller
  102016. */
  102017. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  102018. /**
  102019. * If the ray of the gaze should be displayed.
  102020. */
  102021. /**
  102022. * Sets if the ray of the gaze should be displayed.
  102023. */
  102024. displayGaze: boolean;
  102025. /**
  102026. * If the ray of the LaserPointer should be displayed.
  102027. */
  102028. /**
  102029. * Sets if the ray of the LaserPointer should be displayed.
  102030. */
  102031. displayLaserPointer: boolean;
  102032. /**
  102033. * The deviceOrientationCamera used as the camera when not in VR.
  102034. */
  102035. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  102036. /**
  102037. * Based on the current WebVR support, returns the current VR camera used.
  102038. */
  102039. readonly currentVRCamera: Nullable<Camera>;
  102040. /**
  102041. * The webVRCamera which is used when in VR.
  102042. */
  102043. readonly webVRCamera: WebVRFreeCamera;
  102044. /**
  102045. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  102046. */
  102047. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  102048. private readonly _teleportationRequestInitiated;
  102049. /**
  102050. * Defines wether or not Pointer lock should be requested when switching to
  102051. * full screen.
  102052. */
  102053. requestPointerLockOnFullScreen: boolean;
  102054. /**
  102055. * Instantiates a VRExperienceHelper.
  102056. * Helps to quickly add VR support to an existing scene.
  102057. * @param scene The scene the VRExperienceHelper belongs to.
  102058. * @param webVROptions Options to modify the vr experience helper's behavior.
  102059. */
  102060. constructor(scene: Scene,
  102061. /** Options to modify the vr experience helper's behavior. */
  102062. webVROptions?: VRExperienceHelperOptions);
  102063. private _onDefaultMeshLoaded;
  102064. private _onResize;
  102065. private _onFullscreenChange;
  102066. /**
  102067. * Gets a value indicating if we are currently in VR mode.
  102068. */
  102069. readonly isInVRMode: boolean;
  102070. private onVrDisplayPresentChange;
  102071. private onVRDisplayChanged;
  102072. private moveButtonToBottomRight;
  102073. private displayVRButton;
  102074. private updateButtonVisibility;
  102075. private _cachedAngularSensibility;
  102076. /**
  102077. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  102078. * Otherwise, will use the fullscreen API.
  102079. */
  102080. enterVR(): void;
  102081. /**
  102082. * Attempt to exit VR, or fullscreen.
  102083. */
  102084. exitVR(): void;
  102085. /**
  102086. * The position of the vr experience helper.
  102087. */
  102088. /**
  102089. * Sets the position of the vr experience helper.
  102090. */
  102091. position: Vector3;
  102092. /**
  102093. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  102094. */
  102095. enableInteractions(): void;
  102096. private readonly _noControllerIsActive;
  102097. private beforeRender;
  102098. private _isTeleportationFloor;
  102099. /**
  102100. * Adds a floor mesh to be used for teleportation.
  102101. * @param floorMesh the mesh to be used for teleportation.
  102102. */
  102103. addFloorMesh(floorMesh: Mesh): void;
  102104. /**
  102105. * Removes a floor mesh from being used for teleportation.
  102106. * @param floorMesh the mesh to be removed.
  102107. */
  102108. removeFloorMesh(floorMesh: Mesh): void;
  102109. /**
  102110. * Enables interactions and teleportation using the VR controllers and gaze.
  102111. * @param vrTeleportationOptions options to modify teleportation behavior.
  102112. */
  102113. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  102114. private _onNewGamepadConnected;
  102115. private _tryEnableInteractionOnController;
  102116. private _onNewGamepadDisconnected;
  102117. private _enableInteractionOnController;
  102118. private _checkTeleportWithRay;
  102119. private _checkRotate;
  102120. private _checkTeleportBackwards;
  102121. private _enableTeleportationOnController;
  102122. private _createTeleportationCircles;
  102123. private _displayTeleportationTarget;
  102124. private _hideTeleportationTarget;
  102125. private _rotateCamera;
  102126. private _moveTeleportationSelectorTo;
  102127. private _workingVector;
  102128. private _workingQuaternion;
  102129. private _workingMatrix;
  102130. /**
  102131. * Teleports the users feet to the desired location
  102132. * @param location The location where the user's feet should be placed
  102133. */
  102134. teleportCamera(location: Vector3): void;
  102135. private _convertNormalToDirectionOfRay;
  102136. private _castRayAndSelectObject;
  102137. private _notifySelectedMeshUnselected;
  102138. /**
  102139. * Sets the color of the laser ray from the vr controllers.
  102140. * @param color new color for the ray.
  102141. */
  102142. changeLaserColor(color: Color3): void;
  102143. /**
  102144. * Sets the color of the ray from the vr headsets gaze.
  102145. * @param color new color for the ray.
  102146. */
  102147. changeGazeColor(color: Color3): void;
  102148. /**
  102149. * Exits VR and disposes of the vr experience helper
  102150. */
  102151. dispose(): void;
  102152. /**
  102153. * Gets the name of the VRExperienceHelper class
  102154. * @returns "VRExperienceHelper"
  102155. */
  102156. getClassName(): string;
  102157. }
  102158. }
  102159. declare module BABYLON {
  102160. /**
  102161. * Manages an XRSession
  102162. * @see https://doc.babylonjs.com/how_to/webxr
  102163. */
  102164. export class WebXRSessionManager implements IDisposable {
  102165. private scene;
  102166. /**
  102167. * Fires every time a new xrFrame arrives which can be used to update the camera
  102168. */
  102169. onXRFrameObservable: Observable<any>;
  102170. /**
  102171. * Fires when the xr session is ended either by the device or manually done
  102172. */
  102173. onXRSessionEnded: Observable<any>;
  102174. /** @hidden */
  102175. _xrSession: XRSession;
  102176. /** @hidden */
  102177. _frameOfReference: XRFrameOfReference;
  102178. /** @hidden */
  102179. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  102180. /** @hidden */
  102181. _currentXRFrame: Nullable<XRFrame>;
  102182. private _xrNavigator;
  102183. private _xrDevice;
  102184. private _tmpMatrix;
  102185. /**
  102186. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  102187. * @param scene The scene which the session should be created for
  102188. */
  102189. constructor(scene: Scene);
  102190. /**
  102191. * Initializes the manager
  102192. * After initialization enterXR can be called to start an XR session
  102193. * @returns Promise which resolves after it is initialized
  102194. */
  102195. initializeAsync(): Promise<void>;
  102196. /**
  102197. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  102198. * @param sessionCreationOptions xr options to create the session with
  102199. * @param frameOfReferenceType option to configure how the xr pose is expressed
  102200. * @returns Promise which resolves after it enters XR
  102201. */
  102202. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  102203. /**
  102204. * Stops the xrSession and restores the renderloop
  102205. * @returns Promise which resolves after it exits XR
  102206. */
  102207. exitXRAsync(): Promise<void>;
  102208. /**
  102209. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102210. * @param ray ray to cast into the environment
  102211. * @returns Promise which resolves with a collision point in the environment if it exists
  102212. */
  102213. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102214. /**
  102215. * Checks if a session would be supported for the creation options specified
  102216. * @param options creation options to check if they are supported
  102217. * @returns true if supported
  102218. */
  102219. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102220. /**
  102221. * @hidden
  102222. * Converts the render layer of xrSession to a render target
  102223. * @param session session to create render target for
  102224. * @param scene scene the new render target should be created for
  102225. */
  102226. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  102227. /**
  102228. * Disposes of the session manager
  102229. */
  102230. dispose(): void;
  102231. }
  102232. }
  102233. declare module BABYLON {
  102234. /**
  102235. * WebXR Camera which holds the views for the xrSession
  102236. * @see https://doc.babylonjs.com/how_to/webxr
  102237. */
  102238. export class WebXRCamera extends FreeCamera {
  102239. private static _TmpMatrix;
  102240. /**
  102241. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  102242. * @param name the name of the camera
  102243. * @param scene the scene to add the camera to
  102244. */
  102245. constructor(name: string, scene: Scene);
  102246. private _updateNumberOfRigCameras;
  102247. /** @hidden */
  102248. _updateForDualEyeDebugging(pupilDistance?: number): void;
  102249. /**
  102250. * Updates the cameras position from the current pose information of the XR session
  102251. * @param xrSessionManager the session containing pose information
  102252. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  102253. */
  102254. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  102255. }
  102256. }
  102257. declare module BABYLON {
  102258. /**
  102259. * States of the webXR experience
  102260. */
  102261. export enum WebXRState {
  102262. /**
  102263. * Transitioning to being in XR mode
  102264. */
  102265. ENTERING_XR = 0,
  102266. /**
  102267. * Transitioning to non XR mode
  102268. */
  102269. EXITING_XR = 1,
  102270. /**
  102271. * In XR mode and presenting
  102272. */
  102273. IN_XR = 2,
  102274. /**
  102275. * Not entered XR mode
  102276. */
  102277. NOT_IN_XR = 3
  102278. }
  102279. /**
  102280. * Helper class used to enable XR
  102281. * @see https://doc.babylonjs.com/how_to/webxr
  102282. */
  102283. export class WebXRExperienceHelper implements IDisposable {
  102284. private scene;
  102285. /**
  102286. * 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
  102287. */
  102288. container: AbstractMesh;
  102289. /**
  102290. * Camera used to render xr content
  102291. */
  102292. camera: WebXRCamera;
  102293. /**
  102294. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  102295. */
  102296. state: WebXRState;
  102297. private _setState;
  102298. private static _TmpVector;
  102299. /**
  102300. * Fires when the state of the experience helper has changed
  102301. */
  102302. onStateChangedObservable: Observable<WebXRState>;
  102303. /** @hidden */
  102304. _sessionManager: WebXRSessionManager;
  102305. private _nonVRCamera;
  102306. private _originalSceneAutoClear;
  102307. private _supported;
  102308. /**
  102309. * Creates the experience helper
  102310. * @param scene the scene to attach the experience helper to
  102311. * @returns a promise for the experience helper
  102312. */
  102313. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  102314. /**
  102315. * Creates a WebXRExperienceHelper
  102316. * @param scene The scene the helper should be created in
  102317. */
  102318. private constructor();
  102319. /**
  102320. * Exits XR mode and returns the scene to its original state
  102321. * @returns promise that resolves after xr mode has exited
  102322. */
  102323. exitXRAsync(): Promise<void>;
  102324. /**
  102325. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  102326. * @param sessionCreationOptions options for the XR session
  102327. * @param frameOfReference frame of reference of the XR session
  102328. * @returns promise that resolves after xr mode has entered
  102329. */
  102330. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  102331. /**
  102332. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  102333. * @param ray ray to cast into the environment
  102334. * @returns Promise which resolves with a collision point in the environment if it exists
  102335. */
  102336. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  102337. /**
  102338. * Updates the global position of the camera by moving the camera's container
  102339. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  102340. * @param position The desired global position of the camera
  102341. */
  102342. setPositionOfCameraUsingContainer(position: Vector3): void;
  102343. /**
  102344. * Rotates the xr camera by rotating the camera's container around the camera's position
  102345. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  102346. * @param rotation the desired quaternion rotation to apply to the camera
  102347. */
  102348. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  102349. /**
  102350. * Checks if the creation options are supported by the xr session
  102351. * @param options creation options
  102352. * @returns true if supported
  102353. */
  102354. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  102355. /**
  102356. * Disposes of the experience helper
  102357. */
  102358. dispose(): void;
  102359. }
  102360. }
  102361. declare module BABYLON {
  102362. /**
  102363. * Button which can be used to enter a different mode of XR
  102364. */
  102365. export class WebXREnterExitUIButton {
  102366. /** button element */
  102367. element: HTMLElement;
  102368. /** XR initialization options for the button */
  102369. initializationOptions: XRSessionCreationOptions;
  102370. /**
  102371. * Creates a WebXREnterExitUIButton
  102372. * @param element button element
  102373. * @param initializationOptions XR initialization options for the button
  102374. */
  102375. constructor(
  102376. /** button element */
  102377. element: HTMLElement,
  102378. /** XR initialization options for the button */
  102379. initializationOptions: XRSessionCreationOptions);
  102380. /**
  102381. * Overwritable function which can be used to update the button's visuals when the state changes
  102382. * @param activeButton the current active button in the UI
  102383. */
  102384. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  102385. }
  102386. /**
  102387. * Options to create the webXR UI
  102388. */
  102389. export class WebXREnterExitUIOptions {
  102390. /**
  102391. * Context to enter xr with
  102392. */
  102393. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  102394. /**
  102395. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  102396. */
  102397. customButtons?: Array<WebXREnterExitUIButton>;
  102398. }
  102399. /**
  102400. * UI to allow the user to enter/exit XR mode
  102401. */
  102402. export class WebXREnterExitUI implements IDisposable {
  102403. private scene;
  102404. private _overlay;
  102405. private _buttons;
  102406. private _activeButton;
  102407. /**
  102408. * Fired every time the active button is changed.
  102409. *
  102410. * When xr is entered via a button that launches xr that button will be the callback parameter
  102411. *
  102412. * When exiting xr the callback parameter will be null)
  102413. */
  102414. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  102415. /**
  102416. * Creates UI to allow the user to enter/exit XR mode
  102417. * @param scene the scene to add the ui to
  102418. * @param helper the xr experience helper to enter/exit xr with
  102419. * @param options options to configure the UI
  102420. * @returns the created ui
  102421. */
  102422. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  102423. private constructor();
  102424. private _updateButtons;
  102425. /**
  102426. * Disposes of the object
  102427. */
  102428. dispose(): void;
  102429. }
  102430. }
  102431. declare module BABYLON {
  102432. /**
  102433. * Represents an XR input
  102434. */
  102435. export class WebXRController {
  102436. /**
  102437. * 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
  102438. */
  102439. grip?: AbstractMesh;
  102440. /**
  102441. * Pointer which can be used to select objects or attach a visible laser to
  102442. */
  102443. pointer: AbstractMesh;
  102444. /**
  102445. * Creates the controller
  102446. * @see https://doc.babylonjs.com/how_to/webxr
  102447. * @param scene the scene which the controller should be associated to
  102448. */
  102449. constructor(scene: Scene);
  102450. /**
  102451. * Disposes of the object
  102452. */
  102453. dispose(): void;
  102454. }
  102455. /**
  102456. * XR input used to track XR inputs such as controllers/rays
  102457. */
  102458. export class WebXRInput implements IDisposable {
  102459. private helper;
  102460. /**
  102461. * XR controllers being tracked
  102462. */
  102463. controllers: Array<WebXRController>;
  102464. private _tmpMatrix;
  102465. private _frameObserver;
  102466. /**
  102467. * Initializes the WebXRInput
  102468. * @param helper experience helper which the input should be created for
  102469. */
  102470. constructor(helper: WebXRExperienceHelper);
  102471. /**
  102472. * Disposes of the object
  102473. */
  102474. dispose(): void;
  102475. }
  102476. }
  102477. declare module BABYLON {
  102478. /**
  102479. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  102480. */
  102481. export class WebXRManagedOutputCanvas implements IDisposable {
  102482. private _canvas;
  102483. /**
  102484. * xrpresent context of the canvas which can be used to display/mirror xr content
  102485. */
  102486. canvasContext: Nullable<WebGLRenderingContext>;
  102487. /**
  102488. * Initializes the canvas to be added/removed upon entering/exiting xr
  102489. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  102490. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  102491. */
  102492. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  102493. /**
  102494. * Disposes of the object
  102495. */
  102496. dispose(): void;
  102497. private _setManagedOutputCanvas;
  102498. private _addCanvas;
  102499. private _removeCanvas;
  102500. }
  102501. }
  102502. declare module BABYLON {
  102503. /**
  102504. * Contains an array of blocks representing the octree
  102505. */
  102506. export interface IOctreeContainer<T> {
  102507. /**
  102508. * Blocks within the octree
  102509. */
  102510. blocks: Array<OctreeBlock<T>>;
  102511. }
  102512. /**
  102513. * Class used to store a cell in an octree
  102514. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102515. */
  102516. export class OctreeBlock<T> {
  102517. /**
  102518. * Gets the content of the current block
  102519. */
  102520. entries: T[];
  102521. /**
  102522. * Gets the list of block children
  102523. */
  102524. blocks: Array<OctreeBlock<T>>;
  102525. private _depth;
  102526. private _maxDepth;
  102527. private _capacity;
  102528. private _minPoint;
  102529. private _maxPoint;
  102530. private _boundingVectors;
  102531. private _creationFunc;
  102532. /**
  102533. * Creates a new block
  102534. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  102535. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  102536. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  102537. * @param depth defines the current depth of this block in the octree
  102538. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  102539. * @param creationFunc defines a callback to call when an element is added to the block
  102540. */
  102541. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  102542. /**
  102543. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  102544. */
  102545. readonly capacity: number;
  102546. /**
  102547. * Gets the minimum vector (in world space) of the block's bounding box
  102548. */
  102549. readonly minPoint: Vector3;
  102550. /**
  102551. * Gets the maximum vector (in world space) of the block's bounding box
  102552. */
  102553. readonly maxPoint: Vector3;
  102554. /**
  102555. * Add a new element to this block
  102556. * @param entry defines the element to add
  102557. */
  102558. addEntry(entry: T): void;
  102559. /**
  102560. * Remove an element from this block
  102561. * @param entry defines the element to remove
  102562. */
  102563. removeEntry(entry: T): void;
  102564. /**
  102565. * Add an array of elements to this block
  102566. * @param entries defines the array of elements to add
  102567. */
  102568. addEntries(entries: T[]): void;
  102569. /**
  102570. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  102571. * @param frustumPlanes defines the frustum planes to test
  102572. * @param selection defines the array to store current content if selection is positive
  102573. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102574. */
  102575. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  102576. /**
  102577. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  102578. * @param sphereCenter defines the bounding sphere center
  102579. * @param sphereRadius defines the bounding sphere radius
  102580. * @param selection defines the array to store current content if selection is positive
  102581. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102582. */
  102583. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  102584. /**
  102585. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  102586. * @param ray defines the ray to test with
  102587. * @param selection defines the array to store current content if selection is positive
  102588. */
  102589. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  102590. /**
  102591. * Subdivide the content into child blocks (this block will then be empty)
  102592. */
  102593. createInnerBlocks(): void;
  102594. /**
  102595. * @hidden
  102596. */
  102597. 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;
  102598. }
  102599. }
  102600. declare module BABYLON {
  102601. /**
  102602. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  102603. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102604. */
  102605. export class Octree<T> {
  102606. /** 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.) */
  102607. maxDepth: number;
  102608. /**
  102609. * Blocks within the octree containing objects
  102610. */
  102611. blocks: Array<OctreeBlock<T>>;
  102612. /**
  102613. * Content stored in the octree
  102614. */
  102615. dynamicContent: T[];
  102616. private _maxBlockCapacity;
  102617. private _selectionContent;
  102618. private _creationFunc;
  102619. /**
  102620. * Creates a octree
  102621. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102622. * @param creationFunc function to be used to instatiate the octree
  102623. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  102624. * @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.)
  102625. */
  102626. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  102627. /** 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.) */
  102628. maxDepth?: number);
  102629. /**
  102630. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  102631. * @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);
  102632. * @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);
  102633. * @param entries meshes to be added to the octree blocks
  102634. */
  102635. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  102636. /**
  102637. * Adds a mesh to the octree
  102638. * @param entry Mesh to add to the octree
  102639. */
  102640. addMesh(entry: T): void;
  102641. /**
  102642. * Remove an element from the octree
  102643. * @param entry defines the element to remove
  102644. */
  102645. removeMesh(entry: T): void;
  102646. /**
  102647. * Selects an array of meshes within the frustum
  102648. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  102649. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  102650. * @returns array of meshes within the frustum
  102651. */
  102652. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  102653. /**
  102654. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  102655. * @param sphereCenter defines the bounding sphere center
  102656. * @param sphereRadius defines the bounding sphere radius
  102657. * @param allowDuplicate defines if the selection array can contains duplicated entries
  102658. * @returns an array of objects that intersect the sphere
  102659. */
  102660. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  102661. /**
  102662. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  102663. * @param ray defines the ray to test with
  102664. * @returns array of intersected objects
  102665. */
  102666. intersectsRay(ray: Ray): SmartArray<T>;
  102667. /**
  102668. * Adds a mesh into the octree block if it intersects the block
  102669. */
  102670. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  102671. /**
  102672. * Adds a submesh into the octree block if it intersects the block
  102673. */
  102674. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  102675. }
  102676. }
  102677. declare module BABYLON {
  102678. interface Scene {
  102679. /**
  102680. * @hidden
  102681. * Backing Filed
  102682. */
  102683. _selectionOctree: Octree<AbstractMesh>;
  102684. /**
  102685. * Gets the octree used to boost mesh selection (picking)
  102686. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102687. */
  102688. selectionOctree: Octree<AbstractMesh>;
  102689. /**
  102690. * Creates or updates the octree used to boost selection (picking)
  102691. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102692. * @param maxCapacity defines the maximum capacity per leaf
  102693. * @param maxDepth defines the maximum depth of the octree
  102694. * @returns an octree of AbstractMesh
  102695. */
  102696. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  102697. }
  102698. interface AbstractMesh {
  102699. /**
  102700. * @hidden
  102701. * Backing Field
  102702. */
  102703. _submeshesOctree: Octree<SubMesh>;
  102704. /**
  102705. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  102706. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  102707. * @param maxCapacity defines the maximum size of each block (64 by default)
  102708. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  102709. * @returns the new octree
  102710. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  102711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  102712. */
  102713. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  102714. }
  102715. /**
  102716. * Defines the octree scene component responsible to manage any octrees
  102717. * in a given scene.
  102718. */
  102719. export class OctreeSceneComponent {
  102720. /**
  102721. * The component name help to identify the component in the list of scene components.
  102722. */
  102723. readonly name: string;
  102724. /**
  102725. * The scene the component belongs to.
  102726. */
  102727. scene: Scene;
  102728. /**
  102729. * Indicates if the meshes have been checked to make sure they are isEnabled()
  102730. */
  102731. readonly checksIsEnabled: boolean;
  102732. /**
  102733. * Creates a new instance of the component for the given scene
  102734. * @param scene Defines the scene to register the component in
  102735. */
  102736. constructor(scene: Scene);
  102737. /**
  102738. * Registers the component in a given scene
  102739. */
  102740. register(): void;
  102741. /**
  102742. * Return the list of active meshes
  102743. * @returns the list of active meshes
  102744. */
  102745. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  102746. /**
  102747. * Return the list of active sub meshes
  102748. * @param mesh The mesh to get the candidates sub meshes from
  102749. * @returns the list of active sub meshes
  102750. */
  102751. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  102752. private _tempRay;
  102753. /**
  102754. * Return the list of sub meshes intersecting with a given local ray
  102755. * @param mesh defines the mesh to find the submesh for
  102756. * @param localRay defines the ray in local space
  102757. * @returns the list of intersecting sub meshes
  102758. */
  102759. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  102760. /**
  102761. * Return the list of sub meshes colliding with a collider
  102762. * @param mesh defines the mesh to find the submesh for
  102763. * @param collider defines the collider to evaluate the collision against
  102764. * @returns the list of colliding sub meshes
  102765. */
  102766. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  102767. /**
  102768. * Rebuilds the elements related to this component in case of
  102769. * context lost for instance.
  102770. */
  102771. rebuild(): void;
  102772. /**
  102773. * Disposes the component and the associated ressources.
  102774. */
  102775. dispose(): void;
  102776. }
  102777. }
  102778. declare module BABYLON {
  102779. /**
  102780. * Renders a layer on top of an existing scene
  102781. */
  102782. export class UtilityLayerRenderer implements IDisposable {
  102783. /** the original scene that will be rendered on top of */
  102784. originalScene: Scene;
  102785. private _pointerCaptures;
  102786. private _lastPointerEvents;
  102787. private static _DefaultUtilityLayer;
  102788. private static _DefaultKeepDepthUtilityLayer;
  102789. private _sharedGizmoLight;
  102790. /**
  102791. * @hidden
  102792. * Light which used by gizmos to get light shading
  102793. */
  102794. _getSharedGizmoLight(): HemisphericLight;
  102795. /**
  102796. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  102797. */
  102798. pickUtilitySceneFirst: boolean;
  102799. /**
  102800. * 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)
  102801. */
  102802. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  102803. /**
  102804. * 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)
  102805. */
  102806. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  102807. /**
  102808. * The scene that is rendered on top of the original scene
  102809. */
  102810. utilityLayerScene: Scene;
  102811. /**
  102812. * If the utility layer should automatically be rendered on top of existing scene
  102813. */
  102814. shouldRender: boolean;
  102815. /**
  102816. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  102817. */
  102818. onlyCheckPointerDownEvents: boolean;
  102819. /**
  102820. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  102821. */
  102822. processAllEvents: boolean;
  102823. /**
  102824. * Observable raised when the pointer move from the utility layer scene to the main scene
  102825. */
  102826. onPointerOutObservable: Observable<number>;
  102827. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  102828. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  102829. private _afterRenderObserver;
  102830. private _sceneDisposeObserver;
  102831. private _originalPointerObserver;
  102832. /**
  102833. * Instantiates a UtilityLayerRenderer
  102834. * @param originalScene the original scene that will be rendered on top of
  102835. * @param handleEvents boolean indicating if the utility layer should handle events
  102836. */
  102837. constructor(
  102838. /** the original scene that will be rendered on top of */
  102839. originalScene: Scene, handleEvents?: boolean);
  102840. private _notifyObservers;
  102841. /**
  102842. * Renders the utility layers scene on top of the original scene
  102843. */
  102844. render(): void;
  102845. /**
  102846. * Disposes of the renderer
  102847. */
  102848. dispose(): void;
  102849. private _updateCamera;
  102850. }
  102851. }
  102852. declare module BABYLON {
  102853. /**
  102854. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  102855. */
  102856. export class Gizmo implements IDisposable {
  102857. /** The utility layer the gizmo will be added to */
  102858. gizmoLayer: UtilityLayerRenderer;
  102859. /**
  102860. * The root mesh of the gizmo
  102861. */
  102862. _rootMesh: Mesh;
  102863. private _attachedMesh;
  102864. /**
  102865. * Ratio for the scale of the gizmo (Default: 1)
  102866. */
  102867. scaleRatio: number;
  102868. /**
  102869. * If a custom mesh has been set (Default: false)
  102870. */
  102871. protected _customMeshSet: boolean;
  102872. /**
  102873. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  102874. * * When set, interactions will be enabled
  102875. */
  102876. attachedMesh: Nullable<AbstractMesh>;
  102877. /**
  102878. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  102879. * @param mesh The mesh to replace the default mesh of the gizmo
  102880. */
  102881. setCustomMesh(mesh: Mesh): void;
  102882. /**
  102883. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  102884. */
  102885. updateGizmoRotationToMatchAttachedMesh: boolean;
  102886. /**
  102887. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  102888. */
  102889. updateGizmoPositionToMatchAttachedMesh: boolean;
  102890. /**
  102891. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  102892. */
  102893. protected _updateScale: boolean;
  102894. protected _interactionsEnabled: boolean;
  102895. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102896. private _beforeRenderObserver;
  102897. private _tempVector;
  102898. /**
  102899. * Creates a gizmo
  102900. * @param gizmoLayer The utility layer the gizmo will be added to
  102901. */
  102902. constructor(
  102903. /** The utility layer the gizmo will be added to */
  102904. gizmoLayer?: UtilityLayerRenderer);
  102905. /**
  102906. * Updates the gizmo to match the attached mesh's position/rotation
  102907. */
  102908. protected _update(): void;
  102909. /**
  102910. * Disposes of the gizmo
  102911. */
  102912. dispose(): void;
  102913. }
  102914. }
  102915. declare module BABYLON {
  102916. /**
  102917. * Single plane drag gizmo
  102918. */
  102919. export class PlaneDragGizmo extends Gizmo {
  102920. /**
  102921. * Drag behavior responsible for the gizmos dragging interactions
  102922. */
  102923. dragBehavior: PointerDragBehavior;
  102924. private _pointerObserver;
  102925. /**
  102926. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102927. */
  102928. snapDistance: number;
  102929. /**
  102930. * Event that fires each time the gizmo snaps to a new location.
  102931. * * snapDistance is the the change in distance
  102932. */
  102933. onSnapObservable: Observable<{
  102934. snapDistance: number;
  102935. }>;
  102936. private _plane;
  102937. private _coloredMaterial;
  102938. private _hoverMaterial;
  102939. private _isEnabled;
  102940. private _parent;
  102941. /** @hidden */
  102942. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  102943. /** @hidden */
  102944. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  102945. /**
  102946. * Creates a PlaneDragGizmo
  102947. * @param gizmoLayer The utility layer the gizmo will be added to
  102948. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  102949. * @param color The color of the gizmo
  102950. */
  102951. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  102952. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  102953. /**
  102954. * If the gizmo is enabled
  102955. */
  102956. isEnabled: boolean;
  102957. /**
  102958. * Disposes of the gizmo
  102959. */
  102960. dispose(): void;
  102961. }
  102962. }
  102963. declare module BABYLON {
  102964. /**
  102965. * Gizmo that enables dragging a mesh along 3 axis
  102966. */
  102967. export class PositionGizmo extends Gizmo {
  102968. /**
  102969. * Internal gizmo used for interactions on the x axis
  102970. */
  102971. xGizmo: AxisDragGizmo;
  102972. /**
  102973. * Internal gizmo used for interactions on the y axis
  102974. */
  102975. yGizmo: AxisDragGizmo;
  102976. /**
  102977. * Internal gizmo used for interactions on the z axis
  102978. */
  102979. zGizmo: AxisDragGizmo;
  102980. /**
  102981. * Internal gizmo used for interactions on the yz plane
  102982. */
  102983. xPlaneGizmo: PlaneDragGizmo;
  102984. /**
  102985. * Internal gizmo used for interactions on the xz plane
  102986. */
  102987. yPlaneGizmo: PlaneDragGizmo;
  102988. /**
  102989. * Internal gizmo used for interactions on the xy plane
  102990. */
  102991. zPlaneGizmo: PlaneDragGizmo;
  102992. /**
  102993. * private variables
  102994. */
  102995. private _meshAttached;
  102996. private _updateGizmoRotationToMatchAttachedMesh;
  102997. private _snapDistance;
  102998. private _scaleRatio;
  102999. /** Fires an event when any of it's sub gizmos are dragged */
  103000. onDragStartObservable: Observable<{}>;
  103001. /** Fires an event when any of it's sub gizmos are released from dragging */
  103002. onDragEndObservable: Observable<{}>;
  103003. /**
  103004. * If set to true, planar drag is enabled
  103005. */
  103006. private _planarGizmoEnabled;
  103007. attachedMesh: Nullable<AbstractMesh>;
  103008. /**
  103009. * Creates a PositionGizmo
  103010. * @param gizmoLayer The utility layer the gizmo will be added to
  103011. */
  103012. constructor(gizmoLayer?: UtilityLayerRenderer);
  103013. /**
  103014. * If the planar drag gizmo is enabled
  103015. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  103016. */
  103017. planarGizmoEnabled: boolean;
  103018. updateGizmoRotationToMatchAttachedMesh: boolean;
  103019. /**
  103020. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103021. */
  103022. snapDistance: number;
  103023. /**
  103024. * Ratio for the scale of the gizmo (Default: 1)
  103025. */
  103026. scaleRatio: number;
  103027. /**
  103028. * Disposes of the gizmo
  103029. */
  103030. dispose(): void;
  103031. /**
  103032. * CustomMeshes are not supported by this gizmo
  103033. * @param mesh The mesh to replace the default mesh of the gizmo
  103034. */
  103035. setCustomMesh(mesh: Mesh): void;
  103036. }
  103037. }
  103038. declare module BABYLON {
  103039. /**
  103040. * Single axis drag gizmo
  103041. */
  103042. export class AxisDragGizmo extends Gizmo {
  103043. /**
  103044. * Drag behavior responsible for the gizmos dragging interactions
  103045. */
  103046. dragBehavior: PointerDragBehavior;
  103047. private _pointerObserver;
  103048. /**
  103049. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  103050. */
  103051. snapDistance: number;
  103052. /**
  103053. * Event that fires each time the gizmo snaps to a new location.
  103054. * * snapDistance is the the change in distance
  103055. */
  103056. onSnapObservable: Observable<{
  103057. snapDistance: number;
  103058. }>;
  103059. private _isEnabled;
  103060. private _parent;
  103061. private _arrow;
  103062. private _coloredMaterial;
  103063. private _hoverMaterial;
  103064. /** @hidden */
  103065. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  103066. /** @hidden */
  103067. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  103068. /**
  103069. * Creates an AxisDragGizmo
  103070. * @param gizmoLayer The utility layer the gizmo will be added to
  103071. * @param dragAxis The axis which the gizmo will be able to drag on
  103072. * @param color The color of the gizmo
  103073. */
  103074. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  103075. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  103076. /**
  103077. * If the gizmo is enabled
  103078. */
  103079. isEnabled: boolean;
  103080. /**
  103081. * Disposes of the gizmo
  103082. */
  103083. dispose(): void;
  103084. }
  103085. }
  103086. declare module BABYLON.Debug {
  103087. /**
  103088. * The Axes viewer will show 3 axes in a specific point in space
  103089. */
  103090. export class AxesViewer {
  103091. private _xAxis;
  103092. private _yAxis;
  103093. private _zAxis;
  103094. private _scaleLinesFactor;
  103095. private _instanced;
  103096. /**
  103097. * Gets the hosting scene
  103098. */
  103099. scene: Scene;
  103100. /**
  103101. * Gets or sets a number used to scale line length
  103102. */
  103103. scaleLines: number;
  103104. /** Gets the node hierarchy used to render x-axis */
  103105. readonly xAxis: TransformNode;
  103106. /** Gets the node hierarchy used to render y-axis */
  103107. readonly yAxis: TransformNode;
  103108. /** Gets the node hierarchy used to render z-axis */
  103109. readonly zAxis: TransformNode;
  103110. /**
  103111. * Creates a new AxesViewer
  103112. * @param scene defines the hosting scene
  103113. * @param scaleLines defines a number used to scale line length (1 by default)
  103114. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  103115. * @param xAxis defines the node hierarchy used to render the x-axis
  103116. * @param yAxis defines the node hierarchy used to render the y-axis
  103117. * @param zAxis defines the node hierarchy used to render the z-axis
  103118. */
  103119. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  103120. /**
  103121. * Force the viewer to update
  103122. * @param position defines the position of the viewer
  103123. * @param xaxis defines the x axis of the viewer
  103124. * @param yaxis defines the y axis of the viewer
  103125. * @param zaxis defines the z axis of the viewer
  103126. */
  103127. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  103128. /**
  103129. * Creates an instance of this axes viewer.
  103130. * @returns a new axes viewer with instanced meshes
  103131. */
  103132. createInstance(): AxesViewer;
  103133. /** Releases resources */
  103134. dispose(): void;
  103135. private static _SetRenderingGroupId;
  103136. }
  103137. }
  103138. declare module BABYLON.Debug {
  103139. /**
  103140. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  103141. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  103142. */
  103143. export class BoneAxesViewer extends AxesViewer {
  103144. /**
  103145. * Gets or sets the target mesh where to display the axes viewer
  103146. */
  103147. mesh: Nullable<Mesh>;
  103148. /**
  103149. * Gets or sets the target bone where to display the axes viewer
  103150. */
  103151. bone: Nullable<Bone>;
  103152. /** Gets current position */
  103153. pos: Vector3;
  103154. /** Gets direction of X axis */
  103155. xaxis: Vector3;
  103156. /** Gets direction of Y axis */
  103157. yaxis: Vector3;
  103158. /** Gets direction of Z axis */
  103159. zaxis: Vector3;
  103160. /**
  103161. * Creates a new BoneAxesViewer
  103162. * @param scene defines the hosting scene
  103163. * @param bone defines the target bone
  103164. * @param mesh defines the target mesh
  103165. * @param scaleLines defines a scaling factor for line length (1 by default)
  103166. */
  103167. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  103168. /**
  103169. * Force the viewer to update
  103170. */
  103171. update(): void;
  103172. /** Releases resources */
  103173. dispose(): void;
  103174. }
  103175. }
  103176. declare module BABYLON {
  103177. /**
  103178. * Interface used to define scene explorer extensibility option
  103179. */
  103180. export interface IExplorerExtensibilityOption {
  103181. /**
  103182. * Define the option label
  103183. */
  103184. label: string;
  103185. /**
  103186. * Defines the action to execute on click
  103187. */
  103188. action: (entity: any) => void;
  103189. }
  103190. /**
  103191. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  103192. */
  103193. export interface IExplorerExtensibilityGroup {
  103194. /**
  103195. * Defines a predicate to test if a given type mut be extended
  103196. */
  103197. predicate: (entity: any) => boolean;
  103198. /**
  103199. * Gets the list of options added to a type
  103200. */
  103201. entries: IExplorerExtensibilityOption[];
  103202. }
  103203. /**
  103204. * Interface used to define the options to use to create the Inspector
  103205. */
  103206. export interface IInspectorOptions {
  103207. /**
  103208. * Display in overlay mode (default: false)
  103209. */
  103210. overlay?: boolean;
  103211. /**
  103212. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  103213. */
  103214. globalRoot?: HTMLElement;
  103215. /**
  103216. * Display the Scene explorer
  103217. */
  103218. showExplorer?: boolean;
  103219. /**
  103220. * Display the property inspector
  103221. */
  103222. showInspector?: boolean;
  103223. /**
  103224. * Display in embed mode (both panes on the right)
  103225. */
  103226. embedMode?: boolean;
  103227. /**
  103228. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  103229. */
  103230. handleResize?: boolean;
  103231. /**
  103232. * Allow the panes to popup (default: true)
  103233. */
  103234. enablePopup?: boolean;
  103235. /**
  103236. * Allow the panes to be closed by users (default: true)
  103237. */
  103238. enableClose?: boolean;
  103239. /**
  103240. * Optional list of extensibility entries
  103241. */
  103242. explorerExtensibility?: IExplorerExtensibilityGroup[];
  103243. /**
  103244. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  103245. */
  103246. inspectorURL?: string;
  103247. }
  103248. interface Scene {
  103249. /**
  103250. * @hidden
  103251. * Backing field
  103252. */
  103253. _debugLayer: DebugLayer;
  103254. /**
  103255. * Gets the debug layer (aka Inspector) associated with the scene
  103256. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103257. */
  103258. debugLayer: DebugLayer;
  103259. }
  103260. /**
  103261. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103262. * what is happening in your scene
  103263. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103264. */
  103265. export class DebugLayer {
  103266. /**
  103267. * Define the url to get the inspector script from.
  103268. * By default it uses the babylonjs CDN.
  103269. * @ignoreNaming
  103270. */
  103271. static InspectorURL: string;
  103272. private _scene;
  103273. private BJSINSPECTOR;
  103274. /**
  103275. * Observable triggered when a property is changed through the inspector.
  103276. */
  103277. onPropertyChangedObservable: Observable<{
  103278. object: any;
  103279. property: string;
  103280. value: any;
  103281. initialValue: any;
  103282. }>;
  103283. /**
  103284. * Instantiates a new debug layer.
  103285. * The debug layer (aka Inspector) is the go to tool in order to better understand
  103286. * what is happening in your scene
  103287. * @see http://doc.babylonjs.com/features/playground_debuglayer
  103288. * @param scene Defines the scene to inspect
  103289. */
  103290. constructor(scene: Scene);
  103291. /** Creates the inspector window. */
  103292. private _createInspector;
  103293. /**
  103294. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  103295. * @param entity defines the entity to select
  103296. * @param lineContainerTitle defines the specific block to highlight
  103297. */
  103298. select(entity: any, lineContainerTitle?: string): void;
  103299. /** Get the inspector from bundle or global */
  103300. private _getGlobalInspector;
  103301. /**
  103302. * Get if the inspector is visible or not.
  103303. * @returns true if visible otherwise, false
  103304. */
  103305. isVisible(): boolean;
  103306. /**
  103307. * Hide the inspector and close its window.
  103308. */
  103309. hide(): void;
  103310. /**
  103311. * Launch the debugLayer.
  103312. * @param config Define the configuration of the inspector
  103313. * @return a promise fulfilled when the debug layer is visible
  103314. */
  103315. show(config?: IInspectorOptions): Promise<DebugLayer>;
  103316. }
  103317. }
  103318. declare module BABYLON {
  103319. /**
  103320. * Class containing static functions to help procedurally build meshes
  103321. */
  103322. export class BoxBuilder {
  103323. /**
  103324. * Creates a box mesh
  103325. * * The parameter `size` sets the size (float) of each box side (default 1)
  103326. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  103327. * * 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)
  103328. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  103329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103332. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  103333. * @param name defines the name of the mesh
  103334. * @param options defines the options used to create the mesh
  103335. * @param scene defines the hosting scene
  103336. * @returns the box mesh
  103337. */
  103338. static CreateBox(name: string, options: {
  103339. size?: number;
  103340. width?: number;
  103341. height?: number;
  103342. depth?: number;
  103343. faceUV?: Vector4[];
  103344. faceColors?: Color4[];
  103345. sideOrientation?: number;
  103346. frontUVs?: Vector4;
  103347. backUVs?: Vector4;
  103348. wrap?: boolean;
  103349. topBaseAt?: number;
  103350. bottomBaseAt?: number;
  103351. updatable?: boolean;
  103352. }, scene?: Nullable<Scene>): Mesh;
  103353. }
  103354. }
  103355. declare module BABYLON {
  103356. /**
  103357. * Class containing static functions to help procedurally build meshes
  103358. */
  103359. export class SphereBuilder {
  103360. /**
  103361. * Creates a sphere mesh
  103362. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  103363. * * 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`)
  103364. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  103365. * * 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
  103366. * * 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)
  103367. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103368. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103369. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103370. * @param name defines the name of the mesh
  103371. * @param options defines the options used to create the mesh
  103372. * @param scene defines the hosting scene
  103373. * @returns the sphere mesh
  103374. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  103375. */
  103376. static CreateSphere(name: string, options: {
  103377. segments?: number;
  103378. diameter?: number;
  103379. diameterX?: number;
  103380. diameterY?: number;
  103381. diameterZ?: number;
  103382. arc?: number;
  103383. slice?: number;
  103384. sideOrientation?: number;
  103385. frontUVs?: Vector4;
  103386. backUVs?: Vector4;
  103387. updatable?: boolean;
  103388. }, scene: any): Mesh;
  103389. }
  103390. }
  103391. declare module BABYLON.Debug {
  103392. /**
  103393. * Used to show the physics impostor around the specific mesh
  103394. */
  103395. export class PhysicsViewer {
  103396. /** @hidden */
  103397. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  103398. /** @hidden */
  103399. protected _meshes: Array<Nullable<AbstractMesh>>;
  103400. /** @hidden */
  103401. protected _scene: Nullable<Scene>;
  103402. /** @hidden */
  103403. protected _numMeshes: number;
  103404. /** @hidden */
  103405. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  103406. private _renderFunction;
  103407. private _utilityLayer;
  103408. private _debugBoxMesh;
  103409. private _debugSphereMesh;
  103410. private _debugCylinderMesh;
  103411. private _debugMaterial;
  103412. private _debugMeshMeshes;
  103413. /**
  103414. * Creates a new PhysicsViewer
  103415. * @param scene defines the hosting scene
  103416. */
  103417. constructor(scene: Scene);
  103418. /** @hidden */
  103419. protected _updateDebugMeshes(): void;
  103420. /**
  103421. * Renders a specified physic impostor
  103422. * @param impostor defines the impostor to render
  103423. * @param targetMesh defines the mesh represented by the impostor
  103424. * @returns the new debug mesh used to render the impostor
  103425. */
  103426. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  103427. /**
  103428. * Hides a specified physic impostor
  103429. * @param impostor defines the impostor to hide
  103430. */
  103431. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  103432. private _getDebugMaterial;
  103433. private _getDebugBoxMesh;
  103434. private _getDebugSphereMesh;
  103435. private _getDebugCylinderMesh;
  103436. private _getDebugMeshMesh;
  103437. private _getDebugMesh;
  103438. /** Releases all resources */
  103439. dispose(): void;
  103440. }
  103441. }
  103442. declare module BABYLON {
  103443. /**
  103444. * Class containing static functions to help procedurally build meshes
  103445. */
  103446. export class LinesBuilder {
  103447. /**
  103448. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  103449. * * 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
  103450. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  103451. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  103452. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  103453. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  103454. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  103455. * * 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
  103456. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  103457. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103458. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  103459. * @param name defines the name of the new line system
  103460. * @param options defines the options used to create the line system
  103461. * @param scene defines the hosting scene
  103462. * @returns a new line system mesh
  103463. */
  103464. static CreateLineSystem(name: string, options: {
  103465. lines: Vector3[][];
  103466. updatable?: boolean;
  103467. instance?: Nullable<LinesMesh>;
  103468. colors?: Nullable<Color4[][]>;
  103469. useVertexAlpha?: boolean;
  103470. }, scene: Nullable<Scene>): LinesMesh;
  103471. /**
  103472. * Creates a line mesh
  103473. * 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
  103474. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103475. * * The parameter `points` is an array successive Vector3
  103476. * * 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
  103477. * * The optional parameter `colors` is an array of successive Color4, one per line point
  103478. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  103479. * * When updating an instance, remember that only point positions can change, not the number of points
  103480. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103481. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  103482. * @param name defines the name of the new line system
  103483. * @param options defines the options used to create the line system
  103484. * @param scene defines the hosting scene
  103485. * @returns a new line mesh
  103486. */
  103487. static CreateLines(name: string, options: {
  103488. points: Vector3[];
  103489. updatable?: boolean;
  103490. instance?: Nullable<LinesMesh>;
  103491. colors?: Color4[];
  103492. useVertexAlpha?: boolean;
  103493. }, scene?: Nullable<Scene>): LinesMesh;
  103494. /**
  103495. * Creates a dashed line mesh
  103496. * * 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
  103497. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  103498. * * The parameter `points` is an array successive Vector3
  103499. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  103500. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  103501. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  103502. * * 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
  103503. * * When updating an instance, remember that only point positions can change, not the number of points
  103504. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103505. * @param name defines the name of the mesh
  103506. * @param options defines the options used to create the mesh
  103507. * @param scene defines the hosting scene
  103508. * @returns the dashed line mesh
  103509. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  103510. */
  103511. static CreateDashedLines(name: string, options: {
  103512. points: Vector3[];
  103513. dashSize?: number;
  103514. gapSize?: number;
  103515. dashNb?: number;
  103516. updatable?: boolean;
  103517. instance?: LinesMesh;
  103518. }, scene?: Nullable<Scene>): LinesMesh;
  103519. }
  103520. }
  103521. declare module BABYLON {
  103522. /**
  103523. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  103524. * in order to better appreciate the issue one might have.
  103525. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  103526. */
  103527. export class RayHelper {
  103528. /**
  103529. * Defines the ray we are currently tryin to visualize.
  103530. */
  103531. ray: Nullable<Ray>;
  103532. private _renderPoints;
  103533. private _renderLine;
  103534. private _renderFunction;
  103535. private _scene;
  103536. private _updateToMeshFunction;
  103537. private _attachedToMesh;
  103538. private _meshSpaceDirection;
  103539. private _meshSpaceOrigin;
  103540. /**
  103541. * Helper function to create a colored helper in a scene in one line.
  103542. * @param ray Defines the ray we are currently tryin to visualize
  103543. * @param scene Defines the scene the ray is used in
  103544. * @param color Defines the color we want to see the ray in
  103545. * @returns The newly created ray helper.
  103546. */
  103547. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  103548. /**
  103549. * Instantiate a new ray helper.
  103550. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  103551. * in order to better appreciate the issue one might have.
  103552. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  103553. * @param ray Defines the ray we are currently tryin to visualize
  103554. */
  103555. constructor(ray: Ray);
  103556. /**
  103557. * Shows the ray we are willing to debug.
  103558. * @param scene Defines the scene the ray needs to be rendered in
  103559. * @param color Defines the color the ray needs to be rendered in
  103560. */
  103561. show(scene: Scene, color?: Color3): void;
  103562. /**
  103563. * Hides the ray we are debugging.
  103564. */
  103565. hide(): void;
  103566. private _render;
  103567. /**
  103568. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  103569. * @param mesh Defines the mesh we want the helper attached to
  103570. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  103571. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  103572. * @param length Defines the length of the ray
  103573. */
  103574. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  103575. /**
  103576. * Detach the ray helper from the mesh it has previously been attached to.
  103577. */
  103578. detachFromMesh(): void;
  103579. private _updateToMesh;
  103580. /**
  103581. * Dispose the helper and release its associated resources.
  103582. */
  103583. dispose(): void;
  103584. }
  103585. }
  103586. declare module BABYLON.Debug {
  103587. /**
  103588. * Class used to render a debug view of a given skeleton
  103589. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  103590. */
  103591. export class SkeletonViewer {
  103592. /** defines the skeleton to render */
  103593. skeleton: Skeleton;
  103594. /** defines the mesh attached to the skeleton */
  103595. mesh: AbstractMesh;
  103596. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  103597. autoUpdateBonesMatrices: boolean;
  103598. /** defines the rendering group id to use with the viewer */
  103599. renderingGroupId: number;
  103600. /** Gets or sets the color used to render the skeleton */
  103601. color: Color3;
  103602. private _scene;
  103603. private _debugLines;
  103604. private _debugMesh;
  103605. private _isEnabled;
  103606. private _renderFunction;
  103607. private _utilityLayer;
  103608. /**
  103609. * Returns the mesh used to render the bones
  103610. */
  103611. readonly debugMesh: Nullable<LinesMesh>;
  103612. /**
  103613. * Creates a new SkeletonViewer
  103614. * @param skeleton defines the skeleton to render
  103615. * @param mesh defines the mesh attached to the skeleton
  103616. * @param scene defines the hosting scene
  103617. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  103618. * @param renderingGroupId defines the rendering group id to use with the viewer
  103619. */
  103620. constructor(
  103621. /** defines the skeleton to render */
  103622. skeleton: Skeleton,
  103623. /** defines the mesh attached to the skeleton */
  103624. mesh: AbstractMesh, scene: Scene,
  103625. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  103626. autoUpdateBonesMatrices?: boolean,
  103627. /** defines the rendering group id to use with the viewer */
  103628. renderingGroupId?: number);
  103629. /** Gets or sets a boolean indicating if the viewer is enabled */
  103630. isEnabled: boolean;
  103631. private _getBonePosition;
  103632. private _getLinesForBonesWithLength;
  103633. private _getLinesForBonesNoLength;
  103634. /** Update the viewer to sync with current skeleton state */
  103635. update(): void;
  103636. /** Release associated resources */
  103637. dispose(): void;
  103638. }
  103639. }
  103640. declare module BABYLON {
  103641. /**
  103642. * Options to create the null engine
  103643. */
  103644. export class NullEngineOptions {
  103645. /**
  103646. * Render width (Default: 512)
  103647. */
  103648. renderWidth: number;
  103649. /**
  103650. * Render height (Default: 256)
  103651. */
  103652. renderHeight: number;
  103653. /**
  103654. * Texture size (Default: 512)
  103655. */
  103656. textureSize: number;
  103657. /**
  103658. * If delta time between frames should be constant
  103659. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103660. */
  103661. deterministicLockstep: boolean;
  103662. /**
  103663. * Maximum about of steps between frames (Default: 4)
  103664. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103665. */
  103666. lockstepMaxSteps: number;
  103667. }
  103668. /**
  103669. * The null engine class provides support for headless version of babylon.js.
  103670. * This can be used in server side scenario or for testing purposes
  103671. */
  103672. export class NullEngine extends Engine {
  103673. private _options;
  103674. /**
  103675. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  103676. */
  103677. isDeterministicLockStep(): boolean;
  103678. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  103679. getLockstepMaxSteps(): number;
  103680. /**
  103681. * Sets hardware scaling, used to save performance if needed
  103682. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  103683. */
  103684. getHardwareScalingLevel(): number;
  103685. constructor(options?: NullEngineOptions);
  103686. createVertexBuffer(vertices: FloatArray): DataBuffer;
  103687. createIndexBuffer(indices: IndicesArray): DataBuffer;
  103688. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  103689. getRenderWidth(useScreen?: boolean): number;
  103690. getRenderHeight(useScreen?: boolean): number;
  103691. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  103692. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  103693. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  103694. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  103695. bindSamplers(effect: Effect): void;
  103696. enableEffect(effect: Effect): void;
  103697. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  103698. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  103699. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  103700. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  103701. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  103702. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  103703. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  103704. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  103705. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  103706. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  103707. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  103708. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  103709. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  103710. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  103711. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  103712. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  103713. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  103714. setFloat(uniform: WebGLUniformLocation, value: number): void;
  103715. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  103716. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  103717. setBool(uniform: WebGLUniformLocation, bool: number): void;
  103718. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  103719. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  103720. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  103721. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  103722. bindBuffers(vertexBuffers: {
  103723. [key: string]: VertexBuffer;
  103724. }, indexBuffer: DataBuffer, effect: Effect): void;
  103725. wipeCaches(bruteForce?: boolean): void;
  103726. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  103727. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  103728. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  103729. /** @hidden */
  103730. _createTexture(): WebGLTexture;
  103731. /** @hidden */
  103732. _releaseTexture(texture: InternalTexture): void;
  103733. 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;
  103734. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  103735. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  103736. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  103737. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  103738. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  103739. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  103740. areAllEffectsReady(): boolean;
  103741. /**
  103742. * @hidden
  103743. * Get the current error code of the webGL context
  103744. * @returns the error code
  103745. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  103746. */
  103747. getError(): number;
  103748. /** @hidden */
  103749. _getUnpackAlignement(): number;
  103750. /** @hidden */
  103751. _unpackFlipY(value: boolean): void;
  103752. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  103753. /**
  103754. * Updates a dynamic vertex buffer.
  103755. * @param vertexBuffer the vertex buffer to update
  103756. * @param data the data used to update the vertex buffer
  103757. * @param byteOffset the byte offset of the data (optional)
  103758. * @param byteLength the byte length of the data (optional)
  103759. */
  103760. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  103761. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  103762. /** @hidden */
  103763. _bindTexture(channel: number, texture: InternalTexture): void;
  103764. /** @hidden */
  103765. _releaseBuffer(buffer: DataBuffer): boolean;
  103766. releaseEffects(): void;
  103767. displayLoadingUI(): void;
  103768. hideLoadingUI(): void;
  103769. /** @hidden */
  103770. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103771. /** @hidden */
  103772. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103773. /** @hidden */
  103774. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  103775. /** @hidden */
  103776. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  103777. }
  103778. }
  103779. declare module BABYLON {
  103780. /** @hidden */
  103781. export class _OcclusionDataStorage {
  103782. /** @hidden */
  103783. occlusionInternalRetryCounter: number;
  103784. /** @hidden */
  103785. isOcclusionQueryInProgress: boolean;
  103786. /** @hidden */
  103787. isOccluded: boolean;
  103788. /** @hidden */
  103789. occlusionRetryCount: number;
  103790. /** @hidden */
  103791. occlusionType: number;
  103792. /** @hidden */
  103793. occlusionQueryAlgorithmType: number;
  103794. }
  103795. interface Engine {
  103796. /**
  103797. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  103798. * @return the new query
  103799. */
  103800. createQuery(): WebGLQuery;
  103801. /**
  103802. * Delete and release a webGL query
  103803. * @param query defines the query to delete
  103804. * @return the current engine
  103805. */
  103806. deleteQuery(query: WebGLQuery): Engine;
  103807. /**
  103808. * Check if a given query has resolved and got its value
  103809. * @param query defines the query to check
  103810. * @returns true if the query got its value
  103811. */
  103812. isQueryResultAvailable(query: WebGLQuery): boolean;
  103813. /**
  103814. * Gets the value of a given query
  103815. * @param query defines the query to check
  103816. * @returns the value of the query
  103817. */
  103818. getQueryResult(query: WebGLQuery): number;
  103819. /**
  103820. * Initiates an occlusion query
  103821. * @param algorithmType defines the algorithm to use
  103822. * @param query defines the query to use
  103823. * @returns the current engine
  103824. * @see http://doc.babylonjs.com/features/occlusionquery
  103825. */
  103826. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  103827. /**
  103828. * Ends an occlusion query
  103829. * @see http://doc.babylonjs.com/features/occlusionquery
  103830. * @param algorithmType defines the algorithm to use
  103831. * @returns the current engine
  103832. */
  103833. endOcclusionQuery(algorithmType: number): Engine;
  103834. /**
  103835. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  103836. * Please note that only one query can be issued at a time
  103837. * @returns a time token used to track the time span
  103838. */
  103839. startTimeQuery(): Nullable<_TimeToken>;
  103840. /**
  103841. * Ends a time query
  103842. * @param token defines the token used to measure the time span
  103843. * @returns the time spent (in ns)
  103844. */
  103845. endTimeQuery(token: _TimeToken): int;
  103846. /** @hidden */
  103847. _currentNonTimestampToken: Nullable<_TimeToken>;
  103848. /** @hidden */
  103849. _createTimeQuery(): WebGLQuery;
  103850. /** @hidden */
  103851. _deleteTimeQuery(query: WebGLQuery): void;
  103852. /** @hidden */
  103853. _getGlAlgorithmType(algorithmType: number): number;
  103854. /** @hidden */
  103855. _getTimeQueryResult(query: WebGLQuery): any;
  103856. /** @hidden */
  103857. _getTimeQueryAvailability(query: WebGLQuery): any;
  103858. }
  103859. interface AbstractMesh {
  103860. /**
  103861. * Backing filed
  103862. * @hidden
  103863. */
  103864. __occlusionDataStorage: _OcclusionDataStorage;
  103865. /**
  103866. * Access property
  103867. * @hidden
  103868. */
  103869. _occlusionDataStorage: _OcclusionDataStorage;
  103870. /**
  103871. * 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.
  103872. * The default value is -1 which means don't break the query and wait till the result
  103873. * @see http://doc.babylonjs.com/features/occlusionquery
  103874. */
  103875. occlusionRetryCount: number;
  103876. /**
  103877. * 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:
  103878. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  103879. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  103880. * * 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.
  103881. * @see http://doc.babylonjs.com/features/occlusionquery
  103882. */
  103883. occlusionType: number;
  103884. /**
  103885. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  103886. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  103887. * * 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.
  103888. * @see http://doc.babylonjs.com/features/occlusionquery
  103889. */
  103890. occlusionQueryAlgorithmType: number;
  103891. /**
  103892. * 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
  103893. * @see http://doc.babylonjs.com/features/occlusionquery
  103894. */
  103895. isOccluded: boolean;
  103896. /**
  103897. * Flag to check the progress status of the query
  103898. * @see http://doc.babylonjs.com/features/occlusionquery
  103899. */
  103900. isOcclusionQueryInProgress: boolean;
  103901. }
  103902. }
  103903. declare module BABYLON {
  103904. /** @hidden */
  103905. export var _forceTransformFeedbackToBundle: boolean;
  103906. interface Engine {
  103907. /**
  103908. * Creates a webGL transform feedback object
  103909. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  103910. * @returns the webGL transform feedback object
  103911. */
  103912. createTransformFeedback(): WebGLTransformFeedback;
  103913. /**
  103914. * Delete a webGL transform feedback object
  103915. * @param value defines the webGL transform feedback object to delete
  103916. */
  103917. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  103918. /**
  103919. * Bind a webGL transform feedback object to the webgl context
  103920. * @param value defines the webGL transform feedback object to bind
  103921. */
  103922. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  103923. /**
  103924. * Begins a transform feedback operation
  103925. * @param usePoints defines if points or triangles must be used
  103926. */
  103927. beginTransformFeedback(usePoints: boolean): void;
  103928. /**
  103929. * Ends a transform feedback operation
  103930. */
  103931. endTransformFeedback(): void;
  103932. /**
  103933. * Specify the varyings to use with transform feedback
  103934. * @param program defines the associated webGL program
  103935. * @param value defines the list of strings representing the varying names
  103936. */
  103937. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  103938. /**
  103939. * Bind a webGL buffer for a transform feedback operation
  103940. * @param value defines the webGL buffer to bind
  103941. */
  103942. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  103943. }
  103944. }
  103945. declare module BABYLON {
  103946. /**
  103947. * Creation options of the multi render target texture.
  103948. */
  103949. export interface IMultiRenderTargetOptions {
  103950. /**
  103951. * Define if the texture needs to create mip maps after render.
  103952. */
  103953. generateMipMaps?: boolean;
  103954. /**
  103955. * Define the types of all the draw buffers we want to create
  103956. */
  103957. types?: number[];
  103958. /**
  103959. * Define the sampling modes of all the draw buffers we want to create
  103960. */
  103961. samplingModes?: number[];
  103962. /**
  103963. * Define if a depth buffer is required
  103964. */
  103965. generateDepthBuffer?: boolean;
  103966. /**
  103967. * Define if a stencil buffer is required
  103968. */
  103969. generateStencilBuffer?: boolean;
  103970. /**
  103971. * Define if a depth texture is required instead of a depth buffer
  103972. */
  103973. generateDepthTexture?: boolean;
  103974. /**
  103975. * Define the number of desired draw buffers
  103976. */
  103977. textureCount?: number;
  103978. /**
  103979. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103980. */
  103981. doNotChangeAspectRatio?: boolean;
  103982. /**
  103983. * Define the default type of the buffers we are creating
  103984. */
  103985. defaultType?: number;
  103986. }
  103987. /**
  103988. * A multi render target, like a render target provides the ability to render to a texture.
  103989. * Unlike the render target, it can render to several draw buffers in one draw.
  103990. * This is specially interesting in deferred rendering or for any effects requiring more than
  103991. * just one color from a single pass.
  103992. */
  103993. export class MultiRenderTarget extends RenderTargetTexture {
  103994. private _internalTextures;
  103995. private _textures;
  103996. private _multiRenderTargetOptions;
  103997. /**
  103998. * Get if draw buffers are currently supported by the used hardware and browser.
  103999. */
  104000. readonly isSupported: boolean;
  104001. /**
  104002. * Get the list of textures generated by the multi render target.
  104003. */
  104004. readonly textures: Texture[];
  104005. /**
  104006. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  104007. */
  104008. readonly depthTexture: Texture;
  104009. /**
  104010. * Set the wrapping mode on U of all the textures we are rendering to.
  104011. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104012. */
  104013. wrapU: number;
  104014. /**
  104015. * Set the wrapping mode on V of all the textures we are rendering to.
  104016. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  104017. */
  104018. wrapV: number;
  104019. /**
  104020. * Instantiate a new multi render target texture.
  104021. * A multi render target, like a render target provides the ability to render to a texture.
  104022. * Unlike the render target, it can render to several draw buffers in one draw.
  104023. * This is specially interesting in deferred rendering or for any effects requiring more than
  104024. * just one color from a single pass.
  104025. * @param name Define the name of the texture
  104026. * @param size Define the size of the buffers to render to
  104027. * @param count Define the number of target we are rendering into
  104028. * @param scene Define the scene the texture belongs to
  104029. * @param options Define the options used to create the multi render target
  104030. */
  104031. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  104032. /** @hidden */
  104033. _rebuild(): void;
  104034. private _createInternalTextures;
  104035. private _createTextures;
  104036. /**
  104037. * Define the number of samples used if MSAA is enabled.
  104038. */
  104039. samples: number;
  104040. /**
  104041. * Resize all the textures in the multi render target.
  104042. * Be carrefull as it will recreate all the data in the new texture.
  104043. * @param size Define the new size
  104044. */
  104045. resize(size: any): void;
  104046. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104047. /**
  104048. * Dispose the render targets and their associated resources
  104049. */
  104050. dispose(): void;
  104051. /**
  104052. * Release all the underlying texture used as draw buffers.
  104053. */
  104054. releaseInternalTextures(): void;
  104055. }
  104056. }
  104057. declare module BABYLON {
  104058. interface Engine {
  104059. /**
  104060. * Unbind a list of render target textures from the webGL context
  104061. * This is used only when drawBuffer extension or webGL2 are active
  104062. * @param textures defines the render target textures to unbind
  104063. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  104064. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  104065. */
  104066. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  104067. /**
  104068. * Create a multi render target texture
  104069. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  104070. * @param size defines the size of the texture
  104071. * @param options defines the creation options
  104072. * @returns the cube texture as an InternalTexture
  104073. */
  104074. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  104075. /**
  104076. * Update the sample count for a given multiple render target texture
  104077. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  104078. * @param textures defines the textures to update
  104079. * @param samples defines the sample count to set
  104080. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  104081. */
  104082. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  104083. }
  104084. }
  104085. declare module BABYLON {
  104086. /**
  104087. * Gather the list of clipboard event types as constants.
  104088. */
  104089. export class ClipboardEventTypes {
  104090. /**
  104091. * The clipboard event is fired when a copy command is active (pressed).
  104092. */
  104093. static readonly COPY: number;
  104094. /**
  104095. * The clipboard event is fired when a cut command is active (pressed).
  104096. */
  104097. static readonly CUT: number;
  104098. /**
  104099. * The clipboard event is fired when a paste command is active (pressed).
  104100. */
  104101. static readonly PASTE: number;
  104102. }
  104103. /**
  104104. * This class is used to store clipboard related info for the onClipboardObservable event.
  104105. */
  104106. export class ClipboardInfo {
  104107. /**
  104108. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104109. */
  104110. type: number;
  104111. /**
  104112. * Defines the related dom event
  104113. */
  104114. event: ClipboardEvent;
  104115. /**
  104116. *Creates an instance of ClipboardInfo.
  104117. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  104118. * @param event Defines the related dom event
  104119. */
  104120. constructor(
  104121. /**
  104122. * Defines the type of event (BABYLON.ClipboardEventTypes)
  104123. */
  104124. type: number,
  104125. /**
  104126. * Defines the related dom event
  104127. */
  104128. event: ClipboardEvent);
  104129. /**
  104130. * Get the clipboard event's type from the keycode.
  104131. * @param keyCode Defines the keyCode for the current keyboard event.
  104132. * @return {number}
  104133. */
  104134. static GetTypeFromCharacter(keyCode: number): number;
  104135. }
  104136. }
  104137. declare module BABYLON {
  104138. /**
  104139. * Class used to represent data loading progression
  104140. */
  104141. export class SceneLoaderProgressEvent {
  104142. /** defines if data length to load can be evaluated */
  104143. readonly lengthComputable: boolean;
  104144. /** defines the loaded data length */
  104145. readonly loaded: number;
  104146. /** defines the data length to load */
  104147. readonly total: number;
  104148. /**
  104149. * Create a new progress event
  104150. * @param lengthComputable defines if data length to load can be evaluated
  104151. * @param loaded defines the loaded data length
  104152. * @param total defines the data length to load
  104153. */
  104154. constructor(
  104155. /** defines if data length to load can be evaluated */
  104156. lengthComputable: boolean,
  104157. /** defines the loaded data length */
  104158. loaded: number,
  104159. /** defines the data length to load */
  104160. total: number);
  104161. /**
  104162. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  104163. * @param event defines the source event
  104164. * @returns a new SceneLoaderProgressEvent
  104165. */
  104166. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  104167. }
  104168. /**
  104169. * Interface used by SceneLoader plugins to define supported file extensions
  104170. */
  104171. export interface ISceneLoaderPluginExtensions {
  104172. /**
  104173. * Defines the list of supported extensions
  104174. */
  104175. [extension: string]: {
  104176. isBinary: boolean;
  104177. };
  104178. }
  104179. /**
  104180. * Interface used by SceneLoader plugin factory
  104181. */
  104182. export interface ISceneLoaderPluginFactory {
  104183. /**
  104184. * Defines the name of the factory
  104185. */
  104186. name: string;
  104187. /**
  104188. * Function called to create a new plugin
  104189. * @return the new plugin
  104190. */
  104191. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  104192. /**
  104193. * Boolean indicating if the plugin can direct load specific data
  104194. */
  104195. canDirectLoad?: (data: string) => boolean;
  104196. }
  104197. /**
  104198. * Interface used to define a SceneLoader plugin
  104199. */
  104200. export interface ISceneLoaderPlugin {
  104201. /**
  104202. * The friendly name of this plugin.
  104203. */
  104204. name: string;
  104205. /**
  104206. * The file extensions supported by this plugin.
  104207. */
  104208. extensions: string | ISceneLoaderPluginExtensions;
  104209. /**
  104210. * Import meshes into a scene.
  104211. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104212. * @param scene The scene to import into
  104213. * @param data The data to import
  104214. * @param rootUrl The root url for scene and resources
  104215. * @param meshes The meshes array to import into
  104216. * @param particleSystems The particle systems array to import into
  104217. * @param skeletons The skeletons array to import into
  104218. * @param onError The callback when import fails
  104219. * @returns True if successful or false otherwise
  104220. */
  104221. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  104222. /**
  104223. * Load into a scene.
  104224. * @param scene The scene to load into
  104225. * @param data The data to import
  104226. * @param rootUrl The root url for scene and resources
  104227. * @param onError The callback when import fails
  104228. * @returns true if successful or false otherwise
  104229. */
  104230. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  104231. /**
  104232. * The callback that returns true if the data can be directly loaded.
  104233. */
  104234. canDirectLoad?: (data: string) => boolean;
  104235. /**
  104236. * The callback that allows custom handling of the root url based on the response url.
  104237. */
  104238. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104239. /**
  104240. * Load into an asset container.
  104241. * @param scene The scene to load into
  104242. * @param data The data to import
  104243. * @param rootUrl The root url for scene and resources
  104244. * @param onError The callback when import fails
  104245. * @returns The loaded asset container
  104246. */
  104247. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  104248. }
  104249. /**
  104250. * Interface used to define an async SceneLoader plugin
  104251. */
  104252. export interface ISceneLoaderPluginAsync {
  104253. /**
  104254. * The friendly name of this plugin.
  104255. */
  104256. name: string;
  104257. /**
  104258. * The file extensions supported by this plugin.
  104259. */
  104260. extensions: string | ISceneLoaderPluginExtensions;
  104261. /**
  104262. * Import meshes into a scene.
  104263. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104264. * @param scene The scene to import into
  104265. * @param data The data to import
  104266. * @param rootUrl The root url for scene and resources
  104267. * @param onProgress The callback when the load progresses
  104268. * @param fileName Defines the name of the file to load
  104269. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  104270. */
  104271. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  104272. meshes: AbstractMesh[];
  104273. particleSystems: IParticleSystem[];
  104274. skeletons: Skeleton[];
  104275. animationGroups: AnimationGroup[];
  104276. }>;
  104277. /**
  104278. * Load into a scene.
  104279. * @param scene The scene to load into
  104280. * @param data The data to import
  104281. * @param rootUrl The root url for scene and resources
  104282. * @param onProgress The callback when the load progresses
  104283. * @param fileName Defines the name of the file to load
  104284. * @returns Nothing
  104285. */
  104286. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  104287. /**
  104288. * The callback that returns true if the data can be directly loaded.
  104289. */
  104290. canDirectLoad?: (data: string) => boolean;
  104291. /**
  104292. * The callback that allows custom handling of the root url based on the response url.
  104293. */
  104294. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  104295. /**
  104296. * Load into an asset container.
  104297. * @param scene The scene to load into
  104298. * @param data The data to import
  104299. * @param rootUrl The root url for scene and resources
  104300. * @param onProgress The callback when the load progresses
  104301. * @param fileName Defines the name of the file to load
  104302. * @returns The loaded asset container
  104303. */
  104304. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  104305. }
  104306. /**
  104307. * Class used to load scene from various file formats using registered plugins
  104308. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  104309. */
  104310. export class SceneLoader {
  104311. /**
  104312. * No logging while loading
  104313. */
  104314. static readonly NO_LOGGING: number;
  104315. /**
  104316. * Minimal logging while loading
  104317. */
  104318. static readonly MINIMAL_LOGGING: number;
  104319. /**
  104320. * Summary logging while loading
  104321. */
  104322. static readonly SUMMARY_LOGGING: number;
  104323. /**
  104324. * Detailled logging while loading
  104325. */
  104326. static readonly DETAILED_LOGGING: number;
  104327. /**
  104328. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  104329. */
  104330. static ForceFullSceneLoadingForIncremental: boolean;
  104331. /**
  104332. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  104333. */
  104334. static ShowLoadingScreen: boolean;
  104335. /**
  104336. * Defines the current logging level (while loading the scene)
  104337. * @ignorenaming
  104338. */
  104339. static loggingLevel: number;
  104340. /**
  104341. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  104342. */
  104343. static CleanBoneMatrixWeights: boolean;
  104344. /**
  104345. * Event raised when a plugin is used to load a scene
  104346. */
  104347. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  104348. private static _registeredPlugins;
  104349. private static _getDefaultPlugin;
  104350. private static _getPluginForExtension;
  104351. private static _getPluginForDirectLoad;
  104352. private static _getPluginForFilename;
  104353. private static _getDirectLoad;
  104354. private static _loadData;
  104355. private static _getFileInfo;
  104356. /**
  104357. * Gets a plugin that can load the given extension
  104358. * @param extension defines the extension to load
  104359. * @returns a plugin or null if none works
  104360. */
  104361. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  104362. /**
  104363. * Gets a boolean indicating that the given extension can be loaded
  104364. * @param extension defines the extension to load
  104365. * @returns true if the extension is supported
  104366. */
  104367. static IsPluginForExtensionAvailable(extension: string): boolean;
  104368. /**
  104369. * Adds a new plugin to the list of registered plugins
  104370. * @param plugin defines the plugin to add
  104371. */
  104372. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  104373. /**
  104374. * Import meshes into a scene
  104375. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104376. * @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)
  104377. * @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)
  104378. * @param scene the instance of BABYLON.Scene to append to
  104379. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  104380. * @param onProgress a callback with a progress event for each file being loaded
  104381. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104382. * @param pluginExtension the extension used to determine the plugin
  104383. * @returns The loaded plugin
  104384. */
  104385. 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>;
  104386. /**
  104387. * Import meshes into a scene
  104388. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  104389. * @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)
  104390. * @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)
  104391. * @param scene the instance of BABYLON.Scene to append to
  104392. * @param onProgress a callback with a progress event for each file being loaded
  104393. * @param pluginExtension the extension used to determine the plugin
  104394. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  104395. */
  104396. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  104397. meshes: AbstractMesh[];
  104398. particleSystems: IParticleSystem[];
  104399. skeletons: Skeleton[];
  104400. animationGroups: AnimationGroup[];
  104401. }>;
  104402. /**
  104403. * Load a scene
  104404. * @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)
  104405. * @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)
  104406. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104407. * @param onSuccess a callback with the scene when import succeeds
  104408. * @param onProgress a callback with a progress event for each file being loaded
  104409. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104410. * @param pluginExtension the extension used to determine the plugin
  104411. * @returns The loaded plugin
  104412. */
  104413. 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>;
  104414. /**
  104415. * Load a scene
  104416. * @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)
  104417. * @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)
  104418. * @param engine is the instance of BABYLON.Engine to use to create the scene
  104419. * @param onProgress a callback with a progress event for each file being loaded
  104420. * @param pluginExtension the extension used to determine the plugin
  104421. * @returns The loaded scene
  104422. */
  104423. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104424. /**
  104425. * Append a scene
  104426. * @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)
  104427. * @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)
  104428. * @param scene is the instance of BABYLON.Scene to append to
  104429. * @param onSuccess a callback with the scene when import succeeds
  104430. * @param onProgress a callback with a progress event for each file being loaded
  104431. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104432. * @param pluginExtension the extension used to determine the plugin
  104433. * @returns The loaded plugin
  104434. */
  104435. 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>;
  104436. /**
  104437. * Append a scene
  104438. * @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)
  104439. * @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)
  104440. * @param scene is the instance of BABYLON.Scene to append to
  104441. * @param onProgress a callback with a progress event for each file being loaded
  104442. * @param pluginExtension the extension used to determine the plugin
  104443. * @returns The given scene
  104444. */
  104445. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  104446. /**
  104447. * Load a scene into an asset container
  104448. * @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)
  104449. * @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)
  104450. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  104451. * @param onSuccess a callback with the scene when import succeeds
  104452. * @param onProgress a callback with a progress event for each file being loaded
  104453. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  104454. * @param pluginExtension the extension used to determine the plugin
  104455. * @returns The loaded plugin
  104456. */
  104457. 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>;
  104458. /**
  104459. * Load a scene into an asset container
  104460. * @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)
  104461. * @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)
  104462. * @param scene is the instance of Scene to append to
  104463. * @param onProgress a callback with a progress event for each file being loaded
  104464. * @param pluginExtension the extension used to determine the plugin
  104465. * @returns The loaded asset container
  104466. */
  104467. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  104468. }
  104469. }
  104470. declare module BABYLON {
  104471. /**
  104472. * Google Daydream controller
  104473. */
  104474. export class DaydreamController extends WebVRController {
  104475. /**
  104476. * Base Url for the controller model.
  104477. */
  104478. static MODEL_BASE_URL: string;
  104479. /**
  104480. * File name for the controller model.
  104481. */
  104482. static MODEL_FILENAME: string;
  104483. /**
  104484. * Gamepad Id prefix used to identify Daydream Controller.
  104485. */
  104486. static readonly GAMEPAD_ID_PREFIX: string;
  104487. /**
  104488. * Creates a new DaydreamController from a gamepad
  104489. * @param vrGamepad the gamepad that the controller should be created from
  104490. */
  104491. constructor(vrGamepad: any);
  104492. /**
  104493. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104494. * @param scene scene in which to add meshes
  104495. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104496. */
  104497. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104498. /**
  104499. * Called once for each button that changed state since the last frame
  104500. * @param buttonIdx Which button index changed
  104501. * @param state New state of the button
  104502. * @param changes Which properties on the state changed since last frame
  104503. */
  104504. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104505. }
  104506. }
  104507. declare module BABYLON {
  104508. /**
  104509. * Gear VR Controller
  104510. */
  104511. export class GearVRController extends WebVRController {
  104512. /**
  104513. * Base Url for the controller model.
  104514. */
  104515. static MODEL_BASE_URL: string;
  104516. /**
  104517. * File name for the controller model.
  104518. */
  104519. static MODEL_FILENAME: string;
  104520. /**
  104521. * Gamepad Id prefix used to identify this controller.
  104522. */
  104523. static readonly GAMEPAD_ID_PREFIX: string;
  104524. private readonly _buttonIndexToObservableNameMap;
  104525. /**
  104526. * Creates a new GearVRController from a gamepad
  104527. * @param vrGamepad the gamepad that the controller should be created from
  104528. */
  104529. constructor(vrGamepad: any);
  104530. /**
  104531. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104532. * @param scene scene in which to add meshes
  104533. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104534. */
  104535. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104536. /**
  104537. * Called once for each button that changed state since the last frame
  104538. * @param buttonIdx Which button index changed
  104539. * @param state New state of the button
  104540. * @param changes Which properties on the state changed since last frame
  104541. */
  104542. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104543. }
  104544. }
  104545. declare module BABYLON {
  104546. /**
  104547. * Generic Controller
  104548. */
  104549. export class GenericController extends WebVRController {
  104550. /**
  104551. * Base Url for the controller model.
  104552. */
  104553. static readonly MODEL_BASE_URL: string;
  104554. /**
  104555. * File name for the controller model.
  104556. */
  104557. static readonly MODEL_FILENAME: string;
  104558. /**
  104559. * Creates a new GenericController from a gamepad
  104560. * @param vrGamepad the gamepad that the controller should be created from
  104561. */
  104562. constructor(vrGamepad: any);
  104563. /**
  104564. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104565. * @param scene scene in which to add meshes
  104566. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104567. */
  104568. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104569. /**
  104570. * Called once for each button that changed state since the last frame
  104571. * @param buttonIdx Which button index changed
  104572. * @param state New state of the button
  104573. * @param changes Which properties on the state changed since last frame
  104574. */
  104575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104576. }
  104577. }
  104578. declare module BABYLON {
  104579. /**
  104580. * Oculus Touch Controller
  104581. */
  104582. export class OculusTouchController extends WebVRController {
  104583. /**
  104584. * Base Url for the controller model.
  104585. */
  104586. static MODEL_BASE_URL: string;
  104587. /**
  104588. * File name for the left controller model.
  104589. */
  104590. static MODEL_LEFT_FILENAME: string;
  104591. /**
  104592. * File name for the right controller model.
  104593. */
  104594. static MODEL_RIGHT_FILENAME: string;
  104595. /**
  104596. * Fired when the secondary trigger on this controller is modified
  104597. */
  104598. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  104599. /**
  104600. * Fired when the thumb rest on this controller is modified
  104601. */
  104602. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  104603. /**
  104604. * Creates a new OculusTouchController from a gamepad
  104605. * @param vrGamepad the gamepad that the controller should be created from
  104606. */
  104607. constructor(vrGamepad: any);
  104608. /**
  104609. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104610. * @param scene scene in which to add meshes
  104611. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104612. */
  104613. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104614. /**
  104615. * Fired when the A button on this controller is modified
  104616. */
  104617. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104618. /**
  104619. * Fired when the B button on this controller is modified
  104620. */
  104621. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104622. /**
  104623. * Fired when the X button on this controller is modified
  104624. */
  104625. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104626. /**
  104627. * Fired when the Y button on this controller is modified
  104628. */
  104629. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104630. /**
  104631. * Called once for each button that changed state since the last frame
  104632. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  104633. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  104634. * 2) secondary trigger (same)
  104635. * 3) A (right) X (left), touch, pressed = value
  104636. * 4) B / Y
  104637. * 5) thumb rest
  104638. * @param buttonIdx Which button index changed
  104639. * @param state New state of the button
  104640. * @param changes Which properties on the state changed since last frame
  104641. */
  104642. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104643. }
  104644. }
  104645. declare module BABYLON {
  104646. /**
  104647. * Vive Controller
  104648. */
  104649. export class ViveController extends WebVRController {
  104650. /**
  104651. * Base Url for the controller model.
  104652. */
  104653. static MODEL_BASE_URL: string;
  104654. /**
  104655. * File name for the controller model.
  104656. */
  104657. static MODEL_FILENAME: string;
  104658. /**
  104659. * Creates a new ViveController from a gamepad
  104660. * @param vrGamepad the gamepad that the controller should be created from
  104661. */
  104662. constructor(vrGamepad: any);
  104663. /**
  104664. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104665. * @param scene scene in which to add meshes
  104666. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104667. */
  104668. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  104669. /**
  104670. * Fired when the left button on this controller is modified
  104671. */
  104672. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104673. /**
  104674. * Fired when the right button on this controller is modified
  104675. */
  104676. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104677. /**
  104678. * Fired when the menu button on this controller is modified
  104679. */
  104680. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104681. /**
  104682. * Called once for each button that changed state since the last frame
  104683. * Vive mapping:
  104684. * 0: touchpad
  104685. * 1: trigger
  104686. * 2: left AND right buttons
  104687. * 3: menu button
  104688. * @param buttonIdx Which button index changed
  104689. * @param state New state of the button
  104690. * @param changes Which properties on the state changed since last frame
  104691. */
  104692. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104693. }
  104694. }
  104695. declare module BABYLON {
  104696. /**
  104697. * Defines the WindowsMotionController object that the state of the windows motion controller
  104698. */
  104699. export class WindowsMotionController extends WebVRController {
  104700. /**
  104701. * The base url used to load the left and right controller models
  104702. */
  104703. static MODEL_BASE_URL: string;
  104704. /**
  104705. * The name of the left controller model file
  104706. */
  104707. static MODEL_LEFT_FILENAME: string;
  104708. /**
  104709. * The name of the right controller model file
  104710. */
  104711. static MODEL_RIGHT_FILENAME: string;
  104712. /**
  104713. * The controller name prefix for this controller type
  104714. */
  104715. static readonly GAMEPAD_ID_PREFIX: string;
  104716. /**
  104717. * The controller id pattern for this controller type
  104718. */
  104719. private static readonly GAMEPAD_ID_PATTERN;
  104720. private _loadedMeshInfo;
  104721. private readonly _mapping;
  104722. /**
  104723. * Fired when the trackpad on this controller is clicked
  104724. */
  104725. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  104726. /**
  104727. * Fired when the trackpad on this controller is modified
  104728. */
  104729. onTrackpadValuesChangedObservable: Observable<StickValues>;
  104730. /**
  104731. * The current x and y values of this controller's trackpad
  104732. */
  104733. trackpad: StickValues;
  104734. /**
  104735. * Creates a new WindowsMotionController from a gamepad
  104736. * @param vrGamepad the gamepad that the controller should be created from
  104737. */
  104738. constructor(vrGamepad: any);
  104739. /**
  104740. * Fired when the trigger on this controller is modified
  104741. */
  104742. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104743. /**
  104744. * Fired when the menu button on this controller is modified
  104745. */
  104746. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104747. /**
  104748. * Fired when the grip button on this controller is modified
  104749. */
  104750. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104751. /**
  104752. * Fired when the thumbstick button on this controller is modified
  104753. */
  104754. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104755. /**
  104756. * Fired when the touchpad button on this controller is modified
  104757. */
  104758. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  104759. /**
  104760. * Fired when the touchpad values on this controller are modified
  104761. */
  104762. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  104763. private _updateTrackpad;
  104764. /**
  104765. * Called once per frame by the engine.
  104766. */
  104767. update(): void;
  104768. /**
  104769. * Called once for each button that changed state since the last frame
  104770. * @param buttonIdx Which button index changed
  104771. * @param state New state of the button
  104772. * @param changes Which properties on the state changed since last frame
  104773. */
  104774. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  104775. /**
  104776. * Moves the buttons on the controller mesh based on their current state
  104777. * @param buttonName the name of the button to move
  104778. * @param buttonValue the value of the button which determines the buttons new position
  104779. */
  104780. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  104781. /**
  104782. * Moves the axis on the controller mesh based on its current state
  104783. * @param axis the index of the axis
  104784. * @param axisValue the value of the axis which determines the meshes new position
  104785. * @hidden
  104786. */
  104787. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  104788. /**
  104789. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  104790. * @param scene scene in which to add meshes
  104791. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  104792. */
  104793. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  104794. /**
  104795. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  104796. * can be transformed by button presses and axes values, based on this._mapping.
  104797. *
  104798. * @param scene scene in which the meshes exist
  104799. * @param meshes list of meshes that make up the controller model to process
  104800. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  104801. */
  104802. private processModel;
  104803. private createMeshInfo;
  104804. /**
  104805. * Gets the ray of the controller in the direction the controller is pointing
  104806. * @param length the length the resulting ray should be
  104807. * @returns a ray in the direction the controller is pointing
  104808. */
  104809. getForwardRay(length?: number): Ray;
  104810. /**
  104811. * Disposes of the controller
  104812. */
  104813. dispose(): void;
  104814. }
  104815. }
  104816. declare module BABYLON {
  104817. /**
  104818. * Class containing static functions to help procedurally build meshes
  104819. */
  104820. export class PolyhedronBuilder {
  104821. /**
  104822. * Creates a polyhedron mesh
  104823. * * 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
  104824. * * The parameter `size` (positive float, default 1) sets the polygon size
  104825. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  104826. * * 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`
  104827. * * 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
  104828. * * 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)`)
  104829. * * 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
  104830. * * 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
  104831. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  104832. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  104833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  104834. * @param name defines the name of the mesh
  104835. * @param options defines the options used to create the mesh
  104836. * @param scene defines the hosting scene
  104837. * @returns the polyhedron mesh
  104838. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  104839. */
  104840. static CreatePolyhedron(name: string, options: {
  104841. type?: number;
  104842. size?: number;
  104843. sizeX?: number;
  104844. sizeY?: number;
  104845. sizeZ?: number;
  104846. custom?: any;
  104847. faceUV?: Vector4[];
  104848. faceColors?: Color4[];
  104849. flat?: boolean;
  104850. updatable?: boolean;
  104851. sideOrientation?: number;
  104852. frontUVs?: Vector4;
  104853. backUVs?: Vector4;
  104854. }, scene?: Nullable<Scene>): Mesh;
  104855. }
  104856. }
  104857. declare module BABYLON {
  104858. /**
  104859. * Gizmo that enables scaling a mesh along 3 axis
  104860. */
  104861. export class ScaleGizmo extends Gizmo {
  104862. /**
  104863. * Internal gizmo used for interactions on the x axis
  104864. */
  104865. xGizmo: AxisScaleGizmo;
  104866. /**
  104867. * Internal gizmo used for interactions on the y axis
  104868. */
  104869. yGizmo: AxisScaleGizmo;
  104870. /**
  104871. * Internal gizmo used for interactions on the z axis
  104872. */
  104873. zGizmo: AxisScaleGizmo;
  104874. /**
  104875. * Internal gizmo used to scale all axis equally
  104876. */
  104877. uniformScaleGizmo: AxisScaleGizmo;
  104878. private _meshAttached;
  104879. private _updateGizmoRotationToMatchAttachedMesh;
  104880. private _snapDistance;
  104881. private _scaleRatio;
  104882. private _uniformScalingMesh;
  104883. private _octahedron;
  104884. /** Fires an event when any of it's sub gizmos are dragged */
  104885. onDragStartObservable: Observable<{}>;
  104886. /** Fires an event when any of it's sub gizmos are released from dragging */
  104887. onDragEndObservable: Observable<{}>;
  104888. attachedMesh: Nullable<AbstractMesh>;
  104889. /**
  104890. * Creates a ScaleGizmo
  104891. * @param gizmoLayer The utility layer the gizmo will be added to
  104892. */
  104893. constructor(gizmoLayer?: UtilityLayerRenderer);
  104894. updateGizmoRotationToMatchAttachedMesh: boolean;
  104895. /**
  104896. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104897. */
  104898. snapDistance: number;
  104899. /**
  104900. * Ratio for the scale of the gizmo (Default: 1)
  104901. */
  104902. scaleRatio: number;
  104903. /**
  104904. * Disposes of the gizmo
  104905. */
  104906. dispose(): void;
  104907. }
  104908. }
  104909. declare module BABYLON {
  104910. /**
  104911. * Single axis scale gizmo
  104912. */
  104913. export class AxisScaleGizmo extends Gizmo {
  104914. /**
  104915. * Drag behavior responsible for the gizmos dragging interactions
  104916. */
  104917. dragBehavior: PointerDragBehavior;
  104918. private _pointerObserver;
  104919. /**
  104920. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  104921. */
  104922. snapDistance: number;
  104923. /**
  104924. * Event that fires each time the gizmo snaps to a new location.
  104925. * * snapDistance is the the change in distance
  104926. */
  104927. onSnapObservable: Observable<{
  104928. snapDistance: number;
  104929. }>;
  104930. /**
  104931. * If the scaling operation should be done on all axis (default: false)
  104932. */
  104933. uniformScaling: boolean;
  104934. private _isEnabled;
  104935. private _parent;
  104936. private _arrow;
  104937. private _coloredMaterial;
  104938. private _hoverMaterial;
  104939. /**
  104940. * Creates an AxisScaleGizmo
  104941. * @param gizmoLayer The utility layer the gizmo will be added to
  104942. * @param dragAxis The axis which the gizmo will be able to scale on
  104943. * @param color The color of the gizmo
  104944. */
  104945. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  104946. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  104947. /**
  104948. * If the gizmo is enabled
  104949. */
  104950. isEnabled: boolean;
  104951. /**
  104952. * Disposes of the gizmo
  104953. */
  104954. dispose(): void;
  104955. /**
  104956. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  104957. * @param mesh The mesh to replace the default mesh of the gizmo
  104958. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  104959. */
  104960. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  104961. }
  104962. }
  104963. declare module BABYLON {
  104964. /**
  104965. * Bounding box gizmo
  104966. */
  104967. export class BoundingBoxGizmo extends Gizmo {
  104968. private _lineBoundingBox;
  104969. private _rotateSpheresParent;
  104970. private _scaleBoxesParent;
  104971. private _boundingDimensions;
  104972. private _renderObserver;
  104973. private _pointerObserver;
  104974. private _scaleDragSpeed;
  104975. private _tmpQuaternion;
  104976. private _tmpVector;
  104977. private _tmpRotationMatrix;
  104978. /**
  104979. * 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)
  104980. */
  104981. ignoreChildren: boolean;
  104982. /**
  104983. * 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)
  104984. */
  104985. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  104986. /**
  104987. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  104988. */
  104989. rotationSphereSize: number;
  104990. /**
  104991. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  104992. */
  104993. scaleBoxSize: number;
  104994. /**
  104995. * 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)
  104996. */
  104997. fixedDragMeshScreenSize: boolean;
  104998. /**
  104999. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  105000. */
  105001. fixedDragMeshScreenSizeDistanceFactor: number;
  105002. /**
  105003. * Fired when a rotation sphere or scale box is dragged
  105004. */
  105005. onDragStartObservable: Observable<{}>;
  105006. /**
  105007. * Fired when a scale box is dragged
  105008. */
  105009. onScaleBoxDragObservable: Observable<{}>;
  105010. /**
  105011. * Fired when a scale box drag is ended
  105012. */
  105013. onScaleBoxDragEndObservable: Observable<{}>;
  105014. /**
  105015. * Fired when a rotation sphere is dragged
  105016. */
  105017. onRotationSphereDragObservable: Observable<{}>;
  105018. /**
  105019. * Fired when a rotation sphere drag is ended
  105020. */
  105021. onRotationSphereDragEndObservable: Observable<{}>;
  105022. /**
  105023. * 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)
  105024. */
  105025. scalePivot: Nullable<Vector3>;
  105026. /**
  105027. * Mesh used as a pivot to rotate the attached mesh
  105028. */
  105029. private _anchorMesh;
  105030. private _existingMeshScale;
  105031. private _dragMesh;
  105032. private pointerDragBehavior;
  105033. private coloredMaterial;
  105034. private hoverColoredMaterial;
  105035. /**
  105036. * Sets the color of the bounding box gizmo
  105037. * @param color the color to set
  105038. */
  105039. setColor(color: Color3): void;
  105040. /**
  105041. * Creates an BoundingBoxGizmo
  105042. * @param gizmoLayer The utility layer the gizmo will be added to
  105043. * @param color The color of the gizmo
  105044. */
  105045. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  105046. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105047. private _selectNode;
  105048. /**
  105049. * Updates the bounding box information for the Gizmo
  105050. */
  105051. updateBoundingBox(): void;
  105052. private _updateRotationSpheres;
  105053. private _updateScaleBoxes;
  105054. /**
  105055. * Enables rotation on the specified axis and disables rotation on the others
  105056. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  105057. */
  105058. setEnabledRotationAxis(axis: string): void;
  105059. /**
  105060. * Enables/disables scaling
  105061. * @param enable if scaling should be enabled
  105062. */
  105063. setEnabledScaling(enable: boolean): void;
  105064. private _updateDummy;
  105065. /**
  105066. * Enables a pointer drag behavior on the bounding box of the gizmo
  105067. */
  105068. enableDragBehavior(): void;
  105069. /**
  105070. * Disposes of the gizmo
  105071. */
  105072. dispose(): void;
  105073. /**
  105074. * 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)
  105075. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  105076. * @returns the bounding box mesh with the passed in mesh as a child
  105077. */
  105078. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  105079. /**
  105080. * CustomMeshes are not supported by this gizmo
  105081. * @param mesh The mesh to replace the default mesh of the gizmo
  105082. */
  105083. setCustomMesh(mesh: Mesh): void;
  105084. }
  105085. }
  105086. declare module BABYLON {
  105087. /**
  105088. * Single plane rotation gizmo
  105089. */
  105090. export class PlaneRotationGizmo extends Gizmo {
  105091. /**
  105092. * Drag behavior responsible for the gizmos dragging interactions
  105093. */
  105094. dragBehavior: PointerDragBehavior;
  105095. private _pointerObserver;
  105096. /**
  105097. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  105098. */
  105099. snapDistance: number;
  105100. /**
  105101. * Event that fires each time the gizmo snaps to a new location.
  105102. * * snapDistance is the the change in distance
  105103. */
  105104. onSnapObservable: Observable<{
  105105. snapDistance: number;
  105106. }>;
  105107. private _isEnabled;
  105108. private _parent;
  105109. /**
  105110. * Creates a PlaneRotationGizmo
  105111. * @param gizmoLayer The utility layer the gizmo will be added to
  105112. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  105113. * @param color The color of the gizmo
  105114. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105115. */
  105116. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>);
  105117. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  105118. /**
  105119. * If the gizmo is enabled
  105120. */
  105121. isEnabled: boolean;
  105122. /**
  105123. * Disposes of the gizmo
  105124. */
  105125. dispose(): void;
  105126. }
  105127. }
  105128. declare module BABYLON {
  105129. /**
  105130. * Gizmo that enables rotating a mesh along 3 axis
  105131. */
  105132. export class RotationGizmo extends Gizmo {
  105133. /**
  105134. * Internal gizmo used for interactions on the x axis
  105135. */
  105136. xGizmo: PlaneRotationGizmo;
  105137. /**
  105138. * Internal gizmo used for interactions on the y axis
  105139. */
  105140. yGizmo: PlaneRotationGizmo;
  105141. /**
  105142. * Internal gizmo used for interactions on the z axis
  105143. */
  105144. zGizmo: PlaneRotationGizmo;
  105145. /** Fires an event when any of it's sub gizmos are dragged */
  105146. onDragStartObservable: Observable<{}>;
  105147. /** Fires an event when any of it's sub gizmos are released from dragging */
  105148. onDragEndObservable: Observable<{}>;
  105149. private _meshAttached;
  105150. attachedMesh: Nullable<AbstractMesh>;
  105151. /**
  105152. * Creates a RotationGizmo
  105153. * @param gizmoLayer The utility layer the gizmo will be added to
  105154. * @param tessellation Amount of tessellation to be used when creating rotation circles
  105155. */
  105156. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  105157. updateGizmoRotationToMatchAttachedMesh: boolean;
  105158. /**
  105159. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  105160. */
  105161. snapDistance: number;
  105162. /**
  105163. * Ratio for the scale of the gizmo (Default: 1)
  105164. */
  105165. scaleRatio: number;
  105166. /**
  105167. * Disposes of the gizmo
  105168. */
  105169. dispose(): void;
  105170. /**
  105171. * CustomMeshes are not supported by this gizmo
  105172. * @param mesh The mesh to replace the default mesh of the gizmo
  105173. */
  105174. setCustomMesh(mesh: Mesh): void;
  105175. }
  105176. }
  105177. declare module BABYLON {
  105178. /**
  105179. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  105180. */
  105181. export class GizmoManager implements IDisposable {
  105182. private scene;
  105183. /**
  105184. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  105185. */
  105186. gizmos: {
  105187. positionGizmo: Nullable<PositionGizmo>;
  105188. rotationGizmo: Nullable<RotationGizmo>;
  105189. scaleGizmo: Nullable<ScaleGizmo>;
  105190. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  105191. };
  105192. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  105193. clearGizmoOnEmptyPointerEvent: boolean;
  105194. /** Fires an event when the manager is attached to a mesh */
  105195. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  105196. private _gizmosEnabled;
  105197. private _pointerObserver;
  105198. private _attachedMesh;
  105199. private _boundingBoxColor;
  105200. private _defaultUtilityLayer;
  105201. private _defaultKeepDepthUtilityLayer;
  105202. /**
  105203. * When bounding box gizmo is enabled, this can be used to track drag/end events
  105204. */
  105205. boundingBoxDragBehavior: SixDofDragBehavior;
  105206. /**
  105207. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  105208. */
  105209. attachableMeshes: Nullable<Array<AbstractMesh>>;
  105210. /**
  105211. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  105212. */
  105213. usePointerToAttachGizmos: boolean;
  105214. /**
  105215. * Instatiates a gizmo manager
  105216. * @param scene the scene to overlay the gizmos on top of
  105217. */
  105218. constructor(scene: Scene);
  105219. /**
  105220. * Attaches a set of gizmos to the specified mesh
  105221. * @param mesh The mesh the gizmo's should be attached to
  105222. */
  105223. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  105224. /**
  105225. * If the position gizmo is enabled
  105226. */
  105227. positionGizmoEnabled: boolean;
  105228. /**
  105229. * If the rotation gizmo is enabled
  105230. */
  105231. rotationGizmoEnabled: boolean;
  105232. /**
  105233. * If the scale gizmo is enabled
  105234. */
  105235. scaleGizmoEnabled: boolean;
  105236. /**
  105237. * If the boundingBox gizmo is enabled
  105238. */
  105239. boundingBoxGizmoEnabled: boolean;
  105240. /**
  105241. * Disposes of the gizmo manager
  105242. */
  105243. dispose(): void;
  105244. }
  105245. }
  105246. declare module BABYLON {
  105247. /**
  105248. * A directional light is defined by a direction (what a surprise!).
  105249. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  105250. * 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.
  105251. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105252. */
  105253. export class DirectionalLight extends ShadowLight {
  105254. private _shadowFrustumSize;
  105255. /**
  105256. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  105257. */
  105258. /**
  105259. * Specifies a fix frustum size for the shadow generation.
  105260. */
  105261. shadowFrustumSize: number;
  105262. private _shadowOrthoScale;
  105263. /**
  105264. * Gets the shadow projection scale against the optimal computed one.
  105265. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105266. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105267. */
  105268. /**
  105269. * Sets the shadow projection scale against the optimal computed one.
  105270. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  105271. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  105272. */
  105273. shadowOrthoScale: number;
  105274. /**
  105275. * Automatically compute the projection matrix to best fit (including all the casters)
  105276. * on each frame.
  105277. */
  105278. autoUpdateExtends: boolean;
  105279. private _orthoLeft;
  105280. private _orthoRight;
  105281. private _orthoTop;
  105282. private _orthoBottom;
  105283. /**
  105284. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  105285. * The directional light is emitted from everywhere in the given direction.
  105286. * It can cast shadows.
  105287. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105288. * @param name The friendly name of the light
  105289. * @param direction The direction of the light
  105290. * @param scene The scene the light belongs to
  105291. */
  105292. constructor(name: string, direction: Vector3, scene: Scene);
  105293. /**
  105294. * Returns the string "DirectionalLight".
  105295. * @return The class name
  105296. */
  105297. getClassName(): string;
  105298. /**
  105299. * Returns the integer 1.
  105300. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105301. */
  105302. getTypeID(): number;
  105303. /**
  105304. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  105305. * Returns the DirectionalLight Shadow projection matrix.
  105306. */
  105307. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105308. /**
  105309. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  105310. * Returns the DirectionalLight Shadow projection matrix.
  105311. */
  105312. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  105313. /**
  105314. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  105315. * Returns the DirectionalLight Shadow projection matrix.
  105316. */
  105317. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105318. protected _buildUniformLayout(): void;
  105319. /**
  105320. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  105321. * @param effect The effect to update
  105322. * @param lightIndex The index of the light in the effect to update
  105323. * @returns The directional light
  105324. */
  105325. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  105326. /**
  105327. * Gets the minZ used for shadow according to both the scene and the light.
  105328. *
  105329. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105330. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105331. * @param activeCamera The camera we are returning the min for
  105332. * @returns the depth min z
  105333. */
  105334. getDepthMinZ(activeCamera: Camera): number;
  105335. /**
  105336. * Gets the maxZ used for shadow according to both the scene and the light.
  105337. *
  105338. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  105339. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  105340. * @param activeCamera The camera we are returning the max for
  105341. * @returns the depth max z
  105342. */
  105343. getDepthMaxZ(activeCamera: Camera): number;
  105344. /**
  105345. * Prepares the list of defines specific to the light type.
  105346. * @param defines the list of defines
  105347. * @param lightIndex defines the index of the light for the effect
  105348. */
  105349. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105350. }
  105351. }
  105352. declare module BABYLON {
  105353. /**
  105354. * Class containing static functions to help procedurally build meshes
  105355. */
  105356. export class HemisphereBuilder {
  105357. /**
  105358. * Creates a hemisphere mesh
  105359. * @param name defines the name of the mesh
  105360. * @param options defines the options used to create the mesh
  105361. * @param scene defines the hosting scene
  105362. * @returns the hemisphere mesh
  105363. */
  105364. static CreateHemisphere(name: string, options: {
  105365. segments?: number;
  105366. diameter?: number;
  105367. sideOrientation?: number;
  105368. }, scene: any): Mesh;
  105369. }
  105370. }
  105371. declare module BABYLON {
  105372. /**
  105373. * A spot light is defined by a position, a direction, an angle, and an exponent.
  105374. * These values define a cone of light starting from the position, emitting toward the direction.
  105375. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  105376. * and the exponent defines the speed of the decay of the light with distance (reach).
  105377. * Documentation: https://doc.babylonjs.com/babylon101/lights
  105378. */
  105379. export class SpotLight extends ShadowLight {
  105380. private _angle;
  105381. private _innerAngle;
  105382. private _cosHalfAngle;
  105383. private _lightAngleScale;
  105384. private _lightAngleOffset;
  105385. /**
  105386. * Gets the cone angle of the spot light in Radians.
  105387. */
  105388. /**
  105389. * Sets the cone angle of the spot light in Radians.
  105390. */
  105391. angle: number;
  105392. /**
  105393. * Only used in gltf falloff mode, this defines the angle where
  105394. * the directional falloff will start before cutting at angle which could be seen
  105395. * as outer angle.
  105396. */
  105397. /**
  105398. * Only used in gltf falloff mode, this defines the angle where
  105399. * the directional falloff will start before cutting at angle which could be seen
  105400. * as outer angle.
  105401. */
  105402. innerAngle: number;
  105403. private _shadowAngleScale;
  105404. /**
  105405. * Allows scaling the angle of the light for shadow generation only.
  105406. */
  105407. /**
  105408. * Allows scaling the angle of the light for shadow generation only.
  105409. */
  105410. shadowAngleScale: number;
  105411. /**
  105412. * The light decay speed with the distance from the emission spot.
  105413. */
  105414. exponent: number;
  105415. private _projectionTextureMatrix;
  105416. /**
  105417. * Allows reading the projecton texture
  105418. */
  105419. readonly projectionTextureMatrix: Matrix;
  105420. protected _projectionTextureLightNear: number;
  105421. /**
  105422. * Gets the near clip of the Spotlight for texture projection.
  105423. */
  105424. /**
  105425. * Sets the near clip of the Spotlight for texture projection.
  105426. */
  105427. projectionTextureLightNear: number;
  105428. protected _projectionTextureLightFar: number;
  105429. /**
  105430. * Gets the far clip of the Spotlight for texture projection.
  105431. */
  105432. /**
  105433. * Sets the far clip of the Spotlight for texture projection.
  105434. */
  105435. projectionTextureLightFar: number;
  105436. protected _projectionTextureUpDirection: Vector3;
  105437. /**
  105438. * Gets the Up vector of the Spotlight for texture projection.
  105439. */
  105440. /**
  105441. * Sets the Up vector of the Spotlight for texture projection.
  105442. */
  105443. projectionTextureUpDirection: Vector3;
  105444. private _projectionTexture;
  105445. /**
  105446. * Gets the projection texture of the light.
  105447. */
  105448. /**
  105449. * Sets the projection texture of the light.
  105450. */
  105451. projectionTexture: Nullable<BaseTexture>;
  105452. private _projectionTextureViewLightDirty;
  105453. private _projectionTextureProjectionLightDirty;
  105454. private _projectionTextureDirty;
  105455. private _projectionTextureViewTargetVector;
  105456. private _projectionTextureViewLightMatrix;
  105457. private _projectionTextureProjectionLightMatrix;
  105458. private _projectionTextureScalingMatrix;
  105459. /**
  105460. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  105461. * It can cast shadows.
  105462. * Documentation : https://doc.babylonjs.com/babylon101/lights
  105463. * @param name The light friendly name
  105464. * @param position The position of the spot light in the scene
  105465. * @param direction The direction of the light in the scene
  105466. * @param angle The cone angle of the light in Radians
  105467. * @param exponent The light decay speed with the distance from the emission spot
  105468. * @param scene The scene the lights belongs to
  105469. */
  105470. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  105471. /**
  105472. * Returns the string "SpotLight".
  105473. * @returns the class name
  105474. */
  105475. getClassName(): string;
  105476. /**
  105477. * Returns the integer 2.
  105478. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  105479. */
  105480. getTypeID(): number;
  105481. /**
  105482. * Overrides the direction setter to recompute the projection texture view light Matrix.
  105483. */
  105484. protected _setDirection(value: Vector3): void;
  105485. /**
  105486. * Overrides the position setter to recompute the projection texture view light Matrix.
  105487. */
  105488. protected _setPosition(value: Vector3): void;
  105489. /**
  105490. * 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.
  105491. * Returns the SpotLight.
  105492. */
  105493. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  105494. protected _computeProjectionTextureViewLightMatrix(): void;
  105495. protected _computeProjectionTextureProjectionLightMatrix(): void;
  105496. /**
  105497. * Main function for light texture projection matrix computing.
  105498. */
  105499. protected _computeProjectionTextureMatrix(): void;
  105500. protected _buildUniformLayout(): void;
  105501. private _computeAngleValues;
  105502. /**
  105503. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  105504. * @param effect The effect to update
  105505. * @param lightIndex The index of the light in the effect to update
  105506. * @returns The spot light
  105507. */
  105508. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  105509. /**
  105510. * Disposes the light and the associated resources.
  105511. */
  105512. dispose(): void;
  105513. /**
  105514. * Prepares the list of defines specific to the light type.
  105515. * @param defines the list of defines
  105516. * @param lightIndex defines the index of the light for the effect
  105517. */
  105518. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  105519. }
  105520. }
  105521. declare module BABYLON {
  105522. /**
  105523. * Gizmo that enables viewing a light
  105524. */
  105525. export class LightGizmo extends Gizmo {
  105526. private _lightMesh;
  105527. private _material;
  105528. private cachedPosition;
  105529. private cachedForward;
  105530. /**
  105531. * Creates a LightGizmo
  105532. * @param gizmoLayer The utility layer the gizmo will be added to
  105533. */
  105534. constructor(gizmoLayer?: UtilityLayerRenderer);
  105535. private _light;
  105536. /**
  105537. * The light that the gizmo is attached to
  105538. */
  105539. light: Nullable<Light>;
  105540. /**
  105541. * @hidden
  105542. * Updates the gizmo to match the attached mesh's position/rotation
  105543. */
  105544. protected _update(): void;
  105545. private static _Scale;
  105546. /**
  105547. * Creates the lines for a light mesh
  105548. */
  105549. private static _createLightLines;
  105550. /**
  105551. * Disposes of the light gizmo
  105552. */
  105553. dispose(): void;
  105554. private static _CreateHemisphericLightMesh;
  105555. private static _CreatePointLightMesh;
  105556. private static _CreateSpotLightMesh;
  105557. private static _CreateDirectionalLightMesh;
  105558. }
  105559. }
  105560. declare module BABYLON {
  105561. /** @hidden */
  105562. export var backgroundFragmentDeclaration: {
  105563. name: string;
  105564. shader: string;
  105565. };
  105566. }
  105567. declare module BABYLON {
  105568. /** @hidden */
  105569. export var backgroundUboDeclaration: {
  105570. name: string;
  105571. shader: string;
  105572. };
  105573. }
  105574. declare module BABYLON {
  105575. /** @hidden */
  105576. export var backgroundPixelShader: {
  105577. name: string;
  105578. shader: string;
  105579. };
  105580. }
  105581. declare module BABYLON {
  105582. /** @hidden */
  105583. export var backgroundVertexDeclaration: {
  105584. name: string;
  105585. shader: string;
  105586. };
  105587. }
  105588. declare module BABYLON {
  105589. /** @hidden */
  105590. export var backgroundVertexShader: {
  105591. name: string;
  105592. shader: string;
  105593. };
  105594. }
  105595. declare module BABYLON {
  105596. /**
  105597. * Background material used to create an efficient environement around your scene.
  105598. */
  105599. export class BackgroundMaterial extends PushMaterial {
  105600. /**
  105601. * Standard reflectance value at parallel view angle.
  105602. */
  105603. static StandardReflectance0: number;
  105604. /**
  105605. * Standard reflectance value at grazing angle.
  105606. */
  105607. static StandardReflectance90: number;
  105608. protected _primaryColor: Color3;
  105609. /**
  105610. * Key light Color (multiply against the environement texture)
  105611. */
  105612. primaryColor: Color3;
  105613. protected __perceptualColor: Nullable<Color3>;
  105614. /**
  105615. * Experimental Internal Use Only.
  105616. *
  105617. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  105618. * This acts as a helper to set the primary color to a more "human friendly" value.
  105619. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  105620. * output color as close as possible from the chosen value.
  105621. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  105622. * part of lighting setup.)
  105623. */
  105624. _perceptualColor: Nullable<Color3>;
  105625. protected _primaryColorShadowLevel: float;
  105626. /**
  105627. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  105628. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  105629. */
  105630. primaryColorShadowLevel: float;
  105631. protected _primaryColorHighlightLevel: float;
  105632. /**
  105633. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  105634. * The primary color is used at the level chosen to define what the white area would look.
  105635. */
  105636. primaryColorHighlightLevel: float;
  105637. protected _reflectionTexture: Nullable<BaseTexture>;
  105638. /**
  105639. * Reflection Texture used in the material.
  105640. * Should be author in a specific way for the best result (refer to the documentation).
  105641. */
  105642. reflectionTexture: Nullable<BaseTexture>;
  105643. protected _reflectionBlur: float;
  105644. /**
  105645. * Reflection Texture level of blur.
  105646. *
  105647. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  105648. * texture twice.
  105649. */
  105650. reflectionBlur: float;
  105651. protected _diffuseTexture: Nullable<BaseTexture>;
  105652. /**
  105653. * Diffuse Texture used in the material.
  105654. * Should be author in a specific way for the best result (refer to the documentation).
  105655. */
  105656. diffuseTexture: Nullable<BaseTexture>;
  105657. protected _shadowLights: Nullable<IShadowLight[]>;
  105658. /**
  105659. * Specify the list of lights casting shadow on the material.
  105660. * All scene shadow lights will be included if null.
  105661. */
  105662. shadowLights: Nullable<IShadowLight[]>;
  105663. protected _shadowLevel: float;
  105664. /**
  105665. * Helps adjusting the shadow to a softer level if required.
  105666. * 0 means black shadows and 1 means no shadows.
  105667. */
  105668. shadowLevel: float;
  105669. protected _sceneCenter: Vector3;
  105670. /**
  105671. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  105672. * It is usually zero but might be interesting to modify according to your setup.
  105673. */
  105674. sceneCenter: Vector3;
  105675. protected _opacityFresnel: boolean;
  105676. /**
  105677. * This helps specifying that the material is falling off to the sky box at grazing angle.
  105678. * This helps ensuring a nice transition when the camera goes under the ground.
  105679. */
  105680. opacityFresnel: boolean;
  105681. protected _reflectionFresnel: boolean;
  105682. /**
  105683. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  105684. * This helps adding a mirror texture on the ground.
  105685. */
  105686. reflectionFresnel: boolean;
  105687. protected _reflectionFalloffDistance: number;
  105688. /**
  105689. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  105690. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  105691. */
  105692. reflectionFalloffDistance: number;
  105693. protected _reflectionAmount: number;
  105694. /**
  105695. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  105696. */
  105697. reflectionAmount: number;
  105698. protected _reflectionReflectance0: number;
  105699. /**
  105700. * This specifies the weight of the reflection at grazing angle.
  105701. */
  105702. reflectionReflectance0: number;
  105703. protected _reflectionReflectance90: number;
  105704. /**
  105705. * This specifies the weight of the reflection at a perpendicular point of view.
  105706. */
  105707. reflectionReflectance90: number;
  105708. /**
  105709. * Sets the reflection reflectance fresnel values according to the default standard
  105710. * empirically know to work well :-)
  105711. */
  105712. reflectionStandardFresnelWeight: number;
  105713. protected _useRGBColor: boolean;
  105714. /**
  105715. * Helps to directly use the maps channels instead of their level.
  105716. */
  105717. useRGBColor: boolean;
  105718. protected _enableNoise: boolean;
  105719. /**
  105720. * This helps reducing the banding effect that could occur on the background.
  105721. */
  105722. enableNoise: boolean;
  105723. /**
  105724. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105725. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  105726. * Recommended to be keep at 1.0 except for special cases.
  105727. */
  105728. fovMultiplier: number;
  105729. private _fovMultiplier;
  105730. /**
  105731. * Enable the FOV adjustment feature controlled by fovMultiplier.
  105732. */
  105733. useEquirectangularFOV: boolean;
  105734. private _maxSimultaneousLights;
  105735. /**
  105736. * Number of Simultaneous lights allowed on the material.
  105737. */
  105738. maxSimultaneousLights: int;
  105739. /**
  105740. * Default configuration related to image processing available in the Background Material.
  105741. */
  105742. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  105743. /**
  105744. * Keep track of the image processing observer to allow dispose and replace.
  105745. */
  105746. private _imageProcessingObserver;
  105747. /**
  105748. * Attaches a new image processing configuration to the PBR Material.
  105749. * @param configuration (if null the scene configuration will be use)
  105750. */
  105751. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  105752. /**
  105753. * Gets the image processing configuration used either in this material.
  105754. */
  105755. /**
  105756. * Sets the Default image processing configuration used either in the this material.
  105757. *
  105758. * If sets to null, the scene one is in use.
  105759. */
  105760. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  105761. /**
  105762. * Gets wether the color curves effect is enabled.
  105763. */
  105764. /**
  105765. * Sets wether the color curves effect is enabled.
  105766. */
  105767. cameraColorCurvesEnabled: boolean;
  105768. /**
  105769. * Gets wether the color grading effect is enabled.
  105770. */
  105771. /**
  105772. * Gets wether the color grading effect is enabled.
  105773. */
  105774. cameraColorGradingEnabled: boolean;
  105775. /**
  105776. * Gets wether tonemapping is enabled or not.
  105777. */
  105778. /**
  105779. * Sets wether tonemapping is enabled or not
  105780. */
  105781. cameraToneMappingEnabled: boolean;
  105782. /**
  105783. * The camera exposure used on this material.
  105784. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105785. * This corresponds to a photographic exposure.
  105786. */
  105787. /**
  105788. * The camera exposure used on this material.
  105789. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105790. * This corresponds to a photographic exposure.
  105791. */
  105792. cameraExposure: float;
  105793. /**
  105794. * Gets The camera contrast used on this material.
  105795. */
  105796. /**
  105797. * Sets The camera contrast used on this material.
  105798. */
  105799. cameraContrast: float;
  105800. /**
  105801. * Gets the Color Grading 2D Lookup Texture.
  105802. */
  105803. /**
  105804. * Sets the Color Grading 2D Lookup Texture.
  105805. */
  105806. cameraColorGradingTexture: Nullable<BaseTexture>;
  105807. /**
  105808. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105809. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105810. * 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;
  105811. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105812. */
  105813. /**
  105814. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105815. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105816. * 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;
  105817. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105818. */
  105819. cameraColorCurves: Nullable<ColorCurves>;
  105820. /**
  105821. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  105822. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  105823. */
  105824. switchToBGR: boolean;
  105825. private _renderTargets;
  105826. private _reflectionControls;
  105827. private _white;
  105828. private _primaryShadowColor;
  105829. private _primaryHighlightColor;
  105830. /**
  105831. * Instantiates a Background Material in the given scene
  105832. * @param name The friendly name of the material
  105833. * @param scene The scene to add the material to
  105834. */
  105835. constructor(name: string, scene: Scene);
  105836. /**
  105837. * Gets a boolean indicating that current material needs to register RTT
  105838. */
  105839. readonly hasRenderTargetTextures: boolean;
  105840. /**
  105841. * The entire material has been created in order to prevent overdraw.
  105842. * @returns false
  105843. */
  105844. needAlphaTesting(): boolean;
  105845. /**
  105846. * The entire material has been created in order to prevent overdraw.
  105847. * @returns true if blending is enable
  105848. */
  105849. needAlphaBlending(): boolean;
  105850. /**
  105851. * Checks wether the material is ready to be rendered for a given mesh.
  105852. * @param mesh The mesh to render
  105853. * @param subMesh The submesh to check against
  105854. * @param useInstances Specify wether or not the material is used with instances
  105855. * @returns true if all the dependencies are ready (Textures, Effects...)
  105856. */
  105857. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105858. /**
  105859. * Compute the primary color according to the chosen perceptual color.
  105860. */
  105861. private _computePrimaryColorFromPerceptualColor;
  105862. /**
  105863. * Compute the highlights and shadow colors according to their chosen levels.
  105864. */
  105865. private _computePrimaryColors;
  105866. /**
  105867. * Build the uniform buffer used in the material.
  105868. */
  105869. buildUniformLayout(): void;
  105870. /**
  105871. * Unbind the material.
  105872. */
  105873. unbind(): void;
  105874. /**
  105875. * Bind only the world matrix to the material.
  105876. * @param world The world matrix to bind.
  105877. */
  105878. bindOnlyWorldMatrix(world: Matrix): void;
  105879. /**
  105880. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  105881. * @param world The world matrix to bind.
  105882. * @param subMesh The submesh to bind for.
  105883. */
  105884. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105885. /**
  105886. * Dispose the material.
  105887. * @param forceDisposeEffect Force disposal of the associated effect.
  105888. * @param forceDisposeTextures Force disposal of the associated textures.
  105889. */
  105890. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  105891. /**
  105892. * Clones the material.
  105893. * @param name The cloned name.
  105894. * @returns The cloned material.
  105895. */
  105896. clone(name: string): BackgroundMaterial;
  105897. /**
  105898. * Serializes the current material to its JSON representation.
  105899. * @returns The JSON representation.
  105900. */
  105901. serialize(): any;
  105902. /**
  105903. * Gets the class name of the material
  105904. * @returns "BackgroundMaterial"
  105905. */
  105906. getClassName(): string;
  105907. /**
  105908. * Parse a JSON input to create back a background material.
  105909. * @param source The JSON data to parse
  105910. * @param scene The scene to create the parsed material in
  105911. * @param rootUrl The root url of the assets the material depends upon
  105912. * @returns the instantiated BackgroundMaterial.
  105913. */
  105914. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  105915. }
  105916. }
  105917. declare module BABYLON {
  105918. /**
  105919. * Represents the different options available during the creation of
  105920. * a Environment helper.
  105921. *
  105922. * This can control the default ground, skybox and image processing setup of your scene.
  105923. */
  105924. export interface IEnvironmentHelperOptions {
  105925. /**
  105926. * Specifies wether or not to create a ground.
  105927. * True by default.
  105928. */
  105929. createGround: boolean;
  105930. /**
  105931. * Specifies the ground size.
  105932. * 15 by default.
  105933. */
  105934. groundSize: number;
  105935. /**
  105936. * The texture used on the ground for the main color.
  105937. * Comes from the BabylonJS CDN by default.
  105938. *
  105939. * Remarks: Can be either a texture or a url.
  105940. */
  105941. groundTexture: string | BaseTexture;
  105942. /**
  105943. * The color mixed in the ground texture by default.
  105944. * BabylonJS clearColor by default.
  105945. */
  105946. groundColor: Color3;
  105947. /**
  105948. * Specifies the ground opacity.
  105949. * 1 by default.
  105950. */
  105951. groundOpacity: number;
  105952. /**
  105953. * Enables the ground to receive shadows.
  105954. * True by default.
  105955. */
  105956. enableGroundShadow: boolean;
  105957. /**
  105958. * Helps preventing the shadow to be fully black on the ground.
  105959. * 0.5 by default.
  105960. */
  105961. groundShadowLevel: number;
  105962. /**
  105963. * Creates a mirror texture attach to the ground.
  105964. * false by default.
  105965. */
  105966. enableGroundMirror: boolean;
  105967. /**
  105968. * Specifies the ground mirror size ratio.
  105969. * 0.3 by default as the default kernel is 64.
  105970. */
  105971. groundMirrorSizeRatio: number;
  105972. /**
  105973. * Specifies the ground mirror blur kernel size.
  105974. * 64 by default.
  105975. */
  105976. groundMirrorBlurKernel: number;
  105977. /**
  105978. * Specifies the ground mirror visibility amount.
  105979. * 1 by default
  105980. */
  105981. groundMirrorAmount: number;
  105982. /**
  105983. * Specifies the ground mirror reflectance weight.
  105984. * This uses the standard weight of the background material to setup the fresnel effect
  105985. * of the mirror.
  105986. * 1 by default.
  105987. */
  105988. groundMirrorFresnelWeight: number;
  105989. /**
  105990. * Specifies the ground mirror Falloff distance.
  105991. * This can helps reducing the size of the reflection.
  105992. * 0 by Default.
  105993. */
  105994. groundMirrorFallOffDistance: number;
  105995. /**
  105996. * Specifies the ground mirror texture type.
  105997. * Unsigned Int by Default.
  105998. */
  105999. groundMirrorTextureType: number;
  106000. /**
  106001. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  106002. * the shown objects.
  106003. */
  106004. groundYBias: number;
  106005. /**
  106006. * Specifies wether or not to create a skybox.
  106007. * True by default.
  106008. */
  106009. createSkybox: boolean;
  106010. /**
  106011. * Specifies the skybox size.
  106012. * 20 by default.
  106013. */
  106014. skyboxSize: number;
  106015. /**
  106016. * The texture used on the skybox for the main color.
  106017. * Comes from the BabylonJS CDN by default.
  106018. *
  106019. * Remarks: Can be either a texture or a url.
  106020. */
  106021. skyboxTexture: string | BaseTexture;
  106022. /**
  106023. * The color mixed in the skybox texture by default.
  106024. * BabylonJS clearColor by default.
  106025. */
  106026. skyboxColor: Color3;
  106027. /**
  106028. * The background rotation around the Y axis of the scene.
  106029. * This helps aligning the key lights of your scene with the background.
  106030. * 0 by default.
  106031. */
  106032. backgroundYRotation: number;
  106033. /**
  106034. * Compute automatically the size of the elements to best fit with the scene.
  106035. */
  106036. sizeAuto: boolean;
  106037. /**
  106038. * Default position of the rootMesh if autoSize is not true.
  106039. */
  106040. rootPosition: Vector3;
  106041. /**
  106042. * Sets up the image processing in the scene.
  106043. * true by default.
  106044. */
  106045. setupImageProcessing: boolean;
  106046. /**
  106047. * The texture used as your environment texture in the scene.
  106048. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  106049. *
  106050. * Remarks: Can be either a texture or a url.
  106051. */
  106052. environmentTexture: string | BaseTexture;
  106053. /**
  106054. * The value of the exposure to apply to the scene.
  106055. * 0.6 by default if setupImageProcessing is true.
  106056. */
  106057. cameraExposure: number;
  106058. /**
  106059. * The value of the contrast to apply to the scene.
  106060. * 1.6 by default if setupImageProcessing is true.
  106061. */
  106062. cameraContrast: number;
  106063. /**
  106064. * Specifies wether or not tonemapping should be enabled in the scene.
  106065. * true by default if setupImageProcessing is true.
  106066. */
  106067. toneMappingEnabled: boolean;
  106068. }
  106069. /**
  106070. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  106071. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  106072. * It also helps with the default setup of your imageProcessing configuration.
  106073. */
  106074. export class EnvironmentHelper {
  106075. /**
  106076. * Default ground texture URL.
  106077. */
  106078. private static _groundTextureCDNUrl;
  106079. /**
  106080. * Default skybox texture URL.
  106081. */
  106082. private static _skyboxTextureCDNUrl;
  106083. /**
  106084. * Default environment texture URL.
  106085. */
  106086. private static _environmentTextureCDNUrl;
  106087. /**
  106088. * Creates the default options for the helper.
  106089. */
  106090. private static _getDefaultOptions;
  106091. private _rootMesh;
  106092. /**
  106093. * Gets the root mesh created by the helper.
  106094. */
  106095. readonly rootMesh: Mesh;
  106096. private _skybox;
  106097. /**
  106098. * Gets the skybox created by the helper.
  106099. */
  106100. readonly skybox: Nullable<Mesh>;
  106101. private _skyboxTexture;
  106102. /**
  106103. * Gets the skybox texture created by the helper.
  106104. */
  106105. readonly skyboxTexture: Nullable<BaseTexture>;
  106106. private _skyboxMaterial;
  106107. /**
  106108. * Gets the skybox material created by the helper.
  106109. */
  106110. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  106111. private _ground;
  106112. /**
  106113. * Gets the ground mesh created by the helper.
  106114. */
  106115. readonly ground: Nullable<Mesh>;
  106116. private _groundTexture;
  106117. /**
  106118. * Gets the ground texture created by the helper.
  106119. */
  106120. readonly groundTexture: Nullable<BaseTexture>;
  106121. private _groundMirror;
  106122. /**
  106123. * Gets the ground mirror created by the helper.
  106124. */
  106125. readonly groundMirror: Nullable<MirrorTexture>;
  106126. /**
  106127. * Gets the ground mirror render list to helps pushing the meshes
  106128. * you wish in the ground reflection.
  106129. */
  106130. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  106131. private _groundMaterial;
  106132. /**
  106133. * Gets the ground material created by the helper.
  106134. */
  106135. readonly groundMaterial: Nullable<BackgroundMaterial>;
  106136. /**
  106137. * Stores the creation options.
  106138. */
  106139. private readonly _scene;
  106140. private _options;
  106141. /**
  106142. * This observable will be notified with any error during the creation of the environment,
  106143. * mainly texture creation errors.
  106144. */
  106145. onErrorObservable: Observable<{
  106146. message?: string;
  106147. exception?: any;
  106148. }>;
  106149. /**
  106150. * constructor
  106151. * @param options Defines the options we want to customize the helper
  106152. * @param scene The scene to add the material to
  106153. */
  106154. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  106155. /**
  106156. * Updates the background according to the new options
  106157. * @param options
  106158. */
  106159. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  106160. /**
  106161. * Sets the primary color of all the available elements.
  106162. * @param color the main color to affect to the ground and the background
  106163. */
  106164. setMainColor(color: Color3): void;
  106165. /**
  106166. * Setup the image processing according to the specified options.
  106167. */
  106168. private _setupImageProcessing;
  106169. /**
  106170. * Setup the environment texture according to the specified options.
  106171. */
  106172. private _setupEnvironmentTexture;
  106173. /**
  106174. * Setup the background according to the specified options.
  106175. */
  106176. private _setupBackground;
  106177. /**
  106178. * Get the scene sizes according to the setup.
  106179. */
  106180. private _getSceneSize;
  106181. /**
  106182. * Setup the ground according to the specified options.
  106183. */
  106184. private _setupGround;
  106185. /**
  106186. * Setup the ground material according to the specified options.
  106187. */
  106188. private _setupGroundMaterial;
  106189. /**
  106190. * Setup the ground diffuse texture according to the specified options.
  106191. */
  106192. private _setupGroundDiffuseTexture;
  106193. /**
  106194. * Setup the ground mirror texture according to the specified options.
  106195. */
  106196. private _setupGroundMirrorTexture;
  106197. /**
  106198. * Setup the ground to receive the mirror texture.
  106199. */
  106200. private _setupMirrorInGroundMaterial;
  106201. /**
  106202. * Setup the skybox according to the specified options.
  106203. */
  106204. private _setupSkybox;
  106205. /**
  106206. * Setup the skybox material according to the specified options.
  106207. */
  106208. private _setupSkyboxMaterial;
  106209. /**
  106210. * Setup the skybox reflection texture according to the specified options.
  106211. */
  106212. private _setupSkyboxReflectionTexture;
  106213. private _errorHandler;
  106214. /**
  106215. * Dispose all the elements created by the Helper.
  106216. */
  106217. dispose(): void;
  106218. }
  106219. }
  106220. declare module BABYLON {
  106221. /**
  106222. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  106223. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  106224. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  106225. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  106226. */
  106227. export class PhotoDome extends TransformNode {
  106228. private _useDirectMapping;
  106229. /**
  106230. * The texture being displayed on the sphere
  106231. */
  106232. protected _photoTexture: Texture;
  106233. /**
  106234. * Gets or sets the texture being displayed on the sphere
  106235. */
  106236. photoTexture: Texture;
  106237. /**
  106238. * Observable raised when an error occured while loading the 360 image
  106239. */
  106240. onLoadErrorObservable: Observable<string>;
  106241. /**
  106242. * The skybox material
  106243. */
  106244. protected _material: BackgroundMaterial;
  106245. /**
  106246. * The surface used for the skybox
  106247. */
  106248. protected _mesh: Mesh;
  106249. /**
  106250. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  106251. * Also see the options.resolution property.
  106252. */
  106253. fovMultiplier: number;
  106254. /**
  106255. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  106256. * @param name Element's name, child elements will append suffixes for their own names.
  106257. * @param urlsOfPhoto defines the url of the photo to display
  106258. * @param options defines an object containing optional or exposed sub element properties
  106259. * @param onError defines a callback called when an error occured while loading the texture
  106260. */
  106261. constructor(name: string, urlOfPhoto: string, options: {
  106262. resolution?: number;
  106263. size?: number;
  106264. useDirectMapping?: boolean;
  106265. faceForward?: boolean;
  106266. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  106267. /**
  106268. * Releases resources associated with this node.
  106269. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  106270. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  106271. */
  106272. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  106273. }
  106274. }
  106275. declare module BABYLON {
  106276. /** @hidden */
  106277. export var rgbdDecodePixelShader: {
  106278. name: string;
  106279. shader: string;
  106280. };
  106281. }
  106282. declare module BABYLON {
  106283. /**
  106284. * Class used to host texture specific utilities
  106285. */
  106286. export class BRDFTextureTools {
  106287. /**
  106288. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  106289. * @param texture the texture to expand.
  106290. */
  106291. private static _ExpandDefaultBRDFTexture;
  106292. /**
  106293. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  106294. * @param scene defines the hosting scene
  106295. * @returns the environment BRDF texture
  106296. */
  106297. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  106298. private static _environmentBRDFBase64Texture;
  106299. }
  106300. }
  106301. declare module BABYLON {
  106302. /**
  106303. * @hidden
  106304. */
  106305. export interface IMaterialClearCoatDefines {
  106306. CLEARCOAT: boolean;
  106307. CLEARCOAT_DEFAULTIOR: boolean;
  106308. CLEARCOAT_TEXTURE: boolean;
  106309. CLEARCOAT_TEXTUREDIRECTUV: number;
  106310. CLEARCOAT_BUMP: boolean;
  106311. CLEARCOAT_BUMPDIRECTUV: number;
  106312. CLEARCOAT_TINT: boolean;
  106313. CLEARCOAT_TINT_TEXTURE: boolean;
  106314. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  106315. /** @hidden */
  106316. _areTexturesDirty: boolean;
  106317. }
  106318. /**
  106319. * Define the code related to the clear coat parameters of the pbr material.
  106320. */
  106321. export class PBRClearCoatConfiguration {
  106322. /**
  106323. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106324. * The default fits with a polyurethane material.
  106325. */
  106326. private static readonly _DefaultIndiceOfRefraction;
  106327. private _isEnabled;
  106328. /**
  106329. * Defines if the clear coat is enabled in the material.
  106330. */
  106331. isEnabled: boolean;
  106332. /**
  106333. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  106334. */
  106335. intensity: number;
  106336. /**
  106337. * Defines the clear coat layer roughness.
  106338. */
  106339. roughness: number;
  106340. private _indiceOfRefraction;
  106341. /**
  106342. * Defines the indice of refraction of the clear coat.
  106343. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  106344. * The default fits with a polyurethane material.
  106345. * Changing the default value is more performance intensive.
  106346. */
  106347. indiceOfRefraction: number;
  106348. private _texture;
  106349. /**
  106350. * Stores the clear coat values in a texture.
  106351. */
  106352. texture: Nullable<BaseTexture>;
  106353. private _bumpTexture;
  106354. /**
  106355. * Define the clear coat specific bump texture.
  106356. */
  106357. bumpTexture: Nullable<BaseTexture>;
  106358. private _isTintEnabled;
  106359. /**
  106360. * Defines if the clear coat tint is enabled in the material.
  106361. */
  106362. isTintEnabled: boolean;
  106363. /**
  106364. * Defines the clear coat tint of the material.
  106365. * This is only use if tint is enabled
  106366. */
  106367. tintColor: Color3;
  106368. /**
  106369. * Defines the distance at which the tint color should be found in the
  106370. * clear coat media.
  106371. * This is only use if tint is enabled
  106372. */
  106373. tintColorAtDistance: number;
  106374. /**
  106375. * Defines the clear coat layer thickness.
  106376. * This is only use if tint is enabled
  106377. */
  106378. tintThickness: number;
  106379. private _tintTexture;
  106380. /**
  106381. * Stores the clear tint values in a texture.
  106382. * rgb is tint
  106383. * a is a thickness factor
  106384. */
  106385. tintTexture: Nullable<BaseTexture>;
  106386. /** @hidden */
  106387. private _internalMarkAllSubMeshesAsTexturesDirty;
  106388. /** @hidden */
  106389. _markAllSubMeshesAsTexturesDirty(): void;
  106390. /**
  106391. * Instantiate a new istance of clear coat configuration.
  106392. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106393. */
  106394. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106395. /**
  106396. * Gets wehter the submesh is ready to be used or not.
  106397. * @param defines the list of "defines" to update.
  106398. * @param scene defines the scene the material belongs to.
  106399. * @param engine defines the engine the material belongs to.
  106400. * @param disableBumpMap defines wether the material disables bump or not.
  106401. * @returns - boolean indicating that the submesh is ready or not.
  106402. */
  106403. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  106404. /**
  106405. * Checks to see if a texture is used in the material.
  106406. * @param defines the list of "defines" to update.
  106407. * @param scene defines the scene to the material belongs to.
  106408. */
  106409. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  106410. /**
  106411. * Binds the material data.
  106412. * @param uniformBuffer defines the Uniform buffer to fill in.
  106413. * @param scene defines the scene the material belongs to.
  106414. * @param engine defines the engine the material belongs to.
  106415. * @param disableBumpMap defines wether the material disables bump or not.
  106416. * @param isFrozen defines wether the material is frozen or not.
  106417. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  106418. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  106419. */
  106420. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  106421. /**
  106422. * Checks to see if a texture is used in the material.
  106423. * @param texture - Base texture to use.
  106424. * @returns - Boolean specifying if a texture is used in the material.
  106425. */
  106426. hasTexture(texture: BaseTexture): boolean;
  106427. /**
  106428. * Returns an array of the actively used textures.
  106429. * @param activeTextures Array of BaseTextures
  106430. */
  106431. getActiveTextures(activeTextures: BaseTexture[]): void;
  106432. /**
  106433. * Returns the animatable textures.
  106434. * @param animatables Array of animatable textures.
  106435. */
  106436. getAnimatables(animatables: IAnimatable[]): void;
  106437. /**
  106438. * Disposes the resources of the material.
  106439. * @param forceDisposeTextures - Forces the disposal of all textures.
  106440. */
  106441. dispose(forceDisposeTextures?: boolean): void;
  106442. /**
  106443. * Get the current class name of the texture useful for serialization or dynamic coding.
  106444. * @returns "PBRClearCoatConfiguration"
  106445. */
  106446. getClassName(): string;
  106447. /**
  106448. * Add fallbacks to the effect fallbacks list.
  106449. * @param defines defines the Base texture to use.
  106450. * @param fallbacks defines the current fallback list.
  106451. * @param currentRank defines the current fallback rank.
  106452. * @returns the new fallback rank.
  106453. */
  106454. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106455. /**
  106456. * Add the required uniforms to the current list.
  106457. * @param uniforms defines the current uniform list.
  106458. */
  106459. static AddUniforms(uniforms: string[]): void;
  106460. /**
  106461. * Add the required samplers to the current list.
  106462. * @param samplers defines the current sampler list.
  106463. */
  106464. static AddSamplers(samplers: string[]): void;
  106465. /**
  106466. * Add the required uniforms to the current buffer.
  106467. * @param uniformBuffer defines the current uniform buffer.
  106468. */
  106469. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106470. /**
  106471. * Makes a duplicate of the current configuration into another one.
  106472. * @param clearCoatConfiguration define the config where to copy the info
  106473. */
  106474. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  106475. /**
  106476. * Serializes this clear coat configuration.
  106477. * @returns - An object with the serialized config.
  106478. */
  106479. serialize(): any;
  106480. /**
  106481. * Parses a Clear Coat Configuration from a serialized object.
  106482. * @param source - Serialized object.
  106483. */
  106484. parse(source: any): void;
  106485. }
  106486. }
  106487. declare module BABYLON {
  106488. /**
  106489. * @hidden
  106490. */
  106491. export interface IMaterialAnisotropicDefines {
  106492. ANISOTROPIC: boolean;
  106493. ANISOTROPIC_TEXTURE: boolean;
  106494. ANISOTROPIC_TEXTUREDIRECTUV: number;
  106495. MAINUV1: boolean;
  106496. _areTexturesDirty: boolean;
  106497. _needUVs: boolean;
  106498. }
  106499. /**
  106500. * Define the code related to the anisotropic parameters of the pbr material.
  106501. */
  106502. export class PBRAnisotropicConfiguration {
  106503. private _isEnabled;
  106504. /**
  106505. * Defines if the anisotropy is enabled in the material.
  106506. */
  106507. isEnabled: boolean;
  106508. /**
  106509. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  106510. */
  106511. intensity: number;
  106512. /**
  106513. * Defines if the effect is along the tangents, bitangents or in between.
  106514. * By default, the effect is "strectching" the highlights along the tangents.
  106515. */
  106516. direction: Vector2;
  106517. private _texture;
  106518. /**
  106519. * Stores the anisotropy values in a texture.
  106520. * rg is direction (like normal from -1 to 1)
  106521. * b is a intensity
  106522. */
  106523. texture: Nullable<BaseTexture>;
  106524. /** @hidden */
  106525. private _internalMarkAllSubMeshesAsTexturesDirty;
  106526. /** @hidden */
  106527. _markAllSubMeshesAsTexturesDirty(): void;
  106528. /**
  106529. * Instantiate a new istance of anisotropy configuration.
  106530. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106531. */
  106532. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106533. /**
  106534. * Specifies that the submesh is ready to be used.
  106535. * @param defines the list of "defines" to update.
  106536. * @param scene defines the scene the material belongs to.
  106537. * @returns - boolean indicating that the submesh is ready or not.
  106538. */
  106539. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  106540. /**
  106541. * Checks to see if a texture is used in the material.
  106542. * @param defines the list of "defines" to update.
  106543. * @param mesh the mesh we are preparing the defines for.
  106544. * @param scene defines the scene the material belongs to.
  106545. */
  106546. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  106547. /**
  106548. * Binds the material data.
  106549. * @param uniformBuffer defines the Uniform buffer to fill in.
  106550. * @param scene defines the scene the material belongs to.
  106551. * @param isFrozen defines wether the material is frozen or not.
  106552. */
  106553. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106554. /**
  106555. * Checks to see if a texture is used in the material.
  106556. * @param texture - Base texture to use.
  106557. * @returns - Boolean specifying if a texture is used in the material.
  106558. */
  106559. hasTexture(texture: BaseTexture): boolean;
  106560. /**
  106561. * Returns an array of the actively used textures.
  106562. * @param activeTextures Array of BaseTextures
  106563. */
  106564. getActiveTextures(activeTextures: BaseTexture[]): void;
  106565. /**
  106566. * Returns the animatable textures.
  106567. * @param animatables Array of animatable textures.
  106568. */
  106569. getAnimatables(animatables: IAnimatable[]): void;
  106570. /**
  106571. * Disposes the resources of the material.
  106572. * @param forceDisposeTextures - Forces the disposal of all textures.
  106573. */
  106574. dispose(forceDisposeTextures?: boolean): void;
  106575. /**
  106576. * Get the current class name of the texture useful for serialization or dynamic coding.
  106577. * @returns "PBRAnisotropicConfiguration"
  106578. */
  106579. getClassName(): string;
  106580. /**
  106581. * Add fallbacks to the effect fallbacks list.
  106582. * @param defines defines the Base texture to use.
  106583. * @param fallbacks defines the current fallback list.
  106584. * @param currentRank defines the current fallback rank.
  106585. * @returns the new fallback rank.
  106586. */
  106587. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106588. /**
  106589. * Add the required uniforms to the current list.
  106590. * @param uniforms defines the current uniform list.
  106591. */
  106592. static AddUniforms(uniforms: string[]): void;
  106593. /**
  106594. * Add the required uniforms to the current buffer.
  106595. * @param uniformBuffer defines the current uniform buffer.
  106596. */
  106597. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106598. /**
  106599. * Add the required samplers to the current list.
  106600. * @param samplers defines the current sampler list.
  106601. */
  106602. static AddSamplers(samplers: string[]): void;
  106603. /**
  106604. * Makes a duplicate of the current configuration into another one.
  106605. * @param anisotropicConfiguration define the config where to copy the info
  106606. */
  106607. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  106608. /**
  106609. * Serializes this anisotropy configuration.
  106610. * @returns - An object with the serialized config.
  106611. */
  106612. serialize(): any;
  106613. /**
  106614. * Parses a anisotropy Configuration from a serialized object.
  106615. * @param source - Serialized object.
  106616. */
  106617. parse(source: any): void;
  106618. }
  106619. }
  106620. declare module BABYLON {
  106621. /**
  106622. * @hidden
  106623. */
  106624. export interface IMaterialBRDFDefines {
  106625. BRDF_V_HEIGHT_CORRELATED: boolean;
  106626. MS_BRDF_ENERGY_CONSERVATION: boolean;
  106627. SPHERICAL_HARMONICS: boolean;
  106628. /** @hidden */
  106629. _areMiscDirty: boolean;
  106630. }
  106631. /**
  106632. * Define the code related to the BRDF parameters of the pbr material.
  106633. */
  106634. export class PBRBRDFConfiguration {
  106635. /**
  106636. * Default value used for the energy conservation.
  106637. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106638. */
  106639. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  106640. /**
  106641. * Default value used for the Smith Visibility Height Correlated mode.
  106642. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  106643. */
  106644. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  106645. /**
  106646. * Default value used for the IBL diffuse part.
  106647. * This can help switching back to the polynomials mode globally which is a tiny bit
  106648. * less GPU intensive at the drawback of a lower quality.
  106649. */
  106650. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  106651. private _useEnergyConservation;
  106652. /**
  106653. * Defines if the material uses energy conservation.
  106654. */
  106655. useEnergyConservation: boolean;
  106656. private _useSmithVisibilityHeightCorrelated;
  106657. /**
  106658. * LEGACY Mode set to false
  106659. * Defines if the material uses height smith correlated visibility term.
  106660. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  106661. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  106662. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  106663. * Not relying on height correlated will also disable energy conservation.
  106664. */
  106665. useSmithVisibilityHeightCorrelated: boolean;
  106666. private _useSphericalHarmonics;
  106667. /**
  106668. * LEGACY Mode set to false
  106669. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  106670. * diffuse part of the IBL.
  106671. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  106672. * to the ground truth.
  106673. */
  106674. useSphericalHarmonics: boolean;
  106675. /** @hidden */
  106676. private _internalMarkAllSubMeshesAsMiscDirty;
  106677. /** @hidden */
  106678. _markAllSubMeshesAsMiscDirty(): void;
  106679. /**
  106680. * Instantiate a new istance of clear coat configuration.
  106681. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  106682. */
  106683. constructor(markAllSubMeshesAsMiscDirty: () => void);
  106684. /**
  106685. * Checks to see if a texture is used in the material.
  106686. * @param defines the list of "defines" to update.
  106687. */
  106688. prepareDefines(defines: IMaterialBRDFDefines): void;
  106689. /**
  106690. * Get the current class name of the texture useful for serialization or dynamic coding.
  106691. * @returns "PBRClearCoatConfiguration"
  106692. */
  106693. getClassName(): string;
  106694. /**
  106695. * Makes a duplicate of the current configuration into another one.
  106696. * @param brdfConfiguration define the config where to copy the info
  106697. */
  106698. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  106699. /**
  106700. * Serializes this BRDF configuration.
  106701. * @returns - An object with the serialized config.
  106702. */
  106703. serialize(): any;
  106704. /**
  106705. * Parses a BRDF Configuration from a serialized object.
  106706. * @param source - Serialized object.
  106707. */
  106708. parse(source: any): void;
  106709. }
  106710. }
  106711. declare module BABYLON {
  106712. /**
  106713. * @hidden
  106714. */
  106715. export interface IMaterialSheenDefines {
  106716. SHEEN: boolean;
  106717. SHEEN_TEXTURE: boolean;
  106718. SHEEN_TEXTUREDIRECTUV: number;
  106719. SHEEN_LINKWITHALBEDO: boolean;
  106720. /** @hidden */
  106721. _areTexturesDirty: boolean;
  106722. }
  106723. /**
  106724. * Define the code related to the Sheen parameters of the pbr material.
  106725. */
  106726. export class PBRSheenConfiguration {
  106727. private _isEnabled;
  106728. /**
  106729. * Defines if the material uses sheen.
  106730. */
  106731. isEnabled: boolean;
  106732. private _linkSheenWithAlbedo;
  106733. /**
  106734. * Defines if the sheen is linked to the sheen color.
  106735. */
  106736. linkSheenWithAlbedo: boolean;
  106737. /**
  106738. * Defines the sheen intensity.
  106739. */
  106740. intensity: number;
  106741. /**
  106742. * Defines the sheen color.
  106743. */
  106744. color: Color3;
  106745. private _texture;
  106746. /**
  106747. * Stores the sheen tint values in a texture.
  106748. * rgb is tint
  106749. * a is a intensity
  106750. */
  106751. texture: Nullable<BaseTexture>;
  106752. /** @hidden */
  106753. private _internalMarkAllSubMeshesAsTexturesDirty;
  106754. /** @hidden */
  106755. _markAllSubMeshesAsTexturesDirty(): void;
  106756. /**
  106757. * Instantiate a new istance of clear coat configuration.
  106758. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106759. */
  106760. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106761. /**
  106762. * Specifies that the submesh is ready to be used.
  106763. * @param defines the list of "defines" to update.
  106764. * @param scene defines the scene the material belongs to.
  106765. * @returns - boolean indicating that the submesh is ready or not.
  106766. */
  106767. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  106768. /**
  106769. * Checks to see if a texture is used in the material.
  106770. * @param defines the list of "defines" to update.
  106771. * @param scene defines the scene the material belongs to.
  106772. */
  106773. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  106774. /**
  106775. * Binds the material data.
  106776. * @param uniformBuffer defines the Uniform buffer to fill in.
  106777. * @param scene defines the scene the material belongs to.
  106778. * @param isFrozen defines wether the material is frozen or not.
  106779. */
  106780. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  106781. /**
  106782. * Checks to see if a texture is used in the material.
  106783. * @param texture - Base texture to use.
  106784. * @returns - Boolean specifying if a texture is used in the material.
  106785. */
  106786. hasTexture(texture: BaseTexture): boolean;
  106787. /**
  106788. * Returns an array of the actively used textures.
  106789. * @param activeTextures Array of BaseTextures
  106790. */
  106791. getActiveTextures(activeTextures: BaseTexture[]): void;
  106792. /**
  106793. * Returns the animatable textures.
  106794. * @param animatables Array of animatable textures.
  106795. */
  106796. getAnimatables(animatables: IAnimatable[]): void;
  106797. /**
  106798. * Disposes the resources of the material.
  106799. * @param forceDisposeTextures - Forces the disposal of all textures.
  106800. */
  106801. dispose(forceDisposeTextures?: boolean): void;
  106802. /**
  106803. * Get the current class name of the texture useful for serialization or dynamic coding.
  106804. * @returns "PBRSheenConfiguration"
  106805. */
  106806. getClassName(): string;
  106807. /**
  106808. * Add fallbacks to the effect fallbacks list.
  106809. * @param defines defines the Base texture to use.
  106810. * @param fallbacks defines the current fallback list.
  106811. * @param currentRank defines the current fallback rank.
  106812. * @returns the new fallback rank.
  106813. */
  106814. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  106815. /**
  106816. * Add the required uniforms to the current list.
  106817. * @param uniforms defines the current uniform list.
  106818. */
  106819. static AddUniforms(uniforms: string[]): void;
  106820. /**
  106821. * Add the required uniforms to the current buffer.
  106822. * @param uniformBuffer defines the current uniform buffer.
  106823. */
  106824. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  106825. /**
  106826. * Add the required samplers to the current list.
  106827. * @param samplers defines the current sampler list.
  106828. */
  106829. static AddSamplers(samplers: string[]): void;
  106830. /**
  106831. * Makes a duplicate of the current configuration into another one.
  106832. * @param sheenConfiguration define the config where to copy the info
  106833. */
  106834. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  106835. /**
  106836. * Serializes this BRDF configuration.
  106837. * @returns - An object with the serialized config.
  106838. */
  106839. serialize(): any;
  106840. /**
  106841. * Parses a Sheen Configuration from a serialized object.
  106842. * @param source - Serialized object.
  106843. */
  106844. parse(source: any): void;
  106845. }
  106846. }
  106847. declare module BABYLON {
  106848. /**
  106849. * @hidden
  106850. */
  106851. export interface IMaterialSubSurfaceDefines {
  106852. SUBSURFACE: boolean;
  106853. SS_REFRACTION: boolean;
  106854. SS_TRANSLUCENCY: boolean;
  106855. SS_SCATERRING: boolean;
  106856. SS_THICKNESSANDMASK_TEXTURE: boolean;
  106857. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  106858. SS_REFRACTIONMAP_3D: boolean;
  106859. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  106860. SS_LODINREFRACTIONALPHA: boolean;
  106861. SS_GAMMAREFRACTION: boolean;
  106862. SS_RGBDREFRACTION: boolean;
  106863. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  106864. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  106865. /** @hidden */
  106866. _areTexturesDirty: boolean;
  106867. }
  106868. /**
  106869. * Define the code related to the sub surface parameters of the pbr material.
  106870. */
  106871. export class PBRSubSurfaceConfiguration {
  106872. private _isRefractionEnabled;
  106873. /**
  106874. * Defines if the refraction is enabled in the material.
  106875. */
  106876. isRefractionEnabled: boolean;
  106877. private _isTranslucencyEnabled;
  106878. /**
  106879. * Defines if the translucency is enabled in the material.
  106880. */
  106881. isTranslucencyEnabled: boolean;
  106882. private _isScatteringEnabled;
  106883. /**
  106884. * Defines the refraction intensity of the material.
  106885. * The refraction when enabled replaces the Diffuse part of the material.
  106886. * The intensity helps transitionning between diffuse and refraction.
  106887. */
  106888. refractionIntensity: number;
  106889. /**
  106890. * Defines the translucency intensity of the material.
  106891. * When translucency has been enabled, this defines how much of the "translucency"
  106892. * is addded to the diffuse part of the material.
  106893. */
  106894. translucencyIntensity: number;
  106895. /**
  106896. * Defines the scattering intensity of the material.
  106897. * When scattering has been enabled, this defines how much of the "scattered light"
  106898. * is addded to the diffuse part of the material.
  106899. */
  106900. scatteringIntensity: number;
  106901. private _thicknessTexture;
  106902. /**
  106903. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  106904. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  106905. * 0 would mean minimumThickness
  106906. * 1 would mean maximumThickness
  106907. * The other channels might be use as a mask to vary the different effects intensity.
  106908. */
  106909. thicknessTexture: Nullable<BaseTexture>;
  106910. private _refractionTexture;
  106911. /**
  106912. * Defines the texture to use for refraction.
  106913. */
  106914. refractionTexture: Nullable<BaseTexture>;
  106915. private _indexOfRefraction;
  106916. /**
  106917. * Defines the indice of refraction used in the material.
  106918. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  106919. */
  106920. indexOfRefraction: number;
  106921. private _invertRefractionY;
  106922. /**
  106923. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  106924. */
  106925. invertRefractionY: boolean;
  106926. private _linkRefractionWithTransparency;
  106927. /**
  106928. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  106929. * Materials half opaque for instance using refraction could benefit from this control.
  106930. */
  106931. linkRefractionWithTransparency: boolean;
  106932. /**
  106933. * Defines the minimum thickness stored in the thickness map.
  106934. * If no thickness map is defined, this value will be used to simulate thickness.
  106935. */
  106936. minimumThickness: number;
  106937. /**
  106938. * Defines the maximum thickness stored in the thickness map.
  106939. */
  106940. maximumThickness: number;
  106941. /**
  106942. * Defines the volume tint of the material.
  106943. * This is used for both translucency and scattering.
  106944. */
  106945. tintColor: Color3;
  106946. /**
  106947. * Defines the distance at which the tint color should be found in the media.
  106948. * This is used for refraction only.
  106949. */
  106950. tintColorAtDistance: number;
  106951. /**
  106952. * Defines how far each channel transmit through the media.
  106953. * It is defined as a color to simplify it selection.
  106954. */
  106955. diffusionDistance: Color3;
  106956. private _useMaskFromThicknessTexture;
  106957. /**
  106958. * Stores the intensity of the different subsurface effects in the thickness texture.
  106959. * * the green channel is the translucency intensity.
  106960. * * the blue channel is the scattering intensity.
  106961. * * the alpha channel is the refraction intensity.
  106962. */
  106963. useMaskFromThicknessTexture: boolean;
  106964. /** @hidden */
  106965. private _internalMarkAllSubMeshesAsTexturesDirty;
  106966. /** @hidden */
  106967. _markAllSubMeshesAsTexturesDirty(): void;
  106968. /**
  106969. * Instantiate a new istance of sub surface configuration.
  106970. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  106971. */
  106972. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  106973. /**
  106974. * Gets wehter the submesh is ready to be used or not.
  106975. * @param defines the list of "defines" to update.
  106976. * @param scene defines the scene the material belongs to.
  106977. * @returns - boolean indicating that the submesh is ready or not.
  106978. */
  106979. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  106980. /**
  106981. * Checks to see if a texture is used in the material.
  106982. * @param defines the list of "defines" to update.
  106983. * @param scene defines the scene to the material belongs to.
  106984. */
  106985. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  106986. /**
  106987. * Binds the material data.
  106988. * @param uniformBuffer defines the Uniform buffer to fill in.
  106989. * @param scene defines the scene the material belongs to.
  106990. * @param engine defines the engine the material belongs to.
  106991. * @param isFrozen defines wether the material is frozen or not.
  106992. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  106993. */
  106994. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  106995. /**
  106996. * Unbinds the material from the mesh.
  106997. * @param activeEffect defines the effect that should be unbound from.
  106998. * @returns true if unbound, otherwise false
  106999. */
  107000. unbind(activeEffect: Effect): boolean;
  107001. /**
  107002. * Returns the texture used for refraction or null if none is used.
  107003. * @param scene defines the scene the material belongs to.
  107004. * @returns - Refraction texture if present. If no refraction texture and refraction
  107005. * is linked with transparency, returns environment texture. Otherwise, returns null.
  107006. */
  107007. private _getRefractionTexture;
  107008. /**
  107009. * Returns true if alpha blending should be disabled.
  107010. */
  107011. readonly disableAlphaBlending: boolean;
  107012. /**
  107013. * Fills the list of render target textures.
  107014. * @param renderTargets the list of render targets to update
  107015. */
  107016. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  107017. /**
  107018. * Checks to see if a texture is used in the material.
  107019. * @param texture - Base texture to use.
  107020. * @returns - Boolean specifying if a texture is used in the material.
  107021. */
  107022. hasTexture(texture: BaseTexture): boolean;
  107023. /**
  107024. * Gets a boolean indicating that current material needs to register RTT
  107025. * @returns true if this uses a render target otherwise false.
  107026. */
  107027. hasRenderTargetTextures(): boolean;
  107028. /**
  107029. * Returns an array of the actively used textures.
  107030. * @param activeTextures Array of BaseTextures
  107031. */
  107032. getActiveTextures(activeTextures: BaseTexture[]): void;
  107033. /**
  107034. * Returns the animatable textures.
  107035. * @param animatables Array of animatable textures.
  107036. */
  107037. getAnimatables(animatables: IAnimatable[]): void;
  107038. /**
  107039. * Disposes the resources of the material.
  107040. * @param forceDisposeTextures - Forces the disposal of all textures.
  107041. */
  107042. dispose(forceDisposeTextures?: boolean): void;
  107043. /**
  107044. * Get the current class name of the texture useful for serialization or dynamic coding.
  107045. * @returns "PBRSubSurfaceConfiguration"
  107046. */
  107047. getClassName(): string;
  107048. /**
  107049. * Add fallbacks to the effect fallbacks list.
  107050. * @param defines defines the Base texture to use.
  107051. * @param fallbacks defines the current fallback list.
  107052. * @param currentRank defines the current fallback rank.
  107053. * @returns the new fallback rank.
  107054. */
  107055. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  107056. /**
  107057. * Add the required uniforms to the current list.
  107058. * @param uniforms defines the current uniform list.
  107059. */
  107060. static AddUniforms(uniforms: string[]): void;
  107061. /**
  107062. * Add the required samplers to the current list.
  107063. * @param samplers defines the current sampler list.
  107064. */
  107065. static AddSamplers(samplers: string[]): void;
  107066. /**
  107067. * Add the required uniforms to the current buffer.
  107068. * @param uniformBuffer defines the current uniform buffer.
  107069. */
  107070. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  107071. /**
  107072. * Makes a duplicate of the current configuration into another one.
  107073. * @param configuration define the config where to copy the info
  107074. */
  107075. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  107076. /**
  107077. * Serializes this Sub Surface configuration.
  107078. * @returns - An object with the serialized config.
  107079. */
  107080. serialize(): any;
  107081. /**
  107082. * Parses a Sub Surface Configuration from a serialized object.
  107083. * @param source - Serialized object.
  107084. */
  107085. parse(source: any): void;
  107086. }
  107087. }
  107088. declare module BABYLON {
  107089. /** @hidden */
  107090. export var pbrFragmentDeclaration: {
  107091. name: string;
  107092. shader: string;
  107093. };
  107094. }
  107095. declare module BABYLON {
  107096. /** @hidden */
  107097. export var pbrUboDeclaration: {
  107098. name: string;
  107099. shader: string;
  107100. };
  107101. }
  107102. declare module BABYLON {
  107103. /** @hidden */
  107104. export var pbrFragmentExtraDeclaration: {
  107105. name: string;
  107106. shader: string;
  107107. };
  107108. }
  107109. declare module BABYLON {
  107110. /** @hidden */
  107111. export var pbrFragmentSamplersDeclaration: {
  107112. name: string;
  107113. shader: string;
  107114. };
  107115. }
  107116. declare module BABYLON {
  107117. /** @hidden */
  107118. export var pbrHelperFunctions: {
  107119. name: string;
  107120. shader: string;
  107121. };
  107122. }
  107123. declare module BABYLON {
  107124. /** @hidden */
  107125. export var harmonicsFunctions: {
  107126. name: string;
  107127. shader: string;
  107128. };
  107129. }
  107130. declare module BABYLON {
  107131. /** @hidden */
  107132. export var pbrDirectLightingSetupFunctions: {
  107133. name: string;
  107134. shader: string;
  107135. };
  107136. }
  107137. declare module BABYLON {
  107138. /** @hidden */
  107139. export var pbrDirectLightingFalloffFunctions: {
  107140. name: string;
  107141. shader: string;
  107142. };
  107143. }
  107144. declare module BABYLON {
  107145. /** @hidden */
  107146. export var pbrBRDFFunctions: {
  107147. name: string;
  107148. shader: string;
  107149. };
  107150. }
  107151. declare module BABYLON {
  107152. /** @hidden */
  107153. export var pbrDirectLightingFunctions: {
  107154. name: string;
  107155. shader: string;
  107156. };
  107157. }
  107158. declare module BABYLON {
  107159. /** @hidden */
  107160. export var pbrIBLFunctions: {
  107161. name: string;
  107162. shader: string;
  107163. };
  107164. }
  107165. declare module BABYLON {
  107166. /** @hidden */
  107167. export var pbrDebug: {
  107168. name: string;
  107169. shader: string;
  107170. };
  107171. }
  107172. declare module BABYLON {
  107173. /** @hidden */
  107174. export var pbrPixelShader: {
  107175. name: string;
  107176. shader: string;
  107177. };
  107178. }
  107179. declare module BABYLON {
  107180. /** @hidden */
  107181. export var pbrVertexDeclaration: {
  107182. name: string;
  107183. shader: string;
  107184. };
  107185. }
  107186. declare module BABYLON {
  107187. /** @hidden */
  107188. export var pbrVertexShader: {
  107189. name: string;
  107190. shader: string;
  107191. };
  107192. }
  107193. declare module BABYLON {
  107194. /**
  107195. * Manages the defines for the PBR Material.
  107196. * @hidden
  107197. */
  107198. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  107199. PBR: boolean;
  107200. MAINUV1: boolean;
  107201. MAINUV2: boolean;
  107202. UV1: boolean;
  107203. UV2: boolean;
  107204. ALBEDO: boolean;
  107205. ALBEDODIRECTUV: number;
  107206. VERTEXCOLOR: boolean;
  107207. AMBIENT: boolean;
  107208. AMBIENTDIRECTUV: number;
  107209. AMBIENTINGRAYSCALE: boolean;
  107210. OPACITY: boolean;
  107211. VERTEXALPHA: boolean;
  107212. OPACITYDIRECTUV: number;
  107213. OPACITYRGB: boolean;
  107214. ALPHATEST: boolean;
  107215. DEPTHPREPASS: boolean;
  107216. ALPHABLEND: boolean;
  107217. ALPHAFROMALBEDO: boolean;
  107218. ALPHATESTVALUE: string;
  107219. SPECULAROVERALPHA: boolean;
  107220. RADIANCEOVERALPHA: boolean;
  107221. ALPHAFRESNEL: boolean;
  107222. LINEARALPHAFRESNEL: boolean;
  107223. PREMULTIPLYALPHA: boolean;
  107224. EMISSIVE: boolean;
  107225. EMISSIVEDIRECTUV: number;
  107226. REFLECTIVITY: boolean;
  107227. REFLECTIVITYDIRECTUV: number;
  107228. SPECULARTERM: boolean;
  107229. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  107230. MICROSURFACEAUTOMATIC: boolean;
  107231. LODBASEDMICROSFURACE: boolean;
  107232. MICROSURFACEMAP: boolean;
  107233. MICROSURFACEMAPDIRECTUV: number;
  107234. METALLICWORKFLOW: boolean;
  107235. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  107236. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  107237. METALLNESSSTOREINMETALMAPBLUE: boolean;
  107238. AOSTOREINMETALMAPRED: boolean;
  107239. ENVIRONMENTBRDF: boolean;
  107240. ENVIRONMENTBRDF_RGBD: boolean;
  107241. NORMAL: boolean;
  107242. TANGENT: boolean;
  107243. BUMP: boolean;
  107244. BUMPDIRECTUV: number;
  107245. OBJECTSPACE_NORMALMAP: boolean;
  107246. PARALLAX: boolean;
  107247. PARALLAXOCCLUSION: boolean;
  107248. NORMALXYSCALE: boolean;
  107249. LIGHTMAP: boolean;
  107250. LIGHTMAPDIRECTUV: number;
  107251. USELIGHTMAPASSHADOWMAP: boolean;
  107252. GAMMALIGHTMAP: boolean;
  107253. REFLECTION: boolean;
  107254. REFLECTIONMAP_3D: boolean;
  107255. REFLECTIONMAP_SPHERICAL: boolean;
  107256. REFLECTIONMAP_PLANAR: boolean;
  107257. REFLECTIONMAP_CUBIC: boolean;
  107258. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  107259. REFLECTIONMAP_PROJECTION: boolean;
  107260. REFLECTIONMAP_SKYBOX: boolean;
  107261. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  107262. REFLECTIONMAP_EXPLICIT: boolean;
  107263. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  107264. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  107265. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  107266. INVERTCUBICMAP: boolean;
  107267. USESPHERICALFROMREFLECTIONMAP: boolean;
  107268. SPHERICAL_HARMONICS: boolean;
  107269. USESPHERICALINVERTEX: boolean;
  107270. REFLECTIONMAP_OPPOSITEZ: boolean;
  107271. LODINREFLECTIONALPHA: boolean;
  107272. GAMMAREFLECTION: boolean;
  107273. RGBDREFLECTION: boolean;
  107274. RADIANCEOCCLUSION: boolean;
  107275. HORIZONOCCLUSION: boolean;
  107276. INSTANCES: boolean;
  107277. NUM_BONE_INFLUENCERS: number;
  107278. BonesPerMesh: number;
  107279. BONETEXTURE: boolean;
  107280. NONUNIFORMSCALING: boolean;
  107281. MORPHTARGETS: boolean;
  107282. MORPHTARGETS_NORMAL: boolean;
  107283. MORPHTARGETS_TANGENT: boolean;
  107284. NUM_MORPH_INFLUENCERS: number;
  107285. IMAGEPROCESSING: boolean;
  107286. VIGNETTE: boolean;
  107287. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107288. VIGNETTEBLENDMODEOPAQUE: boolean;
  107289. TONEMAPPING: boolean;
  107290. TONEMAPPING_ACES: boolean;
  107291. CONTRAST: boolean;
  107292. COLORCURVES: boolean;
  107293. COLORGRADING: boolean;
  107294. COLORGRADING3D: boolean;
  107295. SAMPLER3DGREENDEPTH: boolean;
  107296. SAMPLER3DBGRMAP: boolean;
  107297. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107298. EXPOSURE: boolean;
  107299. MULTIVIEW: boolean;
  107300. USEPHYSICALLIGHTFALLOFF: boolean;
  107301. USEGLTFLIGHTFALLOFF: boolean;
  107302. TWOSIDEDLIGHTING: boolean;
  107303. SHADOWFLOAT: boolean;
  107304. CLIPPLANE: boolean;
  107305. CLIPPLANE2: boolean;
  107306. CLIPPLANE3: boolean;
  107307. CLIPPLANE4: boolean;
  107308. POINTSIZE: boolean;
  107309. FOG: boolean;
  107310. LOGARITHMICDEPTH: boolean;
  107311. FORCENORMALFORWARD: boolean;
  107312. SPECULARAA: boolean;
  107313. CLEARCOAT: boolean;
  107314. CLEARCOAT_DEFAULTIOR: boolean;
  107315. CLEARCOAT_TEXTURE: boolean;
  107316. CLEARCOAT_TEXTUREDIRECTUV: number;
  107317. CLEARCOAT_BUMP: boolean;
  107318. CLEARCOAT_BUMPDIRECTUV: number;
  107319. CLEARCOAT_TINT: boolean;
  107320. CLEARCOAT_TINT_TEXTURE: boolean;
  107321. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  107322. ANISOTROPIC: boolean;
  107323. ANISOTROPIC_TEXTURE: boolean;
  107324. ANISOTROPIC_TEXTUREDIRECTUV: number;
  107325. BRDF_V_HEIGHT_CORRELATED: boolean;
  107326. MS_BRDF_ENERGY_CONSERVATION: boolean;
  107327. SHEEN: boolean;
  107328. SHEEN_TEXTURE: boolean;
  107329. SHEEN_TEXTUREDIRECTUV: number;
  107330. SHEEN_LINKWITHALBEDO: boolean;
  107331. SUBSURFACE: boolean;
  107332. SS_REFRACTION: boolean;
  107333. SS_TRANSLUCENCY: boolean;
  107334. SS_SCATERRING: boolean;
  107335. SS_THICKNESSANDMASK_TEXTURE: boolean;
  107336. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  107337. SS_REFRACTIONMAP_3D: boolean;
  107338. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  107339. SS_LODINREFRACTIONALPHA: boolean;
  107340. SS_GAMMAREFRACTION: boolean;
  107341. SS_RGBDREFRACTION: boolean;
  107342. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  107343. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  107344. UNLIT: boolean;
  107345. DEBUGMODE: number;
  107346. /**
  107347. * Initializes the PBR Material defines.
  107348. */
  107349. constructor();
  107350. /**
  107351. * Resets the PBR Material defines.
  107352. */
  107353. reset(): void;
  107354. }
  107355. /**
  107356. * The Physically based material base class of BJS.
  107357. *
  107358. * This offers the main features of a standard PBR material.
  107359. * For more information, please refer to the documentation :
  107360. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107361. */
  107362. export abstract class PBRBaseMaterial extends PushMaterial {
  107363. /**
  107364. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107365. */
  107366. static readonly PBRMATERIAL_OPAQUE: number;
  107367. /**
  107368. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107369. */
  107370. static readonly PBRMATERIAL_ALPHATEST: number;
  107371. /**
  107372. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107373. */
  107374. static readonly PBRMATERIAL_ALPHABLEND: number;
  107375. /**
  107376. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107377. * They are also discarded below the alpha cutoff threshold to improve performances.
  107378. */
  107379. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107380. /**
  107381. * Defines the default value of how much AO map is occluding the analytical lights
  107382. * (point spot...).
  107383. */
  107384. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107385. /**
  107386. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  107387. */
  107388. static readonly LIGHTFALLOFF_PHYSICAL: number;
  107389. /**
  107390. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  107391. * to enhance interoperability with other engines.
  107392. */
  107393. static readonly LIGHTFALLOFF_GLTF: number;
  107394. /**
  107395. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  107396. * to enhance interoperability with other materials.
  107397. */
  107398. static readonly LIGHTFALLOFF_STANDARD: number;
  107399. /**
  107400. * Intensity of the direct lights e.g. the four lights available in your scene.
  107401. * This impacts both the direct diffuse and specular highlights.
  107402. */
  107403. protected _directIntensity: number;
  107404. /**
  107405. * Intensity of the emissive part of the material.
  107406. * This helps controlling the emissive effect without modifying the emissive color.
  107407. */
  107408. protected _emissiveIntensity: number;
  107409. /**
  107410. * Intensity of the environment e.g. how much the environment will light the object
  107411. * either through harmonics for rough material or through the refelction for shiny ones.
  107412. */
  107413. protected _environmentIntensity: number;
  107414. /**
  107415. * This is a special control allowing the reduction of the specular highlights coming from the
  107416. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107417. */
  107418. protected _specularIntensity: number;
  107419. /**
  107420. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  107421. */
  107422. private _lightingInfos;
  107423. /**
  107424. * Debug Control allowing disabling the bump map on this material.
  107425. */
  107426. protected _disableBumpMap: boolean;
  107427. /**
  107428. * AKA Diffuse Texture in standard nomenclature.
  107429. */
  107430. protected _albedoTexture: Nullable<BaseTexture>;
  107431. /**
  107432. * AKA Occlusion Texture in other nomenclature.
  107433. */
  107434. protected _ambientTexture: Nullable<BaseTexture>;
  107435. /**
  107436. * AKA Occlusion Texture Intensity in other nomenclature.
  107437. */
  107438. protected _ambientTextureStrength: number;
  107439. /**
  107440. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107441. * 1 means it completely occludes it
  107442. * 0 mean it has no impact
  107443. */
  107444. protected _ambientTextureImpactOnAnalyticalLights: number;
  107445. /**
  107446. * Stores the alpha values in a texture.
  107447. */
  107448. protected _opacityTexture: Nullable<BaseTexture>;
  107449. /**
  107450. * Stores the reflection values in a texture.
  107451. */
  107452. protected _reflectionTexture: Nullable<BaseTexture>;
  107453. /**
  107454. * Stores the emissive values in a texture.
  107455. */
  107456. protected _emissiveTexture: Nullable<BaseTexture>;
  107457. /**
  107458. * AKA Specular texture in other nomenclature.
  107459. */
  107460. protected _reflectivityTexture: Nullable<BaseTexture>;
  107461. /**
  107462. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107463. */
  107464. protected _metallicTexture: Nullable<BaseTexture>;
  107465. /**
  107466. * Specifies the metallic scalar of the metallic/roughness workflow.
  107467. * Can also be used to scale the metalness values of the metallic texture.
  107468. */
  107469. protected _metallic: Nullable<number>;
  107470. /**
  107471. * Specifies the roughness scalar of the metallic/roughness workflow.
  107472. * Can also be used to scale the roughness values of the metallic texture.
  107473. */
  107474. protected _roughness: Nullable<number>;
  107475. /**
  107476. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107477. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107478. */
  107479. protected _microSurfaceTexture: Nullable<BaseTexture>;
  107480. /**
  107481. * Stores surface normal data used to displace a mesh in a texture.
  107482. */
  107483. protected _bumpTexture: Nullable<BaseTexture>;
  107484. /**
  107485. * Stores the pre-calculated light information of a mesh in a texture.
  107486. */
  107487. protected _lightmapTexture: Nullable<BaseTexture>;
  107488. /**
  107489. * The color of a material in ambient lighting.
  107490. */
  107491. protected _ambientColor: Color3;
  107492. /**
  107493. * AKA Diffuse Color in other nomenclature.
  107494. */
  107495. protected _albedoColor: Color3;
  107496. /**
  107497. * AKA Specular Color in other nomenclature.
  107498. */
  107499. protected _reflectivityColor: Color3;
  107500. /**
  107501. * The color applied when light is reflected from a material.
  107502. */
  107503. protected _reflectionColor: Color3;
  107504. /**
  107505. * The color applied when light is emitted from a material.
  107506. */
  107507. protected _emissiveColor: Color3;
  107508. /**
  107509. * AKA Glossiness in other nomenclature.
  107510. */
  107511. protected _microSurface: number;
  107512. /**
  107513. * Specifies that the material will use the light map as a show map.
  107514. */
  107515. protected _useLightmapAsShadowmap: boolean;
  107516. /**
  107517. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  107518. * makes the reflect vector face the model (under horizon).
  107519. */
  107520. protected _useHorizonOcclusion: boolean;
  107521. /**
  107522. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  107523. * too much the area relying on ambient texture to define their ambient occlusion.
  107524. */
  107525. protected _useRadianceOcclusion: boolean;
  107526. /**
  107527. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  107528. */
  107529. protected _useAlphaFromAlbedoTexture: boolean;
  107530. /**
  107531. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  107532. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107533. */
  107534. protected _useSpecularOverAlpha: boolean;
  107535. /**
  107536. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  107537. */
  107538. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  107539. /**
  107540. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  107541. */
  107542. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  107543. /**
  107544. * Specifies if the metallic texture contains the roughness information in its green channel.
  107545. */
  107546. protected _useRoughnessFromMetallicTextureGreen: boolean;
  107547. /**
  107548. * Specifies if the metallic texture contains the metallness information in its blue channel.
  107549. */
  107550. protected _useMetallnessFromMetallicTextureBlue: boolean;
  107551. /**
  107552. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  107553. */
  107554. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  107555. /**
  107556. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  107557. */
  107558. protected _useAmbientInGrayScale: boolean;
  107559. /**
  107560. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  107561. * The material will try to infer what glossiness each pixel should be.
  107562. */
  107563. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  107564. /**
  107565. * Defines the falloff type used in this material.
  107566. * It by default is Physical.
  107567. */
  107568. protected _lightFalloff: number;
  107569. /**
  107570. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107571. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107572. */
  107573. protected _useRadianceOverAlpha: boolean;
  107574. /**
  107575. * Allows using an object space normal map (instead of tangent space).
  107576. */
  107577. protected _useObjectSpaceNormalMap: boolean;
  107578. /**
  107579. * Allows using the bump map in parallax mode.
  107580. */
  107581. protected _useParallax: boolean;
  107582. /**
  107583. * Allows using the bump map in parallax occlusion mode.
  107584. */
  107585. protected _useParallaxOcclusion: boolean;
  107586. /**
  107587. * Controls the scale bias of the parallax mode.
  107588. */
  107589. protected _parallaxScaleBias: number;
  107590. /**
  107591. * If sets to true, disables all the lights affecting the material.
  107592. */
  107593. protected _disableLighting: boolean;
  107594. /**
  107595. * Number of Simultaneous lights allowed on the material.
  107596. */
  107597. protected _maxSimultaneousLights: number;
  107598. /**
  107599. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  107600. */
  107601. protected _invertNormalMapX: boolean;
  107602. /**
  107603. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  107604. */
  107605. protected _invertNormalMapY: boolean;
  107606. /**
  107607. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107608. */
  107609. protected _twoSidedLighting: boolean;
  107610. /**
  107611. * Defines the alpha limits in alpha test mode.
  107612. */
  107613. protected _alphaCutOff: number;
  107614. /**
  107615. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  107616. */
  107617. protected _forceAlphaTest: boolean;
  107618. /**
  107619. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107620. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  107621. */
  107622. protected _useAlphaFresnel: boolean;
  107623. /**
  107624. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  107625. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  107626. */
  107627. protected _useLinearAlphaFresnel: boolean;
  107628. /**
  107629. * The transparency mode of the material.
  107630. */
  107631. protected _transparencyMode: Nullable<number>;
  107632. /**
  107633. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  107634. * from cos thetav and roughness:
  107635. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  107636. */
  107637. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  107638. /**
  107639. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  107640. */
  107641. protected _forceIrradianceInFragment: boolean;
  107642. /**
  107643. * Force normal to face away from face.
  107644. */
  107645. protected _forceNormalForward: boolean;
  107646. /**
  107647. * Enables specular anti aliasing in the PBR shader.
  107648. * It will both interacts on the Geometry for analytical and IBL lighting.
  107649. * It also prefilter the roughness map based on the bump values.
  107650. */
  107651. protected _enableSpecularAntiAliasing: boolean;
  107652. /**
  107653. * Default configuration related to image processing available in the PBR Material.
  107654. */
  107655. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107656. /**
  107657. * Keep track of the image processing observer to allow dispose and replace.
  107658. */
  107659. private _imageProcessingObserver;
  107660. /**
  107661. * Attaches a new image processing configuration to the PBR Material.
  107662. * @param configuration
  107663. */
  107664. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107665. /**
  107666. * Stores the available render targets.
  107667. */
  107668. private _renderTargets;
  107669. /**
  107670. * Sets the global ambient color for the material used in lighting calculations.
  107671. */
  107672. private _globalAmbientColor;
  107673. /**
  107674. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  107675. */
  107676. private _useLogarithmicDepth;
  107677. /**
  107678. * If set to true, no lighting calculations will be applied.
  107679. */
  107680. private _unlit;
  107681. private _debugMode;
  107682. /**
  107683. * @hidden
  107684. * This is reserved for the inspector.
  107685. * Defines the material debug mode.
  107686. * It helps seeing only some components of the material while troubleshooting.
  107687. */
  107688. debugMode: number;
  107689. /**
  107690. * @hidden
  107691. * This is reserved for the inspector.
  107692. * Specify from where on screen the debug mode should start.
  107693. * The value goes from -1 (full screen) to 1 (not visible)
  107694. * It helps with side by side comparison against the final render
  107695. * This defaults to -1
  107696. */
  107697. private debugLimit;
  107698. /**
  107699. * @hidden
  107700. * This is reserved for the inspector.
  107701. * As the default viewing range might not be enough (if the ambient is really small for instance)
  107702. * You can use the factor to better multiply the final value.
  107703. */
  107704. private debugFactor;
  107705. /**
  107706. * Defines the clear coat layer parameters for the material.
  107707. */
  107708. readonly clearCoat: PBRClearCoatConfiguration;
  107709. /**
  107710. * Defines the anisotropic parameters for the material.
  107711. */
  107712. readonly anisotropy: PBRAnisotropicConfiguration;
  107713. /**
  107714. * Defines the BRDF parameters for the material.
  107715. */
  107716. readonly brdf: PBRBRDFConfiguration;
  107717. /**
  107718. * Defines the Sheen parameters for the material.
  107719. */
  107720. readonly sheen: PBRSheenConfiguration;
  107721. /**
  107722. * Defines the SubSurface parameters for the material.
  107723. */
  107724. readonly subSurface: PBRSubSurfaceConfiguration;
  107725. /**
  107726. * Custom callback helping to override the default shader used in the material.
  107727. */
  107728. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  107729. /**
  107730. * Instantiates a new PBRMaterial instance.
  107731. *
  107732. * @param name The material name
  107733. * @param scene The scene the material will be use in.
  107734. */
  107735. constructor(name: string, scene: Scene);
  107736. /**
  107737. * Gets a boolean indicating that current material needs to register RTT
  107738. */
  107739. readonly hasRenderTargetTextures: boolean;
  107740. /**
  107741. * Gets the name of the material class.
  107742. */
  107743. getClassName(): string;
  107744. /**
  107745. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107746. */
  107747. /**
  107748. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  107749. */
  107750. useLogarithmicDepth: boolean;
  107751. /**
  107752. * Gets the current transparency mode.
  107753. */
  107754. /**
  107755. * Sets the transparency mode of the material.
  107756. *
  107757. * | Value | Type | Description |
  107758. * | ----- | ----------------------------------- | ----------- |
  107759. * | 0 | OPAQUE | |
  107760. * | 1 | ALPHATEST | |
  107761. * | 2 | ALPHABLEND | |
  107762. * | 3 | ALPHATESTANDBLEND | |
  107763. *
  107764. */
  107765. transparencyMode: Nullable<number>;
  107766. /**
  107767. * Returns true if alpha blending should be disabled.
  107768. */
  107769. private readonly _disableAlphaBlending;
  107770. /**
  107771. * Specifies whether or not this material should be rendered in alpha blend mode.
  107772. */
  107773. needAlphaBlending(): boolean;
  107774. /**
  107775. * Specifies if the mesh will require alpha blending.
  107776. * @param mesh - BJS mesh.
  107777. */
  107778. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  107779. /**
  107780. * Specifies whether or not this material should be rendered in alpha test mode.
  107781. */
  107782. needAlphaTesting(): boolean;
  107783. /**
  107784. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  107785. */
  107786. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  107787. /**
  107788. * Gets the texture used for the alpha test.
  107789. */
  107790. getAlphaTestTexture(): Nullable<BaseTexture>;
  107791. /**
  107792. * Specifies that the submesh is ready to be used.
  107793. * @param mesh - BJS mesh.
  107794. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  107795. * @param useInstances - Specifies that instances should be used.
  107796. * @returns - boolean indicating that the submesh is ready or not.
  107797. */
  107798. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107799. /**
  107800. * Specifies if the material uses metallic roughness workflow.
  107801. * @returns boolean specifiying if the material uses metallic roughness workflow.
  107802. */
  107803. isMetallicWorkflow(): boolean;
  107804. private _prepareEffect;
  107805. private _prepareDefines;
  107806. /**
  107807. * Force shader compilation
  107808. */
  107809. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  107810. clipPlane: boolean;
  107811. }>): void;
  107812. /**
  107813. * Initializes the uniform buffer layout for the shader.
  107814. */
  107815. buildUniformLayout(): void;
  107816. /**
  107817. * Unbinds the material from the mesh
  107818. */
  107819. unbind(): void;
  107820. /**
  107821. * Binds the submesh data.
  107822. * @param world - The world matrix.
  107823. * @param mesh - The BJS mesh.
  107824. * @param subMesh - A submesh of the BJS mesh.
  107825. */
  107826. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107827. /**
  107828. * Returns the animatable textures.
  107829. * @returns - Array of animatable textures.
  107830. */
  107831. getAnimatables(): IAnimatable[];
  107832. /**
  107833. * Returns the texture used for reflections.
  107834. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  107835. */
  107836. private _getReflectionTexture;
  107837. /**
  107838. * Returns an array of the actively used textures.
  107839. * @returns - Array of BaseTextures
  107840. */
  107841. getActiveTextures(): BaseTexture[];
  107842. /**
  107843. * Checks to see if a texture is used in the material.
  107844. * @param texture - Base texture to use.
  107845. * @returns - Boolean specifying if a texture is used in the material.
  107846. */
  107847. hasTexture(texture: BaseTexture): boolean;
  107848. /**
  107849. * Disposes the resources of the material.
  107850. * @param forceDisposeEffect - Forces the disposal of effects.
  107851. * @param forceDisposeTextures - Forces the disposal of all textures.
  107852. */
  107853. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107854. }
  107855. }
  107856. declare module BABYLON {
  107857. /**
  107858. * The Physically based material of BJS.
  107859. *
  107860. * This offers the main features of a standard PBR material.
  107861. * For more information, please refer to the documentation :
  107862. * https://doc.babylonjs.com/how_to/physically_based_rendering
  107863. */
  107864. export class PBRMaterial extends PBRBaseMaterial {
  107865. /**
  107866. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  107867. */
  107868. static readonly PBRMATERIAL_OPAQUE: number;
  107869. /**
  107870. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  107871. */
  107872. static readonly PBRMATERIAL_ALPHATEST: number;
  107873. /**
  107874. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107875. */
  107876. static readonly PBRMATERIAL_ALPHABLEND: number;
  107877. /**
  107878. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  107879. * They are also discarded below the alpha cutoff threshold to improve performances.
  107880. */
  107881. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  107882. /**
  107883. * Defines the default value of how much AO map is occluding the analytical lights
  107884. * (point spot...).
  107885. */
  107886. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  107887. /**
  107888. * Intensity of the direct lights e.g. the four lights available in your scene.
  107889. * This impacts both the direct diffuse and specular highlights.
  107890. */
  107891. directIntensity: number;
  107892. /**
  107893. * Intensity of the emissive part of the material.
  107894. * This helps controlling the emissive effect without modifying the emissive color.
  107895. */
  107896. emissiveIntensity: number;
  107897. /**
  107898. * Intensity of the environment e.g. how much the environment will light the object
  107899. * either through harmonics for rough material or through the refelction for shiny ones.
  107900. */
  107901. environmentIntensity: number;
  107902. /**
  107903. * This is a special control allowing the reduction of the specular highlights coming from the
  107904. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  107905. */
  107906. specularIntensity: number;
  107907. /**
  107908. * Debug Control allowing disabling the bump map on this material.
  107909. */
  107910. disableBumpMap: boolean;
  107911. /**
  107912. * AKA Diffuse Texture in standard nomenclature.
  107913. */
  107914. albedoTexture: BaseTexture;
  107915. /**
  107916. * AKA Occlusion Texture in other nomenclature.
  107917. */
  107918. ambientTexture: BaseTexture;
  107919. /**
  107920. * AKA Occlusion Texture Intensity in other nomenclature.
  107921. */
  107922. ambientTextureStrength: number;
  107923. /**
  107924. * Defines how much the AO map is occluding the analytical lights (point spot...).
  107925. * 1 means it completely occludes it
  107926. * 0 mean it has no impact
  107927. */
  107928. ambientTextureImpactOnAnalyticalLights: number;
  107929. /**
  107930. * Stores the alpha values in a texture.
  107931. */
  107932. opacityTexture: BaseTexture;
  107933. /**
  107934. * Stores the reflection values in a texture.
  107935. */
  107936. reflectionTexture: Nullable<BaseTexture>;
  107937. /**
  107938. * Stores the emissive values in a texture.
  107939. */
  107940. emissiveTexture: BaseTexture;
  107941. /**
  107942. * AKA Specular texture in other nomenclature.
  107943. */
  107944. reflectivityTexture: BaseTexture;
  107945. /**
  107946. * Used to switch from specular/glossiness to metallic/roughness workflow.
  107947. */
  107948. metallicTexture: BaseTexture;
  107949. /**
  107950. * Specifies the metallic scalar of the metallic/roughness workflow.
  107951. * Can also be used to scale the metalness values of the metallic texture.
  107952. */
  107953. metallic: Nullable<number>;
  107954. /**
  107955. * Specifies the roughness scalar of the metallic/roughness workflow.
  107956. * Can also be used to scale the roughness values of the metallic texture.
  107957. */
  107958. roughness: Nullable<number>;
  107959. /**
  107960. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  107961. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  107962. */
  107963. microSurfaceTexture: BaseTexture;
  107964. /**
  107965. * Stores surface normal data used to displace a mesh in a texture.
  107966. */
  107967. bumpTexture: BaseTexture;
  107968. /**
  107969. * Stores the pre-calculated light information of a mesh in a texture.
  107970. */
  107971. lightmapTexture: BaseTexture;
  107972. /**
  107973. * Stores the refracted light information in a texture.
  107974. */
  107975. refractionTexture: Nullable<BaseTexture>;
  107976. /**
  107977. * The color of a material in ambient lighting.
  107978. */
  107979. ambientColor: Color3;
  107980. /**
  107981. * AKA Diffuse Color in other nomenclature.
  107982. */
  107983. albedoColor: Color3;
  107984. /**
  107985. * AKA Specular Color in other nomenclature.
  107986. */
  107987. reflectivityColor: Color3;
  107988. /**
  107989. * The color reflected from the material.
  107990. */
  107991. reflectionColor: Color3;
  107992. /**
  107993. * The color emitted from the material.
  107994. */
  107995. emissiveColor: Color3;
  107996. /**
  107997. * AKA Glossiness in other nomenclature.
  107998. */
  107999. microSurface: number;
  108000. /**
  108001. * source material index of refraction (IOR)' / 'destination material IOR.
  108002. */
  108003. indexOfRefraction: number;
  108004. /**
  108005. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  108006. */
  108007. invertRefractionY: boolean;
  108008. /**
  108009. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  108010. * Materials half opaque for instance using refraction could benefit from this control.
  108011. */
  108012. linkRefractionWithTransparency: boolean;
  108013. /**
  108014. * If true, the light map contains occlusion information instead of lighting info.
  108015. */
  108016. useLightmapAsShadowmap: boolean;
  108017. /**
  108018. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  108019. */
  108020. useAlphaFromAlbedoTexture: boolean;
  108021. /**
  108022. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  108023. */
  108024. forceAlphaTest: boolean;
  108025. /**
  108026. * Defines the alpha limits in alpha test mode.
  108027. */
  108028. alphaCutOff: number;
  108029. /**
  108030. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  108031. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  108032. */
  108033. useSpecularOverAlpha: boolean;
  108034. /**
  108035. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  108036. */
  108037. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  108038. /**
  108039. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  108040. */
  108041. useRoughnessFromMetallicTextureAlpha: boolean;
  108042. /**
  108043. * Specifies if the metallic texture contains the roughness information in its green channel.
  108044. */
  108045. useRoughnessFromMetallicTextureGreen: boolean;
  108046. /**
  108047. * Specifies if the metallic texture contains the metallness information in its blue channel.
  108048. */
  108049. useMetallnessFromMetallicTextureBlue: boolean;
  108050. /**
  108051. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  108052. */
  108053. useAmbientOcclusionFromMetallicTextureRed: boolean;
  108054. /**
  108055. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  108056. */
  108057. useAmbientInGrayScale: boolean;
  108058. /**
  108059. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  108060. * The material will try to infer what glossiness each pixel should be.
  108061. */
  108062. useAutoMicroSurfaceFromReflectivityMap: boolean;
  108063. /**
  108064. * BJS is using an harcoded light falloff based on a manually sets up range.
  108065. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108066. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108067. */
  108068. /**
  108069. * BJS is using an harcoded light falloff based on a manually sets up range.
  108070. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  108071. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  108072. */
  108073. usePhysicalLightFalloff: boolean;
  108074. /**
  108075. * In order to support the falloff compatibility with gltf, a special mode has been added
  108076. * to reproduce the gltf light falloff.
  108077. */
  108078. /**
  108079. * In order to support the falloff compatibility with gltf, a special mode has been added
  108080. * to reproduce the gltf light falloff.
  108081. */
  108082. useGLTFLightFalloff: boolean;
  108083. /**
  108084. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  108085. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  108086. */
  108087. useRadianceOverAlpha: boolean;
  108088. /**
  108089. * Allows using an object space normal map (instead of tangent space).
  108090. */
  108091. useObjectSpaceNormalMap: boolean;
  108092. /**
  108093. * Allows using the bump map in parallax mode.
  108094. */
  108095. useParallax: boolean;
  108096. /**
  108097. * Allows using the bump map in parallax occlusion mode.
  108098. */
  108099. useParallaxOcclusion: boolean;
  108100. /**
  108101. * Controls the scale bias of the parallax mode.
  108102. */
  108103. parallaxScaleBias: number;
  108104. /**
  108105. * If sets to true, disables all the lights affecting the material.
  108106. */
  108107. disableLighting: boolean;
  108108. /**
  108109. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  108110. */
  108111. forceIrradianceInFragment: boolean;
  108112. /**
  108113. * Number of Simultaneous lights allowed on the material.
  108114. */
  108115. maxSimultaneousLights: number;
  108116. /**
  108117. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108118. */
  108119. invertNormalMapX: boolean;
  108120. /**
  108121. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108122. */
  108123. invertNormalMapY: boolean;
  108124. /**
  108125. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108126. */
  108127. twoSidedLighting: boolean;
  108128. /**
  108129. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108130. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  108131. */
  108132. useAlphaFresnel: boolean;
  108133. /**
  108134. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  108135. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  108136. */
  108137. useLinearAlphaFresnel: boolean;
  108138. /**
  108139. * Let user defines the brdf lookup texture used for IBL.
  108140. * A default 8bit version is embedded but you could point at :
  108141. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  108142. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  108143. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  108144. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  108145. */
  108146. environmentBRDFTexture: Nullable<BaseTexture>;
  108147. /**
  108148. * Force normal to face away from face.
  108149. */
  108150. forceNormalForward: boolean;
  108151. /**
  108152. * Enables specular anti aliasing in the PBR shader.
  108153. * It will both interacts on the Geometry for analytical and IBL lighting.
  108154. * It also prefilter the roughness map based on the bump values.
  108155. */
  108156. enableSpecularAntiAliasing: boolean;
  108157. /**
  108158. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  108159. * makes the reflect vector face the model (under horizon).
  108160. */
  108161. useHorizonOcclusion: boolean;
  108162. /**
  108163. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  108164. * too much the area relying on ambient texture to define their ambient occlusion.
  108165. */
  108166. useRadianceOcclusion: boolean;
  108167. /**
  108168. * If set to true, no lighting calculations will be applied.
  108169. */
  108170. unlit: boolean;
  108171. /**
  108172. * Gets the image processing configuration used either in this material.
  108173. */
  108174. /**
  108175. * Sets the Default image processing configuration used either in the this material.
  108176. *
  108177. * If sets to null, the scene one is in use.
  108178. */
  108179. imageProcessingConfiguration: ImageProcessingConfiguration;
  108180. /**
  108181. * Gets wether the color curves effect is enabled.
  108182. */
  108183. /**
  108184. * Sets wether the color curves effect is enabled.
  108185. */
  108186. cameraColorCurvesEnabled: boolean;
  108187. /**
  108188. * Gets wether the color grading effect is enabled.
  108189. */
  108190. /**
  108191. * Gets wether the color grading effect is enabled.
  108192. */
  108193. cameraColorGradingEnabled: boolean;
  108194. /**
  108195. * Gets wether tonemapping is enabled or not.
  108196. */
  108197. /**
  108198. * Sets wether tonemapping is enabled or not
  108199. */
  108200. cameraToneMappingEnabled: boolean;
  108201. /**
  108202. * The camera exposure used on this material.
  108203. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108204. * This corresponds to a photographic exposure.
  108205. */
  108206. /**
  108207. * The camera exposure used on this material.
  108208. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  108209. * This corresponds to a photographic exposure.
  108210. */
  108211. cameraExposure: number;
  108212. /**
  108213. * Gets The camera contrast used on this material.
  108214. */
  108215. /**
  108216. * Sets The camera contrast used on this material.
  108217. */
  108218. cameraContrast: number;
  108219. /**
  108220. * Gets the Color Grading 2D Lookup Texture.
  108221. */
  108222. /**
  108223. * Sets the Color Grading 2D Lookup Texture.
  108224. */
  108225. cameraColorGradingTexture: Nullable<BaseTexture>;
  108226. /**
  108227. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108228. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108229. * 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;
  108230. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108231. */
  108232. /**
  108233. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  108234. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  108235. * 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;
  108236. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  108237. */
  108238. cameraColorCurves: Nullable<ColorCurves>;
  108239. /**
  108240. * Instantiates a new PBRMaterial instance.
  108241. *
  108242. * @param name The material name
  108243. * @param scene The scene the material will be use in.
  108244. */
  108245. constructor(name: string, scene: Scene);
  108246. /**
  108247. * Returns the name of this material class.
  108248. */
  108249. getClassName(): string;
  108250. /**
  108251. * Makes a duplicate of the current material.
  108252. * @param name - name to use for the new material.
  108253. */
  108254. clone(name: string): PBRMaterial;
  108255. /**
  108256. * Serializes this PBR Material.
  108257. * @returns - An object with the serialized material.
  108258. */
  108259. serialize(): any;
  108260. /**
  108261. * Parses a PBR Material from a serialized object.
  108262. * @param source - Serialized object.
  108263. * @param scene - BJS scene instance.
  108264. * @param rootUrl - url for the scene object
  108265. * @returns - PBRMaterial
  108266. */
  108267. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  108268. }
  108269. }
  108270. declare module BABYLON {
  108271. /**
  108272. * Direct draw surface info
  108273. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  108274. */
  108275. export interface DDSInfo {
  108276. /**
  108277. * Width of the texture
  108278. */
  108279. width: number;
  108280. /**
  108281. * Width of the texture
  108282. */
  108283. height: number;
  108284. /**
  108285. * Number of Mipmaps for the texture
  108286. * @see https://en.wikipedia.org/wiki/Mipmap
  108287. */
  108288. mipmapCount: number;
  108289. /**
  108290. * If the textures format is a known fourCC format
  108291. * @see https://www.fourcc.org/
  108292. */
  108293. isFourCC: boolean;
  108294. /**
  108295. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  108296. */
  108297. isRGB: boolean;
  108298. /**
  108299. * If the texture is a lumincance format
  108300. */
  108301. isLuminance: boolean;
  108302. /**
  108303. * If this is a cube texture
  108304. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  108305. */
  108306. isCube: boolean;
  108307. /**
  108308. * If the texture is a compressed format eg. FOURCC_DXT1
  108309. */
  108310. isCompressed: boolean;
  108311. /**
  108312. * The dxgiFormat of the texture
  108313. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  108314. */
  108315. dxgiFormat: number;
  108316. /**
  108317. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  108318. */
  108319. textureType: number;
  108320. /**
  108321. * Sphericle polynomial created for the dds texture
  108322. */
  108323. sphericalPolynomial?: SphericalPolynomial;
  108324. }
  108325. /**
  108326. * Class used to provide DDS decompression tools
  108327. */
  108328. export class DDSTools {
  108329. /**
  108330. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  108331. */
  108332. static StoreLODInAlphaChannel: boolean;
  108333. /**
  108334. * Gets DDS information from an array buffer
  108335. * @param arrayBuffer defines the array buffer to read data from
  108336. * @returns the DDS information
  108337. */
  108338. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  108339. private static _FloatView;
  108340. private static _Int32View;
  108341. private static _ToHalfFloat;
  108342. private static _FromHalfFloat;
  108343. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  108344. private static _GetHalfFloatRGBAArrayBuffer;
  108345. private static _GetFloatRGBAArrayBuffer;
  108346. private static _GetFloatAsUIntRGBAArrayBuffer;
  108347. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  108348. private static _GetRGBAArrayBuffer;
  108349. private static _ExtractLongWordOrder;
  108350. private static _GetRGBArrayBuffer;
  108351. private static _GetLuminanceArrayBuffer;
  108352. /**
  108353. * Uploads DDS Levels to a Babylon Texture
  108354. * @hidden
  108355. */
  108356. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  108357. }
  108358. interface Engine {
  108359. /**
  108360. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  108361. * @param rootUrl defines the url where the file to load is located
  108362. * @param scene defines the current scene
  108363. * @param lodScale defines scale to apply to the mip map selection
  108364. * @param lodOffset defines offset to apply to the mip map selection
  108365. * @param onLoad defines an optional callback raised when the texture is loaded
  108366. * @param onError defines an optional callback raised if there is an issue to load the texture
  108367. * @param format defines the format of the data
  108368. * @param forcedExtension defines the extension to use to pick the right loader
  108369. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  108370. * @returns the cube texture as an InternalTexture
  108371. */
  108372. 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;
  108373. }
  108374. }
  108375. declare module BABYLON {
  108376. /**
  108377. * Implementation of the DDS Texture Loader.
  108378. * @hidden
  108379. */
  108380. export class _DDSTextureLoader implements IInternalTextureLoader {
  108381. /**
  108382. * Defines wether the loader supports cascade loading the different faces.
  108383. */
  108384. readonly supportCascades: boolean;
  108385. /**
  108386. * This returns if the loader support the current file information.
  108387. * @param extension defines the file extension of the file being loaded
  108388. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108389. * @param fallback defines the fallback internal texture if any
  108390. * @param isBase64 defines whether the texture is encoded as a base64
  108391. * @param isBuffer defines whether the texture data are stored as a buffer
  108392. * @returns true if the loader can load the specified file
  108393. */
  108394. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108395. /**
  108396. * Transform the url before loading if required.
  108397. * @param rootUrl the url of the texture
  108398. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108399. * @returns the transformed texture
  108400. */
  108401. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108402. /**
  108403. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108404. * @param rootUrl the url of the texture
  108405. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108406. * @returns the fallback texture
  108407. */
  108408. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108409. /**
  108410. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108411. * @param data contains the texture data
  108412. * @param texture defines the BabylonJS internal texture
  108413. * @param createPolynomials will be true if polynomials have been requested
  108414. * @param onLoad defines the callback to trigger once the texture is ready
  108415. * @param onError defines the callback to trigger in case of error
  108416. */
  108417. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108418. /**
  108419. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108420. * @param data contains the texture data
  108421. * @param texture defines the BabylonJS internal texture
  108422. * @param callback defines the method to call once ready to upload
  108423. */
  108424. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108425. }
  108426. }
  108427. declare module BABYLON {
  108428. /** @hidden */
  108429. export var rgbdEncodePixelShader: {
  108430. name: string;
  108431. shader: string;
  108432. };
  108433. }
  108434. declare module BABYLON {
  108435. /**
  108436. * Raw texture data and descriptor sufficient for WebGL texture upload
  108437. */
  108438. export interface EnvironmentTextureInfo {
  108439. /**
  108440. * Version of the environment map
  108441. */
  108442. version: number;
  108443. /**
  108444. * Width of image
  108445. */
  108446. width: number;
  108447. /**
  108448. * Irradiance information stored in the file.
  108449. */
  108450. irradiance: any;
  108451. /**
  108452. * Specular information stored in the file.
  108453. */
  108454. specular: any;
  108455. }
  108456. /**
  108457. * Sets of helpers addressing the serialization and deserialization of environment texture
  108458. * stored in a BabylonJS env file.
  108459. * Those files are usually stored as .env files.
  108460. */
  108461. export class EnvironmentTextureTools {
  108462. /**
  108463. * Magic number identifying the env file.
  108464. */
  108465. private static _MagicBytes;
  108466. /**
  108467. * Gets the environment info from an env file.
  108468. * @param data The array buffer containing the .env bytes.
  108469. * @returns the environment file info (the json header) if successfully parsed.
  108470. */
  108471. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  108472. /**
  108473. * Creates an environment texture from a loaded cube texture.
  108474. * @param texture defines the cube texture to convert in env file
  108475. * @return a promise containing the environment data if succesfull.
  108476. */
  108477. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  108478. /**
  108479. * Creates a JSON representation of the spherical data.
  108480. * @param texture defines the texture containing the polynomials
  108481. * @return the JSON representation of the spherical info
  108482. */
  108483. private static _CreateEnvTextureIrradiance;
  108484. /**
  108485. * Uploads the texture info contained in the env file to the GPU.
  108486. * @param texture defines the internal texture to upload to
  108487. * @param arrayBuffer defines the buffer cotaining the data to load
  108488. * @param info defines the texture info retrieved through the GetEnvInfo method
  108489. * @returns a promise
  108490. */
  108491. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  108492. /**
  108493. * Uploads the levels of image data to the GPU.
  108494. * @param texture defines the internal texture to upload to
  108495. * @param imageData defines the array buffer views of image data [mipmap][face]
  108496. * @returns a promise
  108497. */
  108498. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  108499. /**
  108500. * Uploads spherical polynomials information to the texture.
  108501. * @param texture defines the texture we are trying to upload the information to
  108502. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  108503. */
  108504. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  108505. /** @hidden */
  108506. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108507. }
  108508. }
  108509. declare module BABYLON {
  108510. /**
  108511. * Implementation of the ENV Texture Loader.
  108512. * @hidden
  108513. */
  108514. export class _ENVTextureLoader implements IInternalTextureLoader {
  108515. /**
  108516. * Defines wether the loader supports cascade loading the different faces.
  108517. */
  108518. readonly supportCascades: boolean;
  108519. /**
  108520. * This returns if the loader support the current file information.
  108521. * @param extension defines the file extension of the file being loaded
  108522. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108523. * @param fallback defines the fallback internal texture if any
  108524. * @param isBase64 defines whether the texture is encoded as a base64
  108525. * @param isBuffer defines whether the texture data are stored as a buffer
  108526. * @returns true if the loader can load the specified file
  108527. */
  108528. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108529. /**
  108530. * Transform the url before loading if required.
  108531. * @param rootUrl the url of the texture
  108532. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108533. * @returns the transformed texture
  108534. */
  108535. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108536. /**
  108537. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108538. * @param rootUrl the url of the texture
  108539. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108540. * @returns the fallback texture
  108541. */
  108542. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108543. /**
  108544. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108545. * @param data contains the texture data
  108546. * @param texture defines the BabylonJS internal texture
  108547. * @param createPolynomials will be true if polynomials have been requested
  108548. * @param onLoad defines the callback to trigger once the texture is ready
  108549. * @param onError defines the callback to trigger in case of error
  108550. */
  108551. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108552. /**
  108553. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108554. * @param data contains the texture data
  108555. * @param texture defines the BabylonJS internal texture
  108556. * @param callback defines the method to call once ready to upload
  108557. */
  108558. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108559. }
  108560. }
  108561. declare module BABYLON {
  108562. /**
  108563. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  108564. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  108565. */
  108566. export class KhronosTextureContainer {
  108567. /** contents of the KTX container file */
  108568. arrayBuffer: any;
  108569. private static HEADER_LEN;
  108570. private static COMPRESSED_2D;
  108571. private static COMPRESSED_3D;
  108572. private static TEX_2D;
  108573. private static TEX_3D;
  108574. /**
  108575. * Gets the openGL type
  108576. */
  108577. glType: number;
  108578. /**
  108579. * Gets the openGL type size
  108580. */
  108581. glTypeSize: number;
  108582. /**
  108583. * Gets the openGL format
  108584. */
  108585. glFormat: number;
  108586. /**
  108587. * Gets the openGL internal format
  108588. */
  108589. glInternalFormat: number;
  108590. /**
  108591. * Gets the base internal format
  108592. */
  108593. glBaseInternalFormat: number;
  108594. /**
  108595. * Gets image width in pixel
  108596. */
  108597. pixelWidth: number;
  108598. /**
  108599. * Gets image height in pixel
  108600. */
  108601. pixelHeight: number;
  108602. /**
  108603. * Gets image depth in pixels
  108604. */
  108605. pixelDepth: number;
  108606. /**
  108607. * Gets the number of array elements
  108608. */
  108609. numberOfArrayElements: number;
  108610. /**
  108611. * Gets the number of faces
  108612. */
  108613. numberOfFaces: number;
  108614. /**
  108615. * Gets the number of mipmap levels
  108616. */
  108617. numberOfMipmapLevels: number;
  108618. /**
  108619. * Gets the bytes of key value data
  108620. */
  108621. bytesOfKeyValueData: number;
  108622. /**
  108623. * Gets the load type
  108624. */
  108625. loadType: number;
  108626. /**
  108627. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  108628. */
  108629. isInvalid: boolean;
  108630. /**
  108631. * Creates a new KhronosTextureContainer
  108632. * @param arrayBuffer contents of the KTX container file
  108633. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  108634. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  108635. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  108636. */
  108637. constructor(
  108638. /** contents of the KTX container file */
  108639. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  108640. /**
  108641. * Uploads KTX content to a Babylon Texture.
  108642. * It is assumed that the texture has already been created & is currently bound
  108643. * @hidden
  108644. */
  108645. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  108646. private _upload2DCompressedLevels;
  108647. }
  108648. }
  108649. declare module BABYLON {
  108650. /**
  108651. * Implementation of the KTX Texture Loader.
  108652. * @hidden
  108653. */
  108654. export class _KTXTextureLoader implements IInternalTextureLoader {
  108655. /**
  108656. * Defines wether the loader supports cascade loading the different faces.
  108657. */
  108658. readonly supportCascades: boolean;
  108659. /**
  108660. * This returns if the loader support the current file information.
  108661. * @param extension defines the file extension of the file being loaded
  108662. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108663. * @param fallback defines the fallback internal texture if any
  108664. * @param isBase64 defines whether the texture is encoded as a base64
  108665. * @param isBuffer defines whether the texture data are stored as a buffer
  108666. * @returns true if the loader can load the specified file
  108667. */
  108668. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108669. /**
  108670. * Transform the url before loading if required.
  108671. * @param rootUrl the url of the texture
  108672. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108673. * @returns the transformed texture
  108674. */
  108675. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108676. /**
  108677. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108678. * @param rootUrl the url of the texture
  108679. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108680. * @returns the fallback texture
  108681. */
  108682. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108683. /**
  108684. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108685. * @param data contains the texture data
  108686. * @param texture defines the BabylonJS internal texture
  108687. * @param createPolynomials will be true if polynomials have been requested
  108688. * @param onLoad defines the callback to trigger once the texture is ready
  108689. * @param onError defines the callback to trigger in case of error
  108690. */
  108691. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108692. /**
  108693. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108694. * @param data contains the texture data
  108695. * @param texture defines the BabylonJS internal texture
  108696. * @param callback defines the method to call once ready to upload
  108697. */
  108698. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  108699. }
  108700. }
  108701. declare module BABYLON {
  108702. /** @hidden */
  108703. export var _forceSceneHelpersToBundle: boolean;
  108704. interface Scene {
  108705. /**
  108706. * Creates a default light for the scene.
  108707. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  108708. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  108709. */
  108710. createDefaultLight(replace?: boolean): void;
  108711. /**
  108712. * Creates a default camera for the scene.
  108713. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  108714. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  108715. * @param replace has default false, when true replaces the active camera in the scene
  108716. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  108717. */
  108718. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  108719. /**
  108720. * Creates a default camera and a default light.
  108721. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  108722. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  108723. * @param replace has the default false, when true replaces the active camera/light in the scene
  108724. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  108725. */
  108726. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  108727. /**
  108728. * Creates a new sky box
  108729. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  108730. * @param environmentTexture defines the texture to use as environment texture
  108731. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  108732. * @param scale defines the overall scale of the skybox
  108733. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  108734. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  108735. * @returns a new mesh holding the sky box
  108736. */
  108737. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  108738. /**
  108739. * Creates a new environment
  108740. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  108741. * @param options defines the options you can use to configure the environment
  108742. * @returns the new EnvironmentHelper
  108743. */
  108744. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  108745. /**
  108746. * Creates a new VREXperienceHelper
  108747. * @see http://doc.babylonjs.com/how_to/webvr_helper
  108748. * @param webVROptions defines the options used to create the new VREXperienceHelper
  108749. * @returns a new VREXperienceHelper
  108750. */
  108751. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  108752. /**
  108753. * Creates a new XREXperienceHelper
  108754. * @see http://doc.babylonjs.com/how_to/webxr
  108755. * @returns a promise for a new XREXperienceHelper
  108756. */
  108757. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  108758. }
  108759. }
  108760. declare module BABYLON {
  108761. /**
  108762. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  108763. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  108764. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  108765. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  108766. */
  108767. export class VideoDome extends TransformNode {
  108768. /**
  108769. * Define the video source as a Monoscopic panoramic 360 video.
  108770. */
  108771. static readonly MODE_MONOSCOPIC: number;
  108772. /**
  108773. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  108774. */
  108775. static readonly MODE_TOPBOTTOM: number;
  108776. /**
  108777. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  108778. */
  108779. static readonly MODE_SIDEBYSIDE: number;
  108780. private _useDirectMapping;
  108781. /**
  108782. * The video texture being displayed on the sphere
  108783. */
  108784. protected _videoTexture: VideoTexture;
  108785. /**
  108786. * Gets the video texture being displayed on the sphere
  108787. */
  108788. readonly videoTexture: VideoTexture;
  108789. /**
  108790. * The skybox material
  108791. */
  108792. protected _material: BackgroundMaterial;
  108793. /**
  108794. * The surface used for the skybox
  108795. */
  108796. protected _mesh: Mesh;
  108797. /**
  108798. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  108799. * Also see the options.resolution property.
  108800. */
  108801. fovMultiplier: number;
  108802. private _videoMode;
  108803. /**
  108804. * Gets or set the current video mode for the video. It can be:
  108805. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  108806. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  108807. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  108808. */
  108809. videoMode: number;
  108810. /**
  108811. * Oberserver used in Stereoscopic VR Mode.
  108812. */
  108813. private _onBeforeCameraRenderObserver;
  108814. /**
  108815. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  108816. * @param name Element's name, child elements will append suffixes for their own names.
  108817. * @param urlsOrVideo defines the url(s) or the video element to use
  108818. * @param options An object containing optional or exposed sub element properties
  108819. */
  108820. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  108821. resolution?: number;
  108822. clickToPlay?: boolean;
  108823. autoPlay?: boolean;
  108824. loop?: boolean;
  108825. size?: number;
  108826. poster?: string;
  108827. faceForward?: boolean;
  108828. useDirectMapping?: boolean;
  108829. }, scene: Scene);
  108830. private _changeVideoMode;
  108831. /**
  108832. * Releases resources associated with this node.
  108833. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  108834. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  108835. */
  108836. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  108837. }
  108838. }
  108839. declare module BABYLON {
  108840. /**
  108841. * This class can be used to get instrumentation data from a Babylon engine
  108842. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108843. */
  108844. export class EngineInstrumentation implements IDisposable {
  108845. /**
  108846. * Define the instrumented engine.
  108847. */
  108848. engine: Engine;
  108849. private _captureGPUFrameTime;
  108850. private _gpuFrameTimeToken;
  108851. private _gpuFrameTime;
  108852. private _captureShaderCompilationTime;
  108853. private _shaderCompilationTime;
  108854. private _onBeginFrameObserver;
  108855. private _onEndFrameObserver;
  108856. private _onBeforeShaderCompilationObserver;
  108857. private _onAfterShaderCompilationObserver;
  108858. /**
  108859. * Gets the perf counter used for GPU frame time
  108860. */
  108861. readonly gpuFrameTimeCounter: PerfCounter;
  108862. /**
  108863. * Gets the GPU frame time capture status
  108864. */
  108865. /**
  108866. * Enable or disable the GPU frame time capture
  108867. */
  108868. captureGPUFrameTime: boolean;
  108869. /**
  108870. * Gets the perf counter used for shader compilation time
  108871. */
  108872. readonly shaderCompilationTimeCounter: PerfCounter;
  108873. /**
  108874. * Gets the shader compilation time capture status
  108875. */
  108876. /**
  108877. * Enable or disable the shader compilation time capture
  108878. */
  108879. captureShaderCompilationTime: boolean;
  108880. /**
  108881. * Instantiates a new engine instrumentation.
  108882. * This class can be used to get instrumentation data from a Babylon engine
  108883. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108884. * @param engine Defines the engine to instrument
  108885. */
  108886. constructor(
  108887. /**
  108888. * Define the instrumented engine.
  108889. */
  108890. engine: Engine);
  108891. /**
  108892. * Dispose and release associated resources.
  108893. */
  108894. dispose(): void;
  108895. }
  108896. }
  108897. declare module BABYLON {
  108898. /**
  108899. * This class can be used to get instrumentation data from a Babylon engine
  108900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  108901. */
  108902. export class SceneInstrumentation implements IDisposable {
  108903. /**
  108904. * Defines the scene to instrument
  108905. */
  108906. scene: Scene;
  108907. private _captureActiveMeshesEvaluationTime;
  108908. private _activeMeshesEvaluationTime;
  108909. private _captureRenderTargetsRenderTime;
  108910. private _renderTargetsRenderTime;
  108911. private _captureFrameTime;
  108912. private _frameTime;
  108913. private _captureRenderTime;
  108914. private _renderTime;
  108915. private _captureInterFrameTime;
  108916. private _interFrameTime;
  108917. private _captureParticlesRenderTime;
  108918. private _particlesRenderTime;
  108919. private _captureSpritesRenderTime;
  108920. private _spritesRenderTime;
  108921. private _capturePhysicsTime;
  108922. private _physicsTime;
  108923. private _captureAnimationsTime;
  108924. private _animationsTime;
  108925. private _captureCameraRenderTime;
  108926. private _cameraRenderTime;
  108927. private _onBeforeActiveMeshesEvaluationObserver;
  108928. private _onAfterActiveMeshesEvaluationObserver;
  108929. private _onBeforeRenderTargetsRenderObserver;
  108930. private _onAfterRenderTargetsRenderObserver;
  108931. private _onAfterRenderObserver;
  108932. private _onBeforeDrawPhaseObserver;
  108933. private _onAfterDrawPhaseObserver;
  108934. private _onBeforeAnimationsObserver;
  108935. private _onBeforeParticlesRenderingObserver;
  108936. private _onAfterParticlesRenderingObserver;
  108937. private _onBeforeSpritesRenderingObserver;
  108938. private _onAfterSpritesRenderingObserver;
  108939. private _onBeforePhysicsObserver;
  108940. private _onAfterPhysicsObserver;
  108941. private _onAfterAnimationsObserver;
  108942. private _onBeforeCameraRenderObserver;
  108943. private _onAfterCameraRenderObserver;
  108944. /**
  108945. * Gets the perf counter used for active meshes evaluation time
  108946. */
  108947. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  108948. /**
  108949. * Gets the active meshes evaluation time capture status
  108950. */
  108951. /**
  108952. * Enable or disable the active meshes evaluation time capture
  108953. */
  108954. captureActiveMeshesEvaluationTime: boolean;
  108955. /**
  108956. * Gets the perf counter used for render targets render time
  108957. */
  108958. readonly renderTargetsRenderTimeCounter: PerfCounter;
  108959. /**
  108960. * Gets the render targets render time capture status
  108961. */
  108962. /**
  108963. * Enable or disable the render targets render time capture
  108964. */
  108965. captureRenderTargetsRenderTime: boolean;
  108966. /**
  108967. * Gets the perf counter used for particles render time
  108968. */
  108969. readonly particlesRenderTimeCounter: PerfCounter;
  108970. /**
  108971. * Gets the particles render time capture status
  108972. */
  108973. /**
  108974. * Enable or disable the particles render time capture
  108975. */
  108976. captureParticlesRenderTime: boolean;
  108977. /**
  108978. * Gets the perf counter used for sprites render time
  108979. */
  108980. readonly spritesRenderTimeCounter: PerfCounter;
  108981. /**
  108982. * Gets the sprites render time capture status
  108983. */
  108984. /**
  108985. * Enable or disable the sprites render time capture
  108986. */
  108987. captureSpritesRenderTime: boolean;
  108988. /**
  108989. * Gets the perf counter used for physics time
  108990. */
  108991. readonly physicsTimeCounter: PerfCounter;
  108992. /**
  108993. * Gets the physics time capture status
  108994. */
  108995. /**
  108996. * Enable or disable the physics time capture
  108997. */
  108998. capturePhysicsTime: boolean;
  108999. /**
  109000. * Gets the perf counter used for animations time
  109001. */
  109002. readonly animationsTimeCounter: PerfCounter;
  109003. /**
  109004. * Gets the animations time capture status
  109005. */
  109006. /**
  109007. * Enable or disable the animations time capture
  109008. */
  109009. captureAnimationsTime: boolean;
  109010. /**
  109011. * Gets the perf counter used for frame time capture
  109012. */
  109013. readonly frameTimeCounter: PerfCounter;
  109014. /**
  109015. * Gets the frame time capture status
  109016. */
  109017. /**
  109018. * Enable or disable the frame time capture
  109019. */
  109020. captureFrameTime: boolean;
  109021. /**
  109022. * Gets the perf counter used for inter-frames time capture
  109023. */
  109024. readonly interFrameTimeCounter: PerfCounter;
  109025. /**
  109026. * Gets the inter-frames time capture status
  109027. */
  109028. /**
  109029. * Enable or disable the inter-frames time capture
  109030. */
  109031. captureInterFrameTime: boolean;
  109032. /**
  109033. * Gets the perf counter used for render time capture
  109034. */
  109035. readonly renderTimeCounter: PerfCounter;
  109036. /**
  109037. * Gets the render time capture status
  109038. */
  109039. /**
  109040. * Enable or disable the render time capture
  109041. */
  109042. captureRenderTime: boolean;
  109043. /**
  109044. * Gets the perf counter used for camera render time capture
  109045. */
  109046. readonly cameraRenderTimeCounter: PerfCounter;
  109047. /**
  109048. * Gets the camera render time capture status
  109049. */
  109050. /**
  109051. * Enable or disable the camera render time capture
  109052. */
  109053. captureCameraRenderTime: boolean;
  109054. /**
  109055. * Gets the perf counter used for draw calls
  109056. */
  109057. readonly drawCallsCounter: PerfCounter;
  109058. /**
  109059. * Instantiates a new scene instrumentation.
  109060. * This class can be used to get instrumentation data from a Babylon engine
  109061. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  109062. * @param scene Defines the scene to instrument
  109063. */
  109064. constructor(
  109065. /**
  109066. * Defines the scene to instrument
  109067. */
  109068. scene: Scene);
  109069. /**
  109070. * Dispose and release associated resources.
  109071. */
  109072. dispose(): void;
  109073. }
  109074. }
  109075. declare module BABYLON {
  109076. /** @hidden */
  109077. export var glowMapGenerationPixelShader: {
  109078. name: string;
  109079. shader: string;
  109080. };
  109081. }
  109082. declare module BABYLON {
  109083. /** @hidden */
  109084. export var glowMapGenerationVertexShader: {
  109085. name: string;
  109086. shader: string;
  109087. };
  109088. }
  109089. declare module BABYLON {
  109090. /**
  109091. * Effect layer options. This helps customizing the behaviour
  109092. * of the effect layer.
  109093. */
  109094. export interface IEffectLayerOptions {
  109095. /**
  109096. * Multiplication factor apply to the canvas size to compute the render target size
  109097. * used to generated the objects (the smaller the faster).
  109098. */
  109099. mainTextureRatio: number;
  109100. /**
  109101. * Enforces a fixed size texture to ensure effect stability across devices.
  109102. */
  109103. mainTextureFixedSize?: number;
  109104. /**
  109105. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  109106. */
  109107. alphaBlendingMode: number;
  109108. /**
  109109. * The camera attached to the layer.
  109110. */
  109111. camera: Nullable<Camera>;
  109112. /**
  109113. * The rendering group to draw the layer in.
  109114. */
  109115. renderingGroupId: number;
  109116. }
  109117. /**
  109118. * The effect layer Helps adding post process effect blended with the main pass.
  109119. *
  109120. * This can be for instance use to generate glow or higlight effects on the scene.
  109121. *
  109122. * The effect layer class can not be used directly and is intented to inherited from to be
  109123. * customized per effects.
  109124. */
  109125. export abstract class EffectLayer {
  109126. private _vertexBuffers;
  109127. private _indexBuffer;
  109128. private _cachedDefines;
  109129. private _effectLayerMapGenerationEffect;
  109130. private _effectLayerOptions;
  109131. private _mergeEffect;
  109132. protected _scene: Scene;
  109133. protected _engine: Engine;
  109134. protected _maxSize: number;
  109135. protected _mainTextureDesiredSize: ISize;
  109136. protected _mainTexture: RenderTargetTexture;
  109137. protected _shouldRender: boolean;
  109138. protected _postProcesses: PostProcess[];
  109139. protected _textures: BaseTexture[];
  109140. protected _emissiveTextureAndColor: {
  109141. texture: Nullable<BaseTexture>;
  109142. color: Color4;
  109143. };
  109144. /**
  109145. * The name of the layer
  109146. */
  109147. name: string;
  109148. /**
  109149. * The clear color of the texture used to generate the glow map.
  109150. */
  109151. neutralColor: Color4;
  109152. /**
  109153. * Specifies wether the highlight layer is enabled or not.
  109154. */
  109155. isEnabled: boolean;
  109156. /**
  109157. * Gets the camera attached to the layer.
  109158. */
  109159. readonly camera: Nullable<Camera>;
  109160. /**
  109161. * Gets the rendering group id the layer should render in.
  109162. */
  109163. readonly renderingGroupId: number;
  109164. /**
  109165. * An event triggered when the effect layer has been disposed.
  109166. */
  109167. onDisposeObservable: Observable<EffectLayer>;
  109168. /**
  109169. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  109170. */
  109171. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  109172. /**
  109173. * An event triggered when the generated texture is being merged in the scene.
  109174. */
  109175. onBeforeComposeObservable: Observable<EffectLayer>;
  109176. /**
  109177. * An event triggered when the generated texture has been merged in the scene.
  109178. */
  109179. onAfterComposeObservable: Observable<EffectLayer>;
  109180. /**
  109181. * An event triggered when the efffect layer changes its size.
  109182. */
  109183. onSizeChangedObservable: Observable<EffectLayer>;
  109184. /** @hidden */
  109185. static _SceneComponentInitialization: (scene: Scene) => void;
  109186. /**
  109187. * Instantiates a new effect Layer and references it in the scene.
  109188. * @param name The name of the layer
  109189. * @param scene The scene to use the layer in
  109190. */
  109191. constructor(
  109192. /** The Friendly of the effect in the scene */
  109193. name: string, scene: Scene);
  109194. /**
  109195. * Get the effect name of the layer.
  109196. * @return The effect name
  109197. */
  109198. abstract getEffectName(): string;
  109199. /**
  109200. * Checks for the readiness of the element composing the layer.
  109201. * @param subMesh the mesh to check for
  109202. * @param useInstances specify wether or not to use instances to render the mesh
  109203. * @return true if ready otherwise, false
  109204. */
  109205. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109206. /**
  109207. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109208. * @returns true if the effect requires stencil during the main canvas render pass.
  109209. */
  109210. abstract needStencil(): boolean;
  109211. /**
  109212. * Create the merge effect. This is the shader use to blit the information back
  109213. * to the main canvas at the end of the scene rendering.
  109214. * @returns The effect containing the shader used to merge the effect on the main canvas
  109215. */
  109216. protected abstract _createMergeEffect(): Effect;
  109217. /**
  109218. * Creates the render target textures and post processes used in the effect layer.
  109219. */
  109220. protected abstract _createTextureAndPostProcesses(): void;
  109221. /**
  109222. * Implementation specific of rendering the generating effect on the main canvas.
  109223. * @param effect The effect used to render through
  109224. */
  109225. protected abstract _internalRender(effect: Effect): void;
  109226. /**
  109227. * Sets the required values for both the emissive texture and and the main color.
  109228. */
  109229. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109230. /**
  109231. * Free any resources and references associated to a mesh.
  109232. * Internal use
  109233. * @param mesh The mesh to free.
  109234. */
  109235. abstract _disposeMesh(mesh: Mesh): void;
  109236. /**
  109237. * Serializes this layer (Glow or Highlight for example)
  109238. * @returns a serialized layer object
  109239. */
  109240. abstract serialize?(): any;
  109241. /**
  109242. * Initializes the effect layer with the required options.
  109243. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  109244. */
  109245. protected _init(options: Partial<IEffectLayerOptions>): void;
  109246. /**
  109247. * Generates the index buffer of the full screen quad blending to the main canvas.
  109248. */
  109249. private _generateIndexBuffer;
  109250. /**
  109251. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  109252. */
  109253. private _generateVertexBuffer;
  109254. /**
  109255. * Sets the main texture desired size which is the closest power of two
  109256. * of the engine canvas size.
  109257. */
  109258. private _setMainTextureSize;
  109259. /**
  109260. * Creates the main texture for the effect layer.
  109261. */
  109262. protected _createMainTexture(): void;
  109263. /**
  109264. * Adds specific effects defines.
  109265. * @param defines The defines to add specifics to.
  109266. */
  109267. protected _addCustomEffectDefines(defines: string[]): void;
  109268. /**
  109269. * Checks for the readiness of the element composing the layer.
  109270. * @param subMesh the mesh to check for
  109271. * @param useInstances specify wether or not to use instances to render the mesh
  109272. * @param emissiveTexture the associated emissive texture used to generate the glow
  109273. * @return true if ready otherwise, false
  109274. */
  109275. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  109276. /**
  109277. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  109278. */
  109279. render(): void;
  109280. /**
  109281. * Determine if a given mesh will be used in the current effect.
  109282. * @param mesh mesh to test
  109283. * @returns true if the mesh will be used
  109284. */
  109285. hasMesh(mesh: AbstractMesh): boolean;
  109286. /**
  109287. * Returns true if the layer contains information to display, otherwise false.
  109288. * @returns true if the glow layer should be rendered
  109289. */
  109290. shouldRender(): boolean;
  109291. /**
  109292. * Returns true if the mesh should render, otherwise false.
  109293. * @param mesh The mesh to render
  109294. * @returns true if it should render otherwise false
  109295. */
  109296. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  109297. /**
  109298. * Returns true if the mesh can be rendered, otherwise false.
  109299. * @param mesh The mesh to render
  109300. * @param material The material used on the mesh
  109301. * @returns true if it can be rendered otherwise false
  109302. */
  109303. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  109304. /**
  109305. * Returns true if the mesh should render, otherwise false.
  109306. * @param mesh The mesh to render
  109307. * @returns true if it should render otherwise false
  109308. */
  109309. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  109310. /**
  109311. * Renders the submesh passed in parameter to the generation map.
  109312. */
  109313. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  109314. /**
  109315. * Rebuild the required buffers.
  109316. * @hidden Internal use only.
  109317. */
  109318. _rebuild(): void;
  109319. /**
  109320. * Dispose only the render target textures and post process.
  109321. */
  109322. private _disposeTextureAndPostProcesses;
  109323. /**
  109324. * Dispose the highlight layer and free resources.
  109325. */
  109326. dispose(): void;
  109327. /**
  109328. * Gets the class name of the effect layer
  109329. * @returns the string with the class name of the effect layer
  109330. */
  109331. getClassName(): string;
  109332. /**
  109333. * Creates an effect layer from parsed effect layer data
  109334. * @param parsedEffectLayer defines effect layer data
  109335. * @param scene defines the current scene
  109336. * @param rootUrl defines the root URL containing the effect layer information
  109337. * @returns a parsed effect Layer
  109338. */
  109339. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  109340. }
  109341. }
  109342. declare module BABYLON {
  109343. interface AbstractScene {
  109344. /**
  109345. * The list of effect layers (highlights/glow) added to the scene
  109346. * @see http://doc.babylonjs.com/how_to/highlight_layer
  109347. * @see http://doc.babylonjs.com/how_to/glow_layer
  109348. */
  109349. effectLayers: Array<EffectLayer>;
  109350. /**
  109351. * Removes the given effect layer from this scene.
  109352. * @param toRemove defines the effect layer to remove
  109353. * @returns the index of the removed effect layer
  109354. */
  109355. removeEffectLayer(toRemove: EffectLayer): number;
  109356. /**
  109357. * Adds the given effect layer to this scene
  109358. * @param newEffectLayer defines the effect layer to add
  109359. */
  109360. addEffectLayer(newEffectLayer: EffectLayer): void;
  109361. }
  109362. /**
  109363. * Defines the layer scene component responsible to manage any effect layers
  109364. * in a given scene.
  109365. */
  109366. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  109367. /**
  109368. * The component name helpfull to identify the component in the list of scene components.
  109369. */
  109370. readonly name: string;
  109371. /**
  109372. * The scene the component belongs to.
  109373. */
  109374. scene: Scene;
  109375. private _engine;
  109376. private _renderEffects;
  109377. private _needStencil;
  109378. private _previousStencilState;
  109379. /**
  109380. * Creates a new instance of the component for the given scene
  109381. * @param scene Defines the scene to register the component in
  109382. */
  109383. constructor(scene: Scene);
  109384. /**
  109385. * Registers the component in a given scene
  109386. */
  109387. register(): void;
  109388. /**
  109389. * Rebuilds the elements related to this component in case of
  109390. * context lost for instance.
  109391. */
  109392. rebuild(): void;
  109393. /**
  109394. * Serializes the component data to the specified json object
  109395. * @param serializationObject The object to serialize to
  109396. */
  109397. serialize(serializationObject: any): void;
  109398. /**
  109399. * Adds all the elements from the container to the scene
  109400. * @param container the container holding the elements
  109401. */
  109402. addFromContainer(container: AbstractScene): void;
  109403. /**
  109404. * Removes all the elements in the container from the scene
  109405. * @param container contains the elements to remove
  109406. * @param dispose if the removed element should be disposed (default: false)
  109407. */
  109408. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  109409. /**
  109410. * Disposes the component and the associated ressources.
  109411. */
  109412. dispose(): void;
  109413. private _isReadyForMesh;
  109414. private _renderMainTexture;
  109415. private _setStencil;
  109416. private _setStencilBack;
  109417. private _draw;
  109418. private _drawCamera;
  109419. private _drawRenderingGroup;
  109420. }
  109421. }
  109422. declare module BABYLON {
  109423. /** @hidden */
  109424. export var glowMapMergePixelShader: {
  109425. name: string;
  109426. shader: string;
  109427. };
  109428. }
  109429. declare module BABYLON {
  109430. /** @hidden */
  109431. export var glowMapMergeVertexShader: {
  109432. name: string;
  109433. shader: string;
  109434. };
  109435. }
  109436. declare module BABYLON {
  109437. interface AbstractScene {
  109438. /**
  109439. * Return a the first highlight layer of the scene with a given name.
  109440. * @param name The name of the highlight layer to look for.
  109441. * @return The highlight layer if found otherwise null.
  109442. */
  109443. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  109444. }
  109445. /**
  109446. * Glow layer options. This helps customizing the behaviour
  109447. * of the glow layer.
  109448. */
  109449. export interface IGlowLayerOptions {
  109450. /**
  109451. * Multiplication factor apply to the canvas size to compute the render target size
  109452. * used to generated the glowing objects (the smaller the faster).
  109453. */
  109454. mainTextureRatio: number;
  109455. /**
  109456. * Enforces a fixed size texture to ensure resize independant blur.
  109457. */
  109458. mainTextureFixedSize?: number;
  109459. /**
  109460. * How big is the kernel of the blur texture.
  109461. */
  109462. blurKernelSize: number;
  109463. /**
  109464. * The camera attached to the layer.
  109465. */
  109466. camera: Nullable<Camera>;
  109467. /**
  109468. * Enable MSAA by chosing the number of samples.
  109469. */
  109470. mainTextureSamples?: number;
  109471. /**
  109472. * The rendering group to draw the layer in.
  109473. */
  109474. renderingGroupId: number;
  109475. }
  109476. /**
  109477. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  109478. *
  109479. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  109480. * glowy meshes to your scene.
  109481. *
  109482. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  109483. */
  109484. export class GlowLayer extends EffectLayer {
  109485. /**
  109486. * Effect Name of the layer.
  109487. */
  109488. static readonly EffectName: string;
  109489. /**
  109490. * The default blur kernel size used for the glow.
  109491. */
  109492. static DefaultBlurKernelSize: number;
  109493. /**
  109494. * The default texture size ratio used for the glow.
  109495. */
  109496. static DefaultTextureRatio: number;
  109497. /**
  109498. * Sets the kernel size of the blur.
  109499. */
  109500. /**
  109501. * Gets the kernel size of the blur.
  109502. */
  109503. blurKernelSize: number;
  109504. /**
  109505. * Sets the glow intensity.
  109506. */
  109507. /**
  109508. * Gets the glow intensity.
  109509. */
  109510. intensity: number;
  109511. private _options;
  109512. private _intensity;
  109513. private _horizontalBlurPostprocess1;
  109514. private _verticalBlurPostprocess1;
  109515. private _horizontalBlurPostprocess2;
  109516. private _verticalBlurPostprocess2;
  109517. private _blurTexture1;
  109518. private _blurTexture2;
  109519. private _postProcesses1;
  109520. private _postProcesses2;
  109521. private _includedOnlyMeshes;
  109522. private _excludedMeshes;
  109523. /**
  109524. * Callback used to let the user override the color selection on a per mesh basis
  109525. */
  109526. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  109527. /**
  109528. * Callback used to let the user override the texture selection on a per mesh basis
  109529. */
  109530. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  109531. /**
  109532. * Instantiates a new glow Layer and references it to the scene.
  109533. * @param name The name of the layer
  109534. * @param scene The scene to use the layer in
  109535. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  109536. */
  109537. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  109538. /**
  109539. * Get the effect name of the layer.
  109540. * @return The effect name
  109541. */
  109542. getEffectName(): string;
  109543. /**
  109544. * Create the merge effect. This is the shader use to blit the information back
  109545. * to the main canvas at the end of the scene rendering.
  109546. */
  109547. protected _createMergeEffect(): Effect;
  109548. /**
  109549. * Creates the render target textures and post processes used in the glow layer.
  109550. */
  109551. protected _createTextureAndPostProcesses(): void;
  109552. /**
  109553. * Checks for the readiness of the element composing the layer.
  109554. * @param subMesh the mesh to check for
  109555. * @param useInstances specify wether or not to use instances to render the mesh
  109556. * @param emissiveTexture the associated emissive texture used to generate the glow
  109557. * @return true if ready otherwise, false
  109558. */
  109559. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109560. /**
  109561. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109562. */
  109563. needStencil(): boolean;
  109564. /**
  109565. * Returns true if the mesh can be rendered, otherwise false.
  109566. * @param mesh The mesh to render
  109567. * @param material The material used on the mesh
  109568. * @returns true if it can be rendered otherwise false
  109569. */
  109570. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  109571. /**
  109572. * Implementation specific of rendering the generating effect on the main canvas.
  109573. * @param effect The effect used to render through
  109574. */
  109575. protected _internalRender(effect: Effect): void;
  109576. /**
  109577. * Sets the required values for both the emissive texture and and the main color.
  109578. */
  109579. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109580. /**
  109581. * Returns true if the mesh should render, otherwise false.
  109582. * @param mesh The mesh to render
  109583. * @returns true if it should render otherwise false
  109584. */
  109585. protected _shouldRenderMesh(mesh: Mesh): boolean;
  109586. /**
  109587. * Adds specific effects defines.
  109588. * @param defines The defines to add specifics to.
  109589. */
  109590. protected _addCustomEffectDefines(defines: string[]): void;
  109591. /**
  109592. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  109593. * @param mesh The mesh to exclude from the glow layer
  109594. */
  109595. addExcludedMesh(mesh: Mesh): void;
  109596. /**
  109597. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  109598. * @param mesh The mesh to remove
  109599. */
  109600. removeExcludedMesh(mesh: Mesh): void;
  109601. /**
  109602. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  109603. * @param mesh The mesh to include in the glow layer
  109604. */
  109605. addIncludedOnlyMesh(mesh: Mesh): void;
  109606. /**
  109607. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  109608. * @param mesh The mesh to remove
  109609. */
  109610. removeIncludedOnlyMesh(mesh: Mesh): void;
  109611. /**
  109612. * Determine if a given mesh will be used in the glow layer
  109613. * @param mesh The mesh to test
  109614. * @returns true if the mesh will be highlighted by the current glow layer
  109615. */
  109616. hasMesh(mesh: AbstractMesh): boolean;
  109617. /**
  109618. * Free any resources and references associated to a mesh.
  109619. * Internal use
  109620. * @param mesh The mesh to free.
  109621. * @hidden
  109622. */
  109623. _disposeMesh(mesh: Mesh): void;
  109624. /**
  109625. * Gets the class name of the effect layer
  109626. * @returns the string with the class name of the effect layer
  109627. */
  109628. getClassName(): string;
  109629. /**
  109630. * Serializes this glow layer
  109631. * @returns a serialized glow layer object
  109632. */
  109633. serialize(): any;
  109634. /**
  109635. * Creates a Glow Layer from parsed glow layer data
  109636. * @param parsedGlowLayer defines glow layer data
  109637. * @param scene defines the current scene
  109638. * @param rootUrl defines the root URL containing the glow layer information
  109639. * @returns a parsed Glow Layer
  109640. */
  109641. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  109642. }
  109643. }
  109644. declare module BABYLON {
  109645. /** @hidden */
  109646. export var glowBlurPostProcessPixelShader: {
  109647. name: string;
  109648. shader: string;
  109649. };
  109650. }
  109651. declare module BABYLON {
  109652. interface AbstractScene {
  109653. /**
  109654. * Return a the first highlight layer of the scene with a given name.
  109655. * @param name The name of the highlight layer to look for.
  109656. * @return The highlight layer if found otherwise null.
  109657. */
  109658. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  109659. }
  109660. /**
  109661. * Highlight layer options. This helps customizing the behaviour
  109662. * of the highlight layer.
  109663. */
  109664. export interface IHighlightLayerOptions {
  109665. /**
  109666. * Multiplication factor apply to the canvas size to compute the render target size
  109667. * used to generated the glowing objects (the smaller the faster).
  109668. */
  109669. mainTextureRatio: number;
  109670. /**
  109671. * Enforces a fixed size texture to ensure resize independant blur.
  109672. */
  109673. mainTextureFixedSize?: number;
  109674. /**
  109675. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  109676. * of the picture to blur (the smaller the faster).
  109677. */
  109678. blurTextureSizeRatio: number;
  109679. /**
  109680. * How big in texel of the blur texture is the vertical blur.
  109681. */
  109682. blurVerticalSize: number;
  109683. /**
  109684. * How big in texel of the blur texture is the horizontal blur.
  109685. */
  109686. blurHorizontalSize: number;
  109687. /**
  109688. * Alpha blending mode used to apply the blur. Default is combine.
  109689. */
  109690. alphaBlendingMode: number;
  109691. /**
  109692. * The camera attached to the layer.
  109693. */
  109694. camera: Nullable<Camera>;
  109695. /**
  109696. * Should we display highlight as a solid stroke?
  109697. */
  109698. isStroke?: boolean;
  109699. /**
  109700. * The rendering group to draw the layer in.
  109701. */
  109702. renderingGroupId: number;
  109703. }
  109704. /**
  109705. * The highlight layer Helps adding a glow effect around a mesh.
  109706. *
  109707. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  109708. * glowy meshes to your scene.
  109709. *
  109710. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  109711. */
  109712. export class HighlightLayer extends EffectLayer {
  109713. name: string;
  109714. /**
  109715. * Effect Name of the highlight layer.
  109716. */
  109717. static readonly EffectName: string;
  109718. /**
  109719. * The neutral color used during the preparation of the glow effect.
  109720. * This is black by default as the blend operation is a blend operation.
  109721. */
  109722. static NeutralColor: Color4;
  109723. /**
  109724. * Stencil value used for glowing meshes.
  109725. */
  109726. static GlowingMeshStencilReference: number;
  109727. /**
  109728. * Stencil value used for the other meshes in the scene.
  109729. */
  109730. static NormalMeshStencilReference: number;
  109731. /**
  109732. * Specifies whether or not the inner glow is ACTIVE in the layer.
  109733. */
  109734. innerGlow: boolean;
  109735. /**
  109736. * Specifies whether or not the outer glow is ACTIVE in the layer.
  109737. */
  109738. outerGlow: boolean;
  109739. /**
  109740. * Specifies the horizontal size of the blur.
  109741. */
  109742. /**
  109743. * Gets the horizontal size of the blur.
  109744. */
  109745. blurHorizontalSize: number;
  109746. /**
  109747. * Specifies the vertical size of the blur.
  109748. */
  109749. /**
  109750. * Gets the vertical size of the blur.
  109751. */
  109752. blurVerticalSize: number;
  109753. /**
  109754. * An event triggered when the highlight layer is being blurred.
  109755. */
  109756. onBeforeBlurObservable: Observable<HighlightLayer>;
  109757. /**
  109758. * An event triggered when the highlight layer has been blurred.
  109759. */
  109760. onAfterBlurObservable: Observable<HighlightLayer>;
  109761. private _instanceGlowingMeshStencilReference;
  109762. private _options;
  109763. private _downSamplePostprocess;
  109764. private _horizontalBlurPostprocess;
  109765. private _verticalBlurPostprocess;
  109766. private _blurTexture;
  109767. private _meshes;
  109768. private _excludedMeshes;
  109769. /**
  109770. * Instantiates a new highlight Layer and references it to the scene..
  109771. * @param name The name of the layer
  109772. * @param scene The scene to use the layer in
  109773. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  109774. */
  109775. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  109776. /**
  109777. * Get the effect name of the layer.
  109778. * @return The effect name
  109779. */
  109780. getEffectName(): string;
  109781. /**
  109782. * Create the merge effect. This is the shader use to blit the information back
  109783. * to the main canvas at the end of the scene rendering.
  109784. */
  109785. protected _createMergeEffect(): Effect;
  109786. /**
  109787. * Creates the render target textures and post processes used in the highlight layer.
  109788. */
  109789. protected _createTextureAndPostProcesses(): void;
  109790. /**
  109791. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  109792. */
  109793. needStencil(): boolean;
  109794. /**
  109795. * Checks for the readiness of the element composing the layer.
  109796. * @param subMesh the mesh to check for
  109797. * @param useInstances specify wether or not to use instances to render the mesh
  109798. * @param emissiveTexture the associated emissive texture used to generate the glow
  109799. * @return true if ready otherwise, false
  109800. */
  109801. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  109802. /**
  109803. * Implementation specific of rendering the generating effect on the main canvas.
  109804. * @param effect The effect used to render through
  109805. */
  109806. protected _internalRender(effect: Effect): void;
  109807. /**
  109808. * Returns true if the layer contains information to display, otherwise false.
  109809. */
  109810. shouldRender(): boolean;
  109811. /**
  109812. * Returns true if the mesh should render, otherwise false.
  109813. * @param mesh The mesh to render
  109814. * @returns true if it should render otherwise false
  109815. */
  109816. protected _shouldRenderMesh(mesh: Mesh): boolean;
  109817. /**
  109818. * Sets the required values for both the emissive texture and and the main color.
  109819. */
  109820. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  109821. /**
  109822. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  109823. * @param mesh The mesh to exclude from the highlight layer
  109824. */
  109825. addExcludedMesh(mesh: Mesh): void;
  109826. /**
  109827. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  109828. * @param mesh The mesh to highlight
  109829. */
  109830. removeExcludedMesh(mesh: Mesh): void;
  109831. /**
  109832. * Determine if a given mesh will be highlighted by the current HighlightLayer
  109833. * @param mesh mesh to test
  109834. * @returns true if the mesh will be highlighted by the current HighlightLayer
  109835. */
  109836. hasMesh(mesh: AbstractMesh): boolean;
  109837. /**
  109838. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  109839. * @param mesh The mesh to highlight
  109840. * @param color The color of the highlight
  109841. * @param glowEmissiveOnly Extract the glow from the emissive texture
  109842. */
  109843. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  109844. /**
  109845. * Remove a mesh from the highlight layer in order to make it stop glowing.
  109846. * @param mesh The mesh to highlight
  109847. */
  109848. removeMesh(mesh: Mesh): void;
  109849. /**
  109850. * Force the stencil to the normal expected value for none glowing parts
  109851. */
  109852. private _defaultStencilReference;
  109853. /**
  109854. * Free any resources and references associated to a mesh.
  109855. * Internal use
  109856. * @param mesh The mesh to free.
  109857. * @hidden
  109858. */
  109859. _disposeMesh(mesh: Mesh): void;
  109860. /**
  109861. * Dispose the highlight layer and free resources.
  109862. */
  109863. dispose(): void;
  109864. /**
  109865. * Gets the class name of the effect layer
  109866. * @returns the string with the class name of the effect layer
  109867. */
  109868. getClassName(): string;
  109869. /**
  109870. * Serializes this Highlight layer
  109871. * @returns a serialized Highlight layer object
  109872. */
  109873. serialize(): any;
  109874. /**
  109875. * Creates a Highlight layer from parsed Highlight layer data
  109876. * @param parsedHightlightLayer defines the Highlight layer data
  109877. * @param scene defines the current scene
  109878. * @param rootUrl defines the root URL containing the Highlight layer information
  109879. * @returns a parsed Highlight layer
  109880. */
  109881. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  109882. }
  109883. }
  109884. declare module BABYLON {
  109885. interface AbstractScene {
  109886. /**
  109887. * The list of layers (background and foreground) of the scene
  109888. */
  109889. layers: Array<Layer>;
  109890. }
  109891. /**
  109892. * Defines the layer scene component responsible to manage any layers
  109893. * in a given scene.
  109894. */
  109895. export class LayerSceneComponent implements ISceneComponent {
  109896. /**
  109897. * The component name helpfull to identify the component in the list of scene components.
  109898. */
  109899. readonly name: string;
  109900. /**
  109901. * The scene the component belongs to.
  109902. */
  109903. scene: Scene;
  109904. private _engine;
  109905. /**
  109906. * Creates a new instance of the component for the given scene
  109907. * @param scene Defines the scene to register the component in
  109908. */
  109909. constructor(scene: Scene);
  109910. /**
  109911. * Registers the component in a given scene
  109912. */
  109913. register(): void;
  109914. /**
  109915. * Rebuilds the elements related to this component in case of
  109916. * context lost for instance.
  109917. */
  109918. rebuild(): void;
  109919. /**
  109920. * Disposes the component and the associated ressources.
  109921. */
  109922. dispose(): void;
  109923. private _draw;
  109924. private _drawCameraPredicate;
  109925. private _drawCameraBackground;
  109926. private _drawCameraForeground;
  109927. private _drawRenderTargetPredicate;
  109928. private _drawRenderTargetBackground;
  109929. private _drawRenderTargetForeground;
  109930. /**
  109931. * Adds all the elements from the container to the scene
  109932. * @param container the container holding the elements
  109933. */
  109934. addFromContainer(container: AbstractScene): void;
  109935. /**
  109936. * Removes all the elements in the container from the scene
  109937. * @param container contains the elements to remove
  109938. * @param dispose if the removed element should be disposed (default: false)
  109939. */
  109940. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  109941. }
  109942. }
  109943. declare module BABYLON {
  109944. /** @hidden */
  109945. export var layerPixelShader: {
  109946. name: string;
  109947. shader: string;
  109948. };
  109949. }
  109950. declare module BABYLON {
  109951. /** @hidden */
  109952. export var layerVertexShader: {
  109953. name: string;
  109954. shader: string;
  109955. };
  109956. }
  109957. declare module BABYLON {
  109958. /**
  109959. * This represents a full screen 2d layer.
  109960. * This can be useful to display a picture in the background of your scene for instance.
  109961. * @see https://www.babylonjs-playground.com/#08A2BS#1
  109962. */
  109963. export class Layer {
  109964. /**
  109965. * Define the name of the layer.
  109966. */
  109967. name: string;
  109968. /**
  109969. * Define the texture the layer should display.
  109970. */
  109971. texture: Nullable<Texture>;
  109972. /**
  109973. * Is the layer in background or foreground.
  109974. */
  109975. isBackground: boolean;
  109976. /**
  109977. * Define the color of the layer (instead of texture).
  109978. */
  109979. color: Color4;
  109980. /**
  109981. * Define the scale of the layer in order to zoom in out of the texture.
  109982. */
  109983. scale: Vector2;
  109984. /**
  109985. * Define an offset for the layer in order to shift the texture.
  109986. */
  109987. offset: Vector2;
  109988. /**
  109989. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  109990. */
  109991. alphaBlendingMode: number;
  109992. /**
  109993. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  109994. * Alpha test will not mix with the background color in case of transparency.
  109995. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  109996. */
  109997. alphaTest: boolean;
  109998. /**
  109999. * Define a mask to restrict the layer to only some of the scene cameras.
  110000. */
  110001. layerMask: number;
  110002. /**
  110003. * Define the list of render target the layer is visible into.
  110004. */
  110005. renderTargetTextures: RenderTargetTexture[];
  110006. /**
  110007. * Define if the layer is only used in renderTarget or if it also
  110008. * renders in the main frame buffer of the canvas.
  110009. */
  110010. renderOnlyInRenderTargetTextures: boolean;
  110011. private _scene;
  110012. private _vertexBuffers;
  110013. private _indexBuffer;
  110014. private _effect;
  110015. private _alphaTestEffect;
  110016. /**
  110017. * An event triggered when the layer is disposed.
  110018. */
  110019. onDisposeObservable: Observable<Layer>;
  110020. private _onDisposeObserver;
  110021. /**
  110022. * Back compatibility with callback before the onDisposeObservable existed.
  110023. * The set callback will be triggered when the layer has been disposed.
  110024. */
  110025. onDispose: () => void;
  110026. /**
  110027. * An event triggered before rendering the scene
  110028. */
  110029. onBeforeRenderObservable: Observable<Layer>;
  110030. private _onBeforeRenderObserver;
  110031. /**
  110032. * Back compatibility with callback before the onBeforeRenderObservable existed.
  110033. * The set callback will be triggered just before rendering the layer.
  110034. */
  110035. onBeforeRender: () => void;
  110036. /**
  110037. * An event triggered after rendering the scene
  110038. */
  110039. onAfterRenderObservable: Observable<Layer>;
  110040. private _onAfterRenderObserver;
  110041. /**
  110042. * Back compatibility with callback before the onAfterRenderObservable existed.
  110043. * The set callback will be triggered just after rendering the layer.
  110044. */
  110045. onAfterRender: () => void;
  110046. /**
  110047. * Instantiates a new layer.
  110048. * This represents a full screen 2d layer.
  110049. * This can be useful to display a picture in the background of your scene for instance.
  110050. * @see https://www.babylonjs-playground.com/#08A2BS#1
  110051. * @param name Define the name of the layer in the scene
  110052. * @param imgUrl Define the url of the texture to display in the layer
  110053. * @param scene Define the scene the layer belongs to
  110054. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  110055. * @param color Defines a color for the layer
  110056. */
  110057. constructor(
  110058. /**
  110059. * Define the name of the layer.
  110060. */
  110061. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  110062. private _createIndexBuffer;
  110063. /** @hidden */
  110064. _rebuild(): void;
  110065. /**
  110066. * Renders the layer in the scene.
  110067. */
  110068. render(): void;
  110069. /**
  110070. * Disposes and releases the associated ressources.
  110071. */
  110072. dispose(): void;
  110073. }
  110074. }
  110075. declare module BABYLON {
  110076. /** @hidden */
  110077. export var lensFlarePixelShader: {
  110078. name: string;
  110079. shader: string;
  110080. };
  110081. }
  110082. declare module BABYLON {
  110083. /** @hidden */
  110084. export var lensFlareVertexShader: {
  110085. name: string;
  110086. shader: string;
  110087. };
  110088. }
  110089. declare module BABYLON {
  110090. /**
  110091. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110092. * It is usually composed of several `lensFlare`.
  110093. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110094. */
  110095. export class LensFlareSystem {
  110096. /**
  110097. * Define the name of the lens flare system
  110098. */
  110099. name: string;
  110100. /**
  110101. * List of lens flares used in this system.
  110102. */
  110103. lensFlares: LensFlare[];
  110104. /**
  110105. * Define a limit from the border the lens flare can be visible.
  110106. */
  110107. borderLimit: number;
  110108. /**
  110109. * Define a viewport border we do not want to see the lens flare in.
  110110. */
  110111. viewportBorder: number;
  110112. /**
  110113. * Define a predicate which could limit the list of meshes able to occlude the effect.
  110114. */
  110115. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  110116. /**
  110117. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  110118. */
  110119. layerMask: number;
  110120. /**
  110121. * Define the id of the lens flare system in the scene.
  110122. * (equal to name by default)
  110123. */
  110124. id: string;
  110125. private _scene;
  110126. private _emitter;
  110127. private _vertexBuffers;
  110128. private _indexBuffer;
  110129. private _effect;
  110130. private _positionX;
  110131. private _positionY;
  110132. private _isEnabled;
  110133. /** @hidden */
  110134. static _SceneComponentInitialization: (scene: Scene) => void;
  110135. /**
  110136. * Instantiates a lens flare system.
  110137. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  110138. * It is usually composed of several `lensFlare`.
  110139. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110140. * @param name Define the name of the lens flare system in the scene
  110141. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  110142. * @param scene Define the scene the lens flare system belongs to
  110143. */
  110144. constructor(
  110145. /**
  110146. * Define the name of the lens flare system
  110147. */
  110148. name: string, emitter: any, scene: Scene);
  110149. /**
  110150. * Define if the lens flare system is enabled.
  110151. */
  110152. isEnabled: boolean;
  110153. /**
  110154. * Get the scene the effects belongs to.
  110155. * @returns the scene holding the lens flare system
  110156. */
  110157. getScene(): Scene;
  110158. /**
  110159. * Get the emitter of the lens flare system.
  110160. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110161. * @returns the emitter of the lens flare system
  110162. */
  110163. getEmitter(): any;
  110164. /**
  110165. * Set the emitter of the lens flare system.
  110166. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  110167. * @param newEmitter Define the new emitter of the system
  110168. */
  110169. setEmitter(newEmitter: any): void;
  110170. /**
  110171. * Get the lens flare system emitter position.
  110172. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  110173. * @returns the position
  110174. */
  110175. getEmitterPosition(): Vector3;
  110176. /**
  110177. * @hidden
  110178. */
  110179. computeEffectivePosition(globalViewport: Viewport): boolean;
  110180. /** @hidden */
  110181. _isVisible(): boolean;
  110182. /**
  110183. * @hidden
  110184. */
  110185. render(): boolean;
  110186. /**
  110187. * Dispose and release the lens flare with its associated resources.
  110188. */
  110189. dispose(): void;
  110190. /**
  110191. * Parse a lens flare system from a JSON repressentation
  110192. * @param parsedLensFlareSystem Define the JSON to parse
  110193. * @param scene Define the scene the parsed system should be instantiated in
  110194. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  110195. * @returns the parsed system
  110196. */
  110197. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  110198. /**
  110199. * Serialize the current Lens Flare System into a JSON representation.
  110200. * @returns the serialized JSON
  110201. */
  110202. serialize(): any;
  110203. }
  110204. }
  110205. declare module BABYLON {
  110206. /**
  110207. * This represents one of the lens effect in a `lensFlareSystem`.
  110208. * It controls one of the indiviual texture used in the effect.
  110209. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110210. */
  110211. export class LensFlare {
  110212. /**
  110213. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110214. */
  110215. size: number;
  110216. /**
  110217. * 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.
  110218. */
  110219. position: number;
  110220. /**
  110221. * Define the lens color.
  110222. */
  110223. color: Color3;
  110224. /**
  110225. * Define the lens texture.
  110226. */
  110227. texture: Nullable<Texture>;
  110228. /**
  110229. * Define the alpha mode to render this particular lens.
  110230. */
  110231. alphaMode: number;
  110232. private _system;
  110233. /**
  110234. * Creates a new Lens Flare.
  110235. * This represents one of the lens effect in a `lensFlareSystem`.
  110236. * It controls one of the indiviual texture used in the effect.
  110237. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110238. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  110239. * @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.
  110240. * @param color Define the lens color
  110241. * @param imgUrl Define the lens texture url
  110242. * @param system Define the `lensFlareSystem` this flare is part of
  110243. * @returns The newly created Lens Flare
  110244. */
  110245. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  110246. /**
  110247. * Instantiates a new Lens Flare.
  110248. * This represents one of the lens effect in a `lensFlareSystem`.
  110249. * It controls one of the indiviual texture used in the effect.
  110250. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110251. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  110252. * @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.
  110253. * @param color Define the lens color
  110254. * @param imgUrl Define the lens texture url
  110255. * @param system Define the `lensFlareSystem` this flare is part of
  110256. */
  110257. constructor(
  110258. /**
  110259. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  110260. */
  110261. size: number,
  110262. /**
  110263. * 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.
  110264. */
  110265. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  110266. /**
  110267. * Dispose and release the lens flare with its associated resources.
  110268. */
  110269. dispose(): void;
  110270. }
  110271. }
  110272. declare module BABYLON {
  110273. interface AbstractScene {
  110274. /**
  110275. * The list of lens flare system added to the scene
  110276. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  110277. */
  110278. lensFlareSystems: Array<LensFlareSystem>;
  110279. /**
  110280. * Removes the given lens flare system from this scene.
  110281. * @param toRemove The lens flare system to remove
  110282. * @returns The index of the removed lens flare system
  110283. */
  110284. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  110285. /**
  110286. * Adds the given lens flare system to this scene
  110287. * @param newLensFlareSystem The lens flare system to add
  110288. */
  110289. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  110290. /**
  110291. * Gets a lens flare system using its name
  110292. * @param name defines the name to look for
  110293. * @returns the lens flare system or null if not found
  110294. */
  110295. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  110296. /**
  110297. * Gets a lens flare system using its id
  110298. * @param id defines the id to look for
  110299. * @returns the lens flare system or null if not found
  110300. */
  110301. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  110302. }
  110303. /**
  110304. * Defines the lens flare scene component responsible to manage any lens flares
  110305. * in a given scene.
  110306. */
  110307. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  110308. /**
  110309. * The component name helpfull to identify the component in the list of scene components.
  110310. */
  110311. readonly name: string;
  110312. /**
  110313. * The scene the component belongs to.
  110314. */
  110315. scene: Scene;
  110316. /**
  110317. * Creates a new instance of the component for the given scene
  110318. * @param scene Defines the scene to register the component in
  110319. */
  110320. constructor(scene: Scene);
  110321. /**
  110322. * Registers the component in a given scene
  110323. */
  110324. register(): void;
  110325. /**
  110326. * Rebuilds the elements related to this component in case of
  110327. * context lost for instance.
  110328. */
  110329. rebuild(): void;
  110330. /**
  110331. * Adds all the elements from the container to the scene
  110332. * @param container the container holding the elements
  110333. */
  110334. addFromContainer(container: AbstractScene): void;
  110335. /**
  110336. * Removes all the elements in the container from the scene
  110337. * @param container contains the elements to remove
  110338. * @param dispose if the removed element should be disposed (default: false)
  110339. */
  110340. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110341. /**
  110342. * Serializes the component data to the specified json object
  110343. * @param serializationObject The object to serialize to
  110344. */
  110345. serialize(serializationObject: any): void;
  110346. /**
  110347. * Disposes the component and the associated ressources.
  110348. */
  110349. dispose(): void;
  110350. private _draw;
  110351. }
  110352. }
  110353. declare module BABYLON {
  110354. /**
  110355. * Defines the shadow generator component responsible to manage any shadow generators
  110356. * in a given scene.
  110357. */
  110358. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  110359. /**
  110360. * The component name helpfull to identify the component in the list of scene components.
  110361. */
  110362. readonly name: string;
  110363. /**
  110364. * The scene the component belongs to.
  110365. */
  110366. scene: Scene;
  110367. /**
  110368. * Creates a new instance of the component for the given scene
  110369. * @param scene Defines the scene to register the component in
  110370. */
  110371. constructor(scene: Scene);
  110372. /**
  110373. * Registers the component in a given scene
  110374. */
  110375. register(): void;
  110376. /**
  110377. * Rebuilds the elements related to this component in case of
  110378. * context lost for instance.
  110379. */
  110380. rebuild(): void;
  110381. /**
  110382. * Serializes the component data to the specified json object
  110383. * @param serializationObject The object to serialize to
  110384. */
  110385. serialize(serializationObject: any): void;
  110386. /**
  110387. * Adds all the elements from the container to the scene
  110388. * @param container the container holding the elements
  110389. */
  110390. addFromContainer(container: AbstractScene): void;
  110391. /**
  110392. * Removes all the elements in the container from the scene
  110393. * @param container contains the elements to remove
  110394. * @param dispose if the removed element should be disposed (default: false)
  110395. */
  110396. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  110397. /**
  110398. * Rebuilds the elements related to this component in case of
  110399. * context lost for instance.
  110400. */
  110401. dispose(): void;
  110402. private _gatherRenderTargets;
  110403. }
  110404. }
  110405. declare module BABYLON {
  110406. /**
  110407. * A point light is a light defined by an unique point in world space.
  110408. * The light is emitted in every direction from this point.
  110409. * A good example of a point light is a standard light bulb.
  110410. * Documentation: https://doc.babylonjs.com/babylon101/lights
  110411. */
  110412. export class PointLight extends ShadowLight {
  110413. private _shadowAngle;
  110414. /**
  110415. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110416. * This specifies what angle the shadow will use to be created.
  110417. *
  110418. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110419. */
  110420. /**
  110421. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110422. * This specifies what angle the shadow will use to be created.
  110423. *
  110424. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  110425. */
  110426. shadowAngle: number;
  110427. /**
  110428. * Gets the direction if it has been set.
  110429. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110430. */
  110431. /**
  110432. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  110433. */
  110434. direction: Vector3;
  110435. /**
  110436. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  110437. * A PointLight emits the light in every direction.
  110438. * It can cast shadows.
  110439. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  110440. * ```javascript
  110441. * var pointLight = new PointLight("pl", camera.position, scene);
  110442. * ```
  110443. * Documentation : https://doc.babylonjs.com/babylon101/lights
  110444. * @param name The light friendly name
  110445. * @param position The position of the point light in the scene
  110446. * @param scene The scene the lights belongs to
  110447. */
  110448. constructor(name: string, position: Vector3, scene: Scene);
  110449. /**
  110450. * Returns the string "PointLight"
  110451. * @returns the class name
  110452. */
  110453. getClassName(): string;
  110454. /**
  110455. * Returns the integer 0.
  110456. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  110457. */
  110458. getTypeID(): number;
  110459. /**
  110460. * Specifies wether or not the shadowmap should be a cube texture.
  110461. * @returns true if the shadowmap needs to be a cube texture.
  110462. */
  110463. needCube(): boolean;
  110464. /**
  110465. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  110466. * @param faceIndex The index of the face we are computed the direction to generate shadow
  110467. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  110468. */
  110469. getShadowDirection(faceIndex?: number): Vector3;
  110470. /**
  110471. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  110472. * - fov = PI / 2
  110473. * - aspect ratio : 1.0
  110474. * - z-near and far equal to the active camera minZ and maxZ.
  110475. * Returns the PointLight.
  110476. */
  110477. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  110478. protected _buildUniformLayout(): void;
  110479. /**
  110480. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  110481. * @param effect The effect to update
  110482. * @param lightIndex The index of the light in the effect to update
  110483. * @returns The point light
  110484. */
  110485. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  110486. /**
  110487. * Prepares the list of defines specific to the light type.
  110488. * @param defines the list of defines
  110489. * @param lightIndex defines the index of the light for the effect
  110490. */
  110491. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  110492. }
  110493. }
  110494. declare module BABYLON {
  110495. /**
  110496. * Header information of HDR texture files.
  110497. */
  110498. export interface HDRInfo {
  110499. /**
  110500. * The height of the texture in pixels.
  110501. */
  110502. height: number;
  110503. /**
  110504. * The width of the texture in pixels.
  110505. */
  110506. width: number;
  110507. /**
  110508. * The index of the beginning of the data in the binary file.
  110509. */
  110510. dataPosition: number;
  110511. }
  110512. /**
  110513. * This groups tools to convert HDR texture to native colors array.
  110514. */
  110515. export class HDRTools {
  110516. private static Ldexp;
  110517. private static Rgbe2float;
  110518. private static readStringLine;
  110519. /**
  110520. * Reads header information from an RGBE texture stored in a native array.
  110521. * More information on this format are available here:
  110522. * https://en.wikipedia.org/wiki/RGBE_image_format
  110523. *
  110524. * @param uint8array The binary file stored in native array.
  110525. * @return The header information.
  110526. */
  110527. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  110528. /**
  110529. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  110530. * This RGBE texture needs to store the information as a panorama.
  110531. *
  110532. * More information on this format are available here:
  110533. * https://en.wikipedia.org/wiki/RGBE_image_format
  110534. *
  110535. * @param buffer The binary file stored in an array buffer.
  110536. * @param size The expected size of the extracted cubemap.
  110537. * @return The Cube Map information.
  110538. */
  110539. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  110540. /**
  110541. * Returns the pixels data extracted from an RGBE texture.
  110542. * This pixels will be stored left to right up to down in the R G B order in one array.
  110543. *
  110544. * More information on this format are available here:
  110545. * https://en.wikipedia.org/wiki/RGBE_image_format
  110546. *
  110547. * @param uint8array The binary file stored in an array buffer.
  110548. * @param hdrInfo The header information of the file.
  110549. * @return The pixels data in RGB right to left up to down order.
  110550. */
  110551. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  110552. private static RGBE_ReadPixels_RLE;
  110553. }
  110554. }
  110555. declare module BABYLON {
  110556. /**
  110557. * This represents a texture coming from an HDR input.
  110558. *
  110559. * The only supported format is currently panorama picture stored in RGBE format.
  110560. * Example of such files can be found on HDRLib: http://hdrlib.com/
  110561. */
  110562. export class HDRCubeTexture extends BaseTexture {
  110563. private static _facesMapping;
  110564. private _generateHarmonics;
  110565. private _noMipmap;
  110566. private _textureMatrix;
  110567. private _size;
  110568. private _onLoad;
  110569. private _onError;
  110570. /**
  110571. * The texture URL.
  110572. */
  110573. url: string;
  110574. /**
  110575. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  110576. */
  110577. coordinatesMode: number;
  110578. protected _isBlocking: boolean;
  110579. /**
  110580. * Sets wether or not the texture is blocking during loading.
  110581. */
  110582. /**
  110583. * Gets wether or not the texture is blocking during loading.
  110584. */
  110585. isBlocking: boolean;
  110586. protected _rotationY: number;
  110587. /**
  110588. * Sets texture matrix rotation angle around Y axis in radians.
  110589. */
  110590. /**
  110591. * Gets texture matrix rotation angle around Y axis radians.
  110592. */
  110593. rotationY: number;
  110594. /**
  110595. * Gets or sets the center of the bounding box associated with the cube texture
  110596. * It must define where the camera used to render the texture was set
  110597. */
  110598. boundingBoxPosition: Vector3;
  110599. private _boundingBoxSize;
  110600. /**
  110601. * Gets or sets the size of the bounding box associated with the cube texture
  110602. * When defined, the cubemap will switch to local mode
  110603. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  110604. * @example https://www.babylonjs-playground.com/#RNASML
  110605. */
  110606. boundingBoxSize: Vector3;
  110607. /**
  110608. * Instantiates an HDRTexture from the following parameters.
  110609. *
  110610. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  110611. * @param scene The scene the texture will be used in
  110612. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  110613. * @param noMipmap Forces to not generate the mipmap if true
  110614. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  110615. * @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)
  110616. * @param reserved Reserved flag for internal use.
  110617. */
  110618. 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>);
  110619. /**
  110620. * Get the current class name of the texture useful for serialization or dynamic coding.
  110621. * @returns "HDRCubeTexture"
  110622. */
  110623. getClassName(): string;
  110624. /**
  110625. * Occurs when the file is raw .hdr file.
  110626. */
  110627. private loadTexture;
  110628. clone(): HDRCubeTexture;
  110629. delayLoad(): void;
  110630. /**
  110631. * Get the texture reflection matrix used to rotate/transform the reflection.
  110632. * @returns the reflection matrix
  110633. */
  110634. getReflectionTextureMatrix(): Matrix;
  110635. /**
  110636. * Set the texture reflection matrix used to rotate/transform the reflection.
  110637. * @param value Define the reflection matrix to set
  110638. */
  110639. setReflectionTextureMatrix(value: Matrix): void;
  110640. /**
  110641. * Parses a JSON representation of an HDR Texture in order to create the texture
  110642. * @param parsedTexture Define the JSON representation
  110643. * @param scene Define the scene the texture should be created in
  110644. * @param rootUrl Define the root url in case we need to load relative dependencies
  110645. * @returns the newly created texture after parsing
  110646. */
  110647. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  110648. serialize(): any;
  110649. }
  110650. }
  110651. declare module BABYLON {
  110652. /**
  110653. * Class used to control physics engine
  110654. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  110655. */
  110656. export class PhysicsEngine implements IPhysicsEngine {
  110657. private _physicsPlugin;
  110658. /**
  110659. * Global value used to control the smallest number supported by the simulation
  110660. */
  110661. static Epsilon: number;
  110662. private _impostors;
  110663. private _joints;
  110664. /**
  110665. * Gets the gravity vector used by the simulation
  110666. */
  110667. gravity: Vector3;
  110668. /**
  110669. * Factory used to create the default physics plugin.
  110670. * @returns The default physics plugin
  110671. */
  110672. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  110673. /**
  110674. * Creates a new Physics Engine
  110675. * @param gravity defines the gravity vector used by the simulation
  110676. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  110677. */
  110678. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  110679. /**
  110680. * Sets the gravity vector used by the simulation
  110681. * @param gravity defines the gravity vector to use
  110682. */
  110683. setGravity(gravity: Vector3): void;
  110684. /**
  110685. * Set the time step of the physics engine.
  110686. * Default is 1/60.
  110687. * To slow it down, enter 1/600 for example.
  110688. * To speed it up, 1/30
  110689. * @param newTimeStep defines the new timestep to apply to this world.
  110690. */
  110691. setTimeStep(newTimeStep?: number): void;
  110692. /**
  110693. * Get the time step of the physics engine.
  110694. * @returns the current time step
  110695. */
  110696. getTimeStep(): number;
  110697. /**
  110698. * Release all resources
  110699. */
  110700. dispose(): void;
  110701. /**
  110702. * Gets the name of the current physics plugin
  110703. * @returns the name of the plugin
  110704. */
  110705. getPhysicsPluginName(): string;
  110706. /**
  110707. * Adding a new impostor for the impostor tracking.
  110708. * This will be done by the impostor itself.
  110709. * @param impostor the impostor to add
  110710. */
  110711. addImpostor(impostor: PhysicsImpostor): void;
  110712. /**
  110713. * Remove an impostor from the engine.
  110714. * This impostor and its mesh will not longer be updated by the physics engine.
  110715. * @param impostor the impostor to remove
  110716. */
  110717. removeImpostor(impostor: PhysicsImpostor): void;
  110718. /**
  110719. * Add a joint to the physics engine
  110720. * @param mainImpostor defines the main impostor to which the joint is added.
  110721. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  110722. * @param joint defines the joint that will connect both impostors.
  110723. */
  110724. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  110725. /**
  110726. * Removes a joint from the simulation
  110727. * @param mainImpostor defines the impostor used with the joint
  110728. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  110729. * @param joint defines the joint to remove
  110730. */
  110731. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  110732. /**
  110733. * Called by the scene. No need to call it.
  110734. * @param delta defines the timespam between frames
  110735. */
  110736. _step(delta: number): void;
  110737. /**
  110738. * Gets the current plugin used to run the simulation
  110739. * @returns current plugin
  110740. */
  110741. getPhysicsPlugin(): IPhysicsEnginePlugin;
  110742. /**
  110743. * Gets the list of physic impostors
  110744. * @returns an array of PhysicsImpostor
  110745. */
  110746. getImpostors(): Array<PhysicsImpostor>;
  110747. /**
  110748. * Gets the impostor for a physics enabled object
  110749. * @param object defines the object impersonated by the impostor
  110750. * @returns the PhysicsImpostor or null if not found
  110751. */
  110752. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  110753. /**
  110754. * Gets the impostor for a physics body object
  110755. * @param body defines physics body used by the impostor
  110756. * @returns the PhysicsImpostor or null if not found
  110757. */
  110758. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  110759. /**
  110760. * Does a raycast in the physics world
  110761. * @param from when should the ray start?
  110762. * @param to when should the ray end?
  110763. * @returns PhysicsRaycastResult
  110764. */
  110765. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  110766. }
  110767. }
  110768. declare module BABYLON {
  110769. /** @hidden */
  110770. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  110771. private _useDeltaForWorldStep;
  110772. world: any;
  110773. name: string;
  110774. private _physicsMaterials;
  110775. private _fixedTimeStep;
  110776. private _cannonRaycastResult;
  110777. private _raycastResult;
  110778. private _removeAfterStep;
  110779. BJSCANNON: any;
  110780. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  110781. setGravity(gravity: Vector3): void;
  110782. setTimeStep(timeStep: number): void;
  110783. getTimeStep(): number;
  110784. executeStep(delta: number): void;
  110785. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110786. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110787. generatePhysicsBody(impostor: PhysicsImpostor): void;
  110788. private _processChildMeshes;
  110789. removePhysicsBody(impostor: PhysicsImpostor): void;
  110790. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  110791. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  110792. private _addMaterial;
  110793. private _checkWithEpsilon;
  110794. private _createShape;
  110795. private _createHeightmap;
  110796. private _minus90X;
  110797. private _plus90X;
  110798. private _tmpPosition;
  110799. private _tmpDeltaPosition;
  110800. private _tmpUnityRotation;
  110801. private _updatePhysicsBodyTransformation;
  110802. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  110803. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  110804. isSupported(): boolean;
  110805. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110806. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110807. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110808. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110809. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  110810. getBodyMass(impostor: PhysicsImpostor): number;
  110811. getBodyFriction(impostor: PhysicsImpostor): number;
  110812. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  110813. getBodyRestitution(impostor: PhysicsImpostor): number;
  110814. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  110815. sleepBody(impostor: PhysicsImpostor): void;
  110816. wakeUpBody(impostor: PhysicsImpostor): void;
  110817. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  110818. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  110819. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  110820. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  110821. getRadius(impostor: PhysicsImpostor): number;
  110822. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  110823. dispose(): void;
  110824. private _extendNamespace;
  110825. /**
  110826. * Does a raycast in the physics world
  110827. * @param from when should the ray start?
  110828. * @param to when should the ray end?
  110829. * @returns PhysicsRaycastResult
  110830. */
  110831. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  110832. }
  110833. }
  110834. declare module BABYLON {
  110835. /** @hidden */
  110836. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  110837. world: any;
  110838. name: string;
  110839. BJSOIMO: any;
  110840. private _raycastResult;
  110841. constructor(iterations?: number, oimoInjection?: any);
  110842. setGravity(gravity: Vector3): void;
  110843. setTimeStep(timeStep: number): void;
  110844. getTimeStep(): number;
  110845. private _tmpImpostorsArray;
  110846. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  110847. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110848. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  110849. generatePhysicsBody(impostor: PhysicsImpostor): void;
  110850. private _tmpPositionVector;
  110851. removePhysicsBody(impostor: PhysicsImpostor): void;
  110852. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  110853. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  110854. isSupported(): boolean;
  110855. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  110856. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  110857. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110858. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  110859. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110860. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  110861. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  110862. getBodyMass(impostor: PhysicsImpostor): number;
  110863. getBodyFriction(impostor: PhysicsImpostor): number;
  110864. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  110865. getBodyRestitution(impostor: PhysicsImpostor): number;
  110866. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  110867. sleepBody(impostor: PhysicsImpostor): void;
  110868. wakeUpBody(impostor: PhysicsImpostor): void;
  110869. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  110870. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  110871. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  110872. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  110873. getRadius(impostor: PhysicsImpostor): number;
  110874. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  110875. dispose(): void;
  110876. /**
  110877. * Does a raycast in the physics world
  110878. * @param from when should the ray start?
  110879. * @param to when should the ray end?
  110880. * @returns PhysicsRaycastResult
  110881. */
  110882. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  110883. }
  110884. }
  110885. declare module BABYLON {
  110886. /**
  110887. * Class containing static functions to help procedurally build meshes
  110888. */
  110889. export class RibbonBuilder {
  110890. /**
  110891. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110892. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  110893. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  110894. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  110895. * * 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
  110896. * * 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
  110897. * * 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
  110898. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110899. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110900. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110901. * * 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
  110902. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  110903. * * 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
  110904. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  110905. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110906. * @param name defines the name of the mesh
  110907. * @param options defines the options used to create the mesh
  110908. * @param scene defines the hosting scene
  110909. * @returns the ribbon mesh
  110910. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  110911. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110912. */
  110913. static CreateRibbon(name: string, options: {
  110914. pathArray: Vector3[][];
  110915. closeArray?: boolean;
  110916. closePath?: boolean;
  110917. offset?: number;
  110918. updatable?: boolean;
  110919. sideOrientation?: number;
  110920. frontUVs?: Vector4;
  110921. backUVs?: Vector4;
  110922. instance?: Mesh;
  110923. invertUV?: boolean;
  110924. uvs?: Vector2[];
  110925. colors?: Color4[];
  110926. }, scene?: Nullable<Scene>): Mesh;
  110927. }
  110928. }
  110929. declare module BABYLON {
  110930. /**
  110931. * Class containing static functions to help procedurally build meshes
  110932. */
  110933. export class ShapeBuilder {
  110934. /**
  110935. * 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.
  110936. * * 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.
  110937. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110938. * * 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.
  110939. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  110940. * * 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
  110941. * * 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
  110942. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  110943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110945. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  110946. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110947. * @param name defines the name of the mesh
  110948. * @param options defines the options used to create the mesh
  110949. * @param scene defines the hosting scene
  110950. * @returns the extruded shape mesh
  110951. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110952. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110953. */
  110954. static ExtrudeShape(name: string, options: {
  110955. shape: Vector3[];
  110956. path: Vector3[];
  110957. scale?: number;
  110958. rotation?: number;
  110959. cap?: number;
  110960. updatable?: boolean;
  110961. sideOrientation?: number;
  110962. frontUVs?: Vector4;
  110963. backUVs?: Vector4;
  110964. instance?: Mesh;
  110965. invertUV?: boolean;
  110966. }, scene?: Nullable<Scene>): Mesh;
  110967. /**
  110968. * Creates an custom extruded shape mesh.
  110969. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  110970. * * 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.
  110971. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  110972. * * 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
  110973. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  110974. * * 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
  110975. * * It must returns a float value that will be the scale value applied to the shape on each path point
  110976. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  110977. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  110978. * * 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
  110979. * * 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
  110980. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  110981. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110982. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110983. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110984. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110985. * @param name defines the name of the mesh
  110986. * @param options defines the options used to create the mesh
  110987. * @param scene defines the hosting scene
  110988. * @returns the custom extruded shape mesh
  110989. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  110990. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110991. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  110992. */
  110993. static ExtrudeShapeCustom(name: string, options: {
  110994. shape: Vector3[];
  110995. path: Vector3[];
  110996. scaleFunction?: any;
  110997. rotationFunction?: any;
  110998. ribbonCloseArray?: boolean;
  110999. ribbonClosePath?: boolean;
  111000. cap?: number;
  111001. updatable?: boolean;
  111002. sideOrientation?: number;
  111003. frontUVs?: Vector4;
  111004. backUVs?: Vector4;
  111005. instance?: Mesh;
  111006. invertUV?: boolean;
  111007. }, scene?: Nullable<Scene>): Mesh;
  111008. private static _ExtrudeShapeGeneric;
  111009. }
  111010. }
  111011. declare module BABYLON {
  111012. /**
  111013. * AmmoJS Physics plugin
  111014. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111015. * @see https://github.com/kripken/ammo.js/
  111016. */
  111017. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  111018. private _useDeltaForWorldStep;
  111019. /**
  111020. * Reference to the Ammo library
  111021. */
  111022. bjsAMMO: any;
  111023. /**
  111024. * Created ammoJS world which physics bodies are added to
  111025. */
  111026. world: any;
  111027. /**
  111028. * Name of the plugin
  111029. */
  111030. name: string;
  111031. private _timeStep;
  111032. private _fixedTimeStep;
  111033. private _maxSteps;
  111034. private _tmpQuaternion;
  111035. private _tmpAmmoTransform;
  111036. private _tmpAmmoQuaternion;
  111037. private _tmpAmmoConcreteContactResultCallback;
  111038. private _collisionConfiguration;
  111039. private _dispatcher;
  111040. private _overlappingPairCache;
  111041. private _solver;
  111042. private _softBodySolver;
  111043. private _tmpAmmoVectorA;
  111044. private _tmpAmmoVectorB;
  111045. private _tmpAmmoVectorC;
  111046. private _tmpAmmoVectorD;
  111047. private _tmpContactCallbackResult;
  111048. private _tmpAmmoVectorRCA;
  111049. private _tmpAmmoVectorRCB;
  111050. private _raycastResult;
  111051. private static readonly DISABLE_COLLISION_FLAG;
  111052. private static readonly KINEMATIC_FLAG;
  111053. private static readonly DISABLE_DEACTIVATION_FLAG;
  111054. /**
  111055. * Initializes the ammoJS plugin
  111056. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  111057. * @param ammoInjection can be used to inject your own ammo reference
  111058. */
  111059. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  111060. /**
  111061. * Sets the gravity of the physics world (m/(s^2))
  111062. * @param gravity Gravity to set
  111063. */
  111064. setGravity(gravity: Vector3): void;
  111065. /**
  111066. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  111067. * @param timeStep timestep to use in seconds
  111068. */
  111069. setTimeStep(timeStep: number): void;
  111070. /**
  111071. * 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)
  111072. * @param fixedTimeStep fixedTimeStep to use in seconds
  111073. */
  111074. setFixedTimeStep(fixedTimeStep: number): void;
  111075. /**
  111076. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  111077. * @param maxSteps the maximum number of steps by the physics engine per frame
  111078. */
  111079. setMaxSteps(maxSteps: number): void;
  111080. /**
  111081. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  111082. * @returns the current timestep in seconds
  111083. */
  111084. getTimeStep(): number;
  111085. private _isImpostorInContact;
  111086. private _isImpostorPairInContact;
  111087. private _stepSimulation;
  111088. /**
  111089. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  111090. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  111091. * After the step the babylon meshes are set to the position of the physics imposters
  111092. * @param delta amount of time to step forward
  111093. * @param impostors array of imposters to update before/after the step
  111094. */
  111095. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  111096. /**
  111097. * Update babylon mesh to match physics world object
  111098. * @param impostor imposter to match
  111099. */
  111100. private _afterSoftStep;
  111101. /**
  111102. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111103. * @param impostor imposter to match
  111104. */
  111105. private _ropeStep;
  111106. /**
  111107. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  111108. * @param impostor imposter to match
  111109. */
  111110. private _softbodyOrClothStep;
  111111. private _tmpVector;
  111112. private _tmpMatrix;
  111113. /**
  111114. * Applies an impulse on the imposter
  111115. * @param impostor imposter to apply impulse to
  111116. * @param force amount of force to be applied to the imposter
  111117. * @param contactPoint the location to apply the impulse on the imposter
  111118. */
  111119. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111120. /**
  111121. * Applies a force on the imposter
  111122. * @param impostor imposter to apply force
  111123. * @param force amount of force to be applied to the imposter
  111124. * @param contactPoint the location to apply the force on the imposter
  111125. */
  111126. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  111127. /**
  111128. * Creates a physics body using the plugin
  111129. * @param impostor the imposter to create the physics body on
  111130. */
  111131. generatePhysicsBody(impostor: PhysicsImpostor): void;
  111132. /**
  111133. * Removes the physics body from the imposter and disposes of the body's memory
  111134. * @param impostor imposter to remove the physics body from
  111135. */
  111136. removePhysicsBody(impostor: PhysicsImpostor): void;
  111137. /**
  111138. * Generates a joint
  111139. * @param impostorJoint the imposter joint to create the joint with
  111140. */
  111141. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  111142. /**
  111143. * Removes a joint
  111144. * @param impostorJoint the imposter joint to remove the joint from
  111145. */
  111146. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  111147. private _addMeshVerts;
  111148. /**
  111149. * Initialise the soft body vertices to match its object's (mesh) vertices
  111150. * Softbody vertices (nodes) are in world space and to match this
  111151. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  111152. * @param impostor to create the softbody for
  111153. */
  111154. private _softVertexData;
  111155. /**
  111156. * Create an impostor's soft body
  111157. * @param impostor to create the softbody for
  111158. */
  111159. private _createSoftbody;
  111160. /**
  111161. * Create cloth for an impostor
  111162. * @param impostor to create the softbody for
  111163. */
  111164. private _createCloth;
  111165. /**
  111166. * Create rope for an impostor
  111167. * @param impostor to create the softbody for
  111168. */
  111169. private _createRope;
  111170. private _addHullVerts;
  111171. private _createShape;
  111172. /**
  111173. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  111174. * @param impostor imposter containing the physics body and babylon object
  111175. */
  111176. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  111177. /**
  111178. * Sets the babylon object's position/rotation from the physics body's position/rotation
  111179. * @param impostor imposter containing the physics body and babylon object
  111180. * @param newPosition new position
  111181. * @param newRotation new rotation
  111182. */
  111183. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  111184. /**
  111185. * If this plugin is supported
  111186. * @returns true if its supported
  111187. */
  111188. isSupported(): boolean;
  111189. /**
  111190. * Sets the linear velocity of the physics body
  111191. * @param impostor imposter to set the velocity on
  111192. * @param velocity velocity to set
  111193. */
  111194. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111195. /**
  111196. * Sets the angular velocity of the physics body
  111197. * @param impostor imposter to set the velocity on
  111198. * @param velocity velocity to set
  111199. */
  111200. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  111201. /**
  111202. * gets the linear velocity
  111203. * @param impostor imposter to get linear velocity from
  111204. * @returns linear velocity
  111205. */
  111206. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111207. /**
  111208. * gets the angular velocity
  111209. * @param impostor imposter to get angular velocity from
  111210. * @returns angular velocity
  111211. */
  111212. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  111213. /**
  111214. * Sets the mass of physics body
  111215. * @param impostor imposter to set the mass on
  111216. * @param mass mass to set
  111217. */
  111218. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  111219. /**
  111220. * Gets the mass of the physics body
  111221. * @param impostor imposter to get the mass from
  111222. * @returns mass
  111223. */
  111224. getBodyMass(impostor: PhysicsImpostor): number;
  111225. /**
  111226. * Gets friction of the impostor
  111227. * @param impostor impostor to get friction from
  111228. * @returns friction value
  111229. */
  111230. getBodyFriction(impostor: PhysicsImpostor): number;
  111231. /**
  111232. * Sets friction of the impostor
  111233. * @param impostor impostor to set friction on
  111234. * @param friction friction value
  111235. */
  111236. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  111237. /**
  111238. * Gets restitution of the impostor
  111239. * @param impostor impostor to get restitution from
  111240. * @returns restitution value
  111241. */
  111242. getBodyRestitution(impostor: PhysicsImpostor): number;
  111243. /**
  111244. * Sets resitution of the impostor
  111245. * @param impostor impostor to set resitution on
  111246. * @param restitution resitution value
  111247. */
  111248. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  111249. /**
  111250. * Gets pressure inside the impostor
  111251. * @param impostor impostor to get pressure from
  111252. * @returns pressure value
  111253. */
  111254. getBodyPressure(impostor: PhysicsImpostor): number;
  111255. /**
  111256. * Sets pressure inside a soft body impostor
  111257. * Cloth and rope must remain 0 pressure
  111258. * @param impostor impostor to set pressure on
  111259. * @param pressure pressure value
  111260. */
  111261. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  111262. /**
  111263. * Gets stiffness of the impostor
  111264. * @param impostor impostor to get stiffness from
  111265. * @returns pressure value
  111266. */
  111267. getBodyStiffness(impostor: PhysicsImpostor): number;
  111268. /**
  111269. * Sets stiffness of the impostor
  111270. * @param impostor impostor to set stiffness on
  111271. * @param stiffness stiffness value from 0 to 1
  111272. */
  111273. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  111274. /**
  111275. * Gets velocityIterations of the impostor
  111276. * @param impostor impostor to get velocity iterations from
  111277. * @returns velocityIterations value
  111278. */
  111279. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  111280. /**
  111281. * Sets velocityIterations of the impostor
  111282. * @param impostor impostor to set velocity iterations on
  111283. * @param velocityIterations velocityIterations value
  111284. */
  111285. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  111286. /**
  111287. * Gets positionIterations of the impostor
  111288. * @param impostor impostor to get position iterations from
  111289. * @returns positionIterations value
  111290. */
  111291. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  111292. /**
  111293. * Sets positionIterations of the impostor
  111294. * @param impostor impostor to set position on
  111295. * @param positionIterations positionIterations value
  111296. */
  111297. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  111298. /**
  111299. * Append an anchor to a cloth object
  111300. * @param impostor is the cloth impostor to add anchor to
  111301. * @param otherImpostor is the rigid impostor to anchor to
  111302. * @param width ratio across width from 0 to 1
  111303. * @param height ratio up height from 0 to 1
  111304. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  111305. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111306. */
  111307. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111308. /**
  111309. * Append an hook to a rope object
  111310. * @param impostor is the rope impostor to add hook to
  111311. * @param otherImpostor is the rigid impostor to hook to
  111312. * @param length ratio along the rope from 0 to 1
  111313. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  111314. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  111315. */
  111316. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  111317. /**
  111318. * Sleeps the physics body and stops it from being active
  111319. * @param impostor impostor to sleep
  111320. */
  111321. sleepBody(impostor: PhysicsImpostor): void;
  111322. /**
  111323. * Activates the physics body
  111324. * @param impostor impostor to activate
  111325. */
  111326. wakeUpBody(impostor: PhysicsImpostor): void;
  111327. /**
  111328. * Updates the distance parameters of the joint
  111329. * @param joint joint to update
  111330. * @param maxDistance maximum distance of the joint
  111331. * @param minDistance minimum distance of the joint
  111332. */
  111333. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  111334. /**
  111335. * Sets a motor on the joint
  111336. * @param joint joint to set motor on
  111337. * @param speed speed of the motor
  111338. * @param maxForce maximum force of the motor
  111339. * @param motorIndex index of the motor
  111340. */
  111341. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  111342. /**
  111343. * Sets the motors limit
  111344. * @param joint joint to set limit on
  111345. * @param upperLimit upper limit
  111346. * @param lowerLimit lower limit
  111347. */
  111348. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  111349. /**
  111350. * Syncs the position and rotation of a mesh with the impostor
  111351. * @param mesh mesh to sync
  111352. * @param impostor impostor to update the mesh with
  111353. */
  111354. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  111355. /**
  111356. * Gets the radius of the impostor
  111357. * @param impostor impostor to get radius from
  111358. * @returns the radius
  111359. */
  111360. getRadius(impostor: PhysicsImpostor): number;
  111361. /**
  111362. * Gets the box size of the impostor
  111363. * @param impostor impostor to get box size from
  111364. * @param result the resulting box size
  111365. */
  111366. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  111367. /**
  111368. * Disposes of the impostor
  111369. */
  111370. dispose(): void;
  111371. /**
  111372. * Does a raycast in the physics world
  111373. * @param from when should the ray start?
  111374. * @param to when should the ray end?
  111375. * @returns PhysicsRaycastResult
  111376. */
  111377. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  111378. }
  111379. }
  111380. declare module BABYLON {
  111381. interface AbstractScene {
  111382. /**
  111383. * The list of reflection probes added to the scene
  111384. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111385. */
  111386. reflectionProbes: Array<ReflectionProbe>;
  111387. /**
  111388. * Removes the given reflection probe from this scene.
  111389. * @param toRemove The reflection probe to remove
  111390. * @returns The index of the removed reflection probe
  111391. */
  111392. removeReflectionProbe(toRemove: ReflectionProbe): number;
  111393. /**
  111394. * Adds the given reflection probe to this scene.
  111395. * @param newReflectionProbe The reflection probe to add
  111396. */
  111397. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  111398. }
  111399. /**
  111400. * Class used to generate realtime reflection / refraction cube textures
  111401. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  111402. */
  111403. export class ReflectionProbe {
  111404. /** defines the name of the probe */
  111405. name: string;
  111406. private _scene;
  111407. private _renderTargetTexture;
  111408. private _projectionMatrix;
  111409. private _viewMatrix;
  111410. private _target;
  111411. private _add;
  111412. private _attachedMesh;
  111413. private _invertYAxis;
  111414. /** Gets or sets probe position (center of the cube map) */
  111415. position: Vector3;
  111416. /**
  111417. * Creates a new reflection probe
  111418. * @param name defines the name of the probe
  111419. * @param size defines the texture resolution (for each face)
  111420. * @param scene defines the hosting scene
  111421. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  111422. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  111423. */
  111424. constructor(
  111425. /** defines the name of the probe */
  111426. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  111427. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  111428. samples: number;
  111429. /** Gets or sets the refresh rate to use (on every frame by default) */
  111430. refreshRate: number;
  111431. /**
  111432. * Gets the hosting scene
  111433. * @returns a Scene
  111434. */
  111435. getScene(): Scene;
  111436. /** Gets the internal CubeTexture used to render to */
  111437. readonly cubeTexture: RenderTargetTexture;
  111438. /** Gets the list of meshes to render */
  111439. readonly renderList: Nullable<AbstractMesh[]>;
  111440. /**
  111441. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  111442. * @param mesh defines the mesh to attach to
  111443. */
  111444. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  111445. /**
  111446. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  111447. * @param renderingGroupId The rendering group id corresponding to its index
  111448. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111449. */
  111450. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  111451. /**
  111452. * Clean all associated resources
  111453. */
  111454. dispose(): void;
  111455. /**
  111456. * Converts the reflection probe information to a readable string for debug purpose.
  111457. * @param fullDetails Supports for multiple levels of logging within scene loading
  111458. * @returns the human readable reflection probe info
  111459. */
  111460. toString(fullDetails?: boolean): string;
  111461. /**
  111462. * Get the class name of the relfection probe.
  111463. * @returns "ReflectionProbe"
  111464. */
  111465. getClassName(): string;
  111466. /**
  111467. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  111468. * @returns The JSON representation of the texture
  111469. */
  111470. serialize(): any;
  111471. /**
  111472. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  111473. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  111474. * @param scene Define the scene the parsed reflection probe should be instantiated in
  111475. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  111476. * @returns The parsed reflection probe if successful
  111477. */
  111478. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  111479. }
  111480. }
  111481. declare module BABYLON {
  111482. /** @hidden */
  111483. export var _BabylonLoaderRegistered: boolean;
  111484. }
  111485. declare module BABYLON {
  111486. /**
  111487. * The Physically based simple base material of BJS.
  111488. *
  111489. * This enables better naming and convention enforcements on top of the pbrMaterial.
  111490. * It is used as the base class for both the specGloss and metalRough conventions.
  111491. */
  111492. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  111493. /**
  111494. * Number of Simultaneous lights allowed on the material.
  111495. */
  111496. maxSimultaneousLights: number;
  111497. /**
  111498. * If sets to true, disables all the lights affecting the material.
  111499. */
  111500. disableLighting: boolean;
  111501. /**
  111502. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  111503. */
  111504. environmentTexture: BaseTexture;
  111505. /**
  111506. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111507. */
  111508. invertNormalMapX: boolean;
  111509. /**
  111510. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111511. */
  111512. invertNormalMapY: boolean;
  111513. /**
  111514. * Normal map used in the model.
  111515. */
  111516. normalTexture: BaseTexture;
  111517. /**
  111518. * Emissivie color used to self-illuminate the model.
  111519. */
  111520. emissiveColor: Color3;
  111521. /**
  111522. * Emissivie texture used to self-illuminate the model.
  111523. */
  111524. emissiveTexture: BaseTexture;
  111525. /**
  111526. * Occlusion Channel Strenght.
  111527. */
  111528. occlusionStrength: number;
  111529. /**
  111530. * Occlusion Texture of the material (adding extra occlusion effects).
  111531. */
  111532. occlusionTexture: BaseTexture;
  111533. /**
  111534. * Defines the alpha limits in alpha test mode.
  111535. */
  111536. alphaCutOff: number;
  111537. /**
  111538. * Gets the current double sided mode.
  111539. */
  111540. /**
  111541. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111542. */
  111543. doubleSided: boolean;
  111544. /**
  111545. * Stores the pre-calculated light information of a mesh in a texture.
  111546. */
  111547. lightmapTexture: BaseTexture;
  111548. /**
  111549. * If true, the light map contains occlusion information instead of lighting info.
  111550. */
  111551. useLightmapAsShadowmap: boolean;
  111552. /**
  111553. * Instantiates a new PBRMaterial instance.
  111554. *
  111555. * @param name The material name
  111556. * @param scene The scene the material will be use in.
  111557. */
  111558. constructor(name: string, scene: Scene);
  111559. getClassName(): string;
  111560. }
  111561. }
  111562. declare module BABYLON {
  111563. /**
  111564. * The PBR material of BJS following the metal roughness convention.
  111565. *
  111566. * This fits to the PBR convention in the GLTF definition:
  111567. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  111568. */
  111569. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  111570. /**
  111571. * The base color has two different interpretations depending on the value of metalness.
  111572. * When the material is a metal, the base color is the specific measured reflectance value
  111573. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  111574. * of the material.
  111575. */
  111576. baseColor: Color3;
  111577. /**
  111578. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  111579. * well as opacity information in the alpha channel.
  111580. */
  111581. baseTexture: BaseTexture;
  111582. /**
  111583. * Specifies the metallic scalar value of the material.
  111584. * Can also be used to scale the metalness values of the metallic texture.
  111585. */
  111586. metallic: number;
  111587. /**
  111588. * Specifies the roughness scalar value of the material.
  111589. * Can also be used to scale the roughness values of the metallic texture.
  111590. */
  111591. roughness: number;
  111592. /**
  111593. * Texture containing both the metallic value in the B channel and the
  111594. * roughness value in the G channel to keep better precision.
  111595. */
  111596. metallicRoughnessTexture: BaseTexture;
  111597. /**
  111598. * Instantiates a new PBRMetalRoughnessMaterial instance.
  111599. *
  111600. * @param name The material name
  111601. * @param scene The scene the material will be use in.
  111602. */
  111603. constructor(name: string, scene: Scene);
  111604. /**
  111605. * Return the currrent class name of the material.
  111606. */
  111607. getClassName(): string;
  111608. /**
  111609. * Makes a duplicate of the current material.
  111610. * @param name - name to use for the new material.
  111611. */
  111612. clone(name: string): PBRMetallicRoughnessMaterial;
  111613. /**
  111614. * Serialize the material to a parsable JSON object.
  111615. */
  111616. serialize(): any;
  111617. /**
  111618. * Parses a JSON object correponding to the serialize function.
  111619. */
  111620. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  111621. }
  111622. }
  111623. declare module BABYLON {
  111624. /**
  111625. * The PBR material of BJS following the specular glossiness convention.
  111626. *
  111627. * This fits to the PBR convention in the GLTF definition:
  111628. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  111629. */
  111630. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  111631. /**
  111632. * Specifies the diffuse color of the material.
  111633. */
  111634. diffuseColor: Color3;
  111635. /**
  111636. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  111637. * channel.
  111638. */
  111639. diffuseTexture: BaseTexture;
  111640. /**
  111641. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  111642. */
  111643. specularColor: Color3;
  111644. /**
  111645. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  111646. */
  111647. glossiness: number;
  111648. /**
  111649. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  111650. */
  111651. specularGlossinessTexture: BaseTexture;
  111652. /**
  111653. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  111654. *
  111655. * @param name The material name
  111656. * @param scene The scene the material will be use in.
  111657. */
  111658. constructor(name: string, scene: Scene);
  111659. /**
  111660. * Return the currrent class name of the material.
  111661. */
  111662. getClassName(): string;
  111663. /**
  111664. * Makes a duplicate of the current material.
  111665. * @param name - name to use for the new material.
  111666. */
  111667. clone(name: string): PBRSpecularGlossinessMaterial;
  111668. /**
  111669. * Serialize the material to a parsable JSON object.
  111670. */
  111671. serialize(): any;
  111672. /**
  111673. * Parses a JSON object correponding to the serialize function.
  111674. */
  111675. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  111676. }
  111677. }
  111678. declare module BABYLON {
  111679. /**
  111680. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  111681. * It can help converting any input color in a desired output one. This can then be used to create effects
  111682. * from sepia, black and white to sixties or futuristic rendering...
  111683. *
  111684. * The only supported format is currently 3dl.
  111685. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  111686. */
  111687. export class ColorGradingTexture extends BaseTexture {
  111688. /**
  111689. * The current texture matrix. (will always be identity in color grading texture)
  111690. */
  111691. private _textureMatrix;
  111692. /**
  111693. * The texture URL.
  111694. */
  111695. url: string;
  111696. /**
  111697. * Empty line regex stored for GC.
  111698. */
  111699. private static _noneEmptyLineRegex;
  111700. private _engine;
  111701. /**
  111702. * Instantiates a ColorGradingTexture from the following parameters.
  111703. *
  111704. * @param url The location of the color gradind data (currently only supporting 3dl)
  111705. * @param scene The scene the texture will be used in
  111706. */
  111707. constructor(url: string, scene: Scene);
  111708. /**
  111709. * Returns the texture matrix used in most of the material.
  111710. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  111711. */
  111712. getTextureMatrix(): Matrix;
  111713. /**
  111714. * Occurs when the file being loaded is a .3dl LUT file.
  111715. */
  111716. private load3dlTexture;
  111717. /**
  111718. * Starts the loading process of the texture.
  111719. */
  111720. private loadTexture;
  111721. /**
  111722. * Clones the color gradind texture.
  111723. */
  111724. clone(): ColorGradingTexture;
  111725. /**
  111726. * Called during delayed load for textures.
  111727. */
  111728. delayLoad(): void;
  111729. /**
  111730. * Parses a color grading texture serialized by Babylon.
  111731. * @param parsedTexture The texture information being parsedTexture
  111732. * @param scene The scene to load the texture in
  111733. * @param rootUrl The root url of the data assets to load
  111734. * @return A color gradind texture
  111735. */
  111736. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  111737. /**
  111738. * Serializes the LUT texture to json format.
  111739. */
  111740. serialize(): any;
  111741. }
  111742. }
  111743. declare module BABYLON {
  111744. /**
  111745. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  111746. */
  111747. export class EquiRectangularCubeTexture extends BaseTexture {
  111748. /** The six faces of the cube. */
  111749. private static _FacesMapping;
  111750. private _noMipmap;
  111751. private _onLoad;
  111752. private _onError;
  111753. /** The size of the cubemap. */
  111754. private _size;
  111755. /** The buffer of the image. */
  111756. private _buffer;
  111757. /** The width of the input image. */
  111758. private _width;
  111759. /** The height of the input image. */
  111760. private _height;
  111761. /** The URL to the image. */
  111762. url: string;
  111763. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  111764. coordinatesMode: number;
  111765. /**
  111766. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  111767. * @param url The location of the image
  111768. * @param scene The scene the texture will be used in
  111769. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  111770. * @param noMipmap Forces to not generate the mipmap if true
  111771. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  111772. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  111773. * @param onLoad — defines a callback called when texture is loaded
  111774. * @param onError — defines a callback called if there is an error
  111775. */
  111776. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  111777. /**
  111778. * Load the image data, by putting the image on a canvas and extracting its buffer.
  111779. */
  111780. private loadImage;
  111781. /**
  111782. * Convert the image buffer into a cubemap and create a CubeTexture.
  111783. */
  111784. private loadTexture;
  111785. /**
  111786. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  111787. * @param buffer The ArrayBuffer that should be converted.
  111788. * @returns The buffer as Float32Array.
  111789. */
  111790. private getFloat32ArrayFromArrayBuffer;
  111791. /**
  111792. * Get the current class name of the texture useful for serialization or dynamic coding.
  111793. * @returns "EquiRectangularCubeTexture"
  111794. */
  111795. getClassName(): string;
  111796. /**
  111797. * Create a clone of the current EquiRectangularCubeTexture and return it.
  111798. * @returns A clone of the current EquiRectangularCubeTexture.
  111799. */
  111800. clone(): EquiRectangularCubeTexture;
  111801. }
  111802. }
  111803. declare module BABYLON {
  111804. /**
  111805. * Based on jsTGALoader - Javascript loader for TGA file
  111806. * By Vincent Thibault
  111807. * @see http://blog.robrowser.com/javascript-tga-loader.html
  111808. */
  111809. export class TGATools {
  111810. private static _TYPE_INDEXED;
  111811. private static _TYPE_RGB;
  111812. private static _TYPE_GREY;
  111813. private static _TYPE_RLE_INDEXED;
  111814. private static _TYPE_RLE_RGB;
  111815. private static _TYPE_RLE_GREY;
  111816. private static _ORIGIN_MASK;
  111817. private static _ORIGIN_SHIFT;
  111818. private static _ORIGIN_BL;
  111819. private static _ORIGIN_BR;
  111820. private static _ORIGIN_UL;
  111821. private static _ORIGIN_UR;
  111822. /**
  111823. * Gets the header of a TGA file
  111824. * @param data defines the TGA data
  111825. * @returns the header
  111826. */
  111827. static GetTGAHeader(data: Uint8Array): any;
  111828. /**
  111829. * Uploads TGA content to a Babylon Texture
  111830. * @hidden
  111831. */
  111832. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  111833. /** @hidden */
  111834. 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;
  111835. /** @hidden */
  111836. 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;
  111837. /** @hidden */
  111838. 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;
  111839. /** @hidden */
  111840. 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;
  111841. /** @hidden */
  111842. 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;
  111843. /** @hidden */
  111844. 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;
  111845. }
  111846. }
  111847. declare module BABYLON {
  111848. /**
  111849. * Implementation of the TGA Texture Loader.
  111850. * @hidden
  111851. */
  111852. export class _TGATextureLoader implements IInternalTextureLoader {
  111853. /**
  111854. * Defines wether the loader supports cascade loading the different faces.
  111855. */
  111856. readonly supportCascades: boolean;
  111857. /**
  111858. * This returns if the loader support the current file information.
  111859. * @param extension defines the file extension of the file being loaded
  111860. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111861. * @param fallback defines the fallback internal texture if any
  111862. * @param isBase64 defines whether the texture is encoded as a base64
  111863. * @param isBuffer defines whether the texture data are stored as a buffer
  111864. * @returns true if the loader can load the specified file
  111865. */
  111866. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  111867. /**
  111868. * Transform the url before loading if required.
  111869. * @param rootUrl the url of the texture
  111870. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111871. * @returns the transformed texture
  111872. */
  111873. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  111874. /**
  111875. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  111876. * @param rootUrl the url of the texture
  111877. * @param textureFormatInUse defines the current compressed format in use iun the engine
  111878. * @returns the fallback texture
  111879. */
  111880. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  111881. /**
  111882. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  111883. * @param data contains the texture data
  111884. * @param texture defines the BabylonJS internal texture
  111885. * @param createPolynomials will be true if polynomials have been requested
  111886. * @param onLoad defines the callback to trigger once the texture is ready
  111887. * @param onError defines the callback to trigger in case of error
  111888. */
  111889. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  111890. /**
  111891. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  111892. * @param data contains the texture data
  111893. * @param texture defines the BabylonJS internal texture
  111894. * @param callback defines the method to call once ready to upload
  111895. */
  111896. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  111897. }
  111898. }
  111899. declare module BABYLON {
  111900. /**
  111901. * 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.
  111902. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  111903. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  111904. */
  111905. export class CustomProceduralTexture extends ProceduralTexture {
  111906. private _animate;
  111907. private _time;
  111908. private _config;
  111909. private _texturePath;
  111910. /**
  111911. * Instantiates a new Custom Procedural Texture.
  111912. * 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.
  111913. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  111914. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  111915. * @param name Define the name of the texture
  111916. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  111917. * @param size Define the size of the texture to create
  111918. * @param scene Define the scene the texture belongs to
  111919. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  111920. * @param generateMipMaps Define if the texture should creates mip maps or not
  111921. */
  111922. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  111923. private _loadJson;
  111924. /**
  111925. * Is the texture ready to be used ? (rendered at least once)
  111926. * @returns true if ready, otherwise, false.
  111927. */
  111928. isReady(): boolean;
  111929. /**
  111930. * Render the texture to its associated render target.
  111931. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  111932. */
  111933. render(useCameraPostProcess?: boolean): void;
  111934. /**
  111935. * Update the list of dependant textures samplers in the shader.
  111936. */
  111937. updateTextures(): void;
  111938. /**
  111939. * Update the uniform values of the procedural texture in the shader.
  111940. */
  111941. updateShaderUniforms(): void;
  111942. /**
  111943. * Define if the texture animates or not.
  111944. */
  111945. animate: boolean;
  111946. }
  111947. }
  111948. declare module BABYLON {
  111949. /** @hidden */
  111950. export var noisePixelShader: {
  111951. name: string;
  111952. shader: string;
  111953. };
  111954. }
  111955. declare module BABYLON {
  111956. /**
  111957. * Class used to generate noise procedural textures
  111958. */
  111959. export class NoiseProceduralTexture extends ProceduralTexture {
  111960. private _time;
  111961. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  111962. brightness: number;
  111963. /** Defines the number of octaves to process */
  111964. octaves: number;
  111965. /** Defines the level of persistence (0.8 by default) */
  111966. persistence: number;
  111967. /** Gets or sets animation speed factor (default is 1) */
  111968. animationSpeedFactor: number;
  111969. /**
  111970. * Creates a new NoiseProceduralTexture
  111971. * @param name defines the name fo the texture
  111972. * @param size defines the size of the texture (default is 256)
  111973. * @param scene defines the hosting scene
  111974. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  111975. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  111976. */
  111977. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  111978. private _updateShaderUniforms;
  111979. protected _getDefines(): string;
  111980. /** Generate the current state of the procedural texture */
  111981. render(useCameraPostProcess?: boolean): void;
  111982. /**
  111983. * Serializes this noise procedural texture
  111984. * @returns a serialized noise procedural texture object
  111985. */
  111986. serialize(): any;
  111987. /**
  111988. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  111989. * @param parsedTexture defines parsed texture data
  111990. * @param scene defines the current scene
  111991. * @param rootUrl defines the root URL containing noise procedural texture information
  111992. * @returns a parsed NoiseProceduralTexture
  111993. */
  111994. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  111995. }
  111996. }
  111997. declare module BABYLON {
  111998. /**
  111999. * Raw cube texture where the raw buffers are passed in
  112000. */
  112001. export class RawCubeTexture extends CubeTexture {
  112002. /**
  112003. * Creates a cube texture where the raw buffers are passed in.
  112004. * @param scene defines the scene the texture is attached to
  112005. * @param data defines the array of data to use to create each face
  112006. * @param size defines the size of the textures
  112007. * @param format defines the format of the data
  112008. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  112009. * @param generateMipMaps defines if the engine should generate the mip levels
  112010. * @param invertY defines if data must be stored with Y axis inverted
  112011. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  112012. * @param compression defines the compression used (null by default)
  112013. */
  112014. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  112015. /**
  112016. * Updates the raw cube texture.
  112017. * @param data defines the data to store
  112018. * @param format defines the data format
  112019. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  112020. * @param invertY defines if data must be stored with Y axis inverted
  112021. * @param compression defines the compression used (null by default)
  112022. * @param level defines which level of the texture to update
  112023. */
  112024. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  112025. /**
  112026. * Updates a raw cube texture with RGBD encoded data.
  112027. * @param data defines the array of data [mipmap][face] to use to create each face
  112028. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  112029. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  112030. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  112031. * @returns a promsie that resolves when the operation is complete
  112032. */
  112033. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  112034. /**
  112035. * Clones the raw cube texture.
  112036. * @return a new cube texture
  112037. */
  112038. clone(): CubeTexture;
  112039. /** @hidden */
  112040. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  112041. }
  112042. }
  112043. declare module BABYLON {
  112044. /**
  112045. * Class used to store 3D textures containing user data
  112046. */
  112047. export class RawTexture3D extends Texture {
  112048. /** Gets or sets the texture format to use */
  112049. format: number;
  112050. private _engine;
  112051. /**
  112052. * Create a new RawTexture3D
  112053. * @param data defines the data of the texture
  112054. * @param width defines the width of the texture
  112055. * @param height defines the height of the texture
  112056. * @param depth defines the depth of the texture
  112057. * @param format defines the texture format to use
  112058. * @param scene defines the hosting scene
  112059. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  112060. * @param invertY defines if texture must be stored with Y axis inverted
  112061. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  112062. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  112063. */
  112064. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  112065. /** Gets or sets the texture format to use */
  112066. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  112067. /**
  112068. * Update the texture with new data
  112069. * @param data defines the data to store in the texture
  112070. */
  112071. update(data: ArrayBufferView): void;
  112072. }
  112073. }
  112074. declare module BABYLON {
  112075. /**
  112076. * Creates a refraction texture used by refraction channel of the standard material.
  112077. * It is like a mirror but to see through a material.
  112078. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112079. */
  112080. export class RefractionTexture extends RenderTargetTexture {
  112081. /**
  112082. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  112083. * 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.
  112084. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112085. */
  112086. refractionPlane: Plane;
  112087. /**
  112088. * Define how deep under the surface we should see.
  112089. */
  112090. depth: number;
  112091. /**
  112092. * Creates a refraction texture used by refraction channel of the standard material.
  112093. * It is like a mirror but to see through a material.
  112094. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  112095. * @param name Define the texture name
  112096. * @param size Define the size of the underlying texture
  112097. * @param scene Define the scene the refraction belongs to
  112098. * @param generateMipMaps Define if we need to generate mips level for the refraction
  112099. */
  112100. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  112101. /**
  112102. * Clone the refraction texture.
  112103. * @returns the cloned texture
  112104. */
  112105. clone(): RefractionTexture;
  112106. /**
  112107. * Serialize the texture to a JSON representation you could use in Parse later on
  112108. * @returns the serialized JSON representation
  112109. */
  112110. serialize(): any;
  112111. }
  112112. }
  112113. declare module BABYLON {
  112114. /**
  112115. * Defines the options related to the creation of an HtmlElementTexture
  112116. */
  112117. export interface IHtmlElementTextureOptions {
  112118. /**
  112119. * Defines wether mip maps should be created or not.
  112120. */
  112121. generateMipMaps?: boolean;
  112122. /**
  112123. * Defines the sampling mode of the texture.
  112124. */
  112125. samplingMode?: number;
  112126. /**
  112127. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  112128. */
  112129. engine: Nullable<Engine>;
  112130. /**
  112131. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  112132. */
  112133. scene: Nullable<Scene>;
  112134. }
  112135. /**
  112136. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  112137. * To be as efficient as possible depending on your constraints nothing aside the first upload
  112138. * is automatically managed.
  112139. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  112140. * in your application.
  112141. *
  112142. * As the update is not automatic, you need to call them manually.
  112143. */
  112144. export class HtmlElementTexture extends BaseTexture {
  112145. /**
  112146. * The texture URL.
  112147. */
  112148. element: HTMLVideoElement | HTMLCanvasElement;
  112149. private static readonly DefaultOptions;
  112150. private _textureMatrix;
  112151. private _engine;
  112152. private _isVideo;
  112153. private _generateMipMaps;
  112154. private _samplingMode;
  112155. /**
  112156. * Instantiates a HtmlElementTexture from the following parameters.
  112157. *
  112158. * @param name Defines the name of the texture
  112159. * @param element Defines the video or canvas the texture is filled with
  112160. * @param options Defines the other none mandatory texture creation options
  112161. */
  112162. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  112163. private _createInternalTexture;
  112164. /**
  112165. * Returns the texture matrix used in most of the material.
  112166. */
  112167. getTextureMatrix(): Matrix;
  112168. /**
  112169. * Updates the content of the texture.
  112170. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  112171. */
  112172. update(invertY?: Nullable<boolean>): void;
  112173. }
  112174. }
  112175. declare module BABYLON {
  112176. /**
  112177. * Enum used to define the target of a block
  112178. */
  112179. export enum NodeMaterialBlockTargets {
  112180. /** Vertex shader */
  112181. Vertex = 1,
  112182. /** Fragment shader */
  112183. Fragment = 2,
  112184. /** Vertex and Fragment */
  112185. VertexAndFragment = 3
  112186. }
  112187. }
  112188. declare module BABYLON {
  112189. /**
  112190. * Defines the kind of connection point for node based material
  112191. */
  112192. export enum NodeMaterialBlockConnectionPointTypes {
  112193. /** Float */
  112194. Float = 1,
  112195. /** Int */
  112196. Int = 2,
  112197. /** Vector2 */
  112198. Vector2 = 4,
  112199. /** Vector3 */
  112200. Vector3 = 8,
  112201. /** Vector4 */
  112202. Vector4 = 16,
  112203. /** Color3 */
  112204. Color3 = 32,
  112205. /** Color4 */
  112206. Color4 = 64,
  112207. /** Matrix */
  112208. Matrix = 128,
  112209. /** Texture */
  112210. Texture = 256,
  112211. /** Texture3D */
  112212. Texture3D = 512,
  112213. /** Vector3 or Color3 */
  112214. Vector3OrColor3 = 40,
  112215. /** Vector3 or Vector4 */
  112216. Vector3OrVector4 = 24,
  112217. /** Vector4 or Color4 */
  112218. Vector4OrColor4 = 80,
  112219. /** Color3 or Color4 */
  112220. Color3OrColor4 = 96,
  112221. /** Vector3 or Color3 */
  112222. Vector3OrColor3OrVector4OrColor4 = 120
  112223. }
  112224. }
  112225. declare module BABYLON {
  112226. /**
  112227. * Enum used to define well known values e.g. values automatically provided by the system
  112228. */
  112229. export enum NodeMaterialWellKnownValues {
  112230. /** World */
  112231. World = 1,
  112232. /** View */
  112233. View = 2,
  112234. /** Projection */
  112235. Projection = 3,
  112236. /** ViewProjection */
  112237. ViewProjection = 4,
  112238. /** WorldView */
  112239. WorldView = 5,
  112240. /** WorldViewProjection */
  112241. WorldViewProjection = 6,
  112242. /** Will be filled by the block itself */
  112243. Automatic = 7
  112244. }
  112245. }
  112246. declare module BABYLON {
  112247. /**
  112248. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  112249. */
  112250. export enum NodeMaterialBlockConnectionPointMode {
  112251. /** Value is an uniform */
  112252. Uniform = 0,
  112253. /** Value is a mesh attribute */
  112254. Attribute = 1,
  112255. /** Value is a varying between vertex and fragment shaders */
  112256. Varying = 2,
  112257. /** Mode is undefined */
  112258. Undefined = 3
  112259. }
  112260. }
  112261. declare module BABYLON {
  112262. /**
  112263. * Class used to store shared data between 2 NodeMaterialBuildState
  112264. */
  112265. export class NodeMaterialBuildStateSharedData {
  112266. /**
  112267. * Gets the list of emitted varyings
  112268. */
  112269. varyings: string[];
  112270. /**
  112271. * Gets the varying declaration string
  112272. */
  112273. varyingDeclaration: string;
  112274. /**
  112275. * Uniform connection points
  112276. */
  112277. uniformConnectionPoints: NodeMaterialConnectionPoint[];
  112278. /**
  112279. * Bindable blocks (Blocks that need to set data to the effect)
  112280. */
  112281. bindableBlocks: NodeMaterialBlock[];
  112282. /**
  112283. * List of blocks that can provide a compilation fallback
  112284. */
  112285. blocksWithFallbacks: NodeMaterialBlock[];
  112286. /**
  112287. * List of blocks that can provide a define update
  112288. */
  112289. blocksWithDefines: NodeMaterialBlock[];
  112290. /**
  112291. * List of blocks that can provide a repeatable content
  112292. */
  112293. repeatableContentBlocks: NodeMaterialBlock[];
  112294. /**
  112295. * List of blocks that can block the isReady function for the material
  112296. */
  112297. blockingBlocks: NodeMaterialBlock[];
  112298. /**
  112299. * Build Id used to avoid multiple recompilations
  112300. */
  112301. buildId: number;
  112302. /** List of emitted variables */
  112303. variableNames: {
  112304. [key: string]: number;
  112305. };
  112306. /** List of emitted defines */
  112307. defineNames: {
  112308. [key: string]: number;
  112309. };
  112310. /** Should emit comments? */
  112311. emitComments: boolean;
  112312. /** Emit build activity */
  112313. verbose: boolean;
  112314. /**
  112315. * Gets the compilation hints emitted at compilation time
  112316. */
  112317. hints: {
  112318. needWorldViewMatrix: boolean;
  112319. needWorldViewProjectionMatrix: boolean;
  112320. needAlphaBlending: boolean;
  112321. needAlphaTesting: boolean;
  112322. };
  112323. /**
  112324. * List of compilation checks
  112325. */
  112326. checks: {
  112327. emitVertex: boolean;
  112328. emitFragment: boolean;
  112329. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  112330. };
  112331. /** Creates a new shared data */
  112332. constructor();
  112333. /**
  112334. * Emits console errors and exceptions if there is a failing check
  112335. */
  112336. emitErrors(): void;
  112337. }
  112338. }
  112339. declare module BABYLON {
  112340. /**
  112341. * Class used to store node based material build state
  112342. */
  112343. export class NodeMaterialBuildState {
  112344. /**
  112345. * Gets the list of emitted attributes
  112346. */
  112347. attributes: string[];
  112348. /**
  112349. * Gets the list of emitted uniforms
  112350. */
  112351. uniforms: string[];
  112352. /**
  112353. * Gets the list of emitted samplers
  112354. */
  112355. samplers: string[];
  112356. /**
  112357. * Gets the list of emitted functions
  112358. */
  112359. functions: {
  112360. [key: string]: string;
  112361. };
  112362. /**
  112363. * Gets the target of the compilation state
  112364. */
  112365. target: NodeMaterialBlockTargets;
  112366. /**
  112367. * Shared data between multiple NodeMaterialBuildState instances
  112368. */
  112369. sharedData: NodeMaterialBuildStateSharedData;
  112370. /** @hidden */
  112371. _vertexState: NodeMaterialBuildState;
  112372. private _attributeDeclaration;
  112373. private _uniformDeclaration;
  112374. private _samplerDeclaration;
  112375. private _varyingTransfer;
  112376. private _repeatableContentAnchorIndex;
  112377. /** @hidden */
  112378. _builtCompilationString: string;
  112379. /**
  112380. * Gets the emitted compilation strings
  112381. */
  112382. compilationString: string;
  112383. /**
  112384. * Finalize the compilation strings
  112385. * @param state defines the current compilation state
  112386. */
  112387. finalize(state: NodeMaterialBuildState): void;
  112388. /** @hidden */
  112389. readonly _repeatableContentAnchor: string;
  112390. /** @hidden */
  112391. _getFreeVariableName(prefix: string): string;
  112392. /** @hidden */
  112393. _getFreeDefineName(prefix: string): string;
  112394. /** @hidden */
  112395. _excludeVariableName(name: string): void;
  112396. /** @hidden */
  112397. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  112398. /** @hidden */
  112399. _emitFunction(name: string, code: string, comments: string): void;
  112400. /** @hidden */
  112401. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  112402. replaceStrings?: {
  112403. search: RegExp;
  112404. replace: string;
  112405. }[];
  112406. }): string;
  112407. /** @hidden */
  112408. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  112409. repeatKey?: string;
  112410. removeAttributes?: boolean;
  112411. removeUniforms?: boolean;
  112412. removeVaryings?: boolean;
  112413. removeIfDef?: boolean;
  112414. replaceStrings?: {
  112415. search: RegExp;
  112416. replace: string;
  112417. }[];
  112418. }): void;
  112419. /** @hidden */
  112420. _emitVaryings(point: NodeMaterialConnectionPoint, define?: string, force?: boolean, fromFragment?: boolean, replacementName?: string): void;
  112421. private _emitDefine;
  112422. /** @hidden */
  112423. _emitUniformOrAttributes(point: NodeMaterialConnectionPoint, define?: string): void;
  112424. }
  112425. }
  112426. declare module BABYLON {
  112427. /**
  112428. * Root class for all node material optimizers
  112429. */
  112430. export class NodeMaterialOptimizer {
  112431. /**
  112432. * Function used to optimize a NodeMaterial graph
  112433. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  112434. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  112435. */
  112436. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  112437. }
  112438. }
  112439. declare module BABYLON {
  112440. /**
  112441. * Interface used to configure the node material editor
  112442. */
  112443. export interface INodeMaterialEditorOptions {
  112444. /** Define the URl to load node editor script */
  112445. editorURL?: string;
  112446. }
  112447. /** @hidden */
  112448. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  112449. /** BONES */
  112450. NUM_BONE_INFLUENCERS: number;
  112451. BonesPerMesh: number;
  112452. BONETEXTURE: boolean;
  112453. /** MORPH TARGETS */
  112454. MORPHTARGETS: boolean;
  112455. MORPHTARGETS_NORMAL: boolean;
  112456. MORPHTARGETS_TANGENT: boolean;
  112457. NUM_MORPH_INFLUENCERS: number;
  112458. /** IMAGE PROCESSING */
  112459. IMAGEPROCESSING: boolean;
  112460. VIGNETTE: boolean;
  112461. VIGNETTEBLENDMODEMULTIPLY: boolean;
  112462. VIGNETTEBLENDMODEOPAQUE: boolean;
  112463. TONEMAPPING: boolean;
  112464. TONEMAPPING_ACES: boolean;
  112465. CONTRAST: boolean;
  112466. EXPOSURE: boolean;
  112467. COLORCURVES: boolean;
  112468. COLORGRADING: boolean;
  112469. COLORGRADING3D: boolean;
  112470. SAMPLER3DGREENDEPTH: boolean;
  112471. SAMPLER3DBGRMAP: boolean;
  112472. IMAGEPROCESSINGPOSTPROCESS: boolean;
  112473. constructor();
  112474. setValue(name: string, value: boolean): void;
  112475. }
  112476. /**
  112477. * Class used to configure NodeMaterial
  112478. */
  112479. export interface INodeMaterialOptions {
  112480. /**
  112481. * Defines if blocks should emit comments
  112482. */
  112483. emitComments: boolean;
  112484. }
  112485. /**
  112486. * Class used to create a node based material built by assembling shader blocks
  112487. */
  112488. export class NodeMaterial extends PushMaterial {
  112489. private _options;
  112490. private _vertexCompilationState;
  112491. private _fragmentCompilationState;
  112492. private _sharedData;
  112493. private _buildId;
  112494. private _buildWasSuccessful;
  112495. private _cachedWorldViewMatrix;
  112496. private _cachedWorldViewProjectionMatrix;
  112497. private _textureConnectionPoints;
  112498. private _optimizers;
  112499. /** Define the URl to load node editor script */
  112500. static EditorURL: string;
  112501. private BJSNODEMATERIALEDITOR;
  112502. /** Get the inspector from bundle or global */
  112503. private _getGlobalNodeMaterialEditor;
  112504. /**
  112505. * Defines the maximum number of lights that can be used in the material
  112506. */
  112507. maxSimultaneousLights: number;
  112508. /**
  112509. * Observable raised when the material is built
  112510. */
  112511. onBuildObservable: Observable<NodeMaterial>;
  112512. /**
  112513. * Gets or sets the root nodes of the material vertex shader
  112514. */
  112515. _vertexOutputNodes: NodeMaterialBlock[];
  112516. /**
  112517. * Gets or sets the root nodes of the material fragment (pixel) shader
  112518. */
  112519. _fragmentOutputNodes: NodeMaterialBlock[];
  112520. /** Gets or sets options to control the node material overall behavior */
  112521. options: INodeMaterialOptions;
  112522. /**
  112523. * Default configuration related to image processing available in the standard Material.
  112524. */
  112525. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112526. /**
  112527. * Gets the image processing configuration used either in this material.
  112528. */
  112529. /**
  112530. * Sets the Default image processing configuration used either in the this material.
  112531. *
  112532. * If sets to null, the scene one is in use.
  112533. */
  112534. imageProcessingConfiguration: ImageProcessingConfiguration;
  112535. /**
  112536. * Create a new node based material
  112537. * @param name defines the material name
  112538. * @param scene defines the hosting scene
  112539. * @param options defines creation option
  112540. */
  112541. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  112542. /**
  112543. * Gets the current class name of the material e.g. "NodeMaterial"
  112544. * @returns the class name
  112545. */
  112546. getClassName(): string;
  112547. /**
  112548. * Keep track of the image processing observer to allow dispose and replace.
  112549. */
  112550. private _imageProcessingObserver;
  112551. /**
  112552. * Attaches a new image processing configuration to the Standard Material.
  112553. * @param configuration
  112554. */
  112555. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112556. /**
  112557. * Adds a new optimizer to the list of optimizers
  112558. * @param optimizer defines the optimizers to add
  112559. * @returns the current material
  112560. */
  112561. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  112562. /**
  112563. * Remove an optimizer from the list of optimizers
  112564. * @param optimizer defines the optimizers to remove
  112565. * @returns the current material
  112566. */
  112567. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  112568. /**
  112569. * Add a new block to the list of output nodes
  112570. * @param node defines the node to add
  112571. * @returns the current material
  112572. */
  112573. addOutputNode(node: NodeMaterialBlock): this;
  112574. /**
  112575. * Remove a block from the list of root nodes
  112576. * @param node defines the node to remove
  112577. * @returns the current material
  112578. */
  112579. removeOutputNode(node: NodeMaterialBlock): this;
  112580. private _addVertexOutputNode;
  112581. private _removeVertexOutputNode;
  112582. private _addFragmentOutputNode;
  112583. private _removeFragmentOutputNode;
  112584. /**
  112585. * Specifies if the material will require alpha blending
  112586. * @returns a boolean specifying if alpha blending is needed
  112587. */
  112588. needAlphaBlending(): boolean;
  112589. /**
  112590. * Specifies if this material should be rendered in alpha test mode
  112591. * @returns a boolean specifying if an alpha test is needed.
  112592. */
  112593. needAlphaTesting(): boolean;
  112594. private _initializeBlock;
  112595. private _resetDualBlocks;
  112596. /**
  112597. * Build the material and generates the inner effect
  112598. * @param verbose defines if the build should log activity
  112599. */
  112600. build(verbose?: boolean): void;
  112601. /**
  112602. * Runs an otpimization phase to try to improve the shader code
  112603. */
  112604. optimize(): void;
  112605. private _prepareDefinesForAttributes;
  112606. /**
  112607. * Get if the submesh is ready to be used and all its information available.
  112608. * Child classes can use it to update shaders
  112609. * @param mesh defines the mesh to check
  112610. * @param subMesh defines which submesh to check
  112611. * @param useInstances specifies that instances should be used
  112612. * @returns a boolean indicating that the submesh is ready or not
  112613. */
  112614. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112615. /**
  112616. * Binds the world matrix to the material
  112617. * @param world defines the world transformation matrix
  112618. */
  112619. bindOnlyWorldMatrix(world: Matrix): void;
  112620. /**
  112621. * Binds the submesh to this material by preparing the effect and shader to draw
  112622. * @param world defines the world transformation matrix
  112623. * @param mesh defines the mesh containing the submesh
  112624. * @param subMesh defines the submesh to bind the material to
  112625. */
  112626. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112627. /**
  112628. * Gets the active textures from the material
  112629. * @returns an array of textures
  112630. */
  112631. getActiveTextures(): BaseTexture[];
  112632. /**
  112633. * Specifies if the material uses a texture
  112634. * @param texture defines the texture to check against the material
  112635. * @returns a boolean specifying if the material uses the texture
  112636. */
  112637. hasTexture(texture: BaseTexture): boolean;
  112638. /**
  112639. * Disposes the material
  112640. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  112641. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  112642. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  112643. */
  112644. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  112645. /** Creates the node editor window. */
  112646. private _createNodeEditor;
  112647. /**
  112648. * Launch the node material editor
  112649. * @param config Define the configuration of the editor
  112650. * @return a promise fulfilled when the node editor is visible
  112651. */
  112652. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  112653. }
  112654. }
  112655. declare module BABYLON {
  112656. /**
  112657. * Defines a block that can be used inside a node based material
  112658. */
  112659. export class NodeMaterialBlock {
  112660. private _buildId;
  112661. private _target;
  112662. private _isFinalMerger;
  112663. /** @hidden */
  112664. _inputs: NodeMaterialConnectionPoint[];
  112665. /** @hidden */
  112666. _outputs: NodeMaterialConnectionPoint[];
  112667. /**
  112668. * Gets or sets the name of the block
  112669. */
  112670. name: string;
  112671. /**
  112672. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  112673. */
  112674. readonly isFinalMerger: boolean;
  112675. /**
  112676. * Gets or sets the build Id
  112677. */
  112678. buildId: number;
  112679. /**
  112680. * Gets or sets the target of the block
  112681. */
  112682. target: NodeMaterialBlockTargets;
  112683. /**
  112684. * Gets the list of input points
  112685. */
  112686. readonly inputs: NodeMaterialConnectionPoint[];
  112687. /** Gets the list of output points */
  112688. readonly outputs: NodeMaterialConnectionPoint[];
  112689. /**
  112690. * Find an input by its name
  112691. * @param name defines the name of the input to look for
  112692. * @returns the input or null if not found
  112693. */
  112694. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  112695. /**
  112696. * Find an output by its name
  112697. * @param name defines the name of the outputto look for
  112698. * @returns the output or null if not found
  112699. */
  112700. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  112701. /**
  112702. * Creates a new NodeMaterialBlock
  112703. * @param name defines the block name
  112704. * @param target defines the target of that block (Vertex by default)
  112705. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  112706. */
  112707. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean);
  112708. /**
  112709. * Initialize the block and prepare the context for build
  112710. * @param state defines the state that will be used for the build
  112711. */
  112712. initialize(state: NodeMaterialBuildState): void;
  112713. /**
  112714. * Bind data to effect. Will only be called for blocks with isBindable === true
  112715. * @param effect defines the effect to bind data to
  112716. * @param nodeMaterial defines the hosting NodeMaterial
  112717. * @param mesh defines the mesh that will be rendered
  112718. */
  112719. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  112720. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  112721. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  112722. protected _writeFloat(value: number): string;
  112723. /**
  112724. * Gets the current class name e.g. "NodeMaterialBlock"
  112725. * @returns the class name
  112726. */
  112727. getClassName(): string;
  112728. /**
  112729. * Register a new input. Must be called inside a block constructor
  112730. * @param name defines the connection point name
  112731. * @param type defines the connection point type
  112732. * @param isOptional defines a boolean indicating that this input can be omitted
  112733. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  112734. * @returns the current block
  112735. */
  112736. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  112737. /**
  112738. * Register a new output. Must be called inside a block constructor
  112739. * @param name defines the connection point name
  112740. * @param type defines the connection point type
  112741. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  112742. * @returns the current block
  112743. */
  112744. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  112745. /**
  112746. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  112747. * @param forOutput defines an optional connection point to check compatibility with
  112748. * @returns the first available input or null
  112749. */
  112750. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  112751. /**
  112752. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  112753. * @param forBlock defines an optional block to check compatibility with
  112754. * @returns the first available input or null
  112755. */
  112756. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  112757. /**
  112758. * Connect current block with another block
  112759. * @param other defines the block to connect with
  112760. * @param options define the various options to help pick the right connections
  112761. * @returns the current block
  112762. */
  112763. connectTo(other: NodeMaterialBlock, options?: {
  112764. input?: string;
  112765. output?: string;
  112766. outputSwizzle?: string;
  112767. }): this | undefined;
  112768. protected _buildBlock(state: NodeMaterialBuildState): void;
  112769. /**
  112770. * Add potential fallbacks if shader compilation fails
  112771. * @param mesh defines the mesh to be rendered
  112772. * @param fallbacks defines the current prioritized list of fallbacks
  112773. */
  112774. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  112775. /**
  112776. * Update defines for shader compilation
  112777. * @param mesh defines the mesh to be rendered
  112778. * @param nodeMaterial defines the node material requesting the update
  112779. * @param defines defines the material defines to update
  112780. * @param useInstances specifies that instances should be used
  112781. */
  112782. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  112783. /**
  112784. * Lets the block try to connect some inputs automatically
  112785. */
  112786. autoConfigure(): void;
  112787. /**
  112788. * Function called when a block is declared as repeatable content generator
  112789. * @param vertexShaderState defines the current compilation state for the vertex shader
  112790. * @param fragmentShaderState defines the current compilation state for the fragment shader
  112791. * @param mesh defines the mesh to be rendered
  112792. * @param defines defines the material defines to update
  112793. */
  112794. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  112795. /**
  112796. * Checks if the block is ready
  112797. * @param mesh defines the mesh to be rendered
  112798. * @param nodeMaterial defines the node material requesting the update
  112799. * @param defines defines the material defines to update
  112800. * @param useInstances specifies that instances should be used
  112801. * @returns true if the block is ready
  112802. */
  112803. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  112804. /**
  112805. * Compile the current node and generate the shader code
  112806. * @param state defines the current compilation state (uniforms, samplers, current string)
  112807. * @returns the current block
  112808. */
  112809. build(state: NodeMaterialBuildState): this | undefined;
  112810. }
  112811. }
  112812. declare module BABYLON {
  112813. /**
  112814. * Defines a connection point for a block
  112815. */
  112816. export class NodeMaterialConnectionPoint {
  112817. /** @hidden */
  112818. _ownerBlock: NodeMaterialBlock;
  112819. /** @hidden */
  112820. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  112821. private _associatedVariableName;
  112822. private _endpoints;
  112823. private _storedValue;
  112824. private _valueCallback;
  112825. private _mode;
  112826. /** @hidden */
  112827. _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  112828. /**
  112829. * Gets or sets the connection point type (default is float)
  112830. */
  112831. type: NodeMaterialBlockConnectionPointTypes;
  112832. /**
  112833. * Gets or sets the connection point name
  112834. */
  112835. name: string;
  112836. /**
  112837. * Gets or sets the swizzle to apply to this connection point when reading or writing
  112838. */
  112839. swizzle: string;
  112840. /**
  112841. * Gets or sets a boolean indicating that this connection point can be omitted
  112842. */
  112843. isOptional: boolean;
  112844. /**
  112845. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  112846. */
  112847. define: string;
  112848. /** Gets or sets the target of that connection point */
  112849. target: NodeMaterialBlockTargets;
  112850. /**
  112851. * Gets or sets the value of that point.
  112852. * Please note that this value will be ignored if valueCallback is defined
  112853. */
  112854. value: any;
  112855. /**
  112856. * Gets or sets a callback used to get the value of that point.
  112857. * Please note that setting this value will force the connection point to ignore the value property
  112858. */
  112859. valueCallback: () => any;
  112860. /**
  112861. * Gets or sets the associated variable name in the shader
  112862. */
  112863. associatedVariableName: string;
  112864. /**
  112865. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  112866. * In this case the connection point name must be the name of the uniform to use.
  112867. * Can only be set on inputs
  112868. */
  112869. isUniform: boolean;
  112870. /**
  112871. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  112872. * In this case the connection point name must be the name of the attribute to use
  112873. * Can only be set on inputs
  112874. */
  112875. isAttribute: boolean;
  112876. /**
  112877. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  112878. * Can only be set on exit points
  112879. */
  112880. isVarying: boolean;
  112881. /** Get the other side of the connection (if any) */
  112882. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  112883. /** Get the block that owns this connection point */
  112884. readonly ownerBlock: NodeMaterialBlock;
  112885. /** Get the block connected on the other side of this connection (if any) */
  112886. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  112887. /** Get the block connected on the endpoints of this connection (if any) */
  112888. readonly connectedBlocks: Array<NodeMaterialBlock>;
  112889. /**
  112890. * Creates a new connection point
  112891. * @param name defines the connection point name
  112892. * @param ownerBlock defines the block hosting this connection point
  112893. */
  112894. constructor(name: string, ownerBlock: NodeMaterialBlock);
  112895. /**
  112896. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  112897. * @returns the class name
  112898. */
  112899. getClassName(): string;
  112900. /**
  112901. * Set the source of this connection point to a vertex attribute
  112902. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  112903. * @returns the current connection point
  112904. */
  112905. setAsAttribute(attributeName?: string): NodeMaterialConnectionPoint;
  112906. /**
  112907. * Set the source of this connection point to a well known value
  112908. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  112909. * @returns the current connection point
  112910. */
  112911. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): NodeMaterialConnectionPoint;
  112912. /**
  112913. * Gets a boolean indicating that the current connection point is a well known value
  112914. */
  112915. readonly isWellKnownValue: boolean;
  112916. /**
  112917. * Gets or sets the current well known value or null if not defined as well know value
  112918. */
  112919. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  112920. private _getTypeLength;
  112921. /**
  112922. * Connect this point to another connection point
  112923. * @param connectionPoint defines the other connection point
  112924. * @returns the current connection point
  112925. */
  112926. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  112927. /**
  112928. * Disconnect this point from one of his endpoint
  112929. * @param endpoint defines the other connection point
  112930. * @returns the current connection point
  112931. */
  112932. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  112933. /**
  112934. * When connection point is an uniform, this function will send its value to the effect
  112935. * @param effect defines the effect to transmit value to
  112936. * @param world defines the world matrix
  112937. * @param worldView defines the worldxview matrix
  112938. * @param worldViewProjection defines the worldxviewxprojection matrix
  112939. */
  112940. transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  112941. /**
  112942. * When connection point is an uniform, this function will send its value to the effect
  112943. * @param effect defines the effect to transmit value to
  112944. * @param scene defines the hosting scene
  112945. */
  112946. transmit(effect: Effect, scene: Scene): void;
  112947. }
  112948. }
  112949. declare module BABYLON {
  112950. /**
  112951. * Block used to output the vertex position
  112952. */
  112953. export class VertexOutputBlock extends NodeMaterialBlock {
  112954. /**
  112955. * Creates a new VertexOutputBlock
  112956. * @param name defines the block name
  112957. */
  112958. constructor(name: string);
  112959. /**
  112960. * Gets the current class name
  112961. * @returns the class name
  112962. */
  112963. getClassName(): string;
  112964. /**
  112965. * Gets the vector input component
  112966. */
  112967. readonly vector: NodeMaterialConnectionPoint;
  112968. protected _buildBlock(state: NodeMaterialBuildState): this;
  112969. }
  112970. }
  112971. declare module BABYLON {
  112972. /**
  112973. * Block used to add support for vertex skinning (bones)
  112974. */
  112975. export class BonesBlock extends NodeMaterialBlock {
  112976. /**
  112977. * Creates a new BonesBlock
  112978. * @param name defines the block name
  112979. */
  112980. constructor(name: string);
  112981. /**
  112982. * Initialize the block and prepare the context for build
  112983. * @param state defines the state that will be used for the build
  112984. */
  112985. initialize(state: NodeMaterialBuildState): void;
  112986. /**
  112987. * Gets the current class name
  112988. * @returns the class name
  112989. */
  112990. getClassName(): string;
  112991. /**
  112992. * Gets the matrix indices input component
  112993. */
  112994. readonly matricesIndices: NodeMaterialConnectionPoint;
  112995. /**
  112996. * Gets the matrix weights input component
  112997. */
  112998. readonly matricesWeights: NodeMaterialConnectionPoint;
  112999. /**
  113000. * Gets the extra matrix indices input component
  113001. */
  113002. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  113003. /**
  113004. * Gets the extra matrix weights input component
  113005. */
  113006. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  113007. /**
  113008. * Gets the world input component
  113009. */
  113010. readonly world: NodeMaterialConnectionPoint;
  113011. autoConfigure(): void;
  113012. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  113013. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113014. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113015. protected _buildBlock(state: NodeMaterialBuildState): this;
  113016. }
  113017. }
  113018. declare module BABYLON {
  113019. /**
  113020. * Block used to add support for instances
  113021. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  113022. */
  113023. export class InstancesBlock extends NodeMaterialBlock {
  113024. /**
  113025. * Creates a new InstancesBlock
  113026. * @param name defines the block name
  113027. */
  113028. constructor(name: string);
  113029. /**
  113030. * Gets the current class name
  113031. * @returns the class name
  113032. */
  113033. getClassName(): string;
  113034. /**
  113035. * Gets the first world row input component
  113036. */
  113037. readonly world0: NodeMaterialConnectionPoint;
  113038. /**
  113039. * Gets the second world row input component
  113040. */
  113041. readonly world1: NodeMaterialConnectionPoint;
  113042. /**
  113043. * Gets the third world row input component
  113044. */
  113045. readonly world2: NodeMaterialConnectionPoint;
  113046. /**
  113047. * Gets the forth world row input component
  113048. */
  113049. readonly world3: NodeMaterialConnectionPoint;
  113050. /**
  113051. * Gets the world input component
  113052. */
  113053. readonly world: NodeMaterialConnectionPoint;
  113054. /**
  113055. * Gets the output component
  113056. */
  113057. readonly output: NodeMaterialConnectionPoint;
  113058. autoConfigure(): void;
  113059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  113060. protected _buildBlock(state: NodeMaterialBuildState): this;
  113061. }
  113062. }
  113063. declare module BABYLON {
  113064. /**
  113065. * Block used to add morph targets support to vertex shader
  113066. */
  113067. export class MorphTargetsBlock extends NodeMaterialBlock {
  113068. private _repeatableContentAnchor;
  113069. private _repeatebleContentGenerated;
  113070. /**
  113071. * Create a new MorphTargetsBlock
  113072. * @param name defines the block name
  113073. */
  113074. constructor(name: string);
  113075. /**
  113076. * Gets the current class name
  113077. * @returns the class name
  113078. */
  113079. getClassName(): string;
  113080. /**
  113081. * Gets the position input component
  113082. */
  113083. readonly position: NodeMaterialConnectionPoint;
  113084. /**
  113085. * Gets the normal input component
  113086. */
  113087. readonly normal: NodeMaterialConnectionPoint;
  113088. /**
  113089. * Gets the tangent input component
  113090. */
  113091. readonly tangent: NodeMaterialConnectionPoint;
  113092. /**
  113093. * Gets the position output component
  113094. */
  113095. readonly positionOutput: NodeMaterialConnectionPoint;
  113096. /**
  113097. * Gets the normal output component
  113098. */
  113099. readonly normalOutput: NodeMaterialConnectionPoint;
  113100. /**
  113101. * Gets the tangent output component
  113102. */
  113103. readonly tangentOutput: NodeMaterialConnectionPoint;
  113104. initialize(state: NodeMaterialBuildState): void;
  113105. autoConfigure(): void;
  113106. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113107. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113108. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  113109. protected _buildBlock(state: NodeMaterialBuildState): this;
  113110. }
  113111. }
  113112. declare module BABYLON {
  113113. /**
  113114. * Block used to output the final color
  113115. */
  113116. export class FragmentOutputBlock extends NodeMaterialBlock {
  113117. /**
  113118. * Gets or sets a boolean indicating if this block will output an alpha value
  113119. */
  113120. alphaBlendingEnabled: boolean;
  113121. /**
  113122. * Create a new FragmentOutputBlock
  113123. * @param name defines the block name
  113124. */
  113125. constructor(name: string);
  113126. /**
  113127. * Gets the current class name
  113128. * @returns the class name
  113129. */
  113130. getClassName(): string;
  113131. /**
  113132. * Gets the color input component
  113133. */
  113134. readonly color: NodeMaterialConnectionPoint;
  113135. protected _buildBlock(state: NodeMaterialBuildState): this;
  113136. }
  113137. }
  113138. declare module BABYLON {
  113139. /**
  113140. * Block used to add an alpha test in the fragment shader
  113141. */
  113142. export class AlphaTestBlock extends NodeMaterialBlock {
  113143. /**
  113144. * Gets or sets the alpha value where alpha testing happens
  113145. */
  113146. alphaCutOff: number;
  113147. /**
  113148. * Create a new AlphaTestBlock
  113149. * @param name defines the block name
  113150. */
  113151. constructor(name: string);
  113152. /**
  113153. * Gets the current class name
  113154. * @returns the class name
  113155. */
  113156. getClassName(): string;
  113157. /**
  113158. * Gets the color input component
  113159. */
  113160. readonly color: NodeMaterialConnectionPoint;
  113161. protected _buildBlock(state: NodeMaterialBuildState): this;
  113162. }
  113163. }
  113164. declare module BABYLON {
  113165. /**
  113166. * Block used to create a Color4 out of 4 inputs (one for each component)
  113167. */
  113168. export class RGBAMergerBlock extends NodeMaterialBlock {
  113169. /**
  113170. * Create a new RGBAMergerBlock
  113171. * @param name defines the block name
  113172. */
  113173. constructor(name: string);
  113174. /**
  113175. * Gets the current class name
  113176. * @returns the class name
  113177. */
  113178. getClassName(): string;
  113179. /**
  113180. * Gets the R input component
  113181. */
  113182. readonly r: NodeMaterialConnectionPoint;
  113183. /**
  113184. * Gets the G input component
  113185. */
  113186. readonly g: NodeMaterialConnectionPoint;
  113187. /**
  113188. * Gets the B input component
  113189. */
  113190. readonly b: NodeMaterialConnectionPoint;
  113191. /**
  113192. * Gets the RGB input component
  113193. */
  113194. readonly rgb: NodeMaterialConnectionPoint;
  113195. /**
  113196. * Gets the R input component
  113197. */
  113198. readonly a: NodeMaterialConnectionPoint;
  113199. protected _buildBlock(state: NodeMaterialBuildState): this;
  113200. }
  113201. }
  113202. declare module BABYLON {
  113203. /**
  113204. * Block used to create a Color3 out of 3 inputs (one for each component)
  113205. */
  113206. export class RGBMergerBlock extends NodeMaterialBlock {
  113207. /**
  113208. * Create a new RGBMergerBlock
  113209. * @param name defines the block name
  113210. */
  113211. constructor(name: string);
  113212. /**
  113213. * Gets the current class name
  113214. * @returns the class name
  113215. */
  113216. getClassName(): string;
  113217. /**
  113218. * Gets the R component input
  113219. */
  113220. readonly r: NodeMaterialConnectionPoint;
  113221. /**
  113222. * Gets the G component input
  113223. */
  113224. readonly g: NodeMaterialConnectionPoint;
  113225. /**
  113226. * Gets the B component input
  113227. */
  113228. readonly b: NodeMaterialConnectionPoint;
  113229. protected _buildBlock(state: NodeMaterialBuildState): this;
  113230. }
  113231. }
  113232. declare module BABYLON {
  113233. /**
  113234. * Block used to expand a Color4 or a Vector4 into 4 outputs (one for each component)
  113235. */
  113236. export class RGBASplitterBlock extends NodeMaterialBlock {
  113237. /**
  113238. * Create a new RGBASplitterBlock
  113239. * @param name defines the block name
  113240. */
  113241. constructor(name: string);
  113242. /**
  113243. * Gets the current class name
  113244. * @returns the class name
  113245. */
  113246. getClassName(): string;
  113247. /**
  113248. * Gets the input component
  113249. */
  113250. readonly input: NodeMaterialConnectionPoint;
  113251. protected _buildBlock(state: NodeMaterialBuildState): this;
  113252. }
  113253. }
  113254. declare module BABYLON {
  113255. /**
  113256. * Block used to expand a Color3 or a Vector3 into 3 outputs (one for each component)
  113257. */
  113258. export class RGBSplitterBlock extends NodeMaterialBlock {
  113259. /**
  113260. * Create a new RGBSplitterBlock
  113261. * @param name defines the block name
  113262. */
  113263. constructor(name: string);
  113264. /**
  113265. * Gets the current class name
  113266. * @returns the class name
  113267. */
  113268. getClassName(): string;
  113269. /**
  113270. * Gets the input component
  113271. */
  113272. readonly input: NodeMaterialConnectionPoint;
  113273. protected _buildBlock(state: NodeMaterialBuildState): this;
  113274. }
  113275. }
  113276. declare module BABYLON {
  113277. /**
  113278. * Block used to read a texture from a sampler
  113279. */
  113280. export class TextureBlock extends NodeMaterialBlock {
  113281. private _defineName;
  113282. /**
  113283. * Gets or sets a boolean indicating that the block can automatically fetch the texture matrix
  113284. */
  113285. autoConnectTextureMatrix: boolean;
  113286. /**
  113287. * Gets or sets a boolean indicating that the block can automatically select the uv channel based on texture
  113288. */
  113289. autoSelectUV: boolean;
  113290. /**
  113291. * Create a new TextureBlock
  113292. * @param name defines the block name
  113293. */
  113294. constructor(name: string);
  113295. /**
  113296. * Gets the current class name
  113297. * @returns the class name
  113298. */
  113299. getClassName(): string;
  113300. /**
  113301. * Gets the uv input component
  113302. */
  113303. readonly uv: NodeMaterialConnectionPoint;
  113304. /**
  113305. * Gets the texture information input component
  113306. */
  113307. readonly textureInfo: NodeMaterialConnectionPoint;
  113308. /**
  113309. * Gets the transformed uv input component
  113310. */
  113311. readonly transformedUV: NodeMaterialConnectionPoint;
  113312. /**
  113313. * Gets the texture input component
  113314. */
  113315. readonly texture: NodeMaterialConnectionPoint;
  113316. /**
  113317. * Gets the texture transform input component
  113318. */
  113319. readonly textureTransform: NodeMaterialConnectionPoint;
  113320. autoConfigure(): void;
  113321. initialize(state: NodeMaterialBuildState): void;
  113322. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113323. isReady(): boolean;
  113324. private _injectVertexCode;
  113325. protected _buildBlock(state: NodeMaterialBuildState): this;
  113326. }
  113327. }
  113328. declare module BABYLON {
  113329. /**
  113330. * Block used to add image processing support to fragment shader
  113331. */
  113332. export class ImageProcessingBlock extends NodeMaterialBlock {
  113333. /**
  113334. * Create a new ImageProcessingBlock
  113335. * @param name defines the block name
  113336. */
  113337. constructor(name: string);
  113338. /**
  113339. * Gets the current class name
  113340. * @returns the class name
  113341. */
  113342. getClassName(): string;
  113343. /**
  113344. * Gets the color input component
  113345. */
  113346. readonly color: NodeMaterialConnectionPoint;
  113347. /**
  113348. * Initialize the block and prepare the context for build
  113349. * @param state defines the state that will be used for the build
  113350. */
  113351. initialize(state: NodeMaterialBuildState): void;
  113352. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  113353. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113354. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113355. protected _buildBlock(state: NodeMaterialBuildState): this;
  113356. }
  113357. }
  113358. declare module BABYLON {
  113359. /**
  113360. * Block used to add support for scene fog
  113361. */
  113362. export class FogBlock extends NodeMaterialBlock {
  113363. /**
  113364. * Create a new FogBlock
  113365. * @param name defines the block name
  113366. */
  113367. constructor(name: string);
  113368. /**
  113369. * Gets the current class name
  113370. * @returns the class name
  113371. */
  113372. getClassName(): string;
  113373. /**
  113374. * Gets the world position input component
  113375. */
  113376. readonly worldPosition: NodeMaterialConnectionPoint;
  113377. /**
  113378. * Gets the view input component
  113379. */
  113380. readonly view: NodeMaterialConnectionPoint;
  113381. /**
  113382. * Gets the color input component
  113383. */
  113384. readonly color: NodeMaterialConnectionPoint;
  113385. /**
  113386. * Gets the fog color input component
  113387. */
  113388. readonly fogColor: NodeMaterialConnectionPoint;
  113389. /**
  113390. * Gets the for parameter input component
  113391. */
  113392. readonly fogParameters: NodeMaterialConnectionPoint;
  113393. autoConfigure(): void;
  113394. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  113395. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  113396. protected _buildBlock(state: NodeMaterialBuildState): this;
  113397. }
  113398. }
  113399. declare module BABYLON {
  113400. /**
  113401. * Block used to multiply 2 vector4
  113402. */
  113403. export class MultiplyBlock extends NodeMaterialBlock {
  113404. /**
  113405. * Creates a new MultiplyBlock
  113406. * @param name defines the block name
  113407. */
  113408. constructor(name: string);
  113409. /**
  113410. * Gets the current class name
  113411. * @returns the class name
  113412. */
  113413. getClassName(): string;
  113414. /**
  113415. * Gets the left operand input component
  113416. */
  113417. readonly left: NodeMaterialConnectionPoint;
  113418. /**
  113419. * Gets the right operand input component
  113420. */
  113421. readonly right: NodeMaterialConnectionPoint;
  113422. protected _buildBlock(state: NodeMaterialBuildState): this;
  113423. }
  113424. }
  113425. declare module BABYLON {
  113426. /**
  113427. * Block used to add 2 vector4
  113428. */
  113429. export class AddBlock extends NodeMaterialBlock {
  113430. /**
  113431. * Creates a new AddBlock
  113432. * @param name defines the block name
  113433. */
  113434. constructor(name: string);
  113435. /**
  113436. * Gets the current class name
  113437. * @returns the class name
  113438. */
  113439. getClassName(): string;
  113440. /**
  113441. * Gets the left operand input component
  113442. */
  113443. readonly left: NodeMaterialConnectionPoint;
  113444. /**
  113445. * Gets the right operand input component
  113446. */
  113447. readonly right: NodeMaterialConnectionPoint;
  113448. protected _buildBlock(state: NodeMaterialBuildState): this;
  113449. }
  113450. }
  113451. declare module BABYLON {
  113452. /**
  113453. * Block used to clamp a float
  113454. */
  113455. export class ClampBlock extends NodeMaterialBlock {
  113456. /** Gets or sets the minimum range */
  113457. minimum: number;
  113458. /** Gets or sets the maximum range */
  113459. maximum: number;
  113460. /**
  113461. * Creates a new ClampBlock
  113462. * @param name defines the block name
  113463. */
  113464. constructor(name: string);
  113465. /**
  113466. * Gets the current class name
  113467. * @returns the class name
  113468. */
  113469. getClassName(): string;
  113470. /**
  113471. * Gets the value input component
  113472. */
  113473. readonly value: NodeMaterialConnectionPoint;
  113474. protected _buildBlock(state: NodeMaterialBuildState): this;
  113475. }
  113476. }
  113477. declare module BABYLON {
  113478. /**
  113479. * Block used to transform a vector2 with a matrix
  113480. */
  113481. export class Vector2TransformBlock extends NodeMaterialBlock {
  113482. /**
  113483. * Defines the value to use to complement Vector2 to transform it to a Vector4
  113484. */
  113485. complementZ: number;
  113486. /**
  113487. * Defines the value to use to complement Vector2 to transform it to a Vector4
  113488. */
  113489. complementW: number;
  113490. /**
  113491. * Creates a new Vector2TransformBlock
  113492. * @param name defines the block name
  113493. */
  113494. constructor(name: string);
  113495. /**
  113496. * Gets the vector input
  113497. */
  113498. readonly vector: NodeMaterialConnectionPoint;
  113499. /**
  113500. * Gets the matrix transform input
  113501. */
  113502. readonly transform: NodeMaterialConnectionPoint;
  113503. /**
  113504. * Gets the current class name
  113505. * @returns the class name
  113506. */
  113507. getClassName(): string;
  113508. protected _buildBlock(state: NodeMaterialBuildState): this;
  113509. }
  113510. }
  113511. declare module BABYLON {
  113512. /**
  113513. * Block used to transform a vector3 with a matrix
  113514. */
  113515. export class Vector3TransformBlock extends NodeMaterialBlock {
  113516. /**
  113517. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113518. */
  113519. complement: number;
  113520. /**
  113521. * Creates a new Vector3TransformBlock
  113522. * @param name defines the block name
  113523. */
  113524. constructor(name: string);
  113525. /**
  113526. * Gets the vector input
  113527. */
  113528. readonly vector: NodeMaterialConnectionPoint;
  113529. /**
  113530. * Gets the matrix transform input
  113531. */
  113532. readonly transform: NodeMaterialConnectionPoint;
  113533. /**
  113534. * Gets the current class name
  113535. * @returns the class name
  113536. */
  113537. getClassName(): string;
  113538. protected _buildBlock(state: NodeMaterialBuildState): this;
  113539. }
  113540. }
  113541. declare module BABYLON {
  113542. /**
  113543. * Block used to transform a vector4 with a matrix
  113544. */
  113545. export class Vector4TransformBlock extends NodeMaterialBlock {
  113546. /**
  113547. * Defines the value to use to complement Vector3 to transform it to a Vector4
  113548. */
  113549. complementW: number;
  113550. /**
  113551. * Creates a new Vector4TransformBlock
  113552. * @param name defines the block name
  113553. */
  113554. constructor(name: string);
  113555. /**
  113556. * Gets the current class name
  113557. * @returns the class name
  113558. */
  113559. getClassName(): string;
  113560. /**
  113561. * Gets the vector input
  113562. */
  113563. readonly vector: NodeMaterialConnectionPoint;
  113564. /**
  113565. * Gets the matrix transform input
  113566. */
  113567. readonly transform: NodeMaterialConnectionPoint;
  113568. protected _buildBlock(state: NodeMaterialBuildState): this;
  113569. }
  113570. }
  113571. declare module BABYLON {
  113572. /**
  113573. * Block used to multiply two matrices
  113574. */
  113575. export class MatrixMultiplicationBlock extends NodeMaterialBlock {
  113576. /**
  113577. * Creates a new MatrixMultiplicationBlock
  113578. * @param name defines the block name
  113579. */
  113580. constructor(name: string);
  113581. /**
  113582. * Gets the left operand
  113583. */
  113584. readonly left: NodeMaterialConnectionPoint;
  113585. /**
  113586. * Gets the right operand
  113587. */
  113588. readonly right: NodeMaterialConnectionPoint;
  113589. /**
  113590. * Gets the current class name
  113591. * @returns the class name
  113592. */
  113593. getClassName(): string;
  113594. protected _buildBlock(state: NodeMaterialBuildState): this;
  113595. }
  113596. }
  113597. declare module BABYLON {
  113598. /**
  113599. * Helper class to push actions to a pool of workers.
  113600. */
  113601. export class WorkerPool implements IDisposable {
  113602. private _workerInfos;
  113603. private _pendingActions;
  113604. /**
  113605. * Constructor
  113606. * @param workers Array of workers to use for actions
  113607. */
  113608. constructor(workers: Array<Worker>);
  113609. /**
  113610. * Terminates all workers and clears any pending actions.
  113611. */
  113612. dispose(): void;
  113613. /**
  113614. * Pushes an action to the worker pool. If all the workers are active, the action will be
  113615. * pended until a worker has completed its action.
  113616. * @param action The action to perform. Call onComplete when the action is complete.
  113617. */
  113618. push(action: (worker: Worker, onComplete: () => void) => void): void;
  113619. private _execute;
  113620. }
  113621. }
  113622. declare module BABYLON {
  113623. /**
  113624. * Configuration for Draco compression
  113625. */
  113626. export interface IDracoCompressionConfiguration {
  113627. /**
  113628. * Configuration for the decoder.
  113629. */
  113630. decoder: {
  113631. /**
  113632. * The url to the WebAssembly module.
  113633. */
  113634. wasmUrl?: string;
  113635. /**
  113636. * The url to the WebAssembly binary.
  113637. */
  113638. wasmBinaryUrl?: string;
  113639. /**
  113640. * The url to the fallback JavaScript module.
  113641. */
  113642. fallbackUrl?: string;
  113643. };
  113644. }
  113645. /**
  113646. * Draco compression (https://google.github.io/draco/)
  113647. *
  113648. * This class wraps the Draco module.
  113649. *
  113650. * **Encoder**
  113651. *
  113652. * The encoder is not currently implemented.
  113653. *
  113654. * **Decoder**
  113655. *
  113656. * 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.
  113657. *
  113658. * To update the configuration, use the following code:
  113659. * ```javascript
  113660. * DracoCompression.Configuration = {
  113661. * decoder: {
  113662. * wasmUrl: "<url to the WebAssembly library>",
  113663. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  113664. * fallbackUrl: "<url to the fallback JavaScript library>",
  113665. * }
  113666. * };
  113667. * ```
  113668. *
  113669. * 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.
  113670. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  113671. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  113672. *
  113673. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  113674. * ```javascript
  113675. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  113676. * ```
  113677. *
  113678. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  113679. */
  113680. export class DracoCompression implements IDisposable {
  113681. private _workerPoolPromise?;
  113682. private _decoderModulePromise?;
  113683. /**
  113684. * The configuration. Defaults to the following urls:
  113685. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  113686. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  113687. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  113688. */
  113689. static Configuration: IDracoCompressionConfiguration;
  113690. /**
  113691. * Returns true if the decoder configuration is available.
  113692. */
  113693. static readonly DecoderAvailable: boolean;
  113694. /**
  113695. * Default number of workers to create when creating the draco compression object.
  113696. */
  113697. static DefaultNumWorkers: number;
  113698. private static GetDefaultNumWorkers;
  113699. private static _Default;
  113700. /**
  113701. * Default instance for the draco compression object.
  113702. */
  113703. static readonly Default: DracoCompression;
  113704. /**
  113705. * Constructor
  113706. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  113707. */
  113708. constructor(numWorkers?: number);
  113709. /**
  113710. * Stop all async operations and release resources.
  113711. */
  113712. dispose(): void;
  113713. /**
  113714. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  113715. * @returns a promise that resolves when ready
  113716. */
  113717. whenReadyAsync(): Promise<void>;
  113718. /**
  113719. * Decode Draco compressed mesh data to vertex data.
  113720. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  113721. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  113722. * @returns A promise that resolves with the decoded vertex data
  113723. */
  113724. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  113725. [kind: string]: number;
  113726. }): Promise<VertexData>;
  113727. }
  113728. }
  113729. declare module BABYLON {
  113730. /**
  113731. * Class for building Constructive Solid Geometry
  113732. */
  113733. export class CSG {
  113734. private polygons;
  113735. /**
  113736. * The world matrix
  113737. */
  113738. matrix: Matrix;
  113739. /**
  113740. * Stores the position
  113741. */
  113742. position: Vector3;
  113743. /**
  113744. * Stores the rotation
  113745. */
  113746. rotation: Vector3;
  113747. /**
  113748. * Stores the rotation quaternion
  113749. */
  113750. rotationQuaternion: Nullable<Quaternion>;
  113751. /**
  113752. * Stores the scaling vector
  113753. */
  113754. scaling: Vector3;
  113755. /**
  113756. * Convert the Mesh to CSG
  113757. * @param mesh The Mesh to convert to CSG
  113758. * @returns A new CSG from the Mesh
  113759. */
  113760. static FromMesh(mesh: Mesh): CSG;
  113761. /**
  113762. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  113763. * @param polygons Polygons used to construct a CSG solid
  113764. */
  113765. private static FromPolygons;
  113766. /**
  113767. * Clones, or makes a deep copy, of the CSG
  113768. * @returns A new CSG
  113769. */
  113770. clone(): CSG;
  113771. /**
  113772. * Unions this CSG with another CSG
  113773. * @param csg The CSG to union against this CSG
  113774. * @returns The unioned CSG
  113775. */
  113776. union(csg: CSG): CSG;
  113777. /**
  113778. * Unions this CSG with another CSG in place
  113779. * @param csg The CSG to union against this CSG
  113780. */
  113781. unionInPlace(csg: CSG): void;
  113782. /**
  113783. * Subtracts this CSG with another CSG
  113784. * @param csg The CSG to subtract against this CSG
  113785. * @returns A new CSG
  113786. */
  113787. subtract(csg: CSG): CSG;
  113788. /**
  113789. * Subtracts this CSG with another CSG in place
  113790. * @param csg The CSG to subtact against this CSG
  113791. */
  113792. subtractInPlace(csg: CSG): void;
  113793. /**
  113794. * Intersect this CSG with another CSG
  113795. * @param csg The CSG to intersect against this CSG
  113796. * @returns A new CSG
  113797. */
  113798. intersect(csg: CSG): CSG;
  113799. /**
  113800. * Intersects this CSG with another CSG in place
  113801. * @param csg The CSG to intersect against this CSG
  113802. */
  113803. intersectInPlace(csg: CSG): void;
  113804. /**
  113805. * Return a new CSG solid with solid and empty space switched. This solid is
  113806. * not modified.
  113807. * @returns A new CSG solid with solid and empty space switched
  113808. */
  113809. inverse(): CSG;
  113810. /**
  113811. * Inverses the CSG in place
  113812. */
  113813. inverseInPlace(): void;
  113814. /**
  113815. * This is used to keep meshes transformations so they can be restored
  113816. * when we build back a Babylon Mesh
  113817. * NB : All CSG operations are performed in world coordinates
  113818. * @param csg The CSG to copy the transform attributes from
  113819. * @returns This CSG
  113820. */
  113821. copyTransformAttributes(csg: CSG): CSG;
  113822. /**
  113823. * Build Raw mesh from CSG
  113824. * Coordinates here are in world space
  113825. * @param name The name of the mesh geometry
  113826. * @param scene The Scene
  113827. * @param keepSubMeshes Specifies if the submeshes should be kept
  113828. * @returns A new Mesh
  113829. */
  113830. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  113831. /**
  113832. * Build Mesh from CSG taking material and transforms into account
  113833. * @param name The name of the Mesh
  113834. * @param material The material of the Mesh
  113835. * @param scene The Scene
  113836. * @param keepSubMeshes Specifies if submeshes should be kept
  113837. * @returns The new Mesh
  113838. */
  113839. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  113840. }
  113841. }
  113842. declare module BABYLON {
  113843. /**
  113844. * Class used to create a trail following a mesh
  113845. */
  113846. export class TrailMesh extends Mesh {
  113847. private _generator;
  113848. private _autoStart;
  113849. private _running;
  113850. private _diameter;
  113851. private _length;
  113852. private _sectionPolygonPointsCount;
  113853. private _sectionVectors;
  113854. private _sectionNormalVectors;
  113855. private _beforeRenderObserver;
  113856. /**
  113857. * @constructor
  113858. * @param name The value used by scene.getMeshByName() to do a lookup.
  113859. * @param generator The mesh to generate a trail.
  113860. * @param scene The scene to add this mesh to.
  113861. * @param diameter Diameter of trailing mesh. Default is 1.
  113862. * @param length Length of trailing mesh. Default is 60.
  113863. * @param autoStart Automatically start trailing mesh. Default true.
  113864. */
  113865. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  113866. /**
  113867. * "TrailMesh"
  113868. * @returns "TrailMesh"
  113869. */
  113870. getClassName(): string;
  113871. private _createMesh;
  113872. /**
  113873. * Start trailing mesh.
  113874. */
  113875. start(): void;
  113876. /**
  113877. * Stop trailing mesh.
  113878. */
  113879. stop(): void;
  113880. /**
  113881. * Update trailing mesh geometry.
  113882. */
  113883. update(): void;
  113884. /**
  113885. * Returns a new TrailMesh object.
  113886. * @param name is a string, the name given to the new mesh
  113887. * @param newGenerator use new generator object for cloned trail mesh
  113888. * @returns a new mesh
  113889. */
  113890. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  113891. /**
  113892. * Serializes this trail mesh
  113893. * @param serializationObject object to write serialization to
  113894. */
  113895. serialize(serializationObject: any): void;
  113896. /**
  113897. * Parses a serialized trail mesh
  113898. * @param parsedMesh the serialized mesh
  113899. * @param scene the scene to create the trail mesh in
  113900. * @returns the created trail mesh
  113901. */
  113902. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  113903. }
  113904. }
  113905. declare module BABYLON {
  113906. /**
  113907. * Class containing static functions to help procedurally build meshes
  113908. */
  113909. export class TiledBoxBuilder {
  113910. /**
  113911. * Creates a box mesh
  113912. * 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)
  113913. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  113914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113917. * @param name defines the name of the mesh
  113918. * @param options defines the options used to create the mesh
  113919. * @param scene defines the hosting scene
  113920. * @returns the box mesh
  113921. */
  113922. static CreateTiledBox(name: string, options: {
  113923. pattern?: number;
  113924. width?: number;
  113925. height?: number;
  113926. depth?: number;
  113927. tileSize?: number;
  113928. tileWidth?: number;
  113929. tileHeight?: number;
  113930. alignHorizontal?: number;
  113931. alignVertical?: number;
  113932. faceUV?: Vector4[];
  113933. faceColors?: Color4[];
  113934. sideOrientation?: number;
  113935. updatable?: boolean;
  113936. }, scene?: Nullable<Scene>): Mesh;
  113937. }
  113938. }
  113939. declare module BABYLON {
  113940. /**
  113941. * Class containing static functions to help procedurally build meshes
  113942. */
  113943. export class TorusKnotBuilder {
  113944. /**
  113945. * Creates a torus knot mesh
  113946. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  113947. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  113948. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  113949. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  113950. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113951. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113952. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  113953. * @param name defines the name of the mesh
  113954. * @param options defines the options used to create the mesh
  113955. * @param scene defines the hosting scene
  113956. * @returns the torus knot mesh
  113957. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  113958. */
  113959. static CreateTorusKnot(name: string, options: {
  113960. radius?: number;
  113961. tube?: number;
  113962. radialSegments?: number;
  113963. tubularSegments?: number;
  113964. p?: number;
  113965. q?: number;
  113966. updatable?: boolean;
  113967. sideOrientation?: number;
  113968. frontUVs?: Vector4;
  113969. backUVs?: Vector4;
  113970. }, scene: any): Mesh;
  113971. }
  113972. }
  113973. declare module BABYLON {
  113974. /**
  113975. * Polygon
  113976. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  113977. */
  113978. export class Polygon {
  113979. /**
  113980. * Creates a rectangle
  113981. * @param xmin bottom X coord
  113982. * @param ymin bottom Y coord
  113983. * @param xmax top X coord
  113984. * @param ymax top Y coord
  113985. * @returns points that make the resulting rectation
  113986. */
  113987. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  113988. /**
  113989. * Creates a circle
  113990. * @param radius radius of circle
  113991. * @param cx scale in x
  113992. * @param cy scale in y
  113993. * @param numberOfSides number of sides that make up the circle
  113994. * @returns points that make the resulting circle
  113995. */
  113996. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  113997. /**
  113998. * Creates a polygon from input string
  113999. * @param input Input polygon data
  114000. * @returns the parsed points
  114001. */
  114002. static Parse(input: string): Vector2[];
  114003. /**
  114004. * Starts building a polygon from x and y coordinates
  114005. * @param x x coordinate
  114006. * @param y y coordinate
  114007. * @returns the started path2
  114008. */
  114009. static StartingAt(x: number, y: number): Path2;
  114010. }
  114011. /**
  114012. * Builds a polygon
  114013. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  114014. */
  114015. export class PolygonMeshBuilder {
  114016. private _points;
  114017. private _outlinepoints;
  114018. private _holes;
  114019. private _name;
  114020. private _scene;
  114021. private _epoints;
  114022. private _eholes;
  114023. private _addToepoint;
  114024. /**
  114025. * Babylon reference to the earcut plugin.
  114026. */
  114027. bjsEarcut: any;
  114028. /**
  114029. * Creates a PolygonMeshBuilder
  114030. * @param name name of the builder
  114031. * @param contours Path of the polygon
  114032. * @param scene scene to add to when creating the mesh
  114033. * @param earcutInjection can be used to inject your own earcut reference
  114034. */
  114035. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  114036. /**
  114037. * Adds a whole within the polygon
  114038. * @param hole Array of points defining the hole
  114039. * @returns this
  114040. */
  114041. addHole(hole: Vector2[]): PolygonMeshBuilder;
  114042. /**
  114043. * Creates the polygon
  114044. * @param updatable If the mesh should be updatable
  114045. * @param depth The depth of the mesh created
  114046. * @returns the created mesh
  114047. */
  114048. build(updatable?: boolean, depth?: number): Mesh;
  114049. /**
  114050. * Creates the polygon
  114051. * @param depth The depth of the mesh created
  114052. * @returns the created VertexData
  114053. */
  114054. buildVertexData(depth?: number): VertexData;
  114055. /**
  114056. * Adds a side to the polygon
  114057. * @param positions points that make the polygon
  114058. * @param normals normals of the polygon
  114059. * @param uvs uvs of the polygon
  114060. * @param indices indices of the polygon
  114061. * @param bounds bounds of the polygon
  114062. * @param points points of the polygon
  114063. * @param depth depth of the polygon
  114064. * @param flip flip of the polygon
  114065. */
  114066. private addSide;
  114067. }
  114068. }
  114069. declare module BABYLON {
  114070. /**
  114071. * Class containing static functions to help procedurally build meshes
  114072. */
  114073. export class PolygonBuilder {
  114074. /**
  114075. * Creates a polygon mesh
  114076. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  114077. * * 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
  114078. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114079. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114080. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  114081. * * Remember you can only change the shape positions, not their number when updating a polygon
  114082. * @param name defines the name of the mesh
  114083. * @param options defines the options used to create the mesh
  114084. * @param scene defines the hosting scene
  114085. * @param earcutInjection can be used to inject your own earcut reference
  114086. * @returns the polygon mesh
  114087. */
  114088. static CreatePolygon(name: string, options: {
  114089. shape: Vector3[];
  114090. holes?: Vector3[][];
  114091. depth?: number;
  114092. faceUV?: Vector4[];
  114093. faceColors?: Color4[];
  114094. updatable?: boolean;
  114095. sideOrientation?: number;
  114096. frontUVs?: Vector4;
  114097. backUVs?: Vector4;
  114098. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114099. /**
  114100. * Creates an extruded polygon mesh, with depth in the Y direction.
  114101. * * 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)
  114102. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114103. * @param name defines the name of the mesh
  114104. * @param options defines the options used to create the mesh
  114105. * @param scene defines the hosting scene
  114106. * @param earcutInjection can be used to inject your own earcut reference
  114107. * @returns the polygon mesh
  114108. */
  114109. static ExtrudePolygon(name: string, options: {
  114110. shape: Vector3[];
  114111. holes?: Vector3[][];
  114112. depth?: number;
  114113. faceUV?: Vector4[];
  114114. faceColors?: Color4[];
  114115. updatable?: boolean;
  114116. sideOrientation?: number;
  114117. frontUVs?: Vector4;
  114118. backUVs?: Vector4;
  114119. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114120. }
  114121. }
  114122. declare module BABYLON {
  114123. /**
  114124. * Class containing static functions to help procedurally build meshes
  114125. */
  114126. export class LatheBuilder {
  114127. /**
  114128. * Creates lathe mesh.
  114129. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  114130. * * 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
  114131. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  114132. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  114133. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  114134. * * 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
  114135. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  114136. * * 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
  114137. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114138. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114139. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114141. * @param name defines the name of the mesh
  114142. * @param options defines the options used to create the mesh
  114143. * @param scene defines the hosting scene
  114144. * @returns the lathe mesh
  114145. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  114146. */
  114147. static CreateLathe(name: string, options: {
  114148. shape: Vector3[];
  114149. radius?: number;
  114150. tessellation?: number;
  114151. clip?: number;
  114152. arc?: number;
  114153. closed?: boolean;
  114154. updatable?: boolean;
  114155. sideOrientation?: number;
  114156. frontUVs?: Vector4;
  114157. backUVs?: Vector4;
  114158. cap?: number;
  114159. invertUV?: boolean;
  114160. }, scene?: Nullable<Scene>): Mesh;
  114161. }
  114162. }
  114163. declare module BABYLON {
  114164. /**
  114165. * Class containing static functions to help procedurally build meshes
  114166. */
  114167. export class TiledPlaneBuilder {
  114168. /**
  114169. * Creates a tiled plane mesh
  114170. * * The parameter `pattern` will, depending on value, do nothing or
  114171. * * * flip (reflect about central vertical) alternate tiles across and up
  114172. * * * flip every tile on alternate rows
  114173. * * * rotate (180 degs) alternate tiles across and up
  114174. * * * rotate every tile on alternate rows
  114175. * * * flip and rotate alternate tiles across and up
  114176. * * * flip and rotate every tile on alternate rows
  114177. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  114178. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  114179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114180. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114181. * * 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)
  114182. * * 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)
  114183. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114184. * @param name defines the name of the mesh
  114185. * @param options defines the options used to create the mesh
  114186. * @param scene defines the hosting scene
  114187. * @returns the box mesh
  114188. */
  114189. static CreateTiledPlane(name: string, options: {
  114190. pattern?: number;
  114191. tileSize?: number;
  114192. tileWidth?: number;
  114193. tileHeight?: number;
  114194. size?: number;
  114195. width?: number;
  114196. height?: number;
  114197. alignHorizontal?: number;
  114198. alignVertical?: number;
  114199. sideOrientation?: number;
  114200. frontUVs?: Vector4;
  114201. backUVs?: Vector4;
  114202. updatable?: boolean;
  114203. }, scene?: Nullable<Scene>): Mesh;
  114204. }
  114205. }
  114206. declare module BABYLON {
  114207. /**
  114208. * Class containing static functions to help procedurally build meshes
  114209. */
  114210. export class TubeBuilder {
  114211. /**
  114212. * Creates a tube mesh.
  114213. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114214. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  114215. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  114216. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  114217. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  114218. * * 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)
  114219. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  114220. * * 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
  114221. * * 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
  114222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114223. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114224. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114225. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114226. * @param name defines the name of the mesh
  114227. * @param options defines the options used to create the mesh
  114228. * @param scene defines the hosting scene
  114229. * @returns the tube mesh
  114230. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114231. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  114232. */
  114233. static CreateTube(name: string, options: {
  114234. path: Vector3[];
  114235. radius?: number;
  114236. tessellation?: number;
  114237. radiusFunction?: {
  114238. (i: number, distance: number): number;
  114239. };
  114240. cap?: number;
  114241. arc?: number;
  114242. updatable?: boolean;
  114243. sideOrientation?: number;
  114244. frontUVs?: Vector4;
  114245. backUVs?: Vector4;
  114246. instance?: Mesh;
  114247. invertUV?: boolean;
  114248. }, scene?: Nullable<Scene>): Mesh;
  114249. }
  114250. }
  114251. declare module BABYLON {
  114252. /**
  114253. * Class containing static functions to help procedurally build meshes
  114254. */
  114255. export class IcoSphereBuilder {
  114256. /**
  114257. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114258. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114259. * * 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`)
  114260. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114261. * * 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
  114262. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114263. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114264. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114265. * @param name defines the name of the mesh
  114266. * @param options defines the options used to create the mesh
  114267. * @param scene defines the hosting scene
  114268. * @returns the icosahedron mesh
  114269. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114270. */
  114271. static CreateIcoSphere(name: string, options: {
  114272. radius?: number;
  114273. radiusX?: number;
  114274. radiusY?: number;
  114275. radiusZ?: number;
  114276. flat?: boolean;
  114277. subdivisions?: number;
  114278. sideOrientation?: number;
  114279. frontUVs?: Vector4;
  114280. backUVs?: Vector4;
  114281. updatable?: boolean;
  114282. }, scene?: Nullable<Scene>): Mesh;
  114283. }
  114284. }
  114285. declare module BABYLON {
  114286. /**
  114287. * Class containing static functions to help procedurally build meshes
  114288. */
  114289. export class DecalBuilder {
  114290. /**
  114291. * Creates a decal mesh.
  114292. * 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
  114293. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  114294. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  114295. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  114296. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  114297. * @param name defines the name of the mesh
  114298. * @param sourceMesh defines the mesh where the decal must be applied
  114299. * @param options defines the options used to create the mesh
  114300. * @param scene defines the hosting scene
  114301. * @returns the decal mesh
  114302. * @see https://doc.babylonjs.com/how_to/decals
  114303. */
  114304. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  114305. position?: Vector3;
  114306. normal?: Vector3;
  114307. size?: Vector3;
  114308. angle?: number;
  114309. }): Mesh;
  114310. }
  114311. }
  114312. declare module BABYLON {
  114313. /**
  114314. * Class containing static functions to help procedurally build meshes
  114315. */
  114316. export class MeshBuilder {
  114317. /**
  114318. * Creates a box mesh
  114319. * * The parameter `size` sets the size (float) of each box side (default 1)
  114320. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  114321. * * 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)
  114322. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114323. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114324. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114325. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114326. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  114327. * @param name defines the name of the mesh
  114328. * @param options defines the options used to create the mesh
  114329. * @param scene defines the hosting scene
  114330. * @returns the box mesh
  114331. */
  114332. static CreateBox(name: string, options: {
  114333. size?: number;
  114334. width?: number;
  114335. height?: number;
  114336. depth?: number;
  114337. faceUV?: Vector4[];
  114338. faceColors?: Color4[];
  114339. sideOrientation?: number;
  114340. frontUVs?: Vector4;
  114341. backUVs?: Vector4;
  114342. updatable?: boolean;
  114343. }, scene?: Nullable<Scene>): Mesh;
  114344. /**
  114345. * Creates a tiled box mesh
  114346. * * faceTiles sets the pattern, tile size and number of tiles for a face
  114347. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114348. * @param name defines the name of the mesh
  114349. * @param options defines the options used to create the mesh
  114350. * @param scene defines the hosting scene
  114351. * @returns the tiled box mesh
  114352. */
  114353. static CreateTiledBox(name: string, options: {
  114354. pattern?: number;
  114355. size?: number;
  114356. width?: number;
  114357. height?: number;
  114358. depth: number;
  114359. tileSize?: number;
  114360. tileWidth?: number;
  114361. tileHeight?: number;
  114362. faceUV?: Vector4[];
  114363. faceColors?: Color4[];
  114364. alignHorizontal?: number;
  114365. alignVertical?: number;
  114366. sideOrientation?: number;
  114367. updatable?: boolean;
  114368. }, scene?: Nullable<Scene>): Mesh;
  114369. /**
  114370. * Creates a sphere mesh
  114371. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  114372. * * 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`)
  114373. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  114374. * * 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
  114375. * * 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)
  114376. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114377. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114378. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114379. * @param name defines the name of the mesh
  114380. * @param options defines the options used to create the mesh
  114381. * @param scene defines the hosting scene
  114382. * @returns the sphere mesh
  114383. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  114384. */
  114385. static CreateSphere(name: string, options: {
  114386. segments?: number;
  114387. diameter?: number;
  114388. diameterX?: number;
  114389. diameterY?: number;
  114390. diameterZ?: number;
  114391. arc?: number;
  114392. slice?: number;
  114393. sideOrientation?: number;
  114394. frontUVs?: Vector4;
  114395. backUVs?: Vector4;
  114396. updatable?: boolean;
  114397. }, scene?: Nullable<Scene>): Mesh;
  114398. /**
  114399. * Creates a plane polygonal mesh. By default, this is a disc
  114400. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  114401. * * 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
  114402. * * 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
  114403. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114404. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114406. * @param name defines the name of the mesh
  114407. * @param options defines the options used to create the mesh
  114408. * @param scene defines the hosting scene
  114409. * @returns the plane polygonal mesh
  114410. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  114411. */
  114412. static CreateDisc(name: string, options: {
  114413. radius?: number;
  114414. tessellation?: number;
  114415. arc?: number;
  114416. updatable?: boolean;
  114417. sideOrientation?: number;
  114418. frontUVs?: Vector4;
  114419. backUVs?: Vector4;
  114420. }, scene?: Nullable<Scene>): Mesh;
  114421. /**
  114422. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  114423. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  114424. * * 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`)
  114425. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  114426. * * 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
  114427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114430. * @param name defines the name of the mesh
  114431. * @param options defines the options used to create the mesh
  114432. * @param scene defines the hosting scene
  114433. * @returns the icosahedron mesh
  114434. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  114435. */
  114436. static CreateIcoSphere(name: string, options: {
  114437. radius?: number;
  114438. radiusX?: number;
  114439. radiusY?: number;
  114440. radiusZ?: number;
  114441. flat?: boolean;
  114442. subdivisions?: number;
  114443. sideOrientation?: number;
  114444. frontUVs?: Vector4;
  114445. backUVs?: Vector4;
  114446. updatable?: boolean;
  114447. }, scene?: Nullable<Scene>): Mesh;
  114448. /**
  114449. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114450. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  114451. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  114452. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  114453. * * 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
  114454. * * 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
  114455. * * 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
  114456. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114457. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114458. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114459. * * 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
  114460. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  114461. * * 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
  114462. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  114463. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114464. * @param name defines the name of the mesh
  114465. * @param options defines the options used to create the mesh
  114466. * @param scene defines the hosting scene
  114467. * @returns the ribbon mesh
  114468. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  114469. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114470. */
  114471. static CreateRibbon(name: string, options: {
  114472. pathArray: Vector3[][];
  114473. closeArray?: boolean;
  114474. closePath?: boolean;
  114475. offset?: number;
  114476. updatable?: boolean;
  114477. sideOrientation?: number;
  114478. frontUVs?: Vector4;
  114479. backUVs?: Vector4;
  114480. instance?: Mesh;
  114481. invertUV?: boolean;
  114482. uvs?: Vector2[];
  114483. colors?: Color4[];
  114484. }, scene?: Nullable<Scene>): Mesh;
  114485. /**
  114486. * Creates a cylinder or a cone mesh
  114487. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  114488. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  114489. * * 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.
  114490. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  114491. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  114492. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  114493. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  114494. * * 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).
  114495. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  114496. * * 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).
  114497. * * 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
  114498. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  114499. * * 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
  114500. * * 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.
  114501. * * If `enclose` is false, a ring surface is one element.
  114502. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  114503. * * 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
  114504. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114505. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114506. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114507. * @param name defines the name of the mesh
  114508. * @param options defines the options used to create the mesh
  114509. * @param scene defines the hosting scene
  114510. * @returns the cylinder mesh
  114511. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  114512. */
  114513. static CreateCylinder(name: string, options: {
  114514. height?: number;
  114515. diameterTop?: number;
  114516. diameterBottom?: number;
  114517. diameter?: number;
  114518. tessellation?: number;
  114519. subdivisions?: number;
  114520. arc?: number;
  114521. faceColors?: Color4[];
  114522. faceUV?: Vector4[];
  114523. updatable?: boolean;
  114524. hasRings?: boolean;
  114525. enclose?: boolean;
  114526. cap?: number;
  114527. sideOrientation?: number;
  114528. frontUVs?: Vector4;
  114529. backUVs?: Vector4;
  114530. }, scene?: Nullable<Scene>): Mesh;
  114531. /**
  114532. * Creates a torus mesh
  114533. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  114534. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  114535. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  114536. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114537. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114539. * @param name defines the name of the mesh
  114540. * @param options defines the options used to create the mesh
  114541. * @param scene defines the hosting scene
  114542. * @returns the torus mesh
  114543. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  114544. */
  114545. static CreateTorus(name: string, options: {
  114546. diameter?: number;
  114547. thickness?: number;
  114548. tessellation?: number;
  114549. updatable?: boolean;
  114550. sideOrientation?: number;
  114551. frontUVs?: Vector4;
  114552. backUVs?: Vector4;
  114553. }, scene?: Nullable<Scene>): Mesh;
  114554. /**
  114555. * Creates a torus knot mesh
  114556. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  114557. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  114558. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  114559. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  114560. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114561. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114562. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114563. * @param name defines the name of the mesh
  114564. * @param options defines the options used to create the mesh
  114565. * @param scene defines the hosting scene
  114566. * @returns the torus knot mesh
  114567. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  114568. */
  114569. static CreateTorusKnot(name: string, options: {
  114570. radius?: number;
  114571. tube?: number;
  114572. radialSegments?: number;
  114573. tubularSegments?: number;
  114574. p?: number;
  114575. q?: number;
  114576. updatable?: boolean;
  114577. sideOrientation?: number;
  114578. frontUVs?: Vector4;
  114579. backUVs?: Vector4;
  114580. }, scene?: Nullable<Scene>): Mesh;
  114581. /**
  114582. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  114583. * * 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
  114584. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  114585. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  114586. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  114587. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  114588. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  114589. * * 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
  114590. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  114591. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114592. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  114593. * @param name defines the name of the new line system
  114594. * @param options defines the options used to create the line system
  114595. * @param scene defines the hosting scene
  114596. * @returns a new line system mesh
  114597. */
  114598. static CreateLineSystem(name: string, options: {
  114599. lines: Vector3[][];
  114600. updatable?: boolean;
  114601. instance?: Nullable<LinesMesh>;
  114602. colors?: Nullable<Color4[][]>;
  114603. useVertexAlpha?: boolean;
  114604. }, scene: Nullable<Scene>): LinesMesh;
  114605. /**
  114606. * Creates a line mesh
  114607. * 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
  114608. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  114609. * * The parameter `points` is an array successive Vector3
  114610. * * 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
  114611. * * The optional parameter `colors` is an array of successive Color4, one per line point
  114612. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  114613. * * When updating an instance, remember that only point positions can change, not the number of points
  114614. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114615. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  114616. * @param name defines the name of the new line system
  114617. * @param options defines the options used to create the line system
  114618. * @param scene defines the hosting scene
  114619. * @returns a new line mesh
  114620. */
  114621. static CreateLines(name: string, options: {
  114622. points: Vector3[];
  114623. updatable?: boolean;
  114624. instance?: Nullable<LinesMesh>;
  114625. colors?: Color4[];
  114626. useVertexAlpha?: boolean;
  114627. }, scene?: Nullable<Scene>): LinesMesh;
  114628. /**
  114629. * Creates a dashed line mesh
  114630. * * 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
  114631. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  114632. * * The parameter `points` is an array successive Vector3
  114633. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  114634. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  114635. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  114636. * * 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
  114637. * * When updating an instance, remember that only point positions can change, not the number of points
  114638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114639. * @param name defines the name of the mesh
  114640. * @param options defines the options used to create the mesh
  114641. * @param scene defines the hosting scene
  114642. * @returns the dashed line mesh
  114643. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  114644. */
  114645. static CreateDashedLines(name: string, options: {
  114646. points: Vector3[];
  114647. dashSize?: number;
  114648. gapSize?: number;
  114649. dashNb?: number;
  114650. updatable?: boolean;
  114651. instance?: LinesMesh;
  114652. }, scene?: Nullable<Scene>): LinesMesh;
  114653. /**
  114654. * 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.
  114655. * * 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.
  114656. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114657. * * 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.
  114658. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  114659. * * 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
  114660. * * 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
  114661. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  114662. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114663. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114664. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  114665. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114666. * @param name defines the name of the mesh
  114667. * @param options defines the options used to create the mesh
  114668. * @param scene defines the hosting scene
  114669. * @returns the extruded shape mesh
  114670. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114671. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114672. */
  114673. static ExtrudeShape(name: string, options: {
  114674. shape: Vector3[];
  114675. path: Vector3[];
  114676. scale?: number;
  114677. rotation?: number;
  114678. cap?: number;
  114679. updatable?: boolean;
  114680. sideOrientation?: number;
  114681. frontUVs?: Vector4;
  114682. backUVs?: Vector4;
  114683. instance?: Mesh;
  114684. invertUV?: boolean;
  114685. }, scene?: Nullable<Scene>): Mesh;
  114686. /**
  114687. * Creates an custom extruded shape mesh.
  114688. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  114689. * * 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.
  114690. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  114691. * * 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
  114692. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  114693. * * 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
  114694. * * It must returns a float value that will be the scale value applied to the shape on each path point
  114695. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  114696. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  114697. * * 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
  114698. * * 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
  114699. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  114700. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114701. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114702. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114703. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114704. * @param name defines the name of the mesh
  114705. * @param options defines the options used to create the mesh
  114706. * @param scene defines the hosting scene
  114707. * @returns the custom extruded shape mesh
  114708. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  114709. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114710. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  114711. */
  114712. static ExtrudeShapeCustom(name: string, options: {
  114713. shape: Vector3[];
  114714. path: Vector3[];
  114715. scaleFunction?: any;
  114716. rotationFunction?: any;
  114717. ribbonCloseArray?: boolean;
  114718. ribbonClosePath?: boolean;
  114719. cap?: number;
  114720. updatable?: boolean;
  114721. sideOrientation?: number;
  114722. frontUVs?: Vector4;
  114723. backUVs?: Vector4;
  114724. instance?: Mesh;
  114725. invertUV?: boolean;
  114726. }, scene?: Nullable<Scene>): Mesh;
  114727. /**
  114728. * Creates lathe mesh.
  114729. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  114730. * * 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
  114731. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  114732. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  114733. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  114734. * * 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
  114735. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  114736. * * 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
  114737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114741. * @param name defines the name of the mesh
  114742. * @param options defines the options used to create the mesh
  114743. * @param scene defines the hosting scene
  114744. * @returns the lathe mesh
  114745. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  114746. */
  114747. static CreateLathe(name: string, options: {
  114748. shape: Vector3[];
  114749. radius?: number;
  114750. tessellation?: number;
  114751. clip?: number;
  114752. arc?: number;
  114753. closed?: boolean;
  114754. updatable?: boolean;
  114755. sideOrientation?: number;
  114756. frontUVs?: Vector4;
  114757. backUVs?: Vector4;
  114758. cap?: number;
  114759. invertUV?: boolean;
  114760. }, scene?: Nullable<Scene>): Mesh;
  114761. /**
  114762. * Creates a tiled plane mesh
  114763. * * You can set a limited pattern arrangement with the tiles
  114764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114767. * @param name defines the name of the mesh
  114768. * @param options defines the options used to create the mesh
  114769. * @param scene defines the hosting scene
  114770. * @returns the plane mesh
  114771. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  114772. */
  114773. static CreateTiledPlane(name: string, options: {
  114774. pattern?: number;
  114775. tileSize?: number;
  114776. tileWidth?: number;
  114777. tileHeight?: number;
  114778. size?: number;
  114779. width?: number;
  114780. height?: number;
  114781. alignHorizontal?: number;
  114782. alignVertical?: number;
  114783. sideOrientation?: number;
  114784. frontUVs?: Vector4;
  114785. backUVs?: Vector4;
  114786. updatable?: boolean;
  114787. }, scene?: Nullable<Scene>): Mesh;
  114788. /**
  114789. * Creates a plane mesh
  114790. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  114791. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  114792. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  114793. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114794. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114795. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114796. * @param name defines the name of the mesh
  114797. * @param options defines the options used to create the mesh
  114798. * @param scene defines the hosting scene
  114799. * @returns the plane mesh
  114800. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  114801. */
  114802. static CreatePlane(name: string, options: {
  114803. size?: number;
  114804. width?: number;
  114805. height?: number;
  114806. sideOrientation?: number;
  114807. frontUVs?: Vector4;
  114808. backUVs?: Vector4;
  114809. updatable?: boolean;
  114810. sourcePlane?: Plane;
  114811. }, scene?: Nullable<Scene>): Mesh;
  114812. /**
  114813. * Creates a ground mesh
  114814. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  114815. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  114816. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114817. * @param name defines the name of the mesh
  114818. * @param options defines the options used to create the mesh
  114819. * @param scene defines the hosting scene
  114820. * @returns the ground mesh
  114821. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  114822. */
  114823. static CreateGround(name: string, options: {
  114824. width?: number;
  114825. height?: number;
  114826. subdivisions?: number;
  114827. subdivisionsX?: number;
  114828. subdivisionsY?: number;
  114829. updatable?: boolean;
  114830. }, scene?: Nullable<Scene>): Mesh;
  114831. /**
  114832. * Creates a tiled ground mesh
  114833. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  114834. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  114835. * * 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
  114836. * * 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
  114837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114838. * @param name defines the name of the mesh
  114839. * @param options defines the options used to create the mesh
  114840. * @param scene defines the hosting scene
  114841. * @returns the tiled ground mesh
  114842. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  114843. */
  114844. static CreateTiledGround(name: string, options: {
  114845. xmin: number;
  114846. zmin: number;
  114847. xmax: number;
  114848. zmax: number;
  114849. subdivisions?: {
  114850. w: number;
  114851. h: number;
  114852. };
  114853. precision?: {
  114854. w: number;
  114855. h: number;
  114856. };
  114857. updatable?: boolean;
  114858. }, scene?: Nullable<Scene>): Mesh;
  114859. /**
  114860. * Creates a ground mesh from a height map
  114861. * * The parameter `url` sets the URL of the height map image resource.
  114862. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  114863. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  114864. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  114865. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  114866. * * 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.
  114867. * * 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).
  114868. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  114869. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  114870. * @param name defines the name of the mesh
  114871. * @param url defines the url to the height map
  114872. * @param options defines the options used to create the mesh
  114873. * @param scene defines the hosting scene
  114874. * @returns the ground mesh
  114875. * @see https://doc.babylonjs.com/babylon101/height_map
  114876. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  114877. */
  114878. static CreateGroundFromHeightMap(name: string, url: string, options: {
  114879. width?: number;
  114880. height?: number;
  114881. subdivisions?: number;
  114882. minHeight?: number;
  114883. maxHeight?: number;
  114884. colorFilter?: Color3;
  114885. alphaFilter?: number;
  114886. updatable?: boolean;
  114887. onReady?: (mesh: GroundMesh) => void;
  114888. }, scene?: Nullable<Scene>): GroundMesh;
  114889. /**
  114890. * Creates a polygon mesh
  114891. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  114892. * * 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
  114893. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  114894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114895. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  114896. * * Remember you can only change the shape positions, not their number when updating a polygon
  114897. * @param name defines the name of the mesh
  114898. * @param options defines the options used to create the mesh
  114899. * @param scene defines the hosting scene
  114900. * @param earcutInjection can be used to inject your own earcut reference
  114901. * @returns the polygon mesh
  114902. */
  114903. static CreatePolygon(name: string, options: {
  114904. shape: Vector3[];
  114905. holes?: Vector3[][];
  114906. depth?: number;
  114907. faceUV?: Vector4[];
  114908. faceColors?: Color4[];
  114909. updatable?: boolean;
  114910. sideOrientation?: number;
  114911. frontUVs?: Vector4;
  114912. backUVs?: Vector4;
  114913. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114914. /**
  114915. * Creates an extruded polygon mesh, with depth in the Y direction.
  114916. * * 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)
  114917. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  114918. * @param name defines the name of the mesh
  114919. * @param options defines the options used to create the mesh
  114920. * @param scene defines the hosting scene
  114921. * @param earcutInjection can be used to inject your own earcut reference
  114922. * @returns the polygon mesh
  114923. */
  114924. static ExtrudePolygon(name: string, options: {
  114925. shape: Vector3[];
  114926. holes?: Vector3[][];
  114927. depth?: number;
  114928. faceUV?: Vector4[];
  114929. faceColors?: Color4[];
  114930. updatable?: boolean;
  114931. sideOrientation?: number;
  114932. frontUVs?: Vector4;
  114933. backUVs?: Vector4;
  114934. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  114935. /**
  114936. * Creates a tube mesh.
  114937. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  114938. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  114939. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  114940. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  114941. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  114942. * * 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)
  114943. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  114944. * * 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
  114945. * * 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
  114946. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114947. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114948. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  114949. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114950. * @param name defines the name of the mesh
  114951. * @param options defines the options used to create the mesh
  114952. * @param scene defines the hosting scene
  114953. * @returns the tube mesh
  114954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  114955. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  114956. */
  114957. static CreateTube(name: string, options: {
  114958. path: Vector3[];
  114959. radius?: number;
  114960. tessellation?: number;
  114961. radiusFunction?: {
  114962. (i: number, distance: number): number;
  114963. };
  114964. cap?: number;
  114965. arc?: number;
  114966. updatable?: boolean;
  114967. sideOrientation?: number;
  114968. frontUVs?: Vector4;
  114969. backUVs?: Vector4;
  114970. instance?: Mesh;
  114971. invertUV?: boolean;
  114972. }, scene?: Nullable<Scene>): Mesh;
  114973. /**
  114974. * Creates a polyhedron mesh
  114975. * * 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
  114976. * * The parameter `size` (positive float, default 1) sets the polygon size
  114977. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  114978. * * 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`
  114979. * * 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
  114980. * * 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)`)
  114981. * * 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
  114982. * * 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
  114983. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  114984. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  114985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  114986. * @param name defines the name of the mesh
  114987. * @param options defines the options used to create the mesh
  114988. * @param scene defines the hosting scene
  114989. * @returns the polyhedron mesh
  114990. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  114991. */
  114992. static CreatePolyhedron(name: string, options: {
  114993. type?: number;
  114994. size?: number;
  114995. sizeX?: number;
  114996. sizeY?: number;
  114997. sizeZ?: number;
  114998. custom?: any;
  114999. faceUV?: Vector4[];
  115000. faceColors?: Color4[];
  115001. flat?: boolean;
  115002. updatable?: boolean;
  115003. sideOrientation?: number;
  115004. frontUVs?: Vector4;
  115005. backUVs?: Vector4;
  115006. }, scene?: Nullable<Scene>): Mesh;
  115007. /**
  115008. * Creates a decal mesh.
  115009. * 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
  115010. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  115011. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  115012. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  115013. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  115014. * @param name defines the name of the mesh
  115015. * @param sourceMesh defines the mesh where the decal must be applied
  115016. * @param options defines the options used to create the mesh
  115017. * @param scene defines the hosting scene
  115018. * @returns the decal mesh
  115019. * @see https://doc.babylonjs.com/how_to/decals
  115020. */
  115021. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  115022. position?: Vector3;
  115023. normal?: Vector3;
  115024. size?: Vector3;
  115025. angle?: number;
  115026. }): Mesh;
  115027. }
  115028. }
  115029. declare module BABYLON {
  115030. /**
  115031. * A simplifier interface for future simplification implementations
  115032. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115033. */
  115034. export interface ISimplifier {
  115035. /**
  115036. * Simplification of a given mesh according to the given settings.
  115037. * Since this requires computation, it is assumed that the function runs async.
  115038. * @param settings The settings of the simplification, including quality and distance
  115039. * @param successCallback A callback that will be called after the mesh was simplified.
  115040. * @param errorCallback in case of an error, this callback will be called. optional.
  115041. */
  115042. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  115043. }
  115044. /**
  115045. * Expected simplification settings.
  115046. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  115047. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115048. */
  115049. export interface ISimplificationSettings {
  115050. /**
  115051. * Gets or sets the expected quality
  115052. */
  115053. quality: number;
  115054. /**
  115055. * Gets or sets the distance when this optimized version should be used
  115056. */
  115057. distance: number;
  115058. /**
  115059. * Gets an already optimized mesh
  115060. */
  115061. optimizeMesh?: boolean;
  115062. }
  115063. /**
  115064. * Class used to specify simplification options
  115065. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115066. */
  115067. export class SimplificationSettings implements ISimplificationSettings {
  115068. /** expected quality */
  115069. quality: number;
  115070. /** distance when this optimized version should be used */
  115071. distance: number;
  115072. /** already optimized mesh */
  115073. optimizeMesh?: boolean | undefined;
  115074. /**
  115075. * Creates a SimplificationSettings
  115076. * @param quality expected quality
  115077. * @param distance distance when this optimized version should be used
  115078. * @param optimizeMesh already optimized mesh
  115079. */
  115080. constructor(
  115081. /** expected quality */
  115082. quality: number,
  115083. /** distance when this optimized version should be used */
  115084. distance: number,
  115085. /** already optimized mesh */
  115086. optimizeMesh?: boolean | undefined);
  115087. }
  115088. /**
  115089. * Interface used to define a simplification task
  115090. */
  115091. export interface ISimplificationTask {
  115092. /**
  115093. * Array of settings
  115094. */
  115095. settings: Array<ISimplificationSettings>;
  115096. /**
  115097. * Simplification type
  115098. */
  115099. simplificationType: SimplificationType;
  115100. /**
  115101. * Mesh to simplify
  115102. */
  115103. mesh: Mesh;
  115104. /**
  115105. * Callback called on success
  115106. */
  115107. successCallback?: () => void;
  115108. /**
  115109. * Defines if parallel processing can be used
  115110. */
  115111. parallelProcessing: boolean;
  115112. }
  115113. /**
  115114. * Queue used to order the simplification tasks
  115115. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115116. */
  115117. export class SimplificationQueue {
  115118. private _simplificationArray;
  115119. /**
  115120. * Gets a boolean indicating that the process is still running
  115121. */
  115122. running: boolean;
  115123. /**
  115124. * Creates a new queue
  115125. */
  115126. constructor();
  115127. /**
  115128. * Adds a new simplification task
  115129. * @param task defines a task to add
  115130. */
  115131. addTask(task: ISimplificationTask): void;
  115132. /**
  115133. * Execute next task
  115134. */
  115135. executeNext(): void;
  115136. /**
  115137. * Execute a simplification task
  115138. * @param task defines the task to run
  115139. */
  115140. runSimplification(task: ISimplificationTask): void;
  115141. private getSimplifier;
  115142. }
  115143. /**
  115144. * The implemented types of simplification
  115145. * At the moment only Quadratic Error Decimation is implemented
  115146. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115147. */
  115148. export enum SimplificationType {
  115149. /** Quadratic error decimation */
  115150. QUADRATIC = 0
  115151. }
  115152. }
  115153. declare module BABYLON {
  115154. interface Scene {
  115155. /** @hidden (Backing field) */
  115156. _simplificationQueue: SimplificationQueue;
  115157. /**
  115158. * Gets or sets the simplification queue attached to the scene
  115159. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  115160. */
  115161. simplificationQueue: SimplificationQueue;
  115162. }
  115163. interface Mesh {
  115164. /**
  115165. * Simplify the mesh according to the given array of settings.
  115166. * Function will return immediately and will simplify async
  115167. * @param settings a collection of simplification settings
  115168. * @param parallelProcessing should all levels calculate parallel or one after the other
  115169. * @param simplificationType the type of simplification to run
  115170. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  115171. * @returns the current mesh
  115172. */
  115173. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  115174. }
  115175. /**
  115176. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  115177. * created in a scene
  115178. */
  115179. export class SimplicationQueueSceneComponent implements ISceneComponent {
  115180. /**
  115181. * The component name helpfull to identify the component in the list of scene components.
  115182. */
  115183. readonly name: string;
  115184. /**
  115185. * The scene the component belongs to.
  115186. */
  115187. scene: Scene;
  115188. /**
  115189. * Creates a new instance of the component for the given scene
  115190. * @param scene Defines the scene to register the component in
  115191. */
  115192. constructor(scene: Scene);
  115193. /**
  115194. * Registers the component in a given scene
  115195. */
  115196. register(): void;
  115197. /**
  115198. * Rebuilds the elements related to this component in case of
  115199. * context lost for instance.
  115200. */
  115201. rebuild(): void;
  115202. /**
  115203. * Disposes the component and the associated ressources
  115204. */
  115205. dispose(): void;
  115206. private _beforeCameraUpdate;
  115207. }
  115208. }
  115209. declare module BABYLON {
  115210. /**
  115211. * Class used to enable access to IndexedDB
  115212. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  115213. */
  115214. export class Database implements IOfflineProvider {
  115215. private _callbackManifestChecked;
  115216. private _currentSceneUrl;
  115217. private _db;
  115218. private _enableSceneOffline;
  115219. private _enableTexturesOffline;
  115220. private _manifestVersionFound;
  115221. private _mustUpdateRessources;
  115222. private _hasReachedQuota;
  115223. private _isSupported;
  115224. private _idbFactory;
  115225. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  115226. private static IsUASupportingBlobStorage;
  115227. /**
  115228. * Gets a boolean indicating if Database storate is enabled (off by default)
  115229. */
  115230. static IDBStorageEnabled: boolean;
  115231. /**
  115232. * Gets a boolean indicating if scene must be saved in the database
  115233. */
  115234. readonly enableSceneOffline: boolean;
  115235. /**
  115236. * Gets a boolean indicating if textures must be saved in the database
  115237. */
  115238. readonly enableTexturesOffline: boolean;
  115239. /**
  115240. * Creates a new Database
  115241. * @param urlToScene defines the url to load the scene
  115242. * @param callbackManifestChecked defines the callback to use when manifest is checked
  115243. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  115244. */
  115245. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  115246. private static _ParseURL;
  115247. private static _ReturnFullUrlLocation;
  115248. private _checkManifestFile;
  115249. /**
  115250. * Open the database and make it available
  115251. * @param successCallback defines the callback to call on success
  115252. * @param errorCallback defines the callback to call on error
  115253. */
  115254. open(successCallback: () => void, errorCallback: () => void): void;
  115255. /**
  115256. * Loads an image from the database
  115257. * @param url defines the url to load from
  115258. * @param image defines the target DOM image
  115259. */
  115260. loadImage(url: string, image: HTMLImageElement): void;
  115261. private _loadImageFromDBAsync;
  115262. private _saveImageIntoDBAsync;
  115263. private _checkVersionFromDB;
  115264. private _loadVersionFromDBAsync;
  115265. private _saveVersionIntoDBAsync;
  115266. /**
  115267. * Loads a file from database
  115268. * @param url defines the URL to load from
  115269. * @param sceneLoaded defines a callback to call on success
  115270. * @param progressCallBack defines a callback to call when progress changed
  115271. * @param errorCallback defines a callback to call on error
  115272. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  115273. */
  115274. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  115275. private _loadFileAsync;
  115276. private _saveFileAsync;
  115277. /**
  115278. * Validates if xhr data is correct
  115279. * @param xhr defines the request to validate
  115280. * @param dataType defines the expected data type
  115281. * @returns true if data is correct
  115282. */
  115283. private static _ValidateXHRData;
  115284. }
  115285. }
  115286. declare module BABYLON {
  115287. /** @hidden */
  115288. export var gpuUpdateParticlesPixelShader: {
  115289. name: string;
  115290. shader: string;
  115291. };
  115292. }
  115293. declare module BABYLON {
  115294. /** @hidden */
  115295. export var gpuUpdateParticlesVertexShader: {
  115296. name: string;
  115297. shader: string;
  115298. };
  115299. }
  115300. declare module BABYLON {
  115301. /** @hidden */
  115302. export var clipPlaneFragmentDeclaration2: {
  115303. name: string;
  115304. shader: string;
  115305. };
  115306. }
  115307. declare module BABYLON {
  115308. /** @hidden */
  115309. export var gpuRenderParticlesPixelShader: {
  115310. name: string;
  115311. shader: string;
  115312. };
  115313. }
  115314. declare module BABYLON {
  115315. /** @hidden */
  115316. export var clipPlaneVertexDeclaration2: {
  115317. name: string;
  115318. shader: string;
  115319. };
  115320. }
  115321. declare module BABYLON {
  115322. /** @hidden */
  115323. export var gpuRenderParticlesVertexShader: {
  115324. name: string;
  115325. shader: string;
  115326. };
  115327. }
  115328. declare module BABYLON {
  115329. /**
  115330. * This represents a GPU particle system in Babylon
  115331. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  115332. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  115333. */
  115334. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  115335. /**
  115336. * The layer mask we are rendering the particles through.
  115337. */
  115338. layerMask: number;
  115339. private _capacity;
  115340. private _activeCount;
  115341. private _currentActiveCount;
  115342. private _accumulatedCount;
  115343. private _renderEffect;
  115344. private _updateEffect;
  115345. private _buffer0;
  115346. private _buffer1;
  115347. private _spriteBuffer;
  115348. private _updateVAO;
  115349. private _renderVAO;
  115350. private _targetIndex;
  115351. private _sourceBuffer;
  115352. private _targetBuffer;
  115353. private _engine;
  115354. private _currentRenderId;
  115355. private _started;
  115356. private _stopped;
  115357. private _timeDelta;
  115358. private _randomTexture;
  115359. private _randomTexture2;
  115360. private _attributesStrideSize;
  115361. private _updateEffectOptions;
  115362. private _randomTextureSize;
  115363. private _actualFrame;
  115364. private readonly _rawTextureWidth;
  115365. /**
  115366. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  115367. */
  115368. static readonly IsSupported: boolean;
  115369. /**
  115370. * An event triggered when the system is disposed.
  115371. */
  115372. onDisposeObservable: Observable<GPUParticleSystem>;
  115373. /**
  115374. * Gets the maximum number of particles active at the same time.
  115375. * @returns The max number of active particles.
  115376. */
  115377. getCapacity(): number;
  115378. /**
  115379. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  115380. * to override the particles.
  115381. */
  115382. forceDepthWrite: boolean;
  115383. /**
  115384. * Gets or set the number of active particles
  115385. */
  115386. activeParticleCount: number;
  115387. private _preWarmDone;
  115388. /**
  115389. * Is this system ready to be used/rendered
  115390. * @return true if the system is ready
  115391. */
  115392. isReady(): boolean;
  115393. /**
  115394. * Gets if the system has been started. (Note: this will still be true after stop is called)
  115395. * @returns True if it has been started, otherwise false.
  115396. */
  115397. isStarted(): boolean;
  115398. /**
  115399. * Starts the particle system and begins to emit
  115400. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  115401. */
  115402. start(delay?: number): void;
  115403. /**
  115404. * Stops the particle system.
  115405. */
  115406. stop(): void;
  115407. /**
  115408. * Remove all active particles
  115409. */
  115410. reset(): void;
  115411. /**
  115412. * Returns the string "GPUParticleSystem"
  115413. * @returns a string containing the class name
  115414. */
  115415. getClassName(): string;
  115416. private _colorGradientsTexture;
  115417. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  115418. /**
  115419. * Adds a new color gradient
  115420. * @param gradient defines the gradient to use (between 0 and 1)
  115421. * @param color1 defines the color to affect to the specified gradient
  115422. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  115423. * @returns the current particle system
  115424. */
  115425. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  115426. /**
  115427. * Remove a specific color gradient
  115428. * @param gradient defines the gradient to remove
  115429. * @returns the current particle system
  115430. */
  115431. removeColorGradient(gradient: number): GPUParticleSystem;
  115432. private _angularSpeedGradientsTexture;
  115433. private _sizeGradientsTexture;
  115434. private _velocityGradientsTexture;
  115435. private _limitVelocityGradientsTexture;
  115436. private _dragGradientsTexture;
  115437. private _addFactorGradient;
  115438. /**
  115439. * Adds a new size gradient
  115440. * @param gradient defines the gradient to use (between 0 and 1)
  115441. * @param factor defines the size factor to affect to the specified gradient
  115442. * @returns the current particle system
  115443. */
  115444. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  115445. /**
  115446. * Remove a specific size gradient
  115447. * @param gradient defines the gradient to remove
  115448. * @returns the current particle system
  115449. */
  115450. removeSizeGradient(gradient: number): GPUParticleSystem;
  115451. /**
  115452. * Adds a new angular speed gradient
  115453. * @param gradient defines the gradient to use (between 0 and 1)
  115454. * @param factor defines the angular speed to affect to the specified gradient
  115455. * @returns the current particle system
  115456. */
  115457. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  115458. /**
  115459. * Remove a specific angular speed gradient
  115460. * @param gradient defines the gradient to remove
  115461. * @returns the current particle system
  115462. */
  115463. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  115464. /**
  115465. * Adds a new velocity gradient
  115466. * @param gradient defines the gradient to use (between 0 and 1)
  115467. * @param factor defines the velocity to affect to the specified gradient
  115468. * @returns the current particle system
  115469. */
  115470. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  115471. /**
  115472. * Remove a specific velocity gradient
  115473. * @param gradient defines the gradient to remove
  115474. * @returns the current particle system
  115475. */
  115476. removeVelocityGradient(gradient: number): GPUParticleSystem;
  115477. /**
  115478. * Adds a new limit velocity gradient
  115479. * @param gradient defines the gradient to use (between 0 and 1)
  115480. * @param factor defines the limit velocity value to affect to the specified gradient
  115481. * @returns the current particle system
  115482. */
  115483. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  115484. /**
  115485. * Remove a specific limit velocity gradient
  115486. * @param gradient defines the gradient to remove
  115487. * @returns the current particle system
  115488. */
  115489. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  115490. /**
  115491. * Adds a new drag gradient
  115492. * @param gradient defines the gradient to use (between 0 and 1)
  115493. * @param factor defines the drag value to affect to the specified gradient
  115494. * @returns the current particle system
  115495. */
  115496. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  115497. /**
  115498. * Remove a specific drag gradient
  115499. * @param gradient defines the gradient to remove
  115500. * @returns the current particle system
  115501. */
  115502. removeDragGradient(gradient: number): GPUParticleSystem;
  115503. /**
  115504. * Not supported by GPUParticleSystem
  115505. * @param gradient defines the gradient to use (between 0 and 1)
  115506. * @param factor defines the emit rate value to affect to the specified gradient
  115507. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115508. * @returns the current particle system
  115509. */
  115510. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115511. /**
  115512. * Not supported by GPUParticleSystem
  115513. * @param gradient defines the gradient to remove
  115514. * @returns the current particle system
  115515. */
  115516. removeEmitRateGradient(gradient: number): IParticleSystem;
  115517. /**
  115518. * Not supported by GPUParticleSystem
  115519. * @param gradient defines the gradient to use (between 0 and 1)
  115520. * @param factor defines the start size value to affect to the specified gradient
  115521. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115522. * @returns the current particle system
  115523. */
  115524. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115525. /**
  115526. * Not supported by GPUParticleSystem
  115527. * @param gradient defines the gradient to remove
  115528. * @returns the current particle system
  115529. */
  115530. removeStartSizeGradient(gradient: number): IParticleSystem;
  115531. /**
  115532. * Not supported by GPUParticleSystem
  115533. * @param gradient defines the gradient to use (between 0 and 1)
  115534. * @param min defines the color remap minimal range
  115535. * @param max defines the color remap maximal range
  115536. * @returns the current particle system
  115537. */
  115538. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  115539. /**
  115540. * Not supported by GPUParticleSystem
  115541. * @param gradient defines the gradient to remove
  115542. * @returns the current particle system
  115543. */
  115544. removeColorRemapGradient(): IParticleSystem;
  115545. /**
  115546. * Not supported by GPUParticleSystem
  115547. * @param gradient defines the gradient to use (between 0 and 1)
  115548. * @param min defines the alpha remap minimal range
  115549. * @param max defines the alpha remap maximal range
  115550. * @returns the current particle system
  115551. */
  115552. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  115553. /**
  115554. * Not supported by GPUParticleSystem
  115555. * @param gradient defines the gradient to remove
  115556. * @returns the current particle system
  115557. */
  115558. removeAlphaRemapGradient(): IParticleSystem;
  115559. /**
  115560. * Not supported by GPUParticleSystem
  115561. * @param gradient defines the gradient to use (between 0 and 1)
  115562. * @param color defines the color to affect to the specified gradient
  115563. * @returns the current particle system
  115564. */
  115565. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  115566. /**
  115567. * Not supported by GPUParticleSystem
  115568. * @param gradient defines the gradient to remove
  115569. * @returns the current particle system
  115570. */
  115571. removeRampGradient(): IParticleSystem;
  115572. /**
  115573. * Not supported by GPUParticleSystem
  115574. * @returns the list of ramp gradients
  115575. */
  115576. getRampGradients(): Nullable<Array<Color3Gradient>>;
  115577. /**
  115578. * Not supported by GPUParticleSystem
  115579. * Gets or sets a boolean indicating that ramp gradients must be used
  115580. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  115581. */
  115582. useRampGradients: boolean;
  115583. /**
  115584. * Not supported by GPUParticleSystem
  115585. * @param gradient defines the gradient to use (between 0 and 1)
  115586. * @param factor defines the life time factor to affect to the specified gradient
  115587. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  115588. * @returns the current particle system
  115589. */
  115590. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  115591. /**
  115592. * Not supported by GPUParticleSystem
  115593. * @param gradient defines the gradient to remove
  115594. * @returns the current particle system
  115595. */
  115596. removeLifeTimeGradient(gradient: number): IParticleSystem;
  115597. /**
  115598. * Instantiates a GPU particle system.
  115599. * 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.
  115600. * @param name The name of the particle system
  115601. * @param options The options used to create the system
  115602. * @param scene The scene the particle system belongs to
  115603. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  115604. */
  115605. constructor(name: string, options: Partial<{
  115606. capacity: number;
  115607. randomTextureSize: number;
  115608. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  115609. protected _reset(): void;
  115610. private _createUpdateVAO;
  115611. private _createRenderVAO;
  115612. private _initialize;
  115613. /** @hidden */
  115614. _recreateUpdateEffect(): void;
  115615. /** @hidden */
  115616. _recreateRenderEffect(): void;
  115617. /**
  115618. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  115619. * @param preWarm defines if we are in the pre-warmimg phase
  115620. */
  115621. animate(preWarm?: boolean): void;
  115622. private _createFactorGradientTexture;
  115623. private _createSizeGradientTexture;
  115624. private _createAngularSpeedGradientTexture;
  115625. private _createVelocityGradientTexture;
  115626. private _createLimitVelocityGradientTexture;
  115627. private _createDragGradientTexture;
  115628. private _createColorGradientTexture;
  115629. /**
  115630. * Renders the particle system in its current state
  115631. * @param preWarm defines if the system should only update the particles but not render them
  115632. * @returns the current number of particles
  115633. */
  115634. render(preWarm?: boolean): number;
  115635. /**
  115636. * Rebuilds the particle system
  115637. */
  115638. rebuild(): void;
  115639. private _releaseBuffers;
  115640. private _releaseVAOs;
  115641. /**
  115642. * Disposes the particle system and free the associated resources
  115643. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  115644. */
  115645. dispose(disposeTexture?: boolean): void;
  115646. /**
  115647. * Clones the particle system.
  115648. * @param name The name of the cloned object
  115649. * @param newEmitter The new emitter to use
  115650. * @returns the cloned particle system
  115651. */
  115652. clone(name: string, newEmitter: any): GPUParticleSystem;
  115653. /**
  115654. * Serializes the particle system to a JSON object.
  115655. * @returns the JSON object
  115656. */
  115657. serialize(): any;
  115658. /**
  115659. * Parses a JSON object to create a GPU particle system.
  115660. * @param parsedParticleSystem The JSON object to parse
  115661. * @param scene The scene to create the particle system in
  115662. * @param rootUrl The root url to use to load external dependencies like texture
  115663. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  115664. * @returns the parsed GPU particle system
  115665. */
  115666. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  115667. }
  115668. }
  115669. declare module BABYLON {
  115670. /**
  115671. * Represents a set of particle systems working together to create a specific effect
  115672. */
  115673. export class ParticleSystemSet implements IDisposable {
  115674. private _emitterCreationOptions;
  115675. private _emitterNode;
  115676. /**
  115677. * Gets the particle system list
  115678. */
  115679. systems: IParticleSystem[];
  115680. /**
  115681. * Gets the emitter node used with this set
  115682. */
  115683. readonly emitterNode: Nullable<TransformNode>;
  115684. /**
  115685. * Creates a new emitter mesh as a sphere
  115686. * @param options defines the options used to create the sphere
  115687. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  115688. * @param scene defines the hosting scene
  115689. */
  115690. setEmitterAsSphere(options: {
  115691. diameter: number;
  115692. segments: number;
  115693. color: Color3;
  115694. }, renderingGroupId: number, scene: Scene): void;
  115695. /**
  115696. * Starts all particle systems of the set
  115697. * @param emitter defines an optional mesh to use as emitter for the particle systems
  115698. */
  115699. start(emitter?: AbstractMesh): void;
  115700. /**
  115701. * Release all associated resources
  115702. */
  115703. dispose(): void;
  115704. /**
  115705. * Serialize the set into a JSON compatible object
  115706. * @returns a JSON compatible representation of the set
  115707. */
  115708. serialize(): any;
  115709. /**
  115710. * Parse a new ParticleSystemSet from a serialized source
  115711. * @param data defines a JSON compatible representation of the set
  115712. * @param scene defines the hosting scene
  115713. * @param gpu defines if we want GPU particles or CPU particles
  115714. * @returns a new ParticleSystemSet
  115715. */
  115716. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  115717. }
  115718. }
  115719. declare module BABYLON {
  115720. /**
  115721. * This class is made for on one-liner static method to help creating particle system set.
  115722. */
  115723. export class ParticleHelper {
  115724. /**
  115725. * Gets or sets base Assets URL
  115726. */
  115727. static BaseAssetsUrl: string;
  115728. /**
  115729. * Create a default particle system that you can tweak
  115730. * @param emitter defines the emitter to use
  115731. * @param capacity defines the system capacity (default is 500 particles)
  115732. * @param scene defines the hosting scene
  115733. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  115734. * @returns the new Particle system
  115735. */
  115736. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  115737. /**
  115738. * This is the main static method (one-liner) of this helper to create different particle systems
  115739. * @param type This string represents the type to the particle system to create
  115740. * @param scene The scene where the particle system should live
  115741. * @param gpu If the system will use gpu
  115742. * @returns the ParticleSystemSet created
  115743. */
  115744. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  115745. /**
  115746. * Static function used to export a particle system to a ParticleSystemSet variable.
  115747. * Please note that the emitter shape is not exported
  115748. * @param systems defines the particle systems to export
  115749. * @returns the created particle system set
  115750. */
  115751. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  115752. }
  115753. }
  115754. declare module BABYLON {
  115755. interface Engine {
  115756. /**
  115757. * Create an effect to use with particle systems.
  115758. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  115759. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  115760. * @param uniformsNames defines a list of attribute names
  115761. * @param samplers defines an array of string used to represent textures
  115762. * @param defines defines the string containing the defines to use to compile the shaders
  115763. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  115764. * @param onCompiled defines a function to call when the effect creation is successful
  115765. * @param onError defines a function to call when the effect creation has failed
  115766. * @returns the new Effect
  115767. */
  115768. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  115769. }
  115770. interface Mesh {
  115771. /**
  115772. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  115773. * @returns an array of IParticleSystem
  115774. */
  115775. getEmittedParticleSystems(): IParticleSystem[];
  115776. /**
  115777. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  115778. * @returns an array of IParticleSystem
  115779. */
  115780. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  115781. }
  115782. /**
  115783. * @hidden
  115784. */
  115785. export var _IDoNeedToBeInTheBuild: number;
  115786. }
  115787. declare module BABYLON {
  115788. interface Scene {
  115789. /** @hidden (Backing field) */
  115790. _physicsEngine: Nullable<IPhysicsEngine>;
  115791. /**
  115792. * Gets the current physics engine
  115793. * @returns a IPhysicsEngine or null if none attached
  115794. */
  115795. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  115796. /**
  115797. * Enables physics to the current scene
  115798. * @param gravity defines the scene's gravity for the physics engine
  115799. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  115800. * @return a boolean indicating if the physics engine was initialized
  115801. */
  115802. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  115803. /**
  115804. * Disables and disposes the physics engine associated with the scene
  115805. */
  115806. disablePhysicsEngine(): void;
  115807. /**
  115808. * Gets a boolean indicating if there is an active physics engine
  115809. * @returns a boolean indicating if there is an active physics engine
  115810. */
  115811. isPhysicsEnabled(): boolean;
  115812. /**
  115813. * Deletes a physics compound impostor
  115814. * @param compound defines the compound to delete
  115815. */
  115816. deleteCompoundImpostor(compound: any): void;
  115817. /**
  115818. * An event triggered when physic simulation is about to be run
  115819. */
  115820. onBeforePhysicsObservable: Observable<Scene>;
  115821. /**
  115822. * An event triggered when physic simulation has been done
  115823. */
  115824. onAfterPhysicsObservable: Observable<Scene>;
  115825. }
  115826. interface AbstractMesh {
  115827. /** @hidden */
  115828. _physicsImpostor: Nullable<PhysicsImpostor>;
  115829. /**
  115830. * Gets or sets impostor used for physic simulation
  115831. * @see http://doc.babylonjs.com/features/physics_engine
  115832. */
  115833. physicsImpostor: Nullable<PhysicsImpostor>;
  115834. /**
  115835. * Gets the current physics impostor
  115836. * @see http://doc.babylonjs.com/features/physics_engine
  115837. * @returns a physics impostor or null
  115838. */
  115839. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  115840. /** Apply a physic impulse to the mesh
  115841. * @param force defines the force to apply
  115842. * @param contactPoint defines where to apply the force
  115843. * @returns the current mesh
  115844. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  115845. */
  115846. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  115847. /**
  115848. * Creates a physic joint between two meshes
  115849. * @param otherMesh defines the other mesh to use
  115850. * @param pivot1 defines the pivot to use on this mesh
  115851. * @param pivot2 defines the pivot to use on the other mesh
  115852. * @param options defines additional options (can be plugin dependent)
  115853. * @returns the current mesh
  115854. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  115855. */
  115856. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  115857. /** @hidden */
  115858. _disposePhysicsObserver: Nullable<Observer<Node>>;
  115859. }
  115860. /**
  115861. * Defines the physics engine scene component responsible to manage a physics engine
  115862. */
  115863. export class PhysicsEngineSceneComponent implements ISceneComponent {
  115864. /**
  115865. * The component name helpful to identify the component in the list of scene components.
  115866. */
  115867. readonly name: string;
  115868. /**
  115869. * The scene the component belongs to.
  115870. */
  115871. scene: Scene;
  115872. /**
  115873. * Creates a new instance of the component for the given scene
  115874. * @param scene Defines the scene to register the component in
  115875. */
  115876. constructor(scene: Scene);
  115877. /**
  115878. * Registers the component in a given scene
  115879. */
  115880. register(): void;
  115881. /**
  115882. * Rebuilds the elements related to this component in case of
  115883. * context lost for instance.
  115884. */
  115885. rebuild(): void;
  115886. /**
  115887. * Disposes the component and the associated ressources
  115888. */
  115889. dispose(): void;
  115890. }
  115891. }
  115892. declare module BABYLON {
  115893. /**
  115894. * A helper for physics simulations
  115895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  115896. */
  115897. export class PhysicsHelper {
  115898. private _scene;
  115899. private _physicsEngine;
  115900. /**
  115901. * Initializes the Physics helper
  115902. * @param scene Babylon.js scene
  115903. */
  115904. constructor(scene: Scene);
  115905. /**
  115906. * Applies a radial explosion impulse
  115907. * @param origin the origin of the explosion
  115908. * @param radiusOrEventOptions the radius or the options of radial explosion
  115909. * @param strength the explosion strength
  115910. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115911. * @returns A physics radial explosion event, or null
  115912. */
  115913. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  115914. /**
  115915. * Applies a radial explosion force
  115916. * @param origin the origin of the explosion
  115917. * @param radiusOrEventOptions the radius or the options of radial explosion
  115918. * @param strength the explosion strength
  115919. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115920. * @returns A physics radial explosion event, or null
  115921. */
  115922. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  115923. /**
  115924. * Creates a gravitational field
  115925. * @param origin the origin of the explosion
  115926. * @param radiusOrEventOptions the radius or the options of radial explosion
  115927. * @param strength the explosion strength
  115928. * @param falloff possible options: Constant & Linear. Defaults to Constant
  115929. * @returns A physics gravitational field event, or null
  115930. */
  115931. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  115932. /**
  115933. * Creates a physics updraft event
  115934. * @param origin the origin of the updraft
  115935. * @param radiusOrEventOptions the radius or the options of the updraft
  115936. * @param strength the strength of the updraft
  115937. * @param height the height of the updraft
  115938. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  115939. * @returns A physics updraft event, or null
  115940. */
  115941. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  115942. /**
  115943. * Creates a physics vortex event
  115944. * @param origin the of the vortex
  115945. * @param radiusOrEventOptions the radius or the options of the vortex
  115946. * @param strength the strength of the vortex
  115947. * @param height the height of the vortex
  115948. * @returns a Physics vortex event, or null
  115949. * A physics vortex event or null
  115950. */
  115951. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  115952. }
  115953. /**
  115954. * Represents a physics radial explosion event
  115955. */
  115956. class PhysicsRadialExplosionEvent {
  115957. private _scene;
  115958. private _options;
  115959. private _sphere;
  115960. private _dataFetched;
  115961. /**
  115962. * Initializes a radial explosioin event
  115963. * @param _scene BabylonJS scene
  115964. * @param _options The options for the vortex event
  115965. */
  115966. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  115967. /**
  115968. * Returns the data related to the radial explosion event (sphere).
  115969. * @returns The radial explosion event data
  115970. */
  115971. getData(): PhysicsRadialExplosionEventData;
  115972. /**
  115973. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  115974. * @param impostor A physics imposter
  115975. * @param origin the origin of the explosion
  115976. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  115977. */
  115978. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  115979. /**
  115980. * Triggers affecterd impostors callbacks
  115981. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  115982. */
  115983. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  115984. /**
  115985. * Disposes the sphere.
  115986. * @param force Specifies if the sphere should be disposed by force
  115987. */
  115988. dispose(force?: boolean): void;
  115989. /*** Helpers ***/
  115990. private _prepareSphere;
  115991. private _intersectsWithSphere;
  115992. }
  115993. /**
  115994. * Represents a gravitational field event
  115995. */
  115996. class PhysicsGravitationalFieldEvent {
  115997. private _physicsHelper;
  115998. private _scene;
  115999. private _origin;
  116000. private _options;
  116001. private _tickCallback;
  116002. private _sphere;
  116003. private _dataFetched;
  116004. /**
  116005. * Initializes the physics gravitational field event
  116006. * @param _physicsHelper A physics helper
  116007. * @param _scene BabylonJS scene
  116008. * @param _origin The origin position of the gravitational field event
  116009. * @param _options The options for the vortex event
  116010. */
  116011. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  116012. /**
  116013. * Returns the data related to the gravitational field event (sphere).
  116014. * @returns A gravitational field event
  116015. */
  116016. getData(): PhysicsGravitationalFieldEventData;
  116017. /**
  116018. * Enables the gravitational field.
  116019. */
  116020. enable(): void;
  116021. /**
  116022. * Disables the gravitational field.
  116023. */
  116024. disable(): void;
  116025. /**
  116026. * Disposes the sphere.
  116027. * @param force The force to dispose from the gravitational field event
  116028. */
  116029. dispose(force?: boolean): void;
  116030. private _tick;
  116031. }
  116032. /**
  116033. * Represents a physics updraft event
  116034. */
  116035. class PhysicsUpdraftEvent {
  116036. private _scene;
  116037. private _origin;
  116038. private _options;
  116039. private _physicsEngine;
  116040. private _originTop;
  116041. private _originDirection;
  116042. private _tickCallback;
  116043. private _cylinder;
  116044. private _cylinderPosition;
  116045. private _dataFetched;
  116046. /**
  116047. * Initializes the physics updraft event
  116048. * @param _scene BabylonJS scene
  116049. * @param _origin The origin position of the updraft
  116050. * @param _options The options for the updraft event
  116051. */
  116052. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  116053. /**
  116054. * Returns the data related to the updraft event (cylinder).
  116055. * @returns A physics updraft event
  116056. */
  116057. getData(): PhysicsUpdraftEventData;
  116058. /**
  116059. * Enables the updraft.
  116060. */
  116061. enable(): void;
  116062. /**
  116063. * Disables the updraft.
  116064. */
  116065. disable(): void;
  116066. /**
  116067. * Disposes the cylinder.
  116068. * @param force Specifies if the updraft should be disposed by force
  116069. */
  116070. dispose(force?: boolean): void;
  116071. private getImpostorHitData;
  116072. private _tick;
  116073. /*** Helpers ***/
  116074. private _prepareCylinder;
  116075. private _intersectsWithCylinder;
  116076. }
  116077. /**
  116078. * Represents a physics vortex event
  116079. */
  116080. class PhysicsVortexEvent {
  116081. private _scene;
  116082. private _origin;
  116083. private _options;
  116084. private _physicsEngine;
  116085. private _originTop;
  116086. private _tickCallback;
  116087. private _cylinder;
  116088. private _cylinderPosition;
  116089. private _dataFetched;
  116090. /**
  116091. * Initializes the physics vortex event
  116092. * @param _scene The BabylonJS scene
  116093. * @param _origin The origin position of the vortex
  116094. * @param _options The options for the vortex event
  116095. */
  116096. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  116097. /**
  116098. * Returns the data related to the vortex event (cylinder).
  116099. * @returns The physics vortex event data
  116100. */
  116101. getData(): PhysicsVortexEventData;
  116102. /**
  116103. * Enables the vortex.
  116104. */
  116105. enable(): void;
  116106. /**
  116107. * Disables the cortex.
  116108. */
  116109. disable(): void;
  116110. /**
  116111. * Disposes the sphere.
  116112. * @param force
  116113. */
  116114. dispose(force?: boolean): void;
  116115. private getImpostorHitData;
  116116. private _tick;
  116117. /*** Helpers ***/
  116118. private _prepareCylinder;
  116119. private _intersectsWithCylinder;
  116120. }
  116121. /**
  116122. * Options fot the radial explosion event
  116123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116124. */
  116125. export class PhysicsRadialExplosionEventOptions {
  116126. /**
  116127. * The radius of the sphere for the radial explosion.
  116128. */
  116129. radius: number;
  116130. /**
  116131. * The strenth of the explosion.
  116132. */
  116133. strength: number;
  116134. /**
  116135. * The strenght of the force in correspondence to the distance of the affected object
  116136. */
  116137. falloff: PhysicsRadialImpulseFalloff;
  116138. /**
  116139. * Sphere options for the radial explosion.
  116140. */
  116141. sphere: {
  116142. segments: number;
  116143. diameter: number;
  116144. };
  116145. /**
  116146. * Sphere options for the radial explosion.
  116147. */
  116148. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  116149. }
  116150. /**
  116151. * Options fot the updraft event
  116152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116153. */
  116154. export class PhysicsUpdraftEventOptions {
  116155. /**
  116156. * The radius of the cylinder for the vortex
  116157. */
  116158. radius: number;
  116159. /**
  116160. * The strenth of the updraft.
  116161. */
  116162. strength: number;
  116163. /**
  116164. * The height of the cylinder for the updraft.
  116165. */
  116166. height: number;
  116167. /**
  116168. * The mode for the the updraft.
  116169. */
  116170. updraftMode: PhysicsUpdraftMode;
  116171. }
  116172. /**
  116173. * Options fot the vortex event
  116174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116175. */
  116176. export class PhysicsVortexEventOptions {
  116177. /**
  116178. * The radius of the cylinder for the vortex
  116179. */
  116180. radius: number;
  116181. /**
  116182. * The strenth of the vortex.
  116183. */
  116184. strength: number;
  116185. /**
  116186. * The height of the cylinder for the vortex.
  116187. */
  116188. height: number;
  116189. /**
  116190. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  116191. */
  116192. centripetalForceThreshold: number;
  116193. /**
  116194. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  116195. */
  116196. centripetalForceMultiplier: number;
  116197. /**
  116198. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  116199. */
  116200. centrifugalForceMultiplier: number;
  116201. /**
  116202. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  116203. */
  116204. updraftForceMultiplier: number;
  116205. }
  116206. /**
  116207. * The strenght of the force in correspondence to the distance of the affected object
  116208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116209. */
  116210. export enum PhysicsRadialImpulseFalloff {
  116211. /** Defines that impulse is constant in strength across it's whole radius */
  116212. Constant = 0,
  116213. /** Defines that impulse gets weaker if it's further from the origin */
  116214. Linear = 1
  116215. }
  116216. /**
  116217. * The strength of the force in correspondence to the distance of the affected object
  116218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116219. */
  116220. export enum PhysicsUpdraftMode {
  116221. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  116222. Center = 0,
  116223. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  116224. Perpendicular = 1
  116225. }
  116226. /**
  116227. * Interface for a physics hit data
  116228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116229. */
  116230. export interface PhysicsHitData {
  116231. /**
  116232. * The force applied at the contact point
  116233. */
  116234. force: Vector3;
  116235. /**
  116236. * The contact point
  116237. */
  116238. contactPoint: Vector3;
  116239. /**
  116240. * The distance from the origin to the contact point
  116241. */
  116242. distanceFromOrigin: number;
  116243. }
  116244. /**
  116245. * Interface for radial explosion event data
  116246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116247. */
  116248. export interface PhysicsRadialExplosionEventData {
  116249. /**
  116250. * A sphere used for the radial explosion event
  116251. */
  116252. sphere: Mesh;
  116253. }
  116254. /**
  116255. * Interface for gravitational field event data
  116256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116257. */
  116258. export interface PhysicsGravitationalFieldEventData {
  116259. /**
  116260. * A sphere mesh used for the gravitational field event
  116261. */
  116262. sphere: Mesh;
  116263. }
  116264. /**
  116265. * Interface for updraft event data
  116266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116267. */
  116268. export interface PhysicsUpdraftEventData {
  116269. /**
  116270. * A cylinder used for the updraft event
  116271. */
  116272. cylinder: Mesh;
  116273. }
  116274. /**
  116275. * Interface for vortex event data
  116276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116277. */
  116278. export interface PhysicsVortexEventData {
  116279. /**
  116280. * A cylinder used for the vortex event
  116281. */
  116282. cylinder: Mesh;
  116283. }
  116284. /**
  116285. * Interface for an affected physics impostor
  116286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  116287. */
  116288. export interface PhysicsAffectedImpostorWithData {
  116289. /**
  116290. * The impostor affected by the effect
  116291. */
  116292. impostor: PhysicsImpostor;
  116293. /**
  116294. * The data about the hit/horce from the explosion
  116295. */
  116296. hitData: PhysicsHitData;
  116297. }
  116298. }
  116299. declare module BABYLON {
  116300. /** @hidden */
  116301. export var blackAndWhitePixelShader: {
  116302. name: string;
  116303. shader: string;
  116304. };
  116305. }
  116306. declare module BABYLON {
  116307. /**
  116308. * Post process used to render in black and white
  116309. */
  116310. export class BlackAndWhitePostProcess extends PostProcess {
  116311. /**
  116312. * Linear about to convert he result to black and white (default: 1)
  116313. */
  116314. degree: number;
  116315. /**
  116316. * Creates a black and white post process
  116317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  116318. * @param name The name of the effect.
  116319. * @param options The required width/height ratio to downsize to before computing the render pass.
  116320. * @param camera The camera to apply the render pass to.
  116321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116322. * @param engine The engine which the post process will be applied. (default: current engine)
  116323. * @param reusable If the post process can be reused on the same frame. (default: false)
  116324. */
  116325. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116326. }
  116327. }
  116328. declare module BABYLON {
  116329. /**
  116330. * This represents a set of one or more post processes in Babylon.
  116331. * A post process can be used to apply a shader to a texture after it is rendered.
  116332. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116333. */
  116334. export class PostProcessRenderEffect {
  116335. private _postProcesses;
  116336. private _getPostProcesses;
  116337. private _singleInstance;
  116338. private _cameras;
  116339. private _indicesForCamera;
  116340. /**
  116341. * Name of the effect
  116342. * @hidden
  116343. */
  116344. _name: string;
  116345. /**
  116346. * Instantiates a post process render effect.
  116347. * A post process can be used to apply a shader to a texture after it is rendered.
  116348. * @param engine The engine the effect is tied to
  116349. * @param name The name of the effect
  116350. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  116351. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  116352. */
  116353. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  116354. /**
  116355. * Checks if all the post processes in the effect are supported.
  116356. */
  116357. readonly isSupported: boolean;
  116358. /**
  116359. * Updates the current state of the effect
  116360. * @hidden
  116361. */
  116362. _update(): void;
  116363. /**
  116364. * Attaches the effect on cameras
  116365. * @param cameras The camera to attach to.
  116366. * @hidden
  116367. */
  116368. _attachCameras(cameras: Camera): void;
  116369. /**
  116370. * Attaches the effect on cameras
  116371. * @param cameras The camera to attach to.
  116372. * @hidden
  116373. */
  116374. _attachCameras(cameras: Camera[]): void;
  116375. /**
  116376. * Detaches the effect on cameras
  116377. * @param cameras The camera to detatch from.
  116378. * @hidden
  116379. */
  116380. _detachCameras(cameras: Camera): void;
  116381. /**
  116382. * Detatches the effect on cameras
  116383. * @param cameras The camera to detatch from.
  116384. * @hidden
  116385. */
  116386. _detachCameras(cameras: Camera[]): void;
  116387. /**
  116388. * Enables the effect on given cameras
  116389. * @param cameras The camera to enable.
  116390. * @hidden
  116391. */
  116392. _enable(cameras: Camera): void;
  116393. /**
  116394. * Enables the effect on given cameras
  116395. * @param cameras The camera to enable.
  116396. * @hidden
  116397. */
  116398. _enable(cameras: Nullable<Camera[]>): void;
  116399. /**
  116400. * Disables the effect on the given cameras
  116401. * @param cameras The camera to disable.
  116402. * @hidden
  116403. */
  116404. _disable(cameras: Camera): void;
  116405. /**
  116406. * Disables the effect on the given cameras
  116407. * @param cameras The camera to disable.
  116408. * @hidden
  116409. */
  116410. _disable(cameras: Nullable<Camera[]>): void;
  116411. /**
  116412. * Gets a list of the post processes contained in the effect.
  116413. * @param camera The camera to get the post processes on.
  116414. * @returns The list of the post processes in the effect.
  116415. */
  116416. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  116417. }
  116418. }
  116419. declare module BABYLON {
  116420. /** @hidden */
  116421. export var extractHighlightsPixelShader: {
  116422. name: string;
  116423. shader: string;
  116424. };
  116425. }
  116426. declare module BABYLON {
  116427. /**
  116428. * 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.
  116429. */
  116430. export class ExtractHighlightsPostProcess extends PostProcess {
  116431. /**
  116432. * The luminance threshold, pixels below this value will be set to black.
  116433. */
  116434. threshold: number;
  116435. /** @hidden */
  116436. _exposure: number;
  116437. /**
  116438. * Post process which has the input texture to be used when performing highlight extraction
  116439. * @hidden
  116440. */
  116441. _inputPostProcess: Nullable<PostProcess>;
  116442. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116443. }
  116444. }
  116445. declare module BABYLON {
  116446. /** @hidden */
  116447. export var bloomMergePixelShader: {
  116448. name: string;
  116449. shader: string;
  116450. };
  116451. }
  116452. declare module BABYLON {
  116453. /**
  116454. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116455. */
  116456. export class BloomMergePostProcess extends PostProcess {
  116457. /** Weight of the bloom to be added to the original input. */
  116458. weight: number;
  116459. /**
  116460. * Creates a new instance of @see BloomMergePostProcess
  116461. * @param name The name of the effect.
  116462. * @param originalFromInput Post process which's input will be used for the merge.
  116463. * @param blurred Blurred highlights post process which's output will be used.
  116464. * @param weight Weight of the bloom to be added to the original input.
  116465. * @param options The required width/height ratio to downsize to before computing the render pass.
  116466. * @param camera The camera to apply the render pass to.
  116467. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116468. * @param engine The engine which the post process will be applied. (default: current engine)
  116469. * @param reusable If the post process can be reused on the same frame. (default: false)
  116470. * @param textureType Type of textures used when performing the post process. (default: 0)
  116471. * @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)
  116472. */
  116473. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  116474. /** Weight of the bloom to be added to the original input. */
  116475. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116476. }
  116477. }
  116478. declare module BABYLON {
  116479. /**
  116480. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  116481. */
  116482. export class BloomEffect extends PostProcessRenderEffect {
  116483. private bloomScale;
  116484. /**
  116485. * @hidden Internal
  116486. */
  116487. _effects: Array<PostProcess>;
  116488. /**
  116489. * @hidden Internal
  116490. */
  116491. _downscale: ExtractHighlightsPostProcess;
  116492. private _blurX;
  116493. private _blurY;
  116494. private _merge;
  116495. /**
  116496. * The luminance threshold to find bright areas of the image to bloom.
  116497. */
  116498. threshold: number;
  116499. /**
  116500. * The strength of the bloom.
  116501. */
  116502. weight: number;
  116503. /**
  116504. * Specifies the size of the bloom blur kernel, relative to the final output size
  116505. */
  116506. kernel: number;
  116507. /**
  116508. * Creates a new instance of @see BloomEffect
  116509. * @param scene The scene the effect belongs to.
  116510. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  116511. * @param bloomKernel The size of the kernel to be used when applying the blur.
  116512. * @param bloomWeight The the strength of bloom.
  116513. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116514. * @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)
  116515. */
  116516. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  116517. /**
  116518. * Disposes each of the internal effects for a given camera.
  116519. * @param camera The camera to dispose the effect on.
  116520. */
  116521. disposeEffects(camera: Camera): void;
  116522. /**
  116523. * @hidden Internal
  116524. */
  116525. _updateEffects(): void;
  116526. /**
  116527. * Internal
  116528. * @returns if all the contained post processes are ready.
  116529. * @hidden
  116530. */
  116531. _isReady(): boolean;
  116532. }
  116533. }
  116534. declare module BABYLON {
  116535. /** @hidden */
  116536. export var chromaticAberrationPixelShader: {
  116537. name: string;
  116538. shader: string;
  116539. };
  116540. }
  116541. declare module BABYLON {
  116542. /**
  116543. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  116544. */
  116545. export class ChromaticAberrationPostProcess extends PostProcess {
  116546. /**
  116547. * The amount of seperation of rgb channels (default: 30)
  116548. */
  116549. aberrationAmount: number;
  116550. /**
  116551. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  116552. */
  116553. radialIntensity: number;
  116554. /**
  116555. * 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))
  116556. */
  116557. direction: Vector2;
  116558. /**
  116559. * 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))
  116560. */
  116561. centerPosition: Vector2;
  116562. /**
  116563. * Creates a new instance ChromaticAberrationPostProcess
  116564. * @param name The name of the effect.
  116565. * @param screenWidth The width of the screen to apply the effect on.
  116566. * @param screenHeight The height of the screen to apply the effect on.
  116567. * @param options The required width/height ratio to downsize to before computing the render pass.
  116568. * @param camera The camera to apply the render pass to.
  116569. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116570. * @param engine The engine which the post process will be applied. (default: current engine)
  116571. * @param reusable If the post process can be reused on the same frame. (default: false)
  116572. * @param textureType Type of textures used when performing the post process. (default: 0)
  116573. * @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)
  116574. */
  116575. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116576. }
  116577. }
  116578. declare module BABYLON {
  116579. /** @hidden */
  116580. export var circleOfConfusionPixelShader: {
  116581. name: string;
  116582. shader: string;
  116583. };
  116584. }
  116585. declare module BABYLON {
  116586. /**
  116587. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  116588. */
  116589. export class CircleOfConfusionPostProcess extends PostProcess {
  116590. /**
  116591. * 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.
  116592. */
  116593. lensSize: number;
  116594. /**
  116595. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116596. */
  116597. fStop: number;
  116598. /**
  116599. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116600. */
  116601. focusDistance: number;
  116602. /**
  116603. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  116604. */
  116605. focalLength: number;
  116606. private _depthTexture;
  116607. /**
  116608. * Creates a new instance CircleOfConfusionPostProcess
  116609. * @param name The name of the effect.
  116610. * @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.
  116611. * @param options The required width/height ratio to downsize to before computing the render pass.
  116612. * @param camera The camera to apply the render pass to.
  116613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116614. * @param engine The engine which the post process will be applied. (default: current engine)
  116615. * @param reusable If the post process can be reused on the same frame. (default: false)
  116616. * @param textureType Type of textures used when performing the post process. (default: 0)
  116617. * @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)
  116618. */
  116619. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116620. /**
  116621. * 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.
  116622. */
  116623. depthTexture: RenderTargetTexture;
  116624. }
  116625. }
  116626. declare module BABYLON {
  116627. /** @hidden */
  116628. export var colorCorrectionPixelShader: {
  116629. name: string;
  116630. shader: string;
  116631. };
  116632. }
  116633. declare module BABYLON {
  116634. /**
  116635. *
  116636. * This post-process allows the modification of rendered colors by using
  116637. * a 'look-up table' (LUT). This effect is also called Color Grading.
  116638. *
  116639. * The object needs to be provided an url to a texture containing the color
  116640. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  116641. * Use an image editing software to tweak the LUT to match your needs.
  116642. *
  116643. * For an example of a color LUT, see here:
  116644. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  116645. * For explanations on color grading, see here:
  116646. * @see http://udn.epicgames.com/Three/ColorGrading.html
  116647. *
  116648. */
  116649. export class ColorCorrectionPostProcess extends PostProcess {
  116650. private _colorTableTexture;
  116651. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116652. }
  116653. }
  116654. declare module BABYLON {
  116655. /** @hidden */
  116656. export var convolutionPixelShader: {
  116657. name: string;
  116658. shader: string;
  116659. };
  116660. }
  116661. declare module BABYLON {
  116662. /**
  116663. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  116664. * input texture to perform effects such as edge detection or sharpening
  116665. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  116666. */
  116667. export class ConvolutionPostProcess extends PostProcess {
  116668. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  116669. kernel: number[];
  116670. /**
  116671. * Creates a new instance ConvolutionPostProcess
  116672. * @param name The name of the effect.
  116673. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  116674. * @param options The required width/height ratio to downsize to before computing the render pass.
  116675. * @param camera The camera to apply the render pass to.
  116676. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116677. * @param engine The engine which the post process will be applied. (default: current engine)
  116678. * @param reusable If the post process can be reused on the same frame. (default: false)
  116679. * @param textureType Type of textures used when performing the post process. (default: 0)
  116680. */
  116681. constructor(name: string,
  116682. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  116683. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  116684. /**
  116685. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116686. */
  116687. static EdgeDetect0Kernel: number[];
  116688. /**
  116689. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116690. */
  116691. static EdgeDetect1Kernel: number[];
  116692. /**
  116693. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116694. */
  116695. static EdgeDetect2Kernel: number[];
  116696. /**
  116697. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116698. */
  116699. static SharpenKernel: number[];
  116700. /**
  116701. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116702. */
  116703. static EmbossKernel: number[];
  116704. /**
  116705. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  116706. */
  116707. static GaussianKernel: number[];
  116708. }
  116709. }
  116710. declare module BABYLON {
  116711. /**
  116712. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  116713. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  116714. * based on samples that have a large difference in distance than the center pixel.
  116715. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  116716. */
  116717. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  116718. direction: Vector2;
  116719. /**
  116720. * Creates a new instance CircleOfConfusionPostProcess
  116721. * @param name The name of the effect.
  116722. * @param scene The scene the effect belongs to.
  116723. * @param direction The direction the blur should be applied.
  116724. * @param kernel The size of the kernel used to blur.
  116725. * @param options The required width/height ratio to downsize to before computing the render pass.
  116726. * @param camera The camera to apply the render pass to.
  116727. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  116728. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  116729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116730. * @param engine The engine which the post process will be applied. (default: current engine)
  116731. * @param reusable If the post process can be reused on the same frame. (default: false)
  116732. * @param textureType Type of textures used when performing the post process. (default: 0)
  116733. * @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)
  116734. */
  116735. 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);
  116736. }
  116737. }
  116738. declare module BABYLON {
  116739. /** @hidden */
  116740. export var depthOfFieldMergePixelShader: {
  116741. name: string;
  116742. shader: string;
  116743. };
  116744. }
  116745. declare module BABYLON {
  116746. /**
  116747. * Options to be set when merging outputs from the default pipeline.
  116748. */
  116749. export class DepthOfFieldMergePostProcessOptions {
  116750. /**
  116751. * The original image to merge on top of
  116752. */
  116753. originalFromInput: PostProcess;
  116754. /**
  116755. * Parameters to perform the merge of the depth of field effect
  116756. */
  116757. depthOfField?: {
  116758. circleOfConfusion: PostProcess;
  116759. blurSteps: Array<PostProcess>;
  116760. };
  116761. /**
  116762. * Parameters to perform the merge of bloom effect
  116763. */
  116764. bloom?: {
  116765. blurred: PostProcess;
  116766. weight: number;
  116767. };
  116768. }
  116769. /**
  116770. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  116771. */
  116772. export class DepthOfFieldMergePostProcess extends PostProcess {
  116773. private blurSteps;
  116774. /**
  116775. * Creates a new instance of DepthOfFieldMergePostProcess
  116776. * @param name The name of the effect.
  116777. * @param originalFromInput Post process which's input will be used for the merge.
  116778. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  116779. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  116780. * @param options The required width/height ratio to downsize to before computing the render pass.
  116781. * @param camera The camera to apply the render pass to.
  116782. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116783. * @param engine The engine which the post process will be applied. (default: current engine)
  116784. * @param reusable If the post process can be reused on the same frame. (default: false)
  116785. * @param textureType Type of textures used when performing the post process. (default: 0)
  116786. * @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)
  116787. */
  116788. 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);
  116789. /**
  116790. * Updates the effect with the current post process compile time values and recompiles the shader.
  116791. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  116792. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  116793. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  116794. * @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
  116795. * @param onCompiled Called when the shader has been compiled.
  116796. * @param onError Called if there is an error when compiling a shader.
  116797. */
  116798. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  116799. }
  116800. }
  116801. declare module BABYLON {
  116802. /**
  116803. * Specifies the level of max blur that should be applied when using the depth of field effect
  116804. */
  116805. export enum DepthOfFieldEffectBlurLevel {
  116806. /**
  116807. * Subtle blur
  116808. */
  116809. Low = 0,
  116810. /**
  116811. * Medium blur
  116812. */
  116813. Medium = 1,
  116814. /**
  116815. * Large blur
  116816. */
  116817. High = 2
  116818. }
  116819. /**
  116820. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  116821. */
  116822. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  116823. private _circleOfConfusion;
  116824. /**
  116825. * @hidden Internal, blurs from high to low
  116826. */
  116827. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  116828. private _depthOfFieldBlurY;
  116829. private _dofMerge;
  116830. /**
  116831. * @hidden Internal post processes in depth of field effect
  116832. */
  116833. _effects: Array<PostProcess>;
  116834. /**
  116835. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  116836. */
  116837. focalLength: number;
  116838. /**
  116839. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  116840. */
  116841. fStop: number;
  116842. /**
  116843. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  116844. */
  116845. focusDistance: number;
  116846. /**
  116847. * 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.
  116848. */
  116849. lensSize: number;
  116850. /**
  116851. * Creates a new instance DepthOfFieldEffect
  116852. * @param scene The scene the effect belongs to.
  116853. * @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.
  116854. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  116855. * @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)
  116856. */
  116857. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  116858. /**
  116859. * Get the current class name of the current effet
  116860. * @returns "DepthOfFieldEffect"
  116861. */
  116862. getClassName(): string;
  116863. /**
  116864. * 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.
  116865. */
  116866. depthTexture: RenderTargetTexture;
  116867. /**
  116868. * Disposes each of the internal effects for a given camera.
  116869. * @param camera The camera to dispose the effect on.
  116870. */
  116871. disposeEffects(camera: Camera): void;
  116872. /**
  116873. * @hidden Internal
  116874. */
  116875. _updateEffects(): void;
  116876. /**
  116877. * Internal
  116878. * @returns if all the contained post processes are ready.
  116879. * @hidden
  116880. */
  116881. _isReady(): boolean;
  116882. }
  116883. }
  116884. declare module BABYLON {
  116885. /** @hidden */
  116886. export var displayPassPixelShader: {
  116887. name: string;
  116888. shader: string;
  116889. };
  116890. }
  116891. declare module BABYLON {
  116892. /**
  116893. * DisplayPassPostProcess which produces an output the same as it's input
  116894. */
  116895. export class DisplayPassPostProcess extends PostProcess {
  116896. /**
  116897. * Creates the DisplayPassPostProcess
  116898. * @param name The name of the effect.
  116899. * @param options The required width/height ratio to downsize to before computing the render pass.
  116900. * @param camera The camera to apply the render pass to.
  116901. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116902. * @param engine The engine which the post process will be applied. (default: current engine)
  116903. * @param reusable If the post process can be reused on the same frame. (default: false)
  116904. */
  116905. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116906. }
  116907. }
  116908. declare module BABYLON {
  116909. /** @hidden */
  116910. export var filterPixelShader: {
  116911. name: string;
  116912. shader: string;
  116913. };
  116914. }
  116915. declare module BABYLON {
  116916. /**
  116917. * Applies a kernel filter to the image
  116918. */
  116919. export class FilterPostProcess extends PostProcess {
  116920. /** The matrix to be applied to the image */
  116921. kernelMatrix: Matrix;
  116922. /**
  116923. *
  116924. * @param name The name of the effect.
  116925. * @param kernelMatrix The matrix to be applied to the image
  116926. * @param options The required width/height ratio to downsize to before computing the render pass.
  116927. * @param camera The camera to apply the render pass to.
  116928. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116929. * @param engine The engine which the post process will be applied. (default: current engine)
  116930. * @param reusable If the post process can be reused on the same frame. (default: false)
  116931. */
  116932. constructor(name: string,
  116933. /** The matrix to be applied to the image */
  116934. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116935. }
  116936. }
  116937. declare module BABYLON {
  116938. /** @hidden */
  116939. export var fxaaPixelShader: {
  116940. name: string;
  116941. shader: string;
  116942. };
  116943. }
  116944. declare module BABYLON {
  116945. /** @hidden */
  116946. export var fxaaVertexShader: {
  116947. name: string;
  116948. shader: string;
  116949. };
  116950. }
  116951. declare module BABYLON {
  116952. /**
  116953. * Fxaa post process
  116954. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  116955. */
  116956. export class FxaaPostProcess extends PostProcess {
  116957. /** @hidden */
  116958. texelWidth: number;
  116959. /** @hidden */
  116960. texelHeight: number;
  116961. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  116962. private _getDefines;
  116963. }
  116964. }
  116965. declare module BABYLON {
  116966. /** @hidden */
  116967. export var grainPixelShader: {
  116968. name: string;
  116969. shader: string;
  116970. };
  116971. }
  116972. declare module BABYLON {
  116973. /**
  116974. * The GrainPostProcess adds noise to the image at mid luminance levels
  116975. */
  116976. export class GrainPostProcess extends PostProcess {
  116977. /**
  116978. * The intensity of the grain added (default: 30)
  116979. */
  116980. intensity: number;
  116981. /**
  116982. * If the grain should be randomized on every frame
  116983. */
  116984. animated: boolean;
  116985. /**
  116986. * Creates a new instance of @see GrainPostProcess
  116987. * @param name The name of the effect.
  116988. * @param options The required width/height ratio to downsize to before computing the render pass.
  116989. * @param camera The camera to apply the render pass to.
  116990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116991. * @param engine The engine which the post process will be applied. (default: current engine)
  116992. * @param reusable If the post process can be reused on the same frame. (default: false)
  116993. * @param textureType Type of textures used when performing the post process. (default: 0)
  116994. * @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)
  116995. */
  116996. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116997. }
  116998. }
  116999. declare module BABYLON {
  117000. /** @hidden */
  117001. export var highlightsPixelShader: {
  117002. name: string;
  117003. shader: string;
  117004. };
  117005. }
  117006. declare module BABYLON {
  117007. /**
  117008. * Extracts highlights from the image
  117009. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117010. */
  117011. export class HighlightsPostProcess extends PostProcess {
  117012. /**
  117013. * Extracts highlights from the image
  117014. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  117015. * @param name The name of the effect.
  117016. * @param options The required width/height ratio to downsize to before computing the render pass.
  117017. * @param camera The camera to apply the render pass to.
  117018. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117019. * @param engine The engine which the post process will be applied. (default: current engine)
  117020. * @param reusable If the post process can be reused on the same frame. (default: false)
  117021. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  117022. */
  117023. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  117024. }
  117025. }
  117026. declare module BABYLON {
  117027. /** @hidden */
  117028. export var mrtFragmentDeclaration: {
  117029. name: string;
  117030. shader: string;
  117031. };
  117032. }
  117033. declare module BABYLON {
  117034. /** @hidden */
  117035. export var geometryPixelShader: {
  117036. name: string;
  117037. shader: string;
  117038. };
  117039. }
  117040. declare module BABYLON {
  117041. /** @hidden */
  117042. export var geometryVertexShader: {
  117043. name: string;
  117044. shader: string;
  117045. };
  117046. }
  117047. declare module BABYLON {
  117048. /** @hidden */
  117049. interface ISavedTransformationMatrix {
  117050. world: Matrix;
  117051. viewProjection: Matrix;
  117052. }
  117053. /**
  117054. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  117055. */
  117056. export class GeometryBufferRenderer {
  117057. /**
  117058. * Constant used to retrieve the position texture index in the G-Buffer textures array
  117059. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  117060. */
  117061. static readonly POSITION_TEXTURE_TYPE: number;
  117062. /**
  117063. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  117064. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  117065. */
  117066. static readonly VELOCITY_TEXTURE_TYPE: number;
  117067. /**
  117068. * Dictionary used to store the previous transformation matrices of each rendered mesh
  117069. * in order to compute objects velocities when enableVelocity is set to "true"
  117070. * @hidden
  117071. */
  117072. _previousTransformationMatrices: {
  117073. [index: number]: ISavedTransformationMatrix;
  117074. };
  117075. /**
  117076. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  117077. * in order to compute objects velocities when enableVelocity is set to "true"
  117078. * @hidden
  117079. */
  117080. _previousBonesTransformationMatrices: {
  117081. [index: number]: Float32Array;
  117082. };
  117083. /**
  117084. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  117085. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  117086. */
  117087. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  117088. private _scene;
  117089. private _multiRenderTarget;
  117090. private _ratio;
  117091. private _enablePosition;
  117092. private _enableVelocity;
  117093. private _positionIndex;
  117094. private _velocityIndex;
  117095. protected _effect: Effect;
  117096. protected _cachedDefines: string;
  117097. /**
  117098. * Set the render list (meshes to be rendered) used in the G buffer.
  117099. */
  117100. renderList: Mesh[];
  117101. /**
  117102. * Gets wether or not G buffer are supported by the running hardware.
  117103. * This requires draw buffer supports
  117104. */
  117105. readonly isSupported: boolean;
  117106. /**
  117107. * Returns the index of the given texture type in the G-Buffer textures array
  117108. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  117109. * @returns the index of the given texture type in the G-Buffer textures array
  117110. */
  117111. getTextureIndex(textureType: number): number;
  117112. /**
  117113. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  117114. */
  117115. /**
  117116. * Sets whether or not objects positions are enabled for the G buffer.
  117117. */
  117118. enablePosition: boolean;
  117119. /**
  117120. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  117121. */
  117122. /**
  117123. * Sets wether or not objects velocities are enabled for the G buffer.
  117124. */
  117125. enableVelocity: boolean;
  117126. /**
  117127. * Gets the scene associated with the buffer.
  117128. */
  117129. readonly scene: Scene;
  117130. /**
  117131. * Gets the ratio used by the buffer during its creation.
  117132. * How big is the buffer related to the main canvas.
  117133. */
  117134. readonly ratio: number;
  117135. /** @hidden */
  117136. static _SceneComponentInitialization: (scene: Scene) => void;
  117137. /**
  117138. * Creates a new G Buffer for the scene
  117139. * @param scene The scene the buffer belongs to
  117140. * @param ratio How big is the buffer related to the main canvas.
  117141. */
  117142. constructor(scene: Scene, ratio?: number);
  117143. /**
  117144. * Checks wether everything is ready to render a submesh to the G buffer.
  117145. * @param subMesh the submesh to check readiness for
  117146. * @param useInstances is the mesh drawn using instance or not
  117147. * @returns true if ready otherwise false
  117148. */
  117149. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  117150. /**
  117151. * Gets the current underlying G Buffer.
  117152. * @returns the buffer
  117153. */
  117154. getGBuffer(): MultiRenderTarget;
  117155. /**
  117156. * Gets the number of samples used to render the buffer (anti aliasing).
  117157. */
  117158. /**
  117159. * Sets the number of samples used to render the buffer (anti aliasing).
  117160. */
  117161. samples: number;
  117162. /**
  117163. * Disposes the renderer and frees up associated resources.
  117164. */
  117165. dispose(): void;
  117166. protected _createRenderTargets(): void;
  117167. private _copyBonesTransformationMatrices;
  117168. }
  117169. }
  117170. declare module BABYLON {
  117171. interface Scene {
  117172. /** @hidden (Backing field) */
  117173. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  117174. /**
  117175. * Gets or Sets the current geometry buffer associated to the scene.
  117176. */
  117177. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  117178. /**
  117179. * Enables a GeometryBufferRender and associates it with the scene
  117180. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  117181. * @returns the GeometryBufferRenderer
  117182. */
  117183. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  117184. /**
  117185. * Disables the GeometryBufferRender associated with the scene
  117186. */
  117187. disableGeometryBufferRenderer(): void;
  117188. }
  117189. /**
  117190. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  117191. * in several rendering techniques.
  117192. */
  117193. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  117194. /**
  117195. * The component name helpful to identify the component in the list of scene components.
  117196. */
  117197. readonly name: string;
  117198. /**
  117199. * The scene the component belongs to.
  117200. */
  117201. scene: Scene;
  117202. /**
  117203. * Creates a new instance of the component for the given scene
  117204. * @param scene Defines the scene to register the component in
  117205. */
  117206. constructor(scene: Scene);
  117207. /**
  117208. * Registers the component in a given scene
  117209. */
  117210. register(): void;
  117211. /**
  117212. * Rebuilds the elements related to this component in case of
  117213. * context lost for instance.
  117214. */
  117215. rebuild(): void;
  117216. /**
  117217. * Disposes the component and the associated ressources
  117218. */
  117219. dispose(): void;
  117220. private _gatherRenderTargets;
  117221. }
  117222. }
  117223. declare module BABYLON {
  117224. /** @hidden */
  117225. export var motionBlurPixelShader: {
  117226. name: string;
  117227. shader: string;
  117228. };
  117229. }
  117230. declare module BABYLON {
  117231. /**
  117232. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  117233. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  117234. * As an example, all you have to do is to create the post-process:
  117235. * var mb = new BABYLON.MotionBlurPostProcess(
  117236. * 'mb', // The name of the effect.
  117237. * scene, // The scene containing the objects to blur according to their velocity.
  117238. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  117239. * camera // The camera to apply the render pass to.
  117240. * );
  117241. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  117242. */
  117243. export class MotionBlurPostProcess extends PostProcess {
  117244. /**
  117245. * Defines how much the image is blurred by the movement. Default value is equal to 1
  117246. */
  117247. motionStrength: number;
  117248. /**
  117249. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  117250. */
  117251. /**
  117252. * Sets the number of iterations to be used for motion blur quality
  117253. */
  117254. motionBlurSamples: number;
  117255. private _motionBlurSamples;
  117256. private _geometryBufferRenderer;
  117257. /**
  117258. * Creates a new instance MotionBlurPostProcess
  117259. * @param name The name of the effect.
  117260. * @param scene The scene containing the objects to blur according to their velocity.
  117261. * @param options The required width/height ratio to downsize to before computing the render pass.
  117262. * @param camera The camera to apply the render pass to.
  117263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117264. * @param engine The engine which the post process will be applied. (default: current engine)
  117265. * @param reusable If the post process can be reused on the same frame. (default: false)
  117266. * @param textureType Type of textures used when performing the post process. (default: 0)
  117267. * @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)
  117268. */
  117269. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117270. /**
  117271. * Excludes the given skinned mesh from computing bones velocities.
  117272. * 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.
  117273. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  117274. */
  117275. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117276. /**
  117277. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  117278. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  117279. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  117280. */
  117281. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  117282. /**
  117283. * Disposes the post process.
  117284. * @param camera The camera to dispose the post process on.
  117285. */
  117286. dispose(camera?: Camera): void;
  117287. }
  117288. }
  117289. declare module BABYLON {
  117290. /** @hidden */
  117291. export var refractionPixelShader: {
  117292. name: string;
  117293. shader: string;
  117294. };
  117295. }
  117296. declare module BABYLON {
  117297. /**
  117298. * Post process which applies a refractin texture
  117299. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117300. */
  117301. export class RefractionPostProcess extends PostProcess {
  117302. /** the base color of the refraction (used to taint the rendering) */
  117303. color: Color3;
  117304. /** simulated refraction depth */
  117305. depth: number;
  117306. /** the coefficient of the base color (0 to remove base color tainting) */
  117307. colorLevel: number;
  117308. private _refTexture;
  117309. private _ownRefractionTexture;
  117310. /**
  117311. * Gets or sets the refraction texture
  117312. * Please note that you are responsible for disposing the texture if you set it manually
  117313. */
  117314. refractionTexture: Texture;
  117315. /**
  117316. * Initializes the RefractionPostProcess
  117317. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  117318. * @param name The name of the effect.
  117319. * @param refractionTextureUrl Url of the refraction texture to use
  117320. * @param color the base color of the refraction (used to taint the rendering)
  117321. * @param depth simulated refraction depth
  117322. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  117323. * @param camera The camera to apply the render pass to.
  117324. * @param options The required width/height ratio to downsize to before computing the render pass.
  117325. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117326. * @param engine The engine which the post process will be applied. (default: current engine)
  117327. * @param reusable If the post process can be reused on the same frame. (default: false)
  117328. */
  117329. constructor(name: string, refractionTextureUrl: string,
  117330. /** the base color of the refraction (used to taint the rendering) */
  117331. color: Color3,
  117332. /** simulated refraction depth */
  117333. depth: number,
  117334. /** the coefficient of the base color (0 to remove base color tainting) */
  117335. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  117336. /**
  117337. * Disposes of the post process
  117338. * @param camera Camera to dispose post process on
  117339. */
  117340. dispose(camera: Camera): void;
  117341. }
  117342. }
  117343. declare module BABYLON {
  117344. /** @hidden */
  117345. export var sharpenPixelShader: {
  117346. name: string;
  117347. shader: string;
  117348. };
  117349. }
  117350. declare module BABYLON {
  117351. /**
  117352. * The SharpenPostProcess applies a sharpen kernel to every pixel
  117353. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117354. */
  117355. export class SharpenPostProcess extends PostProcess {
  117356. /**
  117357. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  117358. */
  117359. colorAmount: number;
  117360. /**
  117361. * How much sharpness should be applied (default: 0.3)
  117362. */
  117363. edgeAmount: number;
  117364. /**
  117365. * Creates a new instance ConvolutionPostProcess
  117366. * @param name The name of the effect.
  117367. * @param options The required width/height ratio to downsize to before computing the render pass.
  117368. * @param camera The camera to apply the render pass to.
  117369. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117370. * @param engine The engine which the post process will be applied. (default: current engine)
  117371. * @param reusable If the post process can be reused on the same frame. (default: false)
  117372. * @param textureType Type of textures used when performing the post process. (default: 0)
  117373. * @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)
  117374. */
  117375. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  117376. }
  117377. }
  117378. declare module BABYLON {
  117379. /**
  117380. * PostProcessRenderPipeline
  117381. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117382. */
  117383. export class PostProcessRenderPipeline {
  117384. private engine;
  117385. private _renderEffects;
  117386. private _renderEffectsForIsolatedPass;
  117387. /**
  117388. * List of inspectable custom properties (used by the Inspector)
  117389. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  117390. */
  117391. inspectableCustomProperties: IInspectable[];
  117392. /**
  117393. * @hidden
  117394. */
  117395. protected _cameras: Camera[];
  117396. /** @hidden */
  117397. _name: string;
  117398. /**
  117399. * Gets pipeline name
  117400. */
  117401. readonly name: string;
  117402. /**
  117403. * Initializes a PostProcessRenderPipeline
  117404. * @param engine engine to add the pipeline to
  117405. * @param name name of the pipeline
  117406. */
  117407. constructor(engine: Engine, name: string);
  117408. /**
  117409. * Gets the class name
  117410. * @returns "PostProcessRenderPipeline"
  117411. */
  117412. getClassName(): string;
  117413. /**
  117414. * If all the render effects in the pipeline are supported
  117415. */
  117416. readonly isSupported: boolean;
  117417. /**
  117418. * Adds an effect to the pipeline
  117419. * @param renderEffect the effect to add
  117420. */
  117421. addEffect(renderEffect: PostProcessRenderEffect): void;
  117422. /** @hidden */
  117423. _rebuild(): void;
  117424. /** @hidden */
  117425. _enableEffect(renderEffectName: string, cameras: Camera): void;
  117426. /** @hidden */
  117427. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  117428. /** @hidden */
  117429. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117430. /** @hidden */
  117431. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  117432. /** @hidden */
  117433. _attachCameras(cameras: Camera, unique: boolean): void;
  117434. /** @hidden */
  117435. _attachCameras(cameras: Camera[], unique: boolean): void;
  117436. /** @hidden */
  117437. _detachCameras(cameras: Camera): void;
  117438. /** @hidden */
  117439. _detachCameras(cameras: Nullable<Camera[]>): void;
  117440. /** @hidden */
  117441. _update(): void;
  117442. /** @hidden */
  117443. _reset(): void;
  117444. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  117445. /**
  117446. * Disposes of the pipeline
  117447. */
  117448. dispose(): void;
  117449. }
  117450. }
  117451. declare module BABYLON {
  117452. /**
  117453. * PostProcessRenderPipelineManager class
  117454. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117455. */
  117456. export class PostProcessRenderPipelineManager {
  117457. private _renderPipelines;
  117458. /**
  117459. * Initializes a PostProcessRenderPipelineManager
  117460. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117461. */
  117462. constructor();
  117463. /**
  117464. * Gets the list of supported render pipelines
  117465. */
  117466. readonly supportedPipelines: PostProcessRenderPipeline[];
  117467. /**
  117468. * Adds a pipeline to the manager
  117469. * @param renderPipeline The pipeline to add
  117470. */
  117471. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  117472. /**
  117473. * Attaches a camera to the pipeline
  117474. * @param renderPipelineName The name of the pipeline to attach to
  117475. * @param cameras the camera to attach
  117476. * @param unique if the camera can be attached multiple times to the pipeline
  117477. */
  117478. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  117479. /**
  117480. * Detaches a camera from the pipeline
  117481. * @param renderPipelineName The name of the pipeline to detach from
  117482. * @param cameras the camera to detach
  117483. */
  117484. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  117485. /**
  117486. * Enables an effect by name on a pipeline
  117487. * @param renderPipelineName the name of the pipeline to enable the effect in
  117488. * @param renderEffectName the name of the effect to enable
  117489. * @param cameras the cameras that the effect should be enabled on
  117490. */
  117491. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  117492. /**
  117493. * Disables an effect by name on a pipeline
  117494. * @param renderPipelineName the name of the pipeline to disable the effect in
  117495. * @param renderEffectName the name of the effect to disable
  117496. * @param cameras the cameras that the effect should be disabled on
  117497. */
  117498. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  117499. /**
  117500. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  117501. */
  117502. update(): void;
  117503. /** @hidden */
  117504. _rebuild(): void;
  117505. /**
  117506. * Disposes of the manager and pipelines
  117507. */
  117508. dispose(): void;
  117509. }
  117510. }
  117511. declare module BABYLON {
  117512. interface Scene {
  117513. /** @hidden (Backing field) */
  117514. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  117515. /**
  117516. * Gets the postprocess render pipeline manager
  117517. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  117518. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117519. */
  117520. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  117521. }
  117522. /**
  117523. * Defines the Render Pipeline scene component responsible to rendering pipelines
  117524. */
  117525. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  117526. /**
  117527. * The component name helpfull to identify the component in the list of scene components.
  117528. */
  117529. readonly name: string;
  117530. /**
  117531. * The scene the component belongs to.
  117532. */
  117533. scene: Scene;
  117534. /**
  117535. * Creates a new instance of the component for the given scene
  117536. * @param scene Defines the scene to register the component in
  117537. */
  117538. constructor(scene: Scene);
  117539. /**
  117540. * Registers the component in a given scene
  117541. */
  117542. register(): void;
  117543. /**
  117544. * Rebuilds the elements related to this component in case of
  117545. * context lost for instance.
  117546. */
  117547. rebuild(): void;
  117548. /**
  117549. * Disposes the component and the associated ressources
  117550. */
  117551. dispose(): void;
  117552. private _gatherRenderTargets;
  117553. }
  117554. }
  117555. declare module BABYLON {
  117556. /**
  117557. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  117558. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  117559. */
  117560. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  117561. private _scene;
  117562. private _camerasToBeAttached;
  117563. /**
  117564. * ID of the sharpen post process,
  117565. */
  117566. private readonly SharpenPostProcessId;
  117567. /**
  117568. * @ignore
  117569. * ID of the image processing post process;
  117570. */
  117571. readonly ImageProcessingPostProcessId: string;
  117572. /**
  117573. * @ignore
  117574. * ID of the Fast Approximate Anti-Aliasing post process;
  117575. */
  117576. readonly FxaaPostProcessId: string;
  117577. /**
  117578. * ID of the chromatic aberration post process,
  117579. */
  117580. private readonly ChromaticAberrationPostProcessId;
  117581. /**
  117582. * ID of the grain post process
  117583. */
  117584. private readonly GrainPostProcessId;
  117585. /**
  117586. * Sharpen post process which will apply a sharpen convolution to enhance edges
  117587. */
  117588. sharpen: SharpenPostProcess;
  117589. private _sharpenEffect;
  117590. private bloom;
  117591. /**
  117592. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  117593. */
  117594. depthOfField: DepthOfFieldEffect;
  117595. /**
  117596. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  117597. */
  117598. fxaa: FxaaPostProcess;
  117599. /**
  117600. * Image post processing pass used to perform operations such as tone mapping or color grading.
  117601. */
  117602. imageProcessing: ImageProcessingPostProcess;
  117603. /**
  117604. * Chromatic aberration post process which will shift rgb colors in the image
  117605. */
  117606. chromaticAberration: ChromaticAberrationPostProcess;
  117607. private _chromaticAberrationEffect;
  117608. /**
  117609. * Grain post process which add noise to the image
  117610. */
  117611. grain: GrainPostProcess;
  117612. private _grainEffect;
  117613. /**
  117614. * Glow post process which adds a glow to emissive areas of the image
  117615. */
  117616. private _glowLayer;
  117617. /**
  117618. * Animations which can be used to tweak settings over a period of time
  117619. */
  117620. animations: Animation[];
  117621. private _imageProcessingConfigurationObserver;
  117622. private _sharpenEnabled;
  117623. private _bloomEnabled;
  117624. private _depthOfFieldEnabled;
  117625. private _depthOfFieldBlurLevel;
  117626. private _fxaaEnabled;
  117627. private _imageProcessingEnabled;
  117628. private _defaultPipelineTextureType;
  117629. private _bloomScale;
  117630. private _chromaticAberrationEnabled;
  117631. private _grainEnabled;
  117632. private _buildAllowed;
  117633. /**
  117634. * Gets active scene
  117635. */
  117636. readonly scene: Scene;
  117637. /**
  117638. * Enable or disable the sharpen process from the pipeline
  117639. */
  117640. sharpenEnabled: boolean;
  117641. private _resizeObserver;
  117642. private _hardwareScaleLevel;
  117643. private _bloomKernel;
  117644. /**
  117645. * Specifies the size of the bloom blur kernel, relative to the final output size
  117646. */
  117647. bloomKernel: number;
  117648. /**
  117649. * Specifies the weight of the bloom in the final rendering
  117650. */
  117651. private _bloomWeight;
  117652. /**
  117653. * Specifies the luma threshold for the area that will be blurred by the bloom
  117654. */
  117655. private _bloomThreshold;
  117656. private _hdr;
  117657. /**
  117658. * The strength of the bloom.
  117659. */
  117660. bloomWeight: number;
  117661. /**
  117662. * The strength of the bloom.
  117663. */
  117664. bloomThreshold: number;
  117665. /**
  117666. * The scale of the bloom, lower value will provide better performance.
  117667. */
  117668. bloomScale: number;
  117669. /**
  117670. * Enable or disable the bloom from the pipeline
  117671. */
  117672. bloomEnabled: boolean;
  117673. private _rebuildBloom;
  117674. /**
  117675. * If the depth of field is enabled.
  117676. */
  117677. depthOfFieldEnabled: boolean;
  117678. /**
  117679. * Blur level of the depth of field effect. (Higher blur will effect performance)
  117680. */
  117681. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  117682. /**
  117683. * If the anti aliasing is enabled.
  117684. */
  117685. fxaaEnabled: boolean;
  117686. private _samples;
  117687. /**
  117688. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  117689. */
  117690. samples: number;
  117691. /**
  117692. * If image processing is enabled.
  117693. */
  117694. imageProcessingEnabled: boolean;
  117695. /**
  117696. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  117697. */
  117698. glowLayerEnabled: boolean;
  117699. /**
  117700. * Gets the glow layer (or null if not defined)
  117701. */
  117702. readonly glowLayer: Nullable<GlowLayer>;
  117703. /**
  117704. * Enable or disable the chromaticAberration process from the pipeline
  117705. */
  117706. chromaticAberrationEnabled: boolean;
  117707. /**
  117708. * Enable or disable the grain process from the pipeline
  117709. */
  117710. grainEnabled: boolean;
  117711. /**
  117712. * @constructor
  117713. * @param name - The rendering pipeline name (default: "")
  117714. * @param hdr - If high dynamic range textures should be used (default: true)
  117715. * @param scene - The scene linked to this pipeline (default: the last created scene)
  117716. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  117717. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  117718. */
  117719. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  117720. /**
  117721. * Get the class name
  117722. * @returns "DefaultRenderingPipeline"
  117723. */
  117724. getClassName(): string;
  117725. /**
  117726. * Force the compilation of the entire pipeline.
  117727. */
  117728. prepare(): void;
  117729. private _hasCleared;
  117730. private _prevPostProcess;
  117731. private _prevPrevPostProcess;
  117732. private _setAutoClearAndTextureSharing;
  117733. private _depthOfFieldSceneObserver;
  117734. private _buildPipeline;
  117735. private _disposePostProcesses;
  117736. /**
  117737. * Adds a camera to the pipeline
  117738. * @param camera the camera to be added
  117739. */
  117740. addCamera(camera: Camera): void;
  117741. /**
  117742. * Removes a camera from the pipeline
  117743. * @param camera the camera to remove
  117744. */
  117745. removeCamera(camera: Camera): void;
  117746. /**
  117747. * Dispose of the pipeline and stop all post processes
  117748. */
  117749. dispose(): void;
  117750. /**
  117751. * Serialize the rendering pipeline (Used when exporting)
  117752. * @returns the serialized object
  117753. */
  117754. serialize(): any;
  117755. /**
  117756. * Parse the serialized pipeline
  117757. * @param source Source pipeline.
  117758. * @param scene The scene to load the pipeline to.
  117759. * @param rootUrl The URL of the serialized pipeline.
  117760. * @returns An instantiated pipeline from the serialized object.
  117761. */
  117762. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  117763. }
  117764. }
  117765. declare module BABYLON {
  117766. /** @hidden */
  117767. export var lensHighlightsPixelShader: {
  117768. name: string;
  117769. shader: string;
  117770. };
  117771. }
  117772. declare module BABYLON {
  117773. /** @hidden */
  117774. export var depthOfFieldPixelShader: {
  117775. name: string;
  117776. shader: string;
  117777. };
  117778. }
  117779. declare module BABYLON {
  117780. /**
  117781. * BABYLON.JS Chromatic Aberration GLSL Shader
  117782. * Author: Olivier Guyot
  117783. * Separates very slightly R, G and B colors on the edges of the screen
  117784. * Inspired by Francois Tarlier & Martins Upitis
  117785. */
  117786. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  117787. /**
  117788. * @ignore
  117789. * The chromatic aberration PostProcess id in the pipeline
  117790. */
  117791. LensChromaticAberrationEffect: string;
  117792. /**
  117793. * @ignore
  117794. * The highlights enhancing PostProcess id in the pipeline
  117795. */
  117796. HighlightsEnhancingEffect: string;
  117797. /**
  117798. * @ignore
  117799. * The depth-of-field PostProcess id in the pipeline
  117800. */
  117801. LensDepthOfFieldEffect: string;
  117802. private _scene;
  117803. private _depthTexture;
  117804. private _grainTexture;
  117805. private _chromaticAberrationPostProcess;
  117806. private _highlightsPostProcess;
  117807. private _depthOfFieldPostProcess;
  117808. private _edgeBlur;
  117809. private _grainAmount;
  117810. private _chromaticAberration;
  117811. private _distortion;
  117812. private _highlightsGain;
  117813. private _highlightsThreshold;
  117814. private _dofDistance;
  117815. private _dofAperture;
  117816. private _dofDarken;
  117817. private _dofPentagon;
  117818. private _blurNoise;
  117819. /**
  117820. * @constructor
  117821. *
  117822. * Effect parameters are as follow:
  117823. * {
  117824. * chromatic_aberration: number; // from 0 to x (1 for realism)
  117825. * edge_blur: number; // from 0 to x (1 for realism)
  117826. * distortion: number; // from 0 to x (1 for realism)
  117827. * grain_amount: number; // from 0 to 1
  117828. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  117829. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  117830. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  117831. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  117832. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  117833. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  117834. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  117835. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  117836. * }
  117837. * Note: if an effect parameter is unset, effect is disabled
  117838. *
  117839. * @param name The rendering pipeline name
  117840. * @param parameters - An object containing all parameters (see above)
  117841. * @param scene The scene linked to this pipeline
  117842. * @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)
  117843. * @param cameras The array of cameras that the rendering pipeline will be attached to
  117844. */
  117845. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  117846. /**
  117847. * Get the class name
  117848. * @returns "LensRenderingPipeline"
  117849. */
  117850. getClassName(): string;
  117851. /**
  117852. * Gets associated scene
  117853. */
  117854. readonly scene: Scene;
  117855. /**
  117856. * Gets or sets the edge blur
  117857. */
  117858. edgeBlur: number;
  117859. /**
  117860. * Gets or sets the grain amount
  117861. */
  117862. grainAmount: number;
  117863. /**
  117864. * Gets or sets the chromatic aberration amount
  117865. */
  117866. chromaticAberration: number;
  117867. /**
  117868. * Gets or sets the depth of field aperture
  117869. */
  117870. dofAperture: number;
  117871. /**
  117872. * Gets or sets the edge distortion
  117873. */
  117874. edgeDistortion: number;
  117875. /**
  117876. * Gets or sets the depth of field distortion
  117877. */
  117878. dofDistortion: number;
  117879. /**
  117880. * Gets or sets the darken out of focus amount
  117881. */
  117882. darkenOutOfFocus: number;
  117883. /**
  117884. * Gets or sets a boolean indicating if blur noise is enabled
  117885. */
  117886. blurNoise: boolean;
  117887. /**
  117888. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  117889. */
  117890. pentagonBokeh: boolean;
  117891. /**
  117892. * Gets or sets the highlight grain amount
  117893. */
  117894. highlightsGain: number;
  117895. /**
  117896. * Gets or sets the highlight threshold
  117897. */
  117898. highlightsThreshold: number;
  117899. /**
  117900. * Sets the amount of blur at the edges
  117901. * @param amount blur amount
  117902. */
  117903. setEdgeBlur(amount: number): void;
  117904. /**
  117905. * Sets edge blur to 0
  117906. */
  117907. disableEdgeBlur(): void;
  117908. /**
  117909. * Sets the amout of grain
  117910. * @param amount Amount of grain
  117911. */
  117912. setGrainAmount(amount: number): void;
  117913. /**
  117914. * Set grain amount to 0
  117915. */
  117916. disableGrain(): void;
  117917. /**
  117918. * Sets the chromatic aberration amount
  117919. * @param amount amount of chromatic aberration
  117920. */
  117921. setChromaticAberration(amount: number): void;
  117922. /**
  117923. * Sets chromatic aberration amount to 0
  117924. */
  117925. disableChromaticAberration(): void;
  117926. /**
  117927. * Sets the EdgeDistortion amount
  117928. * @param amount amount of EdgeDistortion
  117929. */
  117930. setEdgeDistortion(amount: number): void;
  117931. /**
  117932. * Sets edge distortion to 0
  117933. */
  117934. disableEdgeDistortion(): void;
  117935. /**
  117936. * Sets the FocusDistance amount
  117937. * @param amount amount of FocusDistance
  117938. */
  117939. setFocusDistance(amount: number): void;
  117940. /**
  117941. * Disables depth of field
  117942. */
  117943. disableDepthOfField(): void;
  117944. /**
  117945. * Sets the Aperture amount
  117946. * @param amount amount of Aperture
  117947. */
  117948. setAperture(amount: number): void;
  117949. /**
  117950. * Sets the DarkenOutOfFocus amount
  117951. * @param amount amount of DarkenOutOfFocus
  117952. */
  117953. setDarkenOutOfFocus(amount: number): void;
  117954. private _pentagonBokehIsEnabled;
  117955. /**
  117956. * Creates a pentagon bokeh effect
  117957. */
  117958. enablePentagonBokeh(): void;
  117959. /**
  117960. * Disables the pentagon bokeh effect
  117961. */
  117962. disablePentagonBokeh(): void;
  117963. /**
  117964. * Enables noise blur
  117965. */
  117966. enableNoiseBlur(): void;
  117967. /**
  117968. * Disables noise blur
  117969. */
  117970. disableNoiseBlur(): void;
  117971. /**
  117972. * Sets the HighlightsGain amount
  117973. * @param amount amount of HighlightsGain
  117974. */
  117975. setHighlightsGain(amount: number): void;
  117976. /**
  117977. * Sets the HighlightsThreshold amount
  117978. * @param amount amount of HighlightsThreshold
  117979. */
  117980. setHighlightsThreshold(amount: number): void;
  117981. /**
  117982. * Disables highlights
  117983. */
  117984. disableHighlights(): void;
  117985. /**
  117986. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  117987. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  117988. */
  117989. dispose(disableDepthRender?: boolean): void;
  117990. private _createChromaticAberrationPostProcess;
  117991. private _createHighlightsPostProcess;
  117992. private _createDepthOfFieldPostProcess;
  117993. private _createGrainTexture;
  117994. }
  117995. }
  117996. declare module BABYLON {
  117997. /** @hidden */
  117998. export var ssao2PixelShader: {
  117999. name: string;
  118000. shader: string;
  118001. };
  118002. }
  118003. declare module BABYLON {
  118004. /** @hidden */
  118005. export var ssaoCombinePixelShader: {
  118006. name: string;
  118007. shader: string;
  118008. };
  118009. }
  118010. declare module BABYLON {
  118011. /**
  118012. * Render pipeline to produce ssao effect
  118013. */
  118014. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  118015. /**
  118016. * @ignore
  118017. * The PassPostProcess id in the pipeline that contains the original scene color
  118018. */
  118019. SSAOOriginalSceneColorEffect: string;
  118020. /**
  118021. * @ignore
  118022. * The SSAO PostProcess id in the pipeline
  118023. */
  118024. SSAORenderEffect: string;
  118025. /**
  118026. * @ignore
  118027. * The horizontal blur PostProcess id in the pipeline
  118028. */
  118029. SSAOBlurHRenderEffect: string;
  118030. /**
  118031. * @ignore
  118032. * The vertical blur PostProcess id in the pipeline
  118033. */
  118034. SSAOBlurVRenderEffect: string;
  118035. /**
  118036. * @ignore
  118037. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118038. */
  118039. SSAOCombineRenderEffect: string;
  118040. /**
  118041. * The output strength of the SSAO post-process. Default value is 1.0.
  118042. */
  118043. totalStrength: number;
  118044. /**
  118045. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  118046. */
  118047. maxZ: number;
  118048. /**
  118049. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  118050. */
  118051. minZAspect: number;
  118052. private _samples;
  118053. /**
  118054. * Number of samples used for the SSAO calculations. Default value is 8
  118055. */
  118056. samples: number;
  118057. private _textureSamples;
  118058. /**
  118059. * Number of samples to use for antialiasing
  118060. */
  118061. textureSamples: number;
  118062. /**
  118063. * Ratio object used for SSAO ratio and blur ratio
  118064. */
  118065. private _ratio;
  118066. /**
  118067. * Dynamically generated sphere sampler.
  118068. */
  118069. private _sampleSphere;
  118070. /**
  118071. * Blur filter offsets
  118072. */
  118073. private _samplerOffsets;
  118074. private _expensiveBlur;
  118075. /**
  118076. * If bilateral blur should be used
  118077. */
  118078. expensiveBlur: boolean;
  118079. /**
  118080. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  118081. */
  118082. radius: number;
  118083. /**
  118084. * The base color of the SSAO post-process
  118085. * The final result is "base + ssao" between [0, 1]
  118086. */
  118087. base: number;
  118088. /**
  118089. * Support test.
  118090. */
  118091. static readonly IsSupported: boolean;
  118092. private _scene;
  118093. private _depthTexture;
  118094. private _normalTexture;
  118095. private _randomTexture;
  118096. private _originalColorPostProcess;
  118097. private _ssaoPostProcess;
  118098. private _blurHPostProcess;
  118099. private _blurVPostProcess;
  118100. private _ssaoCombinePostProcess;
  118101. private _firstUpdate;
  118102. /**
  118103. * Gets active scene
  118104. */
  118105. readonly scene: Scene;
  118106. /**
  118107. * @constructor
  118108. * @param name The rendering pipeline name
  118109. * @param scene The scene linked to this pipeline
  118110. * @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 }
  118111. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118112. */
  118113. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118114. /**
  118115. * Get the class name
  118116. * @returns "SSAO2RenderingPipeline"
  118117. */
  118118. getClassName(): string;
  118119. /**
  118120. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118121. */
  118122. dispose(disableGeometryBufferRenderer?: boolean): void;
  118123. private _createBlurPostProcess;
  118124. /** @hidden */
  118125. _rebuild(): void;
  118126. private _bits;
  118127. private _radicalInverse_VdC;
  118128. private _hammersley;
  118129. private _hemisphereSample_uniform;
  118130. private _generateHemisphere;
  118131. private _createSSAOPostProcess;
  118132. private _createSSAOCombinePostProcess;
  118133. private _createRandomTexture;
  118134. /**
  118135. * Serialize the rendering pipeline (Used when exporting)
  118136. * @returns the serialized object
  118137. */
  118138. serialize(): any;
  118139. /**
  118140. * Parse the serialized pipeline
  118141. * @param source Source pipeline.
  118142. * @param scene The scene to load the pipeline to.
  118143. * @param rootUrl The URL of the serialized pipeline.
  118144. * @returns An instantiated pipeline from the serialized object.
  118145. */
  118146. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  118147. }
  118148. }
  118149. declare module BABYLON {
  118150. /** @hidden */
  118151. export var ssaoPixelShader: {
  118152. name: string;
  118153. shader: string;
  118154. };
  118155. }
  118156. declare module BABYLON {
  118157. /**
  118158. * Render pipeline to produce ssao effect
  118159. */
  118160. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  118161. /**
  118162. * @ignore
  118163. * The PassPostProcess id in the pipeline that contains the original scene color
  118164. */
  118165. SSAOOriginalSceneColorEffect: string;
  118166. /**
  118167. * @ignore
  118168. * The SSAO PostProcess id in the pipeline
  118169. */
  118170. SSAORenderEffect: string;
  118171. /**
  118172. * @ignore
  118173. * The horizontal blur PostProcess id in the pipeline
  118174. */
  118175. SSAOBlurHRenderEffect: string;
  118176. /**
  118177. * @ignore
  118178. * The vertical blur PostProcess id in the pipeline
  118179. */
  118180. SSAOBlurVRenderEffect: string;
  118181. /**
  118182. * @ignore
  118183. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  118184. */
  118185. SSAOCombineRenderEffect: string;
  118186. /**
  118187. * The output strength of the SSAO post-process. Default value is 1.0.
  118188. */
  118189. totalStrength: number;
  118190. /**
  118191. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  118192. */
  118193. radius: number;
  118194. /**
  118195. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  118196. * Must not be equal to fallOff and superior to fallOff.
  118197. * Default value is 0.0075
  118198. */
  118199. area: number;
  118200. /**
  118201. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  118202. * Must not be equal to area and inferior to area.
  118203. * Default value is 0.000001
  118204. */
  118205. fallOff: number;
  118206. /**
  118207. * The base color of the SSAO post-process
  118208. * The final result is "base + ssao" between [0, 1]
  118209. */
  118210. base: number;
  118211. private _scene;
  118212. private _depthTexture;
  118213. private _randomTexture;
  118214. private _originalColorPostProcess;
  118215. private _ssaoPostProcess;
  118216. private _blurHPostProcess;
  118217. private _blurVPostProcess;
  118218. private _ssaoCombinePostProcess;
  118219. private _firstUpdate;
  118220. /**
  118221. * Gets active scene
  118222. */
  118223. readonly scene: Scene;
  118224. /**
  118225. * @constructor
  118226. * @param name - The rendering pipeline name
  118227. * @param scene - The scene linked to this pipeline
  118228. * @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 }
  118229. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  118230. */
  118231. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  118232. /**
  118233. * Get the class name
  118234. * @returns "SSAORenderingPipeline"
  118235. */
  118236. getClassName(): string;
  118237. /**
  118238. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  118239. */
  118240. dispose(disableDepthRender?: boolean): void;
  118241. private _createBlurPostProcess;
  118242. /** @hidden */
  118243. _rebuild(): void;
  118244. private _createSSAOPostProcess;
  118245. private _createSSAOCombinePostProcess;
  118246. private _createRandomTexture;
  118247. }
  118248. }
  118249. declare module BABYLON {
  118250. /** @hidden */
  118251. export var standardPixelShader: {
  118252. name: string;
  118253. shader: string;
  118254. };
  118255. }
  118256. declare module BABYLON {
  118257. /**
  118258. * Standard rendering pipeline
  118259. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118260. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  118261. */
  118262. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  118263. /**
  118264. * Public members
  118265. */
  118266. /**
  118267. * Post-process which contains the original scene color before the pipeline applies all the effects
  118268. */
  118269. originalPostProcess: Nullable<PostProcess>;
  118270. /**
  118271. * Post-process used to down scale an image x4
  118272. */
  118273. downSampleX4PostProcess: Nullable<PostProcess>;
  118274. /**
  118275. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  118276. */
  118277. brightPassPostProcess: Nullable<PostProcess>;
  118278. /**
  118279. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  118280. */
  118281. blurHPostProcesses: PostProcess[];
  118282. /**
  118283. * Post-process array storing all the vertical blur post-processes used by the pipeline
  118284. */
  118285. blurVPostProcesses: PostProcess[];
  118286. /**
  118287. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  118288. */
  118289. textureAdderPostProcess: Nullable<PostProcess>;
  118290. /**
  118291. * Post-process used to create volumetric lighting effect
  118292. */
  118293. volumetricLightPostProcess: Nullable<PostProcess>;
  118294. /**
  118295. * Post-process used to smooth the previous volumetric light post-process on the X axis
  118296. */
  118297. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  118298. /**
  118299. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  118300. */
  118301. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  118302. /**
  118303. * Post-process used to merge the volumetric light effect and the real scene color
  118304. */
  118305. volumetricLightMergePostProces: Nullable<PostProcess>;
  118306. /**
  118307. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  118308. */
  118309. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  118310. /**
  118311. * Base post-process used to calculate the average luminance of the final image for HDR
  118312. */
  118313. luminancePostProcess: Nullable<PostProcess>;
  118314. /**
  118315. * Post-processes used to create down sample post-processes in order to get
  118316. * the average luminance of the final image for HDR
  118317. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  118318. */
  118319. luminanceDownSamplePostProcesses: PostProcess[];
  118320. /**
  118321. * Post-process used to create a HDR effect (light adaptation)
  118322. */
  118323. hdrPostProcess: Nullable<PostProcess>;
  118324. /**
  118325. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  118326. */
  118327. textureAdderFinalPostProcess: Nullable<PostProcess>;
  118328. /**
  118329. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  118330. */
  118331. lensFlareFinalPostProcess: Nullable<PostProcess>;
  118332. /**
  118333. * Post-process used to merge the final HDR post-process and the real scene color
  118334. */
  118335. hdrFinalPostProcess: Nullable<PostProcess>;
  118336. /**
  118337. * Post-process used to create a lens flare effect
  118338. */
  118339. lensFlarePostProcess: Nullable<PostProcess>;
  118340. /**
  118341. * Post-process that merges the result of the lens flare post-process and the real scene color
  118342. */
  118343. lensFlareComposePostProcess: Nullable<PostProcess>;
  118344. /**
  118345. * Post-process used to create a motion blur effect
  118346. */
  118347. motionBlurPostProcess: Nullable<PostProcess>;
  118348. /**
  118349. * Post-process used to create a depth of field effect
  118350. */
  118351. depthOfFieldPostProcess: Nullable<PostProcess>;
  118352. /**
  118353. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  118354. */
  118355. fxaaPostProcess: Nullable<FxaaPostProcess>;
  118356. /**
  118357. * Represents the brightness threshold in order to configure the illuminated surfaces
  118358. */
  118359. brightThreshold: number;
  118360. /**
  118361. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  118362. */
  118363. blurWidth: number;
  118364. /**
  118365. * Sets if the blur for highlighted surfaces must be only horizontal
  118366. */
  118367. horizontalBlur: boolean;
  118368. /**
  118369. * Gets the overall exposure used by the pipeline
  118370. */
  118371. /**
  118372. * Sets the overall exposure used by the pipeline
  118373. */
  118374. exposure: number;
  118375. /**
  118376. * Texture used typically to simulate "dirty" on camera lens
  118377. */
  118378. lensTexture: Nullable<Texture>;
  118379. /**
  118380. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  118381. */
  118382. volumetricLightCoefficient: number;
  118383. /**
  118384. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  118385. */
  118386. volumetricLightPower: number;
  118387. /**
  118388. * Used the set the blur intensity to smooth the volumetric lights
  118389. */
  118390. volumetricLightBlurScale: number;
  118391. /**
  118392. * Light (spot or directional) used to generate the volumetric lights rays
  118393. * The source light must have a shadow generate so the pipeline can get its
  118394. * depth map
  118395. */
  118396. sourceLight: Nullable<SpotLight | DirectionalLight>;
  118397. /**
  118398. * For eye adaptation, represents the minimum luminance the eye can see
  118399. */
  118400. hdrMinimumLuminance: number;
  118401. /**
  118402. * For eye adaptation, represents the decrease luminance speed
  118403. */
  118404. hdrDecreaseRate: number;
  118405. /**
  118406. * For eye adaptation, represents the increase luminance speed
  118407. */
  118408. hdrIncreaseRate: number;
  118409. /**
  118410. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118411. */
  118412. /**
  118413. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  118414. */
  118415. hdrAutoExposure: boolean;
  118416. /**
  118417. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  118418. */
  118419. lensColorTexture: Nullable<Texture>;
  118420. /**
  118421. * The overall strengh for the lens flare effect
  118422. */
  118423. lensFlareStrength: number;
  118424. /**
  118425. * Dispersion coefficient for lens flare ghosts
  118426. */
  118427. lensFlareGhostDispersal: number;
  118428. /**
  118429. * Main lens flare halo width
  118430. */
  118431. lensFlareHaloWidth: number;
  118432. /**
  118433. * Based on the lens distortion effect, defines how much the lens flare result
  118434. * is distorted
  118435. */
  118436. lensFlareDistortionStrength: number;
  118437. /**
  118438. * Lens star texture must be used to simulate rays on the flares and is available
  118439. * in the documentation
  118440. */
  118441. lensStarTexture: Nullable<Texture>;
  118442. /**
  118443. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  118444. * flare effect by taking account of the dirt texture
  118445. */
  118446. lensFlareDirtTexture: Nullable<Texture>;
  118447. /**
  118448. * Represents the focal length for the depth of field effect
  118449. */
  118450. depthOfFieldDistance: number;
  118451. /**
  118452. * Represents the blur intensity for the blurred part of the depth of field effect
  118453. */
  118454. depthOfFieldBlurWidth: number;
  118455. /**
  118456. * Gets how much the image is blurred by the movement while using the motion blur post-process
  118457. */
  118458. /**
  118459. * Sets how much the image is blurred by the movement while using the motion blur post-process
  118460. */
  118461. motionStrength: number;
  118462. /**
  118463. * Gets wether or not the motion blur post-process is object based or screen based.
  118464. */
  118465. /**
  118466. * Sets wether or not the motion blur post-process should be object based or screen based
  118467. */
  118468. objectBasedMotionBlur: boolean;
  118469. /**
  118470. * List of animations for the pipeline (IAnimatable implementation)
  118471. */
  118472. animations: Animation[];
  118473. /**
  118474. * Private members
  118475. */
  118476. private _scene;
  118477. private _currentDepthOfFieldSource;
  118478. private _basePostProcess;
  118479. private _fixedExposure;
  118480. private _currentExposure;
  118481. private _hdrAutoExposure;
  118482. private _hdrCurrentLuminance;
  118483. private _motionStrength;
  118484. private _isObjectBasedMotionBlur;
  118485. private _floatTextureType;
  118486. private _ratio;
  118487. private _bloomEnabled;
  118488. private _depthOfFieldEnabled;
  118489. private _vlsEnabled;
  118490. private _lensFlareEnabled;
  118491. private _hdrEnabled;
  118492. private _motionBlurEnabled;
  118493. private _fxaaEnabled;
  118494. private _motionBlurSamples;
  118495. private _volumetricLightStepsCount;
  118496. private _samples;
  118497. /**
  118498. * @ignore
  118499. * Specifies if the bloom pipeline is enabled
  118500. */
  118501. BloomEnabled: boolean;
  118502. /**
  118503. * @ignore
  118504. * Specifies if the depth of field pipeline is enabed
  118505. */
  118506. DepthOfFieldEnabled: boolean;
  118507. /**
  118508. * @ignore
  118509. * Specifies if the lens flare pipeline is enabed
  118510. */
  118511. LensFlareEnabled: boolean;
  118512. /**
  118513. * @ignore
  118514. * Specifies if the HDR pipeline is enabled
  118515. */
  118516. HDREnabled: boolean;
  118517. /**
  118518. * @ignore
  118519. * Specifies if the volumetric lights scattering effect is enabled
  118520. */
  118521. VLSEnabled: boolean;
  118522. /**
  118523. * @ignore
  118524. * Specifies if the motion blur effect is enabled
  118525. */
  118526. MotionBlurEnabled: boolean;
  118527. /**
  118528. * Specifies if anti-aliasing is enabled
  118529. */
  118530. fxaaEnabled: boolean;
  118531. /**
  118532. * Specifies the number of steps used to calculate the volumetric lights
  118533. * Typically in interval [50, 200]
  118534. */
  118535. volumetricLightStepsCount: number;
  118536. /**
  118537. * Specifies the number of samples used for the motion blur effect
  118538. * Typically in interval [16, 64]
  118539. */
  118540. motionBlurSamples: number;
  118541. /**
  118542. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  118543. */
  118544. samples: number;
  118545. /**
  118546. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  118547. * @constructor
  118548. * @param name The rendering pipeline name
  118549. * @param scene The scene linked to this pipeline
  118550. * @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)
  118551. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  118552. * @param cameras The array of cameras that the rendering pipeline will be attached to
  118553. */
  118554. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  118555. private _buildPipeline;
  118556. private _createDownSampleX4PostProcess;
  118557. private _createBrightPassPostProcess;
  118558. private _createBlurPostProcesses;
  118559. private _createTextureAdderPostProcess;
  118560. private _createVolumetricLightPostProcess;
  118561. private _createLuminancePostProcesses;
  118562. private _createHdrPostProcess;
  118563. private _createLensFlarePostProcess;
  118564. private _createDepthOfFieldPostProcess;
  118565. private _createMotionBlurPostProcess;
  118566. private _getDepthTexture;
  118567. private _disposePostProcesses;
  118568. /**
  118569. * Dispose of the pipeline and stop all post processes
  118570. */
  118571. dispose(): void;
  118572. /**
  118573. * Serialize the rendering pipeline (Used when exporting)
  118574. * @returns the serialized object
  118575. */
  118576. serialize(): any;
  118577. /**
  118578. * Parse the serialized pipeline
  118579. * @param source Source pipeline.
  118580. * @param scene The scene to load the pipeline to.
  118581. * @param rootUrl The URL of the serialized pipeline.
  118582. * @returns An instantiated pipeline from the serialized object.
  118583. */
  118584. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  118585. /**
  118586. * Luminance steps
  118587. */
  118588. static LuminanceSteps: number;
  118589. }
  118590. }
  118591. declare module BABYLON {
  118592. /** @hidden */
  118593. export var tonemapPixelShader: {
  118594. name: string;
  118595. shader: string;
  118596. };
  118597. }
  118598. declare module BABYLON {
  118599. /** Defines operator used for tonemapping */
  118600. export enum TonemappingOperator {
  118601. /** Hable */
  118602. Hable = 0,
  118603. /** Reinhard */
  118604. Reinhard = 1,
  118605. /** HejiDawson */
  118606. HejiDawson = 2,
  118607. /** Photographic */
  118608. Photographic = 3
  118609. }
  118610. /**
  118611. * Defines a post process to apply tone mapping
  118612. */
  118613. export class TonemapPostProcess extends PostProcess {
  118614. private _operator;
  118615. /** Defines the required exposure adjustement */
  118616. exposureAdjustment: number;
  118617. /**
  118618. * Creates a new TonemapPostProcess
  118619. * @param name defines the name of the postprocess
  118620. * @param _operator defines the operator to use
  118621. * @param exposureAdjustment defines the required exposure adjustement
  118622. * @param camera defines the camera to use (can be null)
  118623. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  118624. * @param engine defines the hosting engine (can be ignore if camera is set)
  118625. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  118626. */
  118627. constructor(name: string, _operator: TonemappingOperator,
  118628. /** Defines the required exposure adjustement */
  118629. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  118630. }
  118631. }
  118632. declare module BABYLON {
  118633. /** @hidden */
  118634. export var depthVertexShader: {
  118635. name: string;
  118636. shader: string;
  118637. };
  118638. }
  118639. declare module BABYLON {
  118640. /** @hidden */
  118641. export var volumetricLightScatteringPixelShader: {
  118642. name: string;
  118643. shader: string;
  118644. };
  118645. }
  118646. declare module BABYLON {
  118647. /** @hidden */
  118648. export var volumetricLightScatteringPassPixelShader: {
  118649. name: string;
  118650. shader: string;
  118651. };
  118652. }
  118653. declare module BABYLON {
  118654. /**
  118655. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  118656. */
  118657. export class VolumetricLightScatteringPostProcess extends PostProcess {
  118658. private _volumetricLightScatteringPass;
  118659. private _volumetricLightScatteringRTT;
  118660. private _viewPort;
  118661. private _screenCoordinates;
  118662. private _cachedDefines;
  118663. /**
  118664. * If not undefined, the mesh position is computed from the attached node position
  118665. */
  118666. attachedNode: {
  118667. position: Vector3;
  118668. };
  118669. /**
  118670. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  118671. */
  118672. customMeshPosition: Vector3;
  118673. /**
  118674. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  118675. */
  118676. useCustomMeshPosition: boolean;
  118677. /**
  118678. * If the post-process should inverse the light scattering direction
  118679. */
  118680. invert: boolean;
  118681. /**
  118682. * The internal mesh used by the post-process
  118683. */
  118684. mesh: Mesh;
  118685. /**
  118686. * @hidden
  118687. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  118688. */
  118689. useDiffuseColor: boolean;
  118690. /**
  118691. * Array containing the excluded meshes not rendered in the internal pass
  118692. */
  118693. excludedMeshes: AbstractMesh[];
  118694. /**
  118695. * Controls the overall intensity of the post-process
  118696. */
  118697. exposure: number;
  118698. /**
  118699. * Dissipates each sample's contribution in range [0, 1]
  118700. */
  118701. decay: number;
  118702. /**
  118703. * Controls the overall intensity of each sample
  118704. */
  118705. weight: number;
  118706. /**
  118707. * Controls the density of each sample
  118708. */
  118709. density: number;
  118710. /**
  118711. * @constructor
  118712. * @param name The post-process name
  118713. * @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)
  118714. * @param camera The camera that the post-process will be attached to
  118715. * @param mesh The mesh used to create the light scattering
  118716. * @param samples The post-process quality, default 100
  118717. * @param samplingModeThe post-process filtering mode
  118718. * @param engine The babylon engine
  118719. * @param reusable If the post-process is reusable
  118720. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  118721. */
  118722. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  118723. /**
  118724. * Returns the string "VolumetricLightScatteringPostProcess"
  118725. * @returns "VolumetricLightScatteringPostProcess"
  118726. */
  118727. getClassName(): string;
  118728. private _isReady;
  118729. /**
  118730. * Sets the new light position for light scattering effect
  118731. * @param position The new custom light position
  118732. */
  118733. setCustomMeshPosition(position: Vector3): void;
  118734. /**
  118735. * Returns the light position for light scattering effect
  118736. * @return Vector3 The custom light position
  118737. */
  118738. getCustomMeshPosition(): Vector3;
  118739. /**
  118740. * Disposes the internal assets and detaches the post-process from the camera
  118741. */
  118742. dispose(camera: Camera): void;
  118743. /**
  118744. * Returns the render target texture used by the post-process
  118745. * @return the render target texture used by the post-process
  118746. */
  118747. getPass(): RenderTargetTexture;
  118748. private _meshExcluded;
  118749. private _createPass;
  118750. private _updateMeshScreenCoordinates;
  118751. /**
  118752. * Creates a default mesh for the Volumeric Light Scattering post-process
  118753. * @param name The mesh name
  118754. * @param scene The scene where to create the mesh
  118755. * @return the default mesh
  118756. */
  118757. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  118758. }
  118759. }
  118760. declare module BABYLON {
  118761. interface Scene {
  118762. /** @hidden (Backing field) */
  118763. _boundingBoxRenderer: BoundingBoxRenderer;
  118764. /** @hidden (Backing field) */
  118765. _forceShowBoundingBoxes: boolean;
  118766. /**
  118767. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  118768. */
  118769. forceShowBoundingBoxes: boolean;
  118770. /**
  118771. * Gets the bounding box renderer associated with the scene
  118772. * @returns a BoundingBoxRenderer
  118773. */
  118774. getBoundingBoxRenderer(): BoundingBoxRenderer;
  118775. }
  118776. interface AbstractMesh {
  118777. /** @hidden (Backing field) */
  118778. _showBoundingBox: boolean;
  118779. /**
  118780. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  118781. */
  118782. showBoundingBox: boolean;
  118783. }
  118784. /**
  118785. * Component responsible of rendering the bounding box of the meshes in a scene.
  118786. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  118787. */
  118788. export class BoundingBoxRenderer implements ISceneComponent {
  118789. /**
  118790. * The component name helpfull to identify the component in the list of scene components.
  118791. */
  118792. readonly name: string;
  118793. /**
  118794. * The scene the component belongs to.
  118795. */
  118796. scene: Scene;
  118797. /**
  118798. * Color of the bounding box lines placed in front of an object
  118799. */
  118800. frontColor: Color3;
  118801. /**
  118802. * Color of the bounding box lines placed behind an object
  118803. */
  118804. backColor: Color3;
  118805. /**
  118806. * Defines if the renderer should show the back lines or not
  118807. */
  118808. showBackLines: boolean;
  118809. /**
  118810. * @hidden
  118811. */
  118812. renderList: SmartArray<BoundingBox>;
  118813. private _colorShader;
  118814. private _vertexBuffers;
  118815. private _indexBuffer;
  118816. /**
  118817. * Instantiates a new bounding box renderer in a scene.
  118818. * @param scene the scene the renderer renders in
  118819. */
  118820. constructor(scene: Scene);
  118821. /**
  118822. * Registers the component in a given scene
  118823. */
  118824. register(): void;
  118825. private _evaluateSubMesh;
  118826. private _activeMesh;
  118827. private _prepareRessources;
  118828. private _createIndexBuffer;
  118829. /**
  118830. * Rebuilds the elements related to this component in case of
  118831. * context lost for instance.
  118832. */
  118833. rebuild(): void;
  118834. /**
  118835. * @hidden
  118836. */
  118837. reset(): void;
  118838. /**
  118839. * Render the bounding boxes of a specific rendering group
  118840. * @param renderingGroupId defines the rendering group to render
  118841. */
  118842. render(renderingGroupId: number): void;
  118843. /**
  118844. * In case of occlusion queries, we can render the occlusion bounding box through this method
  118845. * @param mesh Define the mesh to render the occlusion bounding box for
  118846. */
  118847. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  118848. /**
  118849. * Dispose and release the resources attached to this renderer.
  118850. */
  118851. dispose(): void;
  118852. }
  118853. }
  118854. declare module BABYLON {
  118855. /** @hidden */
  118856. export var depthPixelShader: {
  118857. name: string;
  118858. shader: string;
  118859. };
  118860. }
  118861. declare module BABYLON {
  118862. /**
  118863. * This represents a depth renderer in Babylon.
  118864. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  118865. */
  118866. export class DepthRenderer {
  118867. private _scene;
  118868. private _depthMap;
  118869. private _effect;
  118870. private _cachedDefines;
  118871. private _camera;
  118872. /**
  118873. * Specifiess that the depth renderer will only be used within
  118874. * the camera it is created for.
  118875. * This can help forcing its rendering during the camera processing.
  118876. */
  118877. useOnlyInActiveCamera: boolean;
  118878. /** @hidden */
  118879. static _SceneComponentInitialization: (scene: Scene) => void;
  118880. /**
  118881. * Instantiates a depth renderer
  118882. * @param scene The scene the renderer belongs to
  118883. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  118884. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  118885. */
  118886. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  118887. /**
  118888. * Creates the depth rendering effect and checks if the effect is ready.
  118889. * @param subMesh The submesh to be used to render the depth map of
  118890. * @param useInstances If multiple world instances should be used
  118891. * @returns if the depth renderer is ready to render the depth map
  118892. */
  118893. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  118894. /**
  118895. * Gets the texture which the depth map will be written to.
  118896. * @returns The depth map texture
  118897. */
  118898. getDepthMap(): RenderTargetTexture;
  118899. /**
  118900. * Disposes of the depth renderer.
  118901. */
  118902. dispose(): void;
  118903. }
  118904. }
  118905. declare module BABYLON {
  118906. interface Scene {
  118907. /** @hidden (Backing field) */
  118908. _depthRenderer: {
  118909. [id: string]: DepthRenderer;
  118910. };
  118911. /**
  118912. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  118913. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  118914. * @returns the created depth renderer
  118915. */
  118916. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  118917. /**
  118918. * Disables a depth renderer for a given camera
  118919. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  118920. */
  118921. disableDepthRenderer(camera?: Nullable<Camera>): void;
  118922. }
  118923. /**
  118924. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  118925. * in several rendering techniques.
  118926. */
  118927. export class DepthRendererSceneComponent implements ISceneComponent {
  118928. /**
  118929. * The component name helpfull to identify the component in the list of scene components.
  118930. */
  118931. readonly name: string;
  118932. /**
  118933. * The scene the component belongs to.
  118934. */
  118935. scene: Scene;
  118936. /**
  118937. * Creates a new instance of the component for the given scene
  118938. * @param scene Defines the scene to register the component in
  118939. */
  118940. constructor(scene: Scene);
  118941. /**
  118942. * Registers the component in a given scene
  118943. */
  118944. register(): void;
  118945. /**
  118946. * Rebuilds the elements related to this component in case of
  118947. * context lost for instance.
  118948. */
  118949. rebuild(): void;
  118950. /**
  118951. * Disposes the component and the associated ressources
  118952. */
  118953. dispose(): void;
  118954. private _gatherRenderTargets;
  118955. private _gatherActiveCameraRenderTargets;
  118956. }
  118957. }
  118958. declare module BABYLON {
  118959. /** @hidden */
  118960. export var outlinePixelShader: {
  118961. name: string;
  118962. shader: string;
  118963. };
  118964. }
  118965. declare module BABYLON {
  118966. /** @hidden */
  118967. export var outlineVertexShader: {
  118968. name: string;
  118969. shader: string;
  118970. };
  118971. }
  118972. declare module BABYLON {
  118973. interface Scene {
  118974. /** @hidden */
  118975. _outlineRenderer: OutlineRenderer;
  118976. /**
  118977. * Gets the outline renderer associated with the scene
  118978. * @returns a OutlineRenderer
  118979. */
  118980. getOutlineRenderer(): OutlineRenderer;
  118981. }
  118982. interface AbstractMesh {
  118983. /** @hidden (Backing field) */
  118984. _renderOutline: boolean;
  118985. /**
  118986. * Gets or sets a boolean indicating if the outline must be rendered as well
  118987. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  118988. */
  118989. renderOutline: boolean;
  118990. /** @hidden (Backing field) */
  118991. _renderOverlay: boolean;
  118992. /**
  118993. * Gets or sets a boolean indicating if the overlay must be rendered as well
  118994. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  118995. */
  118996. renderOverlay: boolean;
  118997. }
  118998. /**
  118999. * This class is responsible to draw bothe outline/overlay of meshes.
  119000. * It should not be used directly but through the available method on mesh.
  119001. */
  119002. export class OutlineRenderer implements ISceneComponent {
  119003. /**
  119004. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  119005. */
  119006. private static _StencilReference;
  119007. /**
  119008. * The name of the component. Each component must have a unique name.
  119009. */
  119010. name: string;
  119011. /**
  119012. * The scene the component belongs to.
  119013. */
  119014. scene: Scene;
  119015. /**
  119016. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  119017. */
  119018. zOffset: number;
  119019. private _engine;
  119020. private _effect;
  119021. private _cachedDefines;
  119022. private _savedDepthWrite;
  119023. /**
  119024. * Instantiates a new outline renderer. (There could be only one per scene).
  119025. * @param scene Defines the scene it belongs to
  119026. */
  119027. constructor(scene: Scene);
  119028. /**
  119029. * Register the component to one instance of a scene.
  119030. */
  119031. register(): void;
  119032. /**
  119033. * Rebuilds the elements related to this component in case of
  119034. * context lost for instance.
  119035. */
  119036. rebuild(): void;
  119037. /**
  119038. * Disposes the component and the associated ressources.
  119039. */
  119040. dispose(): void;
  119041. /**
  119042. * Renders the outline in the canvas.
  119043. * @param subMesh Defines the sumesh to render
  119044. * @param batch Defines the batch of meshes in case of instances
  119045. * @param useOverlay Defines if the rendering is for the overlay or the outline
  119046. */
  119047. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  119048. /**
  119049. * Returns whether or not the outline renderer is ready for a given submesh.
  119050. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  119051. * @param subMesh Defines the submesh to check readyness for
  119052. * @param useInstances Defines wheter wee are trying to render instances or not
  119053. * @returns true if ready otherwise false
  119054. */
  119055. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  119056. private _beforeRenderingMesh;
  119057. private _afterRenderingMesh;
  119058. }
  119059. }
  119060. declare module BABYLON {
  119061. /**
  119062. * Defines the list of states available for a task inside a AssetsManager
  119063. */
  119064. export enum AssetTaskState {
  119065. /**
  119066. * Initialization
  119067. */
  119068. INIT = 0,
  119069. /**
  119070. * Running
  119071. */
  119072. RUNNING = 1,
  119073. /**
  119074. * Done
  119075. */
  119076. DONE = 2,
  119077. /**
  119078. * Error
  119079. */
  119080. ERROR = 3
  119081. }
  119082. /**
  119083. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  119084. */
  119085. export abstract class AbstractAssetTask {
  119086. /**
  119087. * Task name
  119088. */ name: string;
  119089. /**
  119090. * Callback called when the task is successful
  119091. */
  119092. onSuccess: (task: any) => void;
  119093. /**
  119094. * Callback called when the task is not successful
  119095. */
  119096. onError: (task: any, message?: string, exception?: any) => void;
  119097. /**
  119098. * Creates a new AssetsManager
  119099. * @param name defines the name of the task
  119100. */
  119101. constructor(
  119102. /**
  119103. * Task name
  119104. */ name: string);
  119105. private _isCompleted;
  119106. private _taskState;
  119107. private _errorObject;
  119108. /**
  119109. * Get if the task is completed
  119110. */
  119111. readonly isCompleted: boolean;
  119112. /**
  119113. * Gets the current state of the task
  119114. */
  119115. readonly taskState: AssetTaskState;
  119116. /**
  119117. * Gets the current error object (if task is in error)
  119118. */
  119119. readonly errorObject: {
  119120. message?: string;
  119121. exception?: any;
  119122. };
  119123. /**
  119124. * Internal only
  119125. * @hidden
  119126. */
  119127. _setErrorObject(message?: string, exception?: any): void;
  119128. /**
  119129. * Execute the current task
  119130. * @param scene defines the scene where you want your assets to be loaded
  119131. * @param onSuccess is a callback called when the task is successfully executed
  119132. * @param onError is a callback called if an error occurs
  119133. */
  119134. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119135. /**
  119136. * Execute the current task
  119137. * @param scene defines the scene where you want your assets to be loaded
  119138. * @param onSuccess is a callback called when the task is successfully executed
  119139. * @param onError is a callback called if an error occurs
  119140. */
  119141. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119142. /**
  119143. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  119144. * This can be used with failed tasks that have the reason for failure fixed.
  119145. */
  119146. reset(): void;
  119147. private onErrorCallback;
  119148. private onDoneCallback;
  119149. }
  119150. /**
  119151. * Define the interface used by progress events raised during assets loading
  119152. */
  119153. export interface IAssetsProgressEvent {
  119154. /**
  119155. * Defines the number of remaining tasks to process
  119156. */
  119157. remainingCount: number;
  119158. /**
  119159. * Defines the total number of tasks
  119160. */
  119161. totalCount: number;
  119162. /**
  119163. * Defines the task that was just processed
  119164. */
  119165. task: AbstractAssetTask;
  119166. }
  119167. /**
  119168. * Class used to share progress information about assets loading
  119169. */
  119170. export class AssetsProgressEvent implements IAssetsProgressEvent {
  119171. /**
  119172. * Defines the number of remaining tasks to process
  119173. */
  119174. remainingCount: number;
  119175. /**
  119176. * Defines the total number of tasks
  119177. */
  119178. totalCount: number;
  119179. /**
  119180. * Defines the task that was just processed
  119181. */
  119182. task: AbstractAssetTask;
  119183. /**
  119184. * Creates a AssetsProgressEvent
  119185. * @param remainingCount defines the number of remaining tasks to process
  119186. * @param totalCount defines the total number of tasks
  119187. * @param task defines the task that was just processed
  119188. */
  119189. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  119190. }
  119191. /**
  119192. * Define a task used by AssetsManager to load meshes
  119193. */
  119194. export class MeshAssetTask extends AbstractAssetTask {
  119195. /**
  119196. * Defines the name of the task
  119197. */
  119198. name: string;
  119199. /**
  119200. * Defines the list of mesh's names you want to load
  119201. */
  119202. meshesNames: any;
  119203. /**
  119204. * Defines the root url to use as a base to load your meshes and associated resources
  119205. */
  119206. rootUrl: string;
  119207. /**
  119208. * Defines the filename of the scene to load from
  119209. */
  119210. sceneFilename: string;
  119211. /**
  119212. * Gets the list of loaded meshes
  119213. */
  119214. loadedMeshes: Array<AbstractMesh>;
  119215. /**
  119216. * Gets the list of loaded particle systems
  119217. */
  119218. loadedParticleSystems: Array<IParticleSystem>;
  119219. /**
  119220. * Gets the list of loaded skeletons
  119221. */
  119222. loadedSkeletons: Array<Skeleton>;
  119223. /**
  119224. * Gets the list of loaded animation groups
  119225. */
  119226. loadedAnimationGroups: Array<AnimationGroup>;
  119227. /**
  119228. * Callback called when the task is successful
  119229. */
  119230. onSuccess: (task: MeshAssetTask) => void;
  119231. /**
  119232. * Callback called when the task is successful
  119233. */
  119234. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  119235. /**
  119236. * Creates a new MeshAssetTask
  119237. * @param name defines the name of the task
  119238. * @param meshesNames defines the list of mesh's names you want to load
  119239. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  119240. * @param sceneFilename defines the filename of the scene to load from
  119241. */
  119242. constructor(
  119243. /**
  119244. * Defines the name of the task
  119245. */
  119246. name: string,
  119247. /**
  119248. * Defines the list of mesh's names you want to load
  119249. */
  119250. meshesNames: any,
  119251. /**
  119252. * Defines the root url to use as a base to load your meshes and associated resources
  119253. */
  119254. rootUrl: string,
  119255. /**
  119256. * Defines the filename of the scene to load from
  119257. */
  119258. sceneFilename: string);
  119259. /**
  119260. * Execute the current task
  119261. * @param scene defines the scene where you want your assets to be loaded
  119262. * @param onSuccess is a callback called when the task is successfully executed
  119263. * @param onError is a callback called if an error occurs
  119264. */
  119265. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119266. }
  119267. /**
  119268. * Define a task used by AssetsManager to load text content
  119269. */
  119270. export class TextFileAssetTask extends AbstractAssetTask {
  119271. /**
  119272. * Defines the name of the task
  119273. */
  119274. name: string;
  119275. /**
  119276. * Defines the location of the file to load
  119277. */
  119278. url: string;
  119279. /**
  119280. * Gets the loaded text string
  119281. */
  119282. text: string;
  119283. /**
  119284. * Callback called when the task is successful
  119285. */
  119286. onSuccess: (task: TextFileAssetTask) => void;
  119287. /**
  119288. * Callback called when the task is successful
  119289. */
  119290. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  119291. /**
  119292. * Creates a new TextFileAssetTask object
  119293. * @param name defines the name of the task
  119294. * @param url defines the location of the file to load
  119295. */
  119296. constructor(
  119297. /**
  119298. * Defines the name of the task
  119299. */
  119300. name: string,
  119301. /**
  119302. * Defines the location of the file to load
  119303. */
  119304. url: string);
  119305. /**
  119306. * Execute the current task
  119307. * @param scene defines the scene where you want your assets to be loaded
  119308. * @param onSuccess is a callback called when the task is successfully executed
  119309. * @param onError is a callback called if an error occurs
  119310. */
  119311. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119312. }
  119313. /**
  119314. * Define a task used by AssetsManager to load binary data
  119315. */
  119316. export class BinaryFileAssetTask extends AbstractAssetTask {
  119317. /**
  119318. * Defines the name of the task
  119319. */
  119320. name: string;
  119321. /**
  119322. * Defines the location of the file to load
  119323. */
  119324. url: string;
  119325. /**
  119326. * Gets the lodaded data (as an array buffer)
  119327. */
  119328. data: ArrayBuffer;
  119329. /**
  119330. * Callback called when the task is successful
  119331. */
  119332. onSuccess: (task: BinaryFileAssetTask) => void;
  119333. /**
  119334. * Callback called when the task is successful
  119335. */
  119336. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  119337. /**
  119338. * Creates a new BinaryFileAssetTask object
  119339. * @param name defines the name of the new task
  119340. * @param url defines the location of the file to load
  119341. */
  119342. constructor(
  119343. /**
  119344. * Defines the name of the task
  119345. */
  119346. name: string,
  119347. /**
  119348. * Defines the location of the file to load
  119349. */
  119350. url: string);
  119351. /**
  119352. * Execute the current task
  119353. * @param scene defines the scene where you want your assets to be loaded
  119354. * @param onSuccess is a callback called when the task is successfully executed
  119355. * @param onError is a callback called if an error occurs
  119356. */
  119357. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119358. }
  119359. /**
  119360. * Define a task used by AssetsManager to load images
  119361. */
  119362. export class ImageAssetTask extends AbstractAssetTask {
  119363. /**
  119364. * Defines the name of the task
  119365. */
  119366. name: string;
  119367. /**
  119368. * Defines the location of the image to load
  119369. */
  119370. url: string;
  119371. /**
  119372. * Gets the loaded images
  119373. */
  119374. image: HTMLImageElement;
  119375. /**
  119376. * Callback called when the task is successful
  119377. */
  119378. onSuccess: (task: ImageAssetTask) => void;
  119379. /**
  119380. * Callback called when the task is successful
  119381. */
  119382. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  119383. /**
  119384. * Creates a new ImageAssetTask
  119385. * @param name defines the name of the task
  119386. * @param url defines the location of the image to load
  119387. */
  119388. constructor(
  119389. /**
  119390. * Defines the name of the task
  119391. */
  119392. name: string,
  119393. /**
  119394. * Defines the location of the image to load
  119395. */
  119396. url: string);
  119397. /**
  119398. * Execute the current task
  119399. * @param scene defines the scene where you want your assets to be loaded
  119400. * @param onSuccess is a callback called when the task is successfully executed
  119401. * @param onError is a callback called if an error occurs
  119402. */
  119403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119404. }
  119405. /**
  119406. * Defines the interface used by texture loading tasks
  119407. */
  119408. export interface ITextureAssetTask<TEX extends BaseTexture> {
  119409. /**
  119410. * Gets the loaded texture
  119411. */
  119412. texture: TEX;
  119413. }
  119414. /**
  119415. * Define a task used by AssetsManager to load 2D textures
  119416. */
  119417. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  119418. /**
  119419. * Defines the name of the task
  119420. */
  119421. name: string;
  119422. /**
  119423. * Defines the location of the file to load
  119424. */
  119425. url: string;
  119426. /**
  119427. * Defines if mipmap should not be generated (default is false)
  119428. */
  119429. noMipmap?: boolean | undefined;
  119430. /**
  119431. * Defines if texture must be inverted on Y axis (default is false)
  119432. */
  119433. invertY?: boolean | undefined;
  119434. /**
  119435. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119436. */
  119437. samplingMode: number;
  119438. /**
  119439. * Gets the loaded texture
  119440. */
  119441. texture: Texture;
  119442. /**
  119443. * Callback called when the task is successful
  119444. */
  119445. onSuccess: (task: TextureAssetTask) => void;
  119446. /**
  119447. * Callback called when the task is successful
  119448. */
  119449. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  119450. /**
  119451. * Creates a new TextureAssetTask object
  119452. * @param name defines the name of the task
  119453. * @param url defines the location of the file to load
  119454. * @param noMipmap defines if mipmap should not be generated (default is false)
  119455. * @param invertY defines if texture must be inverted on Y axis (default is false)
  119456. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119457. */
  119458. constructor(
  119459. /**
  119460. * Defines the name of the task
  119461. */
  119462. name: string,
  119463. /**
  119464. * Defines the location of the file to load
  119465. */
  119466. url: string,
  119467. /**
  119468. * Defines if mipmap should not be generated (default is false)
  119469. */
  119470. noMipmap?: boolean | undefined,
  119471. /**
  119472. * Defines if texture must be inverted on Y axis (default is false)
  119473. */
  119474. invertY?: boolean | undefined,
  119475. /**
  119476. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  119477. */
  119478. samplingMode?: number);
  119479. /**
  119480. * Execute the current task
  119481. * @param scene defines the scene where you want your assets to be loaded
  119482. * @param onSuccess is a callback called when the task is successfully executed
  119483. * @param onError is a callback called if an error occurs
  119484. */
  119485. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119486. }
  119487. /**
  119488. * Define a task used by AssetsManager to load cube textures
  119489. */
  119490. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  119491. /**
  119492. * Defines the name of the task
  119493. */
  119494. name: string;
  119495. /**
  119496. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119497. */
  119498. url: string;
  119499. /**
  119500. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119501. */
  119502. extensions?: string[] | undefined;
  119503. /**
  119504. * Defines if mipmaps should not be generated (default is false)
  119505. */
  119506. noMipmap?: boolean | undefined;
  119507. /**
  119508. * Defines the explicit list of files (undefined by default)
  119509. */
  119510. files?: string[] | undefined;
  119511. /**
  119512. * Gets the loaded texture
  119513. */
  119514. texture: CubeTexture;
  119515. /**
  119516. * Callback called when the task is successful
  119517. */
  119518. onSuccess: (task: CubeTextureAssetTask) => void;
  119519. /**
  119520. * Callback called when the task is successful
  119521. */
  119522. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  119523. /**
  119524. * Creates a new CubeTextureAssetTask
  119525. * @param name defines the name of the task
  119526. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119527. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119528. * @param noMipmap defines if mipmaps should not be generated (default is false)
  119529. * @param files defines the explicit list of files (undefined by default)
  119530. */
  119531. constructor(
  119532. /**
  119533. * Defines the name of the task
  119534. */
  119535. name: string,
  119536. /**
  119537. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  119538. */
  119539. url: string,
  119540. /**
  119541. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  119542. */
  119543. extensions?: string[] | undefined,
  119544. /**
  119545. * Defines if mipmaps should not be generated (default is false)
  119546. */
  119547. noMipmap?: boolean | undefined,
  119548. /**
  119549. * Defines the explicit list of files (undefined by default)
  119550. */
  119551. files?: string[] | undefined);
  119552. /**
  119553. * Execute the current task
  119554. * @param scene defines the scene where you want your assets to be loaded
  119555. * @param onSuccess is a callback called when the task is successfully executed
  119556. * @param onError is a callback called if an error occurs
  119557. */
  119558. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119559. }
  119560. /**
  119561. * Define a task used by AssetsManager to load HDR cube textures
  119562. */
  119563. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  119564. /**
  119565. * Defines the name of the task
  119566. */
  119567. name: string;
  119568. /**
  119569. * Defines the location of the file to load
  119570. */
  119571. url: string;
  119572. /**
  119573. * Defines the desired size (the more it increases the longer the generation will be)
  119574. */
  119575. size: number;
  119576. /**
  119577. * Defines if mipmaps should not be generated (default is false)
  119578. */
  119579. noMipmap: boolean;
  119580. /**
  119581. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  119582. */
  119583. generateHarmonics: boolean;
  119584. /**
  119585. * 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)
  119586. */
  119587. gammaSpace: boolean;
  119588. /**
  119589. * Internal Use Only
  119590. */
  119591. reserved: boolean;
  119592. /**
  119593. * Gets the loaded texture
  119594. */
  119595. texture: HDRCubeTexture;
  119596. /**
  119597. * Callback called when the task is successful
  119598. */
  119599. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  119600. /**
  119601. * Callback called when the task is successful
  119602. */
  119603. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  119604. /**
  119605. * Creates a new HDRCubeTextureAssetTask object
  119606. * @param name defines the name of the task
  119607. * @param url defines the location of the file to load
  119608. * @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.
  119609. * @param noMipmap defines if mipmaps should not be generated (default is false)
  119610. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  119611. * @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)
  119612. * @param reserved Internal use only
  119613. */
  119614. constructor(
  119615. /**
  119616. * Defines the name of the task
  119617. */
  119618. name: string,
  119619. /**
  119620. * Defines the location of the file to load
  119621. */
  119622. url: string,
  119623. /**
  119624. * Defines the desired size (the more it increases the longer the generation will be)
  119625. */
  119626. size: number,
  119627. /**
  119628. * Defines if mipmaps should not be generated (default is false)
  119629. */
  119630. noMipmap?: boolean,
  119631. /**
  119632. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  119633. */
  119634. generateHarmonics?: boolean,
  119635. /**
  119636. * 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)
  119637. */
  119638. gammaSpace?: boolean,
  119639. /**
  119640. * Internal Use Only
  119641. */
  119642. reserved?: boolean);
  119643. /**
  119644. * Execute the current task
  119645. * @param scene defines the scene where you want your assets to be loaded
  119646. * @param onSuccess is a callback called when the task is successfully executed
  119647. * @param onError is a callback called if an error occurs
  119648. */
  119649. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119650. }
  119651. /**
  119652. * Define a task used by AssetsManager to load Equirectangular cube textures
  119653. */
  119654. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  119655. /**
  119656. * Defines the name of the task
  119657. */
  119658. name: string;
  119659. /**
  119660. * Defines the location of the file to load
  119661. */
  119662. url: string;
  119663. /**
  119664. * Defines the desired size (the more it increases the longer the generation will be)
  119665. */
  119666. size: number;
  119667. /**
  119668. * Defines if mipmaps should not be generated (default is false)
  119669. */
  119670. noMipmap: boolean;
  119671. /**
  119672. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  119673. * but the standard material would require them in Gamma space) (default is true)
  119674. */
  119675. gammaSpace: boolean;
  119676. /**
  119677. * Gets the loaded texture
  119678. */
  119679. texture: EquiRectangularCubeTexture;
  119680. /**
  119681. * Callback called when the task is successful
  119682. */
  119683. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  119684. /**
  119685. * Callback called when the task is successful
  119686. */
  119687. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  119688. /**
  119689. * Creates a new EquiRectangularCubeTextureAssetTask object
  119690. * @param name defines the name of the task
  119691. * @param url defines the location of the file to load
  119692. * @param size defines the desired size (the more it increases the longer the generation will be)
  119693. * If the size is omitted this implies you are using a preprocessed cubemap.
  119694. * @param noMipmap defines if mipmaps should not be generated (default is false)
  119695. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  119696. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  119697. * (default is true)
  119698. */
  119699. constructor(
  119700. /**
  119701. * Defines the name of the task
  119702. */
  119703. name: string,
  119704. /**
  119705. * Defines the location of the file to load
  119706. */
  119707. url: string,
  119708. /**
  119709. * Defines the desired size (the more it increases the longer the generation will be)
  119710. */
  119711. size: number,
  119712. /**
  119713. * Defines if mipmaps should not be generated (default is false)
  119714. */
  119715. noMipmap?: boolean,
  119716. /**
  119717. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  119718. * but the standard material would require them in Gamma space) (default is true)
  119719. */
  119720. gammaSpace?: boolean);
  119721. /**
  119722. * Execute the current task
  119723. * @param scene defines the scene where you want your assets to be loaded
  119724. * @param onSuccess is a callback called when the task is successfully executed
  119725. * @param onError is a callback called if an error occurs
  119726. */
  119727. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  119728. }
  119729. /**
  119730. * This class can be used to easily import assets into a scene
  119731. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  119732. */
  119733. export class AssetsManager {
  119734. private _scene;
  119735. private _isLoading;
  119736. protected _tasks: AbstractAssetTask[];
  119737. protected _waitingTasksCount: number;
  119738. protected _totalTasksCount: number;
  119739. /**
  119740. * Callback called when all tasks are processed
  119741. */
  119742. onFinish: (tasks: AbstractAssetTask[]) => void;
  119743. /**
  119744. * Callback called when a task is successful
  119745. */
  119746. onTaskSuccess: (task: AbstractAssetTask) => void;
  119747. /**
  119748. * Callback called when a task had an error
  119749. */
  119750. onTaskError: (task: AbstractAssetTask) => void;
  119751. /**
  119752. * Callback called when a task is done (whatever the result is)
  119753. */
  119754. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  119755. /**
  119756. * Observable called when all tasks are processed
  119757. */
  119758. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  119759. /**
  119760. * Observable called when a task had an error
  119761. */
  119762. onTaskErrorObservable: Observable<AbstractAssetTask>;
  119763. /**
  119764. * Observable called when all tasks were executed
  119765. */
  119766. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  119767. /**
  119768. * Observable called when a task is done (whatever the result is)
  119769. */
  119770. onProgressObservable: Observable<IAssetsProgressEvent>;
  119771. /**
  119772. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  119773. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  119774. */
  119775. useDefaultLoadingScreen: boolean;
  119776. /**
  119777. * Creates a new AssetsManager
  119778. * @param scene defines the scene to work on
  119779. */
  119780. constructor(scene: Scene);
  119781. /**
  119782. * Add a MeshAssetTask to the list of active tasks
  119783. * @param taskName defines the name of the new task
  119784. * @param meshesNames defines the name of meshes to load
  119785. * @param rootUrl defines the root url to use to locate files
  119786. * @param sceneFilename defines the filename of the scene file
  119787. * @returns a new MeshAssetTask object
  119788. */
  119789. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  119790. /**
  119791. * Add a TextFileAssetTask to the list of active tasks
  119792. * @param taskName defines the name of the new task
  119793. * @param url defines the url of the file to load
  119794. * @returns a new TextFileAssetTask object
  119795. */
  119796. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  119797. /**
  119798. * Add a BinaryFileAssetTask to the list of active tasks
  119799. * @param taskName defines the name of the new task
  119800. * @param url defines the url of the file to load
  119801. * @returns a new BinaryFileAssetTask object
  119802. */
  119803. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  119804. /**
  119805. * Add a ImageAssetTask to the list of active tasks
  119806. * @param taskName defines the name of the new task
  119807. * @param url defines the url of the file to load
  119808. * @returns a new ImageAssetTask object
  119809. */
  119810. addImageTask(taskName: string, url: string): ImageAssetTask;
  119811. /**
  119812. * Add a TextureAssetTask to the list of active tasks
  119813. * @param taskName defines the name of the new task
  119814. * @param url defines the url of the file to load
  119815. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  119816. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  119817. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119818. * @returns a new TextureAssetTask object
  119819. */
  119820. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  119821. /**
  119822. * Add a CubeTextureAssetTask to the list of active tasks
  119823. * @param taskName defines the name of the new task
  119824. * @param url defines the url of the file to load
  119825. * @param extensions defines the extension to use to load the cube map (can be null)
  119826. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  119827. * @param files defines the list of files to load (can be null)
  119828. * @returns a new CubeTextureAssetTask object
  119829. */
  119830. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  119831. /**
  119832. *
  119833. * Add a HDRCubeTextureAssetTask to the list of active tasks
  119834. * @param taskName defines the name of the new task
  119835. * @param url defines the url of the file to load
  119836. * @param size defines the size you want for the cubemap (can be null)
  119837. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  119838. * @param generateHarmonics defines if you want to automatically generate (true by default)
  119839. * @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)
  119840. * @param reserved Internal use only
  119841. * @returns a new HDRCubeTextureAssetTask object
  119842. */
  119843. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  119844. /**
  119845. *
  119846. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  119847. * @param taskName defines the name of the new task
  119848. * @param url defines the url of the file to load
  119849. * @param size defines the size you want for the cubemap (can be null)
  119850. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  119851. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  119852. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  119853. * @returns a new EquiRectangularCubeTextureAssetTask object
  119854. */
  119855. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  119856. /**
  119857. * Remove a task from the assets manager.
  119858. * @param task the task to remove
  119859. */
  119860. removeTask(task: AbstractAssetTask): void;
  119861. private _decreaseWaitingTasksCount;
  119862. private _runTask;
  119863. /**
  119864. * Reset the AssetsManager and remove all tasks
  119865. * @return the current instance of the AssetsManager
  119866. */
  119867. reset(): AssetsManager;
  119868. /**
  119869. * Start the loading process
  119870. * @return the current instance of the AssetsManager
  119871. */
  119872. load(): AssetsManager;
  119873. /**
  119874. * Start the loading process as an async operation
  119875. * @return a promise returning the list of failed tasks
  119876. */
  119877. loadAsync(): Promise<void>;
  119878. }
  119879. }
  119880. declare module BABYLON {
  119881. /**
  119882. * Wrapper class for promise with external resolve and reject.
  119883. */
  119884. export class Deferred<T> {
  119885. /**
  119886. * The promise associated with this deferred object.
  119887. */
  119888. readonly promise: Promise<T>;
  119889. private _resolve;
  119890. private _reject;
  119891. /**
  119892. * The resolve method of the promise associated with this deferred object.
  119893. */
  119894. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  119895. /**
  119896. * The reject method of the promise associated with this deferred object.
  119897. */
  119898. readonly reject: (reason?: any) => void;
  119899. /**
  119900. * Constructor for this deferred object.
  119901. */
  119902. constructor();
  119903. }
  119904. }
  119905. declare module BABYLON {
  119906. /**
  119907. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  119908. */
  119909. export class MeshExploder {
  119910. private _centerMesh;
  119911. private _meshes;
  119912. private _meshesOrigins;
  119913. private _toCenterVectors;
  119914. private _scaledDirection;
  119915. private _newPosition;
  119916. private _centerPosition;
  119917. /**
  119918. * Explodes meshes from a center mesh.
  119919. * @param meshes The meshes to explode.
  119920. * @param centerMesh The mesh to be center of explosion.
  119921. */
  119922. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  119923. private _setCenterMesh;
  119924. /**
  119925. * Get class name
  119926. * @returns "MeshExploder"
  119927. */
  119928. getClassName(): string;
  119929. /**
  119930. * "Exploded meshes"
  119931. * @returns Array of meshes with the centerMesh at index 0.
  119932. */
  119933. getMeshes(): Array<Mesh>;
  119934. /**
  119935. * Explodes meshes giving a specific direction
  119936. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  119937. */
  119938. explode(direction?: number): void;
  119939. }
  119940. }
  119941. declare module BABYLON {
  119942. /**
  119943. * Class used to help managing file picking and drag'n'drop
  119944. */
  119945. export class FilesInput {
  119946. /**
  119947. * List of files ready to be loaded
  119948. */
  119949. static readonly FilesToLoad: {
  119950. [key: string]: File;
  119951. };
  119952. /**
  119953. * Callback called when a file is processed
  119954. */
  119955. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  119956. private _engine;
  119957. private _currentScene;
  119958. private _sceneLoadedCallback;
  119959. private _progressCallback;
  119960. private _additionalRenderLoopLogicCallback;
  119961. private _textureLoadingCallback;
  119962. private _startingProcessingFilesCallback;
  119963. private _onReloadCallback;
  119964. private _errorCallback;
  119965. private _elementToMonitor;
  119966. private _sceneFileToLoad;
  119967. private _filesToLoad;
  119968. /**
  119969. * Creates a new FilesInput
  119970. * @param engine defines the rendering engine
  119971. * @param scene defines the hosting scene
  119972. * @param sceneLoadedCallback callback called when scene is loaded
  119973. * @param progressCallback callback called to track progress
  119974. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  119975. * @param textureLoadingCallback callback called when a texture is loading
  119976. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  119977. * @param onReloadCallback callback called when a reload is requested
  119978. * @param errorCallback callback call if an error occurs
  119979. */
  119980. 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);
  119981. private _dragEnterHandler;
  119982. private _dragOverHandler;
  119983. private _dropHandler;
  119984. /**
  119985. * Calls this function to listen to drag'n'drop events on a specific DOM element
  119986. * @param elementToMonitor defines the DOM element to track
  119987. */
  119988. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  119989. /**
  119990. * Release all associated resources
  119991. */
  119992. dispose(): void;
  119993. private renderFunction;
  119994. private drag;
  119995. private drop;
  119996. private _traverseFolder;
  119997. private _processFiles;
  119998. /**
  119999. * Load files from a drop event
  120000. * @param event defines the drop event to use as source
  120001. */
  120002. loadFiles(event: any): void;
  120003. private _processReload;
  120004. /**
  120005. * Reload the current scene from the loaded files
  120006. */
  120007. reload(): void;
  120008. }
  120009. }
  120010. declare module BABYLON {
  120011. /**
  120012. * Defines the root class used to create scene optimization to use with SceneOptimizer
  120013. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120014. */
  120015. export class SceneOptimization {
  120016. /**
  120017. * Defines the priority of this optimization (0 by default which means first in the list)
  120018. */
  120019. priority: number;
  120020. /**
  120021. * Gets a string describing the action executed by the current optimization
  120022. * @returns description string
  120023. */
  120024. getDescription(): string;
  120025. /**
  120026. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120027. * @param scene defines the current scene where to apply this optimization
  120028. * @param optimizer defines the current optimizer
  120029. * @returns true if everything that can be done was applied
  120030. */
  120031. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120032. /**
  120033. * Creates the SceneOptimization object
  120034. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120035. * @param desc defines the description associated with the optimization
  120036. */
  120037. constructor(
  120038. /**
  120039. * Defines the priority of this optimization (0 by default which means first in the list)
  120040. */
  120041. priority?: number);
  120042. }
  120043. /**
  120044. * Defines an optimization used to reduce the size of render target textures
  120045. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120046. */
  120047. export class TextureOptimization extends SceneOptimization {
  120048. /**
  120049. * Defines the priority of this optimization (0 by default which means first in the list)
  120050. */
  120051. priority: number;
  120052. /**
  120053. * 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
  120054. */
  120055. maximumSize: number;
  120056. /**
  120057. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120058. */
  120059. step: number;
  120060. /**
  120061. * Gets a string describing the action executed by the current optimization
  120062. * @returns description string
  120063. */
  120064. getDescription(): string;
  120065. /**
  120066. * Creates the TextureOptimization object
  120067. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120068. * @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
  120069. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120070. */
  120071. constructor(
  120072. /**
  120073. * Defines the priority of this optimization (0 by default which means first in the list)
  120074. */
  120075. priority?: number,
  120076. /**
  120077. * 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
  120078. */
  120079. maximumSize?: number,
  120080. /**
  120081. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  120082. */
  120083. step?: number);
  120084. /**
  120085. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120086. * @param scene defines the current scene where to apply this optimization
  120087. * @param optimizer defines the current optimizer
  120088. * @returns true if everything that can be done was applied
  120089. */
  120090. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120091. }
  120092. /**
  120093. * Defines an optimization used to increase or decrease the rendering resolution
  120094. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120095. */
  120096. export class HardwareScalingOptimization extends SceneOptimization {
  120097. /**
  120098. * Defines the priority of this optimization (0 by default which means first in the list)
  120099. */
  120100. priority: number;
  120101. /**
  120102. * Defines the maximum scale to use (2 by default)
  120103. */
  120104. maximumScale: number;
  120105. /**
  120106. * Defines the step to use between two passes (0.5 by default)
  120107. */
  120108. step: number;
  120109. private _currentScale;
  120110. private _directionOffset;
  120111. /**
  120112. * Gets a string describing the action executed by the current optimization
  120113. * @return description string
  120114. */
  120115. getDescription(): string;
  120116. /**
  120117. * Creates the HardwareScalingOptimization object
  120118. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120119. * @param maximumScale defines the maximum scale to use (2 by default)
  120120. * @param step defines the step to use between two passes (0.5 by default)
  120121. */
  120122. constructor(
  120123. /**
  120124. * Defines the priority of this optimization (0 by default which means first in the list)
  120125. */
  120126. priority?: number,
  120127. /**
  120128. * Defines the maximum scale to use (2 by default)
  120129. */
  120130. maximumScale?: number,
  120131. /**
  120132. * Defines the step to use between two passes (0.5 by default)
  120133. */
  120134. step?: number);
  120135. /**
  120136. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120137. * @param scene defines the current scene where to apply this optimization
  120138. * @param optimizer defines the current optimizer
  120139. * @returns true if everything that can be done was applied
  120140. */
  120141. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120142. }
  120143. /**
  120144. * Defines an optimization used to remove shadows
  120145. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120146. */
  120147. export class ShadowsOptimization extends SceneOptimization {
  120148. /**
  120149. * Gets a string describing the action executed by the current optimization
  120150. * @return description string
  120151. */
  120152. getDescription(): string;
  120153. /**
  120154. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120155. * @param scene defines the current scene where to apply this optimization
  120156. * @param optimizer defines the current optimizer
  120157. * @returns true if everything that can be done was applied
  120158. */
  120159. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120160. }
  120161. /**
  120162. * Defines an optimization used to turn post-processes off
  120163. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120164. */
  120165. export class PostProcessesOptimization extends SceneOptimization {
  120166. /**
  120167. * Gets a string describing the action executed by the current optimization
  120168. * @return description string
  120169. */
  120170. getDescription(): string;
  120171. /**
  120172. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120173. * @param scene defines the current scene where to apply this optimization
  120174. * @param optimizer defines the current optimizer
  120175. * @returns true if everything that can be done was applied
  120176. */
  120177. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120178. }
  120179. /**
  120180. * Defines an optimization used to turn lens flares off
  120181. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120182. */
  120183. export class LensFlaresOptimization extends SceneOptimization {
  120184. /**
  120185. * Gets a string describing the action executed by the current optimization
  120186. * @return description string
  120187. */
  120188. getDescription(): string;
  120189. /**
  120190. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120191. * @param scene defines the current scene where to apply this optimization
  120192. * @param optimizer defines the current optimizer
  120193. * @returns true if everything that can be done was applied
  120194. */
  120195. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120196. }
  120197. /**
  120198. * Defines an optimization based on user defined callback.
  120199. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120200. */
  120201. export class CustomOptimization extends SceneOptimization {
  120202. /**
  120203. * Callback called to apply the custom optimization.
  120204. */
  120205. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  120206. /**
  120207. * Callback called to get custom description
  120208. */
  120209. onGetDescription: () => string;
  120210. /**
  120211. * Gets a string describing the action executed by the current optimization
  120212. * @returns description string
  120213. */
  120214. getDescription(): string;
  120215. /**
  120216. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120217. * @param scene defines the current scene where to apply this optimization
  120218. * @param optimizer defines the current optimizer
  120219. * @returns true if everything that can be done was applied
  120220. */
  120221. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120222. }
  120223. /**
  120224. * Defines an optimization used to turn particles off
  120225. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120226. */
  120227. export class ParticlesOptimization extends SceneOptimization {
  120228. /**
  120229. * Gets a string describing the action executed by the current optimization
  120230. * @return description string
  120231. */
  120232. getDescription(): string;
  120233. /**
  120234. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120235. * @param scene defines the current scene where to apply this optimization
  120236. * @param optimizer defines the current optimizer
  120237. * @returns true if everything that can be done was applied
  120238. */
  120239. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120240. }
  120241. /**
  120242. * Defines an optimization used to turn render targets off
  120243. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120244. */
  120245. export class RenderTargetsOptimization extends SceneOptimization {
  120246. /**
  120247. * Gets a string describing the action executed by the current optimization
  120248. * @return description string
  120249. */
  120250. getDescription(): string;
  120251. /**
  120252. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120253. * @param scene defines the current scene where to apply this optimization
  120254. * @param optimizer defines the current optimizer
  120255. * @returns true if everything that can be done was applied
  120256. */
  120257. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  120258. }
  120259. /**
  120260. * Defines an optimization used to merge meshes with compatible materials
  120261. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120262. */
  120263. export class MergeMeshesOptimization extends SceneOptimization {
  120264. private static _UpdateSelectionTree;
  120265. /**
  120266. * Gets or sets a boolean which defines if optimization octree has to be updated
  120267. */
  120268. /**
  120269. * Gets or sets a boolean which defines if optimization octree has to be updated
  120270. */
  120271. static UpdateSelectionTree: boolean;
  120272. /**
  120273. * Gets a string describing the action executed by the current optimization
  120274. * @return description string
  120275. */
  120276. getDescription(): string;
  120277. private _canBeMerged;
  120278. /**
  120279. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  120280. * @param scene defines the current scene where to apply this optimization
  120281. * @param optimizer defines the current optimizer
  120282. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  120283. * @returns true if everything that can be done was applied
  120284. */
  120285. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  120286. }
  120287. /**
  120288. * Defines a list of options used by SceneOptimizer
  120289. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120290. */
  120291. export class SceneOptimizerOptions {
  120292. /**
  120293. * Defines the target frame rate to reach (60 by default)
  120294. */
  120295. targetFrameRate: number;
  120296. /**
  120297. * Defines the interval between two checkes (2000ms by default)
  120298. */
  120299. trackerDuration: number;
  120300. /**
  120301. * Gets the list of optimizations to apply
  120302. */
  120303. optimizations: SceneOptimization[];
  120304. /**
  120305. * Creates a new list of options used by SceneOptimizer
  120306. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  120307. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  120308. */
  120309. constructor(
  120310. /**
  120311. * Defines the target frame rate to reach (60 by default)
  120312. */
  120313. targetFrameRate?: number,
  120314. /**
  120315. * Defines the interval between two checkes (2000ms by default)
  120316. */
  120317. trackerDuration?: number);
  120318. /**
  120319. * Add a new optimization
  120320. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  120321. * @returns the current SceneOptimizerOptions
  120322. */
  120323. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  120324. /**
  120325. * Add a new custom optimization
  120326. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  120327. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  120328. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  120329. * @returns the current SceneOptimizerOptions
  120330. */
  120331. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  120332. /**
  120333. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  120334. * @param targetFrameRate defines the target frame rate (60 by default)
  120335. * @returns a SceneOptimizerOptions object
  120336. */
  120337. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120338. /**
  120339. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  120340. * @param targetFrameRate defines the target frame rate (60 by default)
  120341. * @returns a SceneOptimizerOptions object
  120342. */
  120343. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120344. /**
  120345. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  120346. * @param targetFrameRate defines the target frame rate (60 by default)
  120347. * @returns a SceneOptimizerOptions object
  120348. */
  120349. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  120350. }
  120351. /**
  120352. * Class used to run optimizations in order to reach a target frame rate
  120353. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  120354. */
  120355. export class SceneOptimizer implements IDisposable {
  120356. private _isRunning;
  120357. private _options;
  120358. private _scene;
  120359. private _currentPriorityLevel;
  120360. private _targetFrameRate;
  120361. private _trackerDuration;
  120362. private _currentFrameRate;
  120363. private _sceneDisposeObserver;
  120364. private _improvementMode;
  120365. /**
  120366. * Defines an observable called when the optimizer reaches the target frame rate
  120367. */
  120368. onSuccessObservable: Observable<SceneOptimizer>;
  120369. /**
  120370. * Defines an observable called when the optimizer enables an optimization
  120371. */
  120372. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  120373. /**
  120374. * Defines an observable called when the optimizer is not able to reach the target frame rate
  120375. */
  120376. onFailureObservable: Observable<SceneOptimizer>;
  120377. /**
  120378. * Gets a boolean indicating if the optimizer is in improvement mode
  120379. */
  120380. readonly isInImprovementMode: boolean;
  120381. /**
  120382. * Gets the current priority level (0 at start)
  120383. */
  120384. readonly currentPriorityLevel: number;
  120385. /**
  120386. * Gets the current frame rate checked by the SceneOptimizer
  120387. */
  120388. readonly currentFrameRate: number;
  120389. /**
  120390. * Gets or sets the current target frame rate (60 by default)
  120391. */
  120392. /**
  120393. * Gets or sets the current target frame rate (60 by default)
  120394. */
  120395. targetFrameRate: number;
  120396. /**
  120397. * Gets or sets the current interval between two checks (every 2000ms by default)
  120398. */
  120399. /**
  120400. * Gets or sets the current interval between two checks (every 2000ms by default)
  120401. */
  120402. trackerDuration: number;
  120403. /**
  120404. * Gets the list of active optimizations
  120405. */
  120406. readonly optimizations: SceneOptimization[];
  120407. /**
  120408. * Creates a new SceneOptimizer
  120409. * @param scene defines the scene to work on
  120410. * @param options defines the options to use with the SceneOptimizer
  120411. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  120412. * @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)
  120413. */
  120414. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  120415. /**
  120416. * Stops the current optimizer
  120417. */
  120418. stop(): void;
  120419. /**
  120420. * Reset the optimizer to initial step (current priority level = 0)
  120421. */
  120422. reset(): void;
  120423. /**
  120424. * Start the optimizer. By default it will try to reach a specific framerate
  120425. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  120426. */
  120427. start(): void;
  120428. private _checkCurrentState;
  120429. /**
  120430. * Release all resources
  120431. */
  120432. dispose(): void;
  120433. /**
  120434. * Helper function to create a SceneOptimizer with one single line of code
  120435. * @param scene defines the scene to work on
  120436. * @param options defines the options to use with the SceneOptimizer
  120437. * @param onSuccess defines a callback to call on success
  120438. * @param onFailure defines a callback to call on failure
  120439. * @returns the new SceneOptimizer object
  120440. */
  120441. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  120442. }
  120443. }
  120444. declare module BABYLON {
  120445. /**
  120446. * Class used to serialize a scene into a string
  120447. */
  120448. export class SceneSerializer {
  120449. /**
  120450. * Clear cache used by a previous serialization
  120451. */
  120452. static ClearCache(): void;
  120453. /**
  120454. * Serialize a scene into a JSON compatible object
  120455. * @param scene defines the scene to serialize
  120456. * @returns a JSON compatible object
  120457. */
  120458. static Serialize(scene: Scene): any;
  120459. /**
  120460. * Serialize a mesh into a JSON compatible object
  120461. * @param toSerialize defines the mesh to serialize
  120462. * @param withParents defines if parents must be serialized as well
  120463. * @param withChildren defines if children must be serialized as well
  120464. * @returns a JSON compatible object
  120465. */
  120466. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  120467. }
  120468. }
  120469. declare module BABYLON {
  120470. /**
  120471. * Class used to host texture specific utilities
  120472. */
  120473. export class TextureTools {
  120474. /**
  120475. * Uses the GPU to create a copy texture rescaled at a given size
  120476. * @param texture Texture to copy from
  120477. * @param width defines the desired width
  120478. * @param height defines the desired height
  120479. * @param useBilinearMode defines if bilinear mode has to be used
  120480. * @return the generated texture
  120481. */
  120482. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  120483. }
  120484. }
  120485. declare module BABYLON {
  120486. /**
  120487. * This represents the different options avilable for the video capture.
  120488. */
  120489. export interface VideoRecorderOptions {
  120490. /** Defines the mime type of the video */
  120491. mimeType: string;
  120492. /** Defines the video the video should be recorded at */
  120493. fps: number;
  120494. /** Defines the chunk size for the recording data */
  120495. recordChunckSize: number;
  120496. /** The audio tracks to attach to the record */
  120497. audioTracks?: MediaStreamTrack[];
  120498. }
  120499. /**
  120500. * This can helps recording videos from BabylonJS.
  120501. * This is based on the available WebRTC functionalities of the browser.
  120502. *
  120503. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  120504. */
  120505. export class VideoRecorder {
  120506. private static readonly _defaultOptions;
  120507. /**
  120508. * Returns wehther or not the VideoRecorder is available in your browser.
  120509. * @param engine Defines the Babylon Engine to check the support for
  120510. * @returns true if supported otherwise false
  120511. */
  120512. static IsSupported(engine: Engine): boolean;
  120513. private readonly _options;
  120514. private _canvas;
  120515. private _mediaRecorder;
  120516. private _recordedChunks;
  120517. private _fileName;
  120518. private _resolve;
  120519. private _reject;
  120520. /**
  120521. * True wether a recording is already in progress.
  120522. */
  120523. readonly isRecording: boolean;
  120524. /**
  120525. * Create a new VideoCapture object which can help converting what you see in Babylon to
  120526. * a video file.
  120527. * @param engine Defines the BabylonJS Engine you wish to record
  120528. * @param options Defines options that can be used to customized the capture
  120529. */
  120530. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  120531. /**
  120532. * Stops the current recording before the default capture timeout passed in the startRecording
  120533. * functions.
  120534. */
  120535. stopRecording(): void;
  120536. /**
  120537. * Starts recording the canvas for a max duration specified in parameters.
  120538. * @param fileName Defines the name of the file to be downloaded when the recording stop. If null no automatic download will start and you can rely on the promise to get the data back.
  120539. * @param maxDuration Defines the maximum recording time in seconds.
  120540. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  120541. * @return a promise callback at the end of the recording with the video data in Blob.
  120542. */
  120543. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  120544. /**
  120545. * Releases internal resources used during the recording.
  120546. */
  120547. dispose(): void;
  120548. private _handleDataAvailable;
  120549. private _handleError;
  120550. private _handleStop;
  120551. }
  120552. }
  120553. declare module BABYLON {
  120554. /**
  120555. * Class containing a set of static utilities functions for screenshots
  120556. */
  120557. export class ScreenshotTools {
  120558. /**
  120559. * Captures a screenshot of the current rendering
  120560. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  120561. * @param engine defines the rendering engine
  120562. * @param camera defines the source camera
  120563. * @param size This parameter can be set to a single number or to an object with the
  120564. * following (optional) properties: precision, width, height. If a single number is passed,
  120565. * it will be used for both width and height. If an object is passed, the screenshot size
  120566. * will be derived from the parameters. The precision property is a multiplier allowing
  120567. * rendering at a higher or lower resolution
  120568. * @param successCallback defines the callback receives a single parameter which contains the
  120569. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  120570. * src parameter of an <img> to display it
  120571. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  120572. * Check your browser for supported MIME types
  120573. */
  120574. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  120575. /**
  120576. * Generates an image screenshot from the specified camera.
  120577. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  120578. * @param engine The engine to use for rendering
  120579. * @param camera The camera to use for rendering
  120580. * @param size This parameter can be set to a single number or to an object with the
  120581. * following (optional) properties: precision, width, height. If a single number is passed,
  120582. * it will be used for both width and height. If an object is passed, the screenshot size
  120583. * will be derived from the parameters. The precision property is a multiplier allowing
  120584. * rendering at a higher or lower resolution
  120585. * @param successCallback The callback receives a single parameter which contains the
  120586. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  120587. * src parameter of an <img> to display it
  120588. * @param mimeType The MIME type of the screenshot image (default: image/png).
  120589. * Check your browser for supported MIME types
  120590. * @param samples Texture samples (default: 1)
  120591. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  120592. * @param fileName A name for for the downloaded file.
  120593. */
  120594. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  120595. }
  120596. }
  120597. declare module BABYLON {
  120598. /**
  120599. * A cursor which tracks a point on a path
  120600. */
  120601. export class PathCursor {
  120602. private path;
  120603. /**
  120604. * Stores path cursor callbacks for when an onchange event is triggered
  120605. */
  120606. private _onchange;
  120607. /**
  120608. * The value of the path cursor
  120609. */
  120610. value: number;
  120611. /**
  120612. * The animation array of the path cursor
  120613. */
  120614. animations: Animation[];
  120615. /**
  120616. * Initializes the path cursor
  120617. * @param path The path to track
  120618. */
  120619. constructor(path: Path2);
  120620. /**
  120621. * Gets the cursor point on the path
  120622. * @returns A point on the path cursor at the cursor location
  120623. */
  120624. getPoint(): Vector3;
  120625. /**
  120626. * Moves the cursor ahead by the step amount
  120627. * @param step The amount to move the cursor forward
  120628. * @returns This path cursor
  120629. */
  120630. moveAhead(step?: number): PathCursor;
  120631. /**
  120632. * Moves the cursor behind by the step amount
  120633. * @param step The amount to move the cursor back
  120634. * @returns This path cursor
  120635. */
  120636. moveBack(step?: number): PathCursor;
  120637. /**
  120638. * Moves the cursor by the step amount
  120639. * If the step amount is greater than one, an exception is thrown
  120640. * @param step The amount to move the cursor
  120641. * @returns This path cursor
  120642. */
  120643. move(step: number): PathCursor;
  120644. /**
  120645. * Ensures that the value is limited between zero and one
  120646. * @returns This path cursor
  120647. */
  120648. private ensureLimits;
  120649. /**
  120650. * Runs onchange callbacks on change (used by the animation engine)
  120651. * @returns This path cursor
  120652. */
  120653. private raiseOnChange;
  120654. /**
  120655. * Executes a function on change
  120656. * @param f A path cursor onchange callback
  120657. * @returns This path cursor
  120658. */
  120659. onchange(f: (cursor: PathCursor) => void): PathCursor;
  120660. }
  120661. }
  120662. declare module BABYLON {
  120663. /** @hidden */
  120664. export var blurPixelShader: {
  120665. name: string;
  120666. shader: string;
  120667. };
  120668. }
  120669. declare module BABYLON {
  120670. /** @hidden */
  120671. export var bones300Declaration: {
  120672. name: string;
  120673. shader: string;
  120674. };
  120675. }
  120676. declare module BABYLON {
  120677. /** @hidden */
  120678. export var instances300Declaration: {
  120679. name: string;
  120680. shader: string;
  120681. };
  120682. }
  120683. declare module BABYLON {
  120684. /** @hidden */
  120685. export var pointCloudVertexDeclaration: {
  120686. name: string;
  120687. shader: string;
  120688. };
  120689. }
  120690. // Mixins
  120691. interface Window {
  120692. mozIndexedDB: IDBFactory;
  120693. webkitIndexedDB: IDBFactory;
  120694. msIndexedDB: IDBFactory;
  120695. webkitURL: typeof URL;
  120696. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  120697. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  120698. WebGLRenderingContext: WebGLRenderingContext;
  120699. MSGesture: MSGesture;
  120700. CANNON: any;
  120701. AudioContext: AudioContext;
  120702. webkitAudioContext: AudioContext;
  120703. PointerEvent: any;
  120704. Math: Math;
  120705. Uint8Array: Uint8ArrayConstructor;
  120706. Float32Array: Float32ArrayConstructor;
  120707. mozURL: typeof URL;
  120708. msURL: typeof URL;
  120709. VRFrameData: any; // WebVR, from specs 1.1
  120710. DracoDecoderModule: any;
  120711. setImmediate(handler: (...args: any[]) => void): number;
  120712. }
  120713. interface HTMLCanvasElement {
  120714. requestPointerLock(): void;
  120715. msRequestPointerLock?(): void;
  120716. mozRequestPointerLock?(): void;
  120717. webkitRequestPointerLock?(): void;
  120718. /** Track wether a record is in progress */
  120719. isRecording: boolean;
  120720. /** Capture Stream method defined by some browsers */
  120721. captureStream(fps?: number): MediaStream;
  120722. }
  120723. interface CanvasRenderingContext2D {
  120724. msImageSmoothingEnabled: boolean;
  120725. }
  120726. interface MouseEvent {
  120727. mozMovementX: number;
  120728. mozMovementY: number;
  120729. webkitMovementX: number;
  120730. webkitMovementY: number;
  120731. msMovementX: number;
  120732. msMovementY: number;
  120733. }
  120734. interface Navigator {
  120735. mozGetVRDevices: (any: any) => any;
  120736. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  120737. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  120738. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  120739. webkitGetGamepads(): Gamepad[];
  120740. msGetGamepads(): Gamepad[];
  120741. webkitGamepads(): Gamepad[];
  120742. }
  120743. interface HTMLVideoElement {
  120744. mozSrcObject: any;
  120745. }
  120746. interface Math {
  120747. fround(x: number): number;
  120748. imul(a: number, b: number): number;
  120749. }
  120750. interface WebGLRenderingContext {
  120751. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  120752. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  120753. vertexAttribDivisor(index: number, divisor: number): void;
  120754. createVertexArray(): any;
  120755. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  120756. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  120757. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  120758. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  120759. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  120760. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  120761. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  120762. // Queries
  120763. createQuery(): WebGLQuery;
  120764. deleteQuery(query: WebGLQuery): void;
  120765. beginQuery(target: number, query: WebGLQuery): void;
  120766. endQuery(target: number): void;
  120767. getQueryParameter(query: WebGLQuery, pname: number): any;
  120768. getQuery(target: number, pname: number): any;
  120769. MAX_SAMPLES: number;
  120770. RGBA8: number;
  120771. READ_FRAMEBUFFER: number;
  120772. DRAW_FRAMEBUFFER: number;
  120773. UNIFORM_BUFFER: number;
  120774. HALF_FLOAT_OES: number;
  120775. RGBA16F: number;
  120776. RGBA32F: number;
  120777. R32F: number;
  120778. RG32F: number;
  120779. RGB32F: number;
  120780. R16F: number;
  120781. RG16F: number;
  120782. RGB16F: number;
  120783. RED: number;
  120784. RG: number;
  120785. R8: number;
  120786. RG8: number;
  120787. UNSIGNED_INT_24_8: number;
  120788. DEPTH24_STENCIL8: number;
  120789. /* Multiple Render Targets */
  120790. drawBuffers(buffers: number[]): void;
  120791. readBuffer(src: number): void;
  120792. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  120793. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  120794. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  120795. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  120796. // Occlusion Query
  120797. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  120798. ANY_SAMPLES_PASSED: number;
  120799. QUERY_RESULT_AVAILABLE: number;
  120800. QUERY_RESULT: number;
  120801. }
  120802. interface WebGLProgram {
  120803. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  120804. }
  120805. interface EXT_disjoint_timer_query {
  120806. QUERY_COUNTER_BITS_EXT: number;
  120807. TIME_ELAPSED_EXT: number;
  120808. TIMESTAMP_EXT: number;
  120809. GPU_DISJOINT_EXT: number;
  120810. QUERY_RESULT_EXT: number;
  120811. QUERY_RESULT_AVAILABLE_EXT: number;
  120812. queryCounterEXT(query: WebGLQuery, target: number): void;
  120813. createQueryEXT(): WebGLQuery;
  120814. beginQueryEXT(target: number, query: WebGLQuery): void;
  120815. endQueryEXT(target: number): void;
  120816. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  120817. deleteQueryEXT(query: WebGLQuery): void;
  120818. }
  120819. interface WebGLUniformLocation {
  120820. _currentState: any;
  120821. }
  120822. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  120823. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  120824. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  120825. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  120826. interface WebGLRenderingContext {
  120827. readonly RASTERIZER_DISCARD: number;
  120828. readonly DEPTH_COMPONENT24: number;
  120829. readonly TEXTURE_3D: number;
  120830. readonly TEXTURE_2D_ARRAY: number;
  120831. readonly TEXTURE_COMPARE_FUNC: number;
  120832. readonly TEXTURE_COMPARE_MODE: number;
  120833. readonly COMPARE_REF_TO_TEXTURE: number;
  120834. readonly TEXTURE_WRAP_R: number;
  120835. readonly HALF_FLOAT: number;
  120836. readonly RGB8: number;
  120837. readonly RED_INTEGER: number;
  120838. readonly RG_INTEGER: number;
  120839. readonly RGB_INTEGER: number;
  120840. readonly RGBA_INTEGER: number;
  120841. readonly R8_SNORM: number;
  120842. readonly RG8_SNORM: number;
  120843. readonly RGB8_SNORM: number;
  120844. readonly RGBA8_SNORM: number;
  120845. readonly R8I: number;
  120846. readonly RG8I: number;
  120847. readonly RGB8I: number;
  120848. readonly RGBA8I: number;
  120849. readonly R8UI: number;
  120850. readonly RG8UI: number;
  120851. readonly RGB8UI: number;
  120852. readonly RGBA8UI: number;
  120853. readonly R16I: number;
  120854. readonly RG16I: number;
  120855. readonly RGB16I: number;
  120856. readonly RGBA16I: number;
  120857. readonly R16UI: number;
  120858. readonly RG16UI: number;
  120859. readonly RGB16UI: number;
  120860. readonly RGBA16UI: number;
  120861. readonly R32I: number;
  120862. readonly RG32I: number;
  120863. readonly RGB32I: number;
  120864. readonly RGBA32I: number;
  120865. readonly R32UI: number;
  120866. readonly RG32UI: number;
  120867. readonly RGB32UI: number;
  120868. readonly RGBA32UI: number;
  120869. readonly RGB10_A2UI: number;
  120870. readonly R11F_G11F_B10F: number;
  120871. readonly RGB9_E5: number;
  120872. readonly RGB10_A2: number;
  120873. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  120874. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  120875. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  120876. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  120877. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  120878. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  120879. 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;
  120880. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  120881. readonly TRANSFORM_FEEDBACK: number;
  120882. readonly INTERLEAVED_ATTRIBS: number;
  120883. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  120884. createTransformFeedback(): WebGLTransformFeedback;
  120885. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  120886. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  120887. beginTransformFeedback(primitiveMode: number): void;
  120888. endTransformFeedback(): void;
  120889. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  120890. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  120891. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  120892. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  120893. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  120894. }
  120895. interface ImageBitmap {
  120896. readonly width: number;
  120897. readonly height: number;
  120898. close(): void;
  120899. }
  120900. interface WebGLQuery extends WebGLObject {
  120901. }
  120902. declare var WebGLQuery: {
  120903. prototype: WebGLQuery;
  120904. new(): WebGLQuery;
  120905. };
  120906. interface WebGLSampler extends WebGLObject {
  120907. }
  120908. declare var WebGLSampler: {
  120909. prototype: WebGLSampler;
  120910. new(): WebGLSampler;
  120911. };
  120912. interface WebGLSync extends WebGLObject {
  120913. }
  120914. declare var WebGLSync: {
  120915. prototype: WebGLSync;
  120916. new(): WebGLSync;
  120917. };
  120918. interface WebGLTransformFeedback extends WebGLObject {
  120919. }
  120920. declare var WebGLTransformFeedback: {
  120921. prototype: WebGLTransformFeedback;
  120922. new(): WebGLTransformFeedback;
  120923. };
  120924. interface WebGLVertexArrayObject extends WebGLObject {
  120925. }
  120926. declare var WebGLVertexArrayObject: {
  120927. prototype: WebGLVertexArrayObject;
  120928. new(): WebGLVertexArrayObject;
  120929. };
  120930. // Type definitions for WebVR API
  120931. // Project: https://w3c.github.io/webvr/
  120932. // Definitions by: six a <https://github.com/lostfictions>
  120933. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  120934. interface VRDisplay extends EventTarget {
  120935. /**
  120936. * Dictionary of capabilities describing the VRDisplay.
  120937. */
  120938. readonly capabilities: VRDisplayCapabilities;
  120939. /**
  120940. * z-depth defining the far plane of the eye view frustum
  120941. * enables mapping of values in the render target depth
  120942. * attachment to scene coordinates. Initially set to 10000.0.
  120943. */
  120944. depthFar: number;
  120945. /**
  120946. * z-depth defining the near plane of the eye view frustum
  120947. * enables mapping of values in the render target depth
  120948. * attachment to scene coordinates. Initially set to 0.01.
  120949. */
  120950. depthNear: number;
  120951. /**
  120952. * An identifier for this distinct VRDisplay. Used as an
  120953. * association point in the Gamepad API.
  120954. */
  120955. readonly displayId: number;
  120956. /**
  120957. * A display name, a user-readable name identifying it.
  120958. */
  120959. readonly displayName: string;
  120960. readonly isConnected: boolean;
  120961. readonly isPresenting: boolean;
  120962. /**
  120963. * If this VRDisplay supports room-scale experiences, the optional
  120964. * stage attribute contains details on the room-scale parameters.
  120965. */
  120966. readonly stageParameters: VRStageParameters | null;
  120967. /**
  120968. * Passing the value returned by `requestAnimationFrame` to
  120969. * `cancelAnimationFrame` will unregister the callback.
  120970. * @param handle Define the hanle of the request to cancel
  120971. */
  120972. cancelAnimationFrame(handle: number): void;
  120973. /**
  120974. * Stops presenting to the VRDisplay.
  120975. * @returns a promise to know when it stopped
  120976. */
  120977. exitPresent(): Promise<void>;
  120978. /**
  120979. * Return the current VREyeParameters for the given eye.
  120980. * @param whichEye Define the eye we want the parameter for
  120981. * @returns the eye parameters
  120982. */
  120983. getEyeParameters(whichEye: string): VREyeParameters;
  120984. /**
  120985. * Populates the passed VRFrameData with the information required to render
  120986. * the current frame.
  120987. * @param frameData Define the data structure to populate
  120988. * @returns true if ok otherwise false
  120989. */
  120990. getFrameData(frameData: VRFrameData): boolean;
  120991. /**
  120992. * Get the layers currently being presented.
  120993. * @returns the list of VR layers
  120994. */
  120995. getLayers(): VRLayer[];
  120996. /**
  120997. * Return a VRPose containing the future predicted pose of the VRDisplay
  120998. * when the current frame will be presented. The value returned will not
  120999. * change until JavaScript has returned control to the browser.
  121000. *
  121001. * The VRPose will contain the position, orientation, velocity,
  121002. * and acceleration of each of these properties.
  121003. * @returns the pose object
  121004. */
  121005. getPose(): VRPose;
  121006. /**
  121007. * Return the current instantaneous pose of the VRDisplay, with no
  121008. * prediction applied.
  121009. * @returns the current instantaneous pose
  121010. */
  121011. getImmediatePose(): VRPose;
  121012. /**
  121013. * The callback passed to `requestAnimationFrame` will be called
  121014. * any time a new frame should be rendered. When the VRDisplay is
  121015. * presenting the callback will be called at the native refresh
  121016. * rate of the HMD. When not presenting this function acts
  121017. * identically to how window.requestAnimationFrame acts. Content should
  121018. * make no assumptions of frame rate or vsync behavior as the HMD runs
  121019. * asynchronously from other displays and at differing refresh rates.
  121020. * @param callback Define the eaction to run next frame
  121021. * @returns the request handle it
  121022. */
  121023. requestAnimationFrame(callback: FrameRequestCallback): number;
  121024. /**
  121025. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  121026. * Repeat calls while already presenting will update the VRLayers being displayed.
  121027. * @param layers Define the list of layer to present
  121028. * @returns a promise to know when the request has been fulfilled
  121029. */
  121030. requestPresent(layers: VRLayer[]): Promise<void>;
  121031. /**
  121032. * Reset the pose for this display, treating its current position and
  121033. * orientation as the "origin/zero" values. VRPose.position,
  121034. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  121035. * updated when calling resetPose(). This should be called in only
  121036. * sitting-space experiences.
  121037. */
  121038. resetPose(): void;
  121039. /**
  121040. * The VRLayer provided to the VRDisplay will be captured and presented
  121041. * in the HMD. Calling this function has the same effect on the source
  121042. * canvas as any other operation that uses its source image, and canvases
  121043. * created without preserveDrawingBuffer set to true will be cleared.
  121044. * @param pose Define the pose to submit
  121045. */
  121046. submitFrame(pose?: VRPose): void;
  121047. }
  121048. declare var VRDisplay: {
  121049. prototype: VRDisplay;
  121050. new(): VRDisplay;
  121051. };
  121052. interface VRLayer {
  121053. leftBounds?: number[] | Float32Array | null;
  121054. rightBounds?: number[] | Float32Array | null;
  121055. source?: HTMLCanvasElement | null;
  121056. }
  121057. interface VRDisplayCapabilities {
  121058. readonly canPresent: boolean;
  121059. readonly hasExternalDisplay: boolean;
  121060. readonly hasOrientation: boolean;
  121061. readonly hasPosition: boolean;
  121062. readonly maxLayers: number;
  121063. }
  121064. interface VREyeParameters {
  121065. /** @deprecated */
  121066. readonly fieldOfView: VRFieldOfView;
  121067. readonly offset: Float32Array;
  121068. readonly renderHeight: number;
  121069. readonly renderWidth: number;
  121070. }
  121071. interface VRFieldOfView {
  121072. readonly downDegrees: number;
  121073. readonly leftDegrees: number;
  121074. readonly rightDegrees: number;
  121075. readonly upDegrees: number;
  121076. }
  121077. interface VRFrameData {
  121078. readonly leftProjectionMatrix: Float32Array;
  121079. readonly leftViewMatrix: Float32Array;
  121080. readonly pose: VRPose;
  121081. readonly rightProjectionMatrix: Float32Array;
  121082. readonly rightViewMatrix: Float32Array;
  121083. readonly timestamp: number;
  121084. }
  121085. interface VRPose {
  121086. readonly angularAcceleration: Float32Array | null;
  121087. readonly angularVelocity: Float32Array | null;
  121088. readonly linearAcceleration: Float32Array | null;
  121089. readonly linearVelocity: Float32Array | null;
  121090. readonly orientation: Float32Array | null;
  121091. readonly position: Float32Array | null;
  121092. readonly timestamp: number;
  121093. }
  121094. interface VRStageParameters {
  121095. sittingToStandingTransform?: Float32Array;
  121096. sizeX?: number;
  121097. sizeY?: number;
  121098. }
  121099. interface Navigator {
  121100. getVRDisplays(): Promise<VRDisplay[]>;
  121101. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  121102. }
  121103. interface Window {
  121104. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  121105. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  121106. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  121107. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121108. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  121109. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  121110. }
  121111. interface Gamepad {
  121112. readonly displayId: number;
  121113. }
  121114. interface XRDevice {
  121115. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  121116. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  121117. }
  121118. interface XRSession {
  121119. getInputSources(): Array<any>;
  121120. baseLayer: XRWebGLLayer;
  121121. requestFrameOfReference(type: string): Promise<void>;
  121122. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  121123. end(): Promise<void>;
  121124. requestAnimationFrame: Function;
  121125. addEventListener: Function;
  121126. }
  121127. interface XRSessionCreationOptions {
  121128. outputContext?: WebGLRenderingContext | null;
  121129. immersive?: boolean;
  121130. environmentIntegration?: boolean;
  121131. }
  121132. interface XRLayer {
  121133. getViewport: Function;
  121134. framebufferWidth: number;
  121135. framebufferHeight: number;
  121136. }
  121137. interface XRView {
  121138. projectionMatrix: Float32Array;
  121139. }
  121140. interface XRFrame {
  121141. getDevicePose: Function;
  121142. getInputPose: Function;
  121143. views: Array<XRView>;
  121144. baseLayer: XRLayer;
  121145. }
  121146. interface XRFrameOfReference {
  121147. }
  121148. interface XRWebGLLayer extends XRLayer {
  121149. framebuffer: WebGLFramebuffer;
  121150. }
  121151. declare var XRWebGLLayer: {
  121152. prototype: XRWebGLLayer;
  121153. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  121154. };